CMS user relationship and user content


User content type

The "User" abstract type has changed.
It now provides the "user" data, which is of type "user".

For projects that have defined their own "user" content type that extends "org.ametys.plugins.userdirectory.Content.user", it will be necessary to change the content metadataset to take the "user" data into account:

  • Above all, you need to position it on the "creation" metadataset in editing.
  • And avoid positioning it on other metadatasets in editing.

SCC

If your directory users are linked to CMS users:

  • Change the definition of your SCC in the administration :

    • If it's a "Data source SQL", select instead "User directory: entities from a data source SQL" and fill in the fields.
    • If it's a "Data source LDAP", select instead "User directory: entities from a data source LDAP" and fill in the fields.
    • If it's a "User directory: users from a population Ametys", just edit and save.

When you change the type of SCC, some settings will be reset. To see the old settings, you can look at the "synchronizable-collection.xml" file in the /data/config folder.
This file will be overwritten when you save.

  • Go to script and set the following parameters:
    • The type of content to be migrated
    • SCC identifier
    • The content data which carries the content's unique field (most of the time this is login)
var contentType = "org.ametys.plugin.defaultud.Content.uduser"; // TODO set this field              
  var sccId = "utilisateurs"; // TODO set this field              
  var fieldId = "login"; // TODO set this field        

  var unlock = function(node)              
  {              
    var lockToken = node.getProperty(RepositoryConstants.METADATA_LOCKTOKEN).getString();              
    var lockManager = node.getSession().getWorkspace().getLockManager();              
    lockManager.addLockToken(lockToken);              
    lockManager.unlock(node.getPath());              

    // Remove residual properties              
    node["setProperty(java.lang.String,javax.jcr.Value)"](RepositoryConstants.METADATA_LOCKTOKEN, null);              
    node["setProperty(java.lang.String,javax.jcr.Value)"](RepositoryConstants.METADATA_LOCKOWNER, null);              
    node.getSession().save();              
  }               
              
  var qm = session.getWorkspace().getQueryManager();              
  var query = qm.createQuery("//element(*, ametys:content)[@ametys-internal:contentType='" + contentType + "' "              
  + "and @ametys-internal:scc = '" + sccId + "']", javax.jcr.query.Query.XPATH);              
  var nodes = query.execute().getNodes();              

  var nbContent = 0;              
  while (nodes.hasNext())              
  {              
    var content = nodes.next();              
              
    if (content.isLocked())              
    {              
      unlock(content);              
    }              
              
    content.setProperty("ametys:uniqueId", content.getProperty("ametys:" + fieldId).getString());              
    content.save();              
              
    nbContent++;              
  }              

  print(nbContent + " contenu(s) changé(s)");           

  queryPage = qm.createQuery("//element(*, ametys:defaultPage)[@ametys-internal:virtual ='org.ametys.plugins.userdirectory.page.VirtualUserDirectoryPageFactory']", javax.jcr.query.Query.XPATH);          
  var nodePages = queryPage.execute().getNodes();          
  var nbPage = 0;          
  while (nodePages.hasNext())          
  {          
    var page = nodePages.next();          
    var metadata = page.getProperty("ametys:user-directory-root-classification-metadata").getString();          
          
    if (metadata == fieldId)          
    {          
      page.setProperty("ametys:user-directory-root-classification-metadata", "uniqueId");          
      page.save();          
          
      nbPage++;          
    }          
  }          
          
  print(nbPage + " page(s) changée(s)");                                
  • Relaunch content synchronization to finalize migration.

 

The UserXSLTHelper

Chances are that in your projects you have created your own helper XSLT to override the getCurrentUserContent method.
You can now remove this override and use the getCurrentUserContent core method of the helper org.ametys.plugins.userdirectory.transformation.xslt.UserXSLTHelper.

You should also remember to put this kernel helper back in your XSL in place of the project helper.

What's more, there's probably a workflow condition that's been created in your project to call up your custom Helper (this condition is often called CheckCurrentUserContentCondition)
It's no longer useful either, so you can delete it (along with its declaration in plugin.xml)

And you can call up the kernel condition again org.ametys.plugins.userdirectory.workflow.CheckCurrentUserContentCondition.

Back to top