User limited=APILocator.getUserAPI().createUser(System.currentTimeMillis()+"", System.currentTimeMillis()+"@dotcms.com");
limited.setPasswordEncrypted(true);
limited.setPassword(Encryptor.digest("123"));
APILocator.getUserAPI().save(limited, user, false);
Role role=APILocator.getRoleAPI().getUserRole(limited);
HibernateUtil.startTransaction();
try {
APILocator.getPermissionAPI().save(
new Permission(demo.getIdentifier(),role.getId(),
PermissionAPI.PERMISSION_CAN_ADD_CHILDREN | PermissionAPI.PERMISSION_EDIT | PermissionAPI.PERMISSION_USE),demo,user,false);
APILocator.getPermissionAPI().save(
new Permission(PermissionAPI.permissionTypes.get("FOLDERS"),demo.getIdentifier(),role.getId(),
PermissionAPI.PERMISSION_CAN_ADD_CHILDREN|PermissionAPI.PERMISSION_EDIT|PermissionAPI.PERMISSION_USE),demo,user,false);
APILocator.getPermissionAPI().save(
new Permission(PermissionAPI.permissionTypes.get("FILES"),demo.getIdentifier(),role.getId(),
PermissionAPI.PERMISSION_EDIT|PermissionAPI.PERMISSION_USE),demo,user,false);
APILocator.getPermissionAPI().save(
new Permission(PermissionAPI.permissionTypes.get("CONTENTLETS"),demo.getIdentifier(),role.getId(),
PermissionAPI.PERMISSION_EDIT|PermissionAPI.PERMISSION_USE),demo,user,false);
HibernateUtil.commitTransaction();
}
catch(Exception ex) {