vasanth
I'm new here

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

Hello Guys,

It worked very well.  Thank you felix.reinhold for share the code.

0 Kudos
vasanth
I'm new here

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

felix.reinhold​  We are using the Permission Service in the meta data. please refer the below screenshot

223043_pastedImage_0.png

If I change the Permission  Service's data for the group ?? then will affect other permission service in the meta data too ??

It would very helpful if you have any sample code.

0 Kudos
felix_reinhold
Returning Responder

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

Hello,

if you're using the same group-File for different usages of the CMS_INPUT_PERMISSION component then a change in the groups-file would affect all of those usages of course. If you want different groups in the CMS_INPUT_PERMISSION then you'd have to create multiple group-files in the permission service. To sync the groups to the file you could just create a server-schedule-entry that runs automatically every x minutes/hours/days to sync the groups to the file. In the schedule entry just get the xml-Files from the service and update them by adding all groups of the project. Something like this (untested):

final String XML_DOCUMENT_INFO = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";

Path projectPath= new File("conf/modules/System.PermissionService/editorgroups.xml").toPath();

// Write groups to file

StringBuffer xmlOut = new StringBuffer(XML_DOCUMENT_INFO);

xmlOut.append("<GROUPS name=\"editorgroups\" version=\"1\">\n");

for (Group group : project.getGroups()) {

     String uid = group.getName().toLowerCase().replaceAll(" ","_");

     xmlOut.append("\t<GROUP id=\"").append(uid).append("\" name=\"").append(group.getName()).append("\"/>\n");

}

xmlOut.append("</GROUPS>\n");

Files.write(projectPath, xmlOut.toString().getBytes(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);

I think you can get the conf-path of the service from the service directly instead of adding it hardcoded. And of course there are better ways to write the xml-markup instead of hardcoded strings.

Maybe you have to always increase the version by 1 to make the service recognize the change - Maybe you could use a timestamp as version or sth. like that.

best regards

Felix

vasanth
I'm new here

Re: How to update the CMS_INPUT_COMBOBOX from script template?

Jump to solution

felix.reinhold​ Thank you for sharing the code felix but my scenario doesn't allow me to change the usage. So i think about other possibilities.

0 Kudos