Conversion of my alfresco javascript file into java class -


i need convert javascript file java code.please help

if (document.iscontainer && document.displaypath == "/company home/user homes") {     var owner = document.properties["cm:owner"];     var pnode = people.getperson(owner);     if (pnode!=null && pnode.exists()){          var username = pnode.properties.username;         var email = pnode.properties.email;         var randpassword = math.random().tostring(36).substr(2, 30)+"-"+(date.now());          people.setpassword(username, randpassword);         logger.debug("invitation mail: user "+username+" password has been changed.");          var mail = actions.create("mail");         //mail.parameters.from = "noreply@customdomain";         mail.parameters.to = email;          mail.parameters.subject = "welcome site, login: "+username+", password: "+randpassword;         mail.parameters.template = companyhome.childbynamepath("data dictionary/email templates/invite email templates/invite_user_email.ftl");         var templatemodel = new array();         templatemodel['newpassword'] = randpassword; // use ${newpassword} expression inside template         mail.parameters.template_model = templatemodel;         mail.executeasynchronously(document);         logger.debug("invitation mail has been sent "+email);     } else {         logger.warn("invitation mail: user not found: "+owner);     } } else {     logger.warn("invitation mail: document "+document.name+" / "+document.noderef+" not user home folder."); }  

hope should you.

public void createuser() {     final string randpassword = getrandonpassword();     final string username= "someuser";     final string email = "someuser@example.com";     authenticationservice.setauthentication(username, randpassword.tochararray());     system.out.println(randpassword);      authenticationutil.runas(new authenticationutil.runaswork<void>()     {         public void dowork() throws exception         {             map<qname, serializable> properties = new hashmap<qname, serializable>();             properties.put(contentmodel.prop_username,username);             properties.put(contentmodel.prop_password,randpassword);             properties.put(contentmodel.prop_email,email);             noderef personnoderef = personservice.createperson(properties);             personservice.notifyperson(username, randpassword);             return null;         }     }, authenticationutil.getsystemusername());          }  private string getrandonpassword() {     calendar calendar = calendar.getinstance();     securerandom random = new securerandom();     string randompassword = new biginteger(130, random).tostring(32);     randompassword  = randompassword +"-" + calendar.gettimeinmillis();     return randompassword ;         } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -