cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Role creation crashes old sites.

avin_jss
Champ on-the-rise
Champ on-the-rise
Hi,

    I have Alfresco 3.2 setup on ubuntu mysql tomcat.

    I already had some sites on my setup and then I got requirement to create some custom roles for new sites that will be created.

   I followed following link to make custom role  http://wiki.alfresco.com/wiki/Custom_Permissions_in_Share

    But As u can see its given in the link that this procedure is only valid for fresh share site, so all my old sites are crashing and throwing the error "An Authority was not found for Group_site_xxx_customrole".

  My requirement is to create custom roles so that they can be applied on new sites, and keeping old sites as they are.

    can anybody tell me how to make custom role so that old sites do not crash, OR suggest some changes in present error so that old sites start working.??

   here is error stack trace for debugging ……


23:35:25,478 ERROR [org.alfresco.web.scripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 10220007 Wrapped Exception (with status template): 10220006 Failed to execute script '/org/alfresco/slingshot/documentlibrary/doclist.get.js (in classpath store file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': 10220005 An authority was not found for GROUP_site_a_SiteCustomManager
org.alfresco.web.scripts.WebScriptException: 10220007 Wrapped Exception (with status template): 10220006 Failed to execute script '/org/alfresco/slingshot/documentlibrary/doclist.get.js (in classpath store file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': 10220005 An authority was not found for GROUP_site_a_SiteCustomManager
   at org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)
   at org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:165)
   at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:357)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:326)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:407)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:424)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:288)
   at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:262)
   at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)
   at org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:595)
Caused by: org.alfresco.scripts.ScriptException: 10220006 Failed to execute script '/org/alfresco/slingshot/documentlibrary/doclist.get.js (in classpath store file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': 10220005 An authority was not found for GROUP_site_a_SiteCustomManager
   at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:178)
   at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:274)
   at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:108)
   at org.alfresco.web.scripts.AbstractWebScript.executeScript(AbstractWebScript.java:819)
   at org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:90)
   … 21 more
Caused by: org.alfresco.repo.security.authority.UnknownAuthorityException: 10220005 An authority was not found for GROUP_site_a_SiteCustomManager
   at org.alfresco.repo.security.authority.AuthorityDAOImpl.getContainedAuthorities(AuthorityDAOImpl.java:246)
   at org.alfresco.repo.security.authority.AuthorityServiceImpl.getContainedAuthorities(AuthorityServiceImpl.java:313)
   at org.alfresco.repo.site.SiteServiceImpl.getPermissionGroups(SiteServiceImpl.java:1188)
   at org.alfresco.repo.site.SiteServiceImpl.getMembersRoles(SiteServiceImpl.java:1158)
   at org.alfresco.repo.site.SiteServiceImpl.getMembersRole(SiteServiceImpl.java:1132)
   at org.alfresco.repo.site.script.Site.getMembersRole(Site.java:327)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
   at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
   at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
   at org.mozilla.javascript.gen.c7._c8(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js:541)
   at org.mozilla.javascript.gen.c7.call(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js)
   at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
   at org.mozilla.javascript.gen.c7._c0(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js:409)
   at org.mozilla.javascript.gen.c7.call(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
   at org.mozilla.javascript.gen.c7.call(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js)
   at org.mozilla.javascript.gen.c7.exec(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:449)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:174)
   … 25 more
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Please help as this solution is required urgently.

Thanks & regards
Avin
12 REPLIES 12

avin_jss
Champ on-the-rise
Champ on-the-rise
Is thier anyway to save custom authority for a old site in database????

loftux
Star Contributor
Star Contributor
Hi,

Try this javascript. Save it in Data Dictionary, Scripts as fixPermission.js

var n=search.findNode("workspace://SpacesStore/bc93bd54-384e-413c-b085-dc9e0314d53f");
if(n!=null)
{
n.setPermission("SiteCustomManager", "GROUP_site_mysite_SiteCustomManager")
}
‍‍‍‍‍‍‍

You have to replace the workspace://SpacesStore/bc93bd54-384e-413c-b085-dc9e0314d53f with the correct id for your space, that is the space id you can find in Alfresco Explorer. Navigate to Company Home/Sites/mysite and select View details. Right click on 'Alfresco Node Reference' and select 'Copy link location'.

Execute the script from any space in Alfresco explorer suing 'Run Action', execute script.

I have not tested this, so you may have to adopt a bit.

avin_jss
Champ on-the-rise
Champ on-the-rise
setting the permission is not following the problem, i think we create authority then add authority.
So can you please suggest a new javascript for that

avin_jss
Champ on-the-rise
Champ on-the-rise
Finally i got the solution and i will posted soon.It required backward compatibility in alfresco share.

djau
Champ in-the-making
Champ in-the-making
solution ?

oscgon
Champ in-the-making
Champ in-the-making
I have the same error, so I´d like to know how can I resolve this problem.

roseta
Champ in-the-making
Champ in-the-making
please, I have the same problem now, could you please be so kind and post the solution you got? THANKS!!! 😃

jperilla
Champ in-the-making
Champ in-the-making
I have this same problem. Any solution yet?

kszosze
Champ in-the-making
Champ in-the-making
At moment the best solution I had found to fix permissions in older share after create new roles is that

var allSites = siteService.listSites(null, null, 0);

//var logFile = companyhome.childByNamePath("log.txt");
//   if (logFile == null)
//   {
//      logFile = companyhome.createFile("log.txt");
//   }

for (var siteIndex = 0; siteIndex < allSites.length; siteIndex++) {
   createAuthorities(allSites[siteIndex].shortName, [CustomRole,CustomRole2], allSites[siteIndex].getNode());
}

function createAuthorities(siteName, rolesList, siteNode) {
   var siteExp = "site_" + siteName;
   var prefix = siteExp + "_";
   //var n=search.findNode("workspace://SpacesStore/"+siteId);

//logFile.content = "Site.id :"+siteNode.id+"\r\n";
//logFile.content += "Node :"+siteNode+"\r\n";
//logFile.save();
   var rootGroup = groups.getGroup(siteExp);
   for (var roleIndex = 0; roleIndex < rolesList.length; roleIndex++) {
      var groupName = prefix + rolesList[roleIndex];
      if (groups.getGroup(groupName) == null){
         rootGroup.createGroup(groupName,siteName+"_"+rolesList[roleIndex]);
      }
      if(siteNode!=null)
      {   
//logFile.content += "Group :GROUP_" + groupName+"\r\n";
//logFile.save();
         siteNode.setPermission(rolesList[roleIndex], "GROUP_" + groupName);
      }
   }
}

Where CustomRole and CustomRole2 are the role name we had created in sitePermissionDefinitions.xml. If you only want to fix the permissions, just only comment the createGroup lines.
There are a collateral effect that I don't know how to solve it. Alfresco have some zones where which contains the node groups linked to the roles. In fact in share that zone is APP.SHARE. The elements contained in that zone are invisible to user in UI, so usually we don't know what are storage in. When we create a group needed for new roles, it is created in a public zone so we will see a lot of groups named like roles in our Groups Management UI. The ideal aproach is make that groups in APP.SHARE zone but doing it in Javascript API I can't. I think I must use Java.

I hope this can help you and be a nice workaround.
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍