Skip to content Skip to sidebar Skip to footer

Conversion Of My Alfresco Javascript File Into Java Class

I need to convert this javascript file into java code.Please help if (document.isContainer && document.displayPath == '/Company Home/User Homes') { var owner = document

Solution 1:

Hope this should help 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 ;        
}

Post a Comment for "Conversion Of My Alfresco Javascript File Into Java Class"