Issue while creating users with profile image in CQ5/AEM - aem

I am using AccountManager API to create users. It works just fine when I don't use profile image in registration form and user gets registered but once I use profile image, I get the following error:
Caused by: javax.jcr.nodetype.ConstraintViolationException: No matching property definition: jcr:primaryType = sling:Folder
at org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.setProperty(NodeDelegate.java:522)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.perform(NodeImpl.java:1308)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.perform(NodeImpl.java:1297)
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:293)
at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:113)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1297)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:340)
at org.apache.sling.jcr.resource.JcrModifiablePropertyMap.save(JcrModifiablePropertyMap.java:180)
... 145 more
There is a hidden field to create this folder
<hidden
jcr:primaryType="nt:unstructured"
sling:resourceSuperType="foundation/components/form/defaults/field"
sling:resourceType="foundation/components/form/hidden"
defaultValue="sling:Folder"
name="photos/jcr:primaryType"/>
Any inputs?

"sling:Folder" cannot be used for a jcr node type when using Node.class.
Use "nt:unstructured"
I faced a similar issue and this resolved it.

Related

Get object from form with errors in play framework 2.0

I am getting an error when I try to extract a user from a form with validation errors.
I have the following route configured in my routes file:
GET /users/:user controllers.UsersController.viewUser(user: models.User)
GET /users/:user/edit controllers.UsersController.editUser(user: models.User)
This is fine at this point, and I can render a link to the user view from my scala templates:
routes.UsersController.viewUser(myUserObject)
My problem is that in my user edition form I need to get myUserObject from a Form[User] object. What I am currently doing is:
routes.UsersController.viewUser(userForm.get)
However, when the userForm has any errors, the get method raises an exception, as shown in the documentation.
The approach I have taken is passing an additional User parameter to the scala view, together with the Form[User] parameter I was passing up to now, I mean,
userEdit.render(user, userForm)
instead of just
userEdit.render(userForm)
However, I would like to know if there is a more suitable solution that does not involve including an additional parameter.
The documentation states that you can prefill a form with existing data:
val filledForm = userForm.fill(User("Bob", 18))
Given the preexisting User, it should be trivial to adapt to your example.

Can I use FLP without default model ?

My json model url is '/destinations/XXX/Collection?time=' + (+new Date) I don't know how to configure it in minifest of Component.js , so I delete the sap.app.dataSources and sap.ui.models."" (the defalut model? ) , and the flp app gave me this error:
Failed to load U5 component for navigation intent
TypeError: Cannot read property 'metadataLoaded' of undefined
sap.ushell.renderers.fiori2.Shell.controller
What should I do ?
i have a couple of links that should get you up and running (I am assuming you are developping on webIDE in SAP HCP (is that correct?)):
How to setup destinations, you need extra properties: WebIDEUsage = odata_gen and WebIDEEnabled = true.
You should then go into your manifest.json and choose Descriptor Editor and choose Data Sources and under OData Services choose the + to add your service.
More information on manifest.json you can find here: Documentation on Manifest

How to allow a specific Role to edit users in Sakai via a specific Tool? (UserPermissionException)

I'm working with user properties in Sakai and I wish that through some Tool I'm developing a Teacher can alter some properties according to some criteria. I've selected the function user.upd.any in the Realm Role configuration but I keep getting the following error when I try to change the User:
org.sakaiproject.user.api.UserPermissionException user=d1dbdfee-d247-44e4-b5c2-d3d787c829ca function=user.upd.any resource=/user/115cf182-17b0-4f2c-a8fc-34fcbe98bac7
at org.sakaiproject.user.impl.BaseUserDirectoryService.unlock(BaseUserDirectoryService.java:270)
at org.sakaiproject.user.impl.BaseUserDirectoryService.editUser(BaseUserDirectoryService.java:1085)
This is the code that generates the stacktrace:
UserEdit ue = userDirectoryService.editUser(userId);
ue.getProperties().addProperty(name, value);
userDirectoryService.commitEdit(ue);
The code should have a if(userDirectoryService.allowUpdateUser(userId)){...}, but I will put this just when this permission issue have been troubleshooted (if I put this now, nothing happens: no permission)
Any advice?
Thanks

Magnolia HierarchyManager and Content are depreciated. How do I replicate functionality using Session and jcrNode?

I'm trying to do some logic in my Spring controller where I route to a website node based on the template used in another website node.
I can use LifeTimeJCRSessionUtil.getHierarchyManager("website").getContent("mynodepath").getTemplate() to do this, but I see that the HierarchyManager and Content classes are depreciated.
I looked at the Session class, but I have thus far been unable to figure out how to get the Template id based on the jcrNode.
You can use instead:
javax.jcr.Session jcrSession = LifeTimeJCRSessionUtil.getSession("website");
Node mynode = jcrSession.getNode("/my/node/path");
info.magnolia.cms.core.MetaData metaData = info.magnolia.jcr.util.MetaDataUtil.getMetaData(mynode);
String template = metaData.getTemplate();
Basically, instead of getHierarchyManager("website").getContent("mynodepath") you should use
getSession("website").getNode("/my/node/path").

Customizing Surf Platform Root-Scoped API

I want to customize Surf Platform Root-Scoped API specifically user object. That means add new property or method to user object to check the user is in certain group in header.inc.ftl [in share] like `<#if user.isAdmin>
How can I implement this?
Is Alfresco Root Scoped Objects can be used as Surf Platform Root-Scoped object?
I have no idea of customizing surf platform root object. Can anyone help me???
Not quite sure what you are trying to accomplish, but the role security model is hardcoded in spring-surf/spring webscripts. There is guest, user and admin. If what you want is another analogous role you'll have to hack the spring-surf libaries, namely:
org/springframework/extensions/surf/mvc/PageView.java
org/springframework/extensions/webscripts/ScriptUser.java
org/springframework/extensions/webscripts/Description.java
org/springframework/extensions/webscripts/connector/User.java
This is what I had to do to implement user.isEmployee. This approach allows you to literally treat your new role just as the others.
you can use
<authentication>employee</authentication>
in page descriptors or
<item type="link" permission="employee" id="people">/people-finder</item>
on the navigation.
Just checking whether the user is in a certain group in a certain webscript is a whole diffrent story and does not provide the same functionality.
If what you want is the latter, you should make a call to
/alfresco/service/api/groups/{shortName}
miss
and works through the response.
Update: The item permission attribute requires a little more tweaking.
In header.get.js, propagate the new role to it gets processed properly in header.inc.ftl:
model.permissions =
{
guest: user.isGuest,
admin: user.isAdmin,
employee : user.isEmployee
};
you could try (in JavaScript I managed something like) this:
user = Application.getCurrentUser(context);
String userName = user.getUserName();
user.isAdmin() >>> result return true if user logining is admin
or in JSP:
#{NavigationBean.currentUser.admin == true}
Sorry, i noticed now you was talking about Surf Platform root objects, but the link you put there, is deprecated for Alfresco versions above 3.3. You still use something so old?
If you manage to use JavaScript API's you could use "person" root object, with boolean isAdmin().