From version 2.0.0 it is possible to define 2 URLs for each link in the directory:
Internet users will be redirected to one or other of these URLs, depending on whether they are browsing from the internal or external network.
The internal IP range is defined in a site parameter. If you wish to differentiate access URLs, remember to enter this site parameter.
After updating plugin and before starting the application for the first time, the file custom_nodetypes.xml (located in the <chemin_repository>/repository/nodetypes) must be deleted.
Stop the server, delete the custom-nodetypes.xml, then restart the server (if you've already done this procedure once, there's no need to do it again).
Run the following script to modify the value of the variables populationId and groupDirectory according to your own data.
Script link migration
var populationId = "ametys_demo_users"; // value of the id of the population your users belong to var groupDirectoryId= "groupes-sql"; // value of the id of the group directory your groups belong to function convertGrantedUsers(node) { if (node.hasProperty("ametys-internal:granted-users")) { var logins = node.getProperty("ametys-internal:granted-users").getValues(); node.getProperty("ametys-internal:granted-users").remove(); var rootNode = node.addNode("ametys-internal:granted-users", "ametys:linkGrantedUsers"); for (var i=0; i < logins.length; i++) { var userNode = rootNode.addNode("ametys-internal:granted-user", "ametys:user"); userNode.setProperty("ametys:login", logins[i].getString()); userNode.setProperty("ametys:population", populationId); } return true; } return false; } function convertGrantedGroups(node) { if (node.hasProperty("ametys-internal:granted-groups")) { var ids = node.getProperty("ametys-internal:granted-groups").getValues(); node.getProperty("ametys-internal:granted-groups").remove(); var rootNode = node.addNode("ametys-internal:granted-groups", "ametys:linkGrantedGroups"); for (var i=0; i < ids.length; i++) { var gpNode = grantedGroups.addNode("ametys-internal:granted-group", "ametys:group"); gpNode.setProperty("ametys:groupId", logins[i].getString()); gpNode.setProperty("ametys:groupDirectory", groupDirectoryId); } return true; } return false; } // Migrate link directory var qm = session.getWorkspace().getQueryManager(); var query = qm.createQuery("//element(*, ametys:directoryLink)", javax.jcr.query.Query.XPATH); var links = query.execute().getNodes(); var count = 0; while (links.hasNext()) { var link = links.next(); try { if (convertGrantedUsers(link) || convertGrantedGroups(link)) { link.save(); count++; } } catch (e) { print("Exception for link '" + link + "'.\n" + e); } } print(count + " links have been migrated");
Run the following script to migrate your link directory services
Script service migration
var ConsoleHelper = Java.type('org.ametys.workspaces.repository.ConsoleHelper'); var qm = session.getWorkspace().getQueryManager(); var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type='SERVICE' and @ametys-internal:service='org.ametys.plugins.linkdirectory.DirectoryService']", javax.jcr.query.Query.XPATH); var nodes = query.execute().getNodes(); var count = 0; while (nodes.hasNext()) { var node = nodes.next(); var paramsNode = node.getNode('ametys:service_parameters'); if (ConsoleHelper.convertSingleToMultipleProperty(paramsNode, "ametys:themes")) { paramsNode.save(); count++ } } print(count + " link services have been migrated");
Run the following script to migrate your link directory services
Script service migration
var ConsoleHelper = Java.type('org.ametys.workspaces.repository.ConsoleHelper'); var qm = session.getWorkspace().getQueryManager(); var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type='SERVICE' and @ametys-internal:service='org.ametys.plugins.linkdirectory.DirectoryService']", javax.jcr.query.Query.XPATH); var nodes = query.execute().getNodes(); var count = 0; while (nodes.hasNext()) { var node = nodes.next(); var paramsNode = node.getNode('ametys:service_parameters'); if (ConsoleHelper.convertSingleToMultipleProperty(paramsNode, "ametys:themes")) { paramsNode.save(); count++ } } print(count + " link services have been migrated");