Merged V2.9 to HEAD

10531: Merged V2.2 to V2.9
      9928: Optimise & consolidate get web project user role (ETWOTWO-568)
      9962: Reverted rev 9902 of RuleServiceImpl
      9964: Fixed transaction read-only declaration
      9979: ETWOTWO-572: Allow OpenOffice to be called remotely
      9987: Second attempt at fixing ETWOTWO-438: versionable aspect and invite user
      10096: Fix for ETWOTWO-507 FSR Service Port
      10224: Fix for ETWOTWO-507 (inconsistent results with add and delete together)
      10225: Adding logging and making FSR work with absolute directories (ETWOTWO-70 and ETWOONE-81)
      10254: ALFCOM-242, ALFCOM-230,  ETWOTWO-437
      10283: Fixed deployment installer builder to use IJ v1.2.7
      10359: Add Display Group for deployment servers to JSF client (ETWOTWO-474)
   10536: MT - simple setup/system test
   10553: Hid domain objects completely within the UsageDeltaDAO


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10613 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-09-01 13:56:46 +00:00
parent 11e3442f4c
commit 14a172a3d0
9 changed files with 450 additions and 86 deletions

View File

@@ -48,7 +48,6 @@ import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
@@ -343,26 +342,64 @@ public class WebProject implements Serializable
return true;
}
final ServiceRegistry serviceRegistry = this.getServiceRegistry();
final NodeService nodeService = serviceRegistry.getNodeService();
final String currentUser = user.getUserName();
final List<ChildAssociationRef> userInfoRefs =
nodeService.getChildAssocs(this.nodeRef,
WCMAppModel.ASSOC_WEBUSER,
RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : userInfoRefs)
{
final NodeRef userInfoRef = ref.getChildRef();
final String username = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
final String userrole = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
if (currentUser.equals(username) && AVMUtil.ROLE_CONTENT_MANAGER.equals(userrole))
{
return true;
}
}
return false;
String userrole = WebProject.getWebProjectUserRole(nodeRef, user);
return AVMUtil.ROLE_CONTENT_MANAGER.equals(userrole);
}
/**
* @return the role of this user in the given Web Project, or null for no assigned role
*/
public static String getWebProjectUserRole(NodeRef webProjectRef, User currentUser)
{
long start = System.currentTimeMillis();
String userrole = null;
if (currentUser.isAdmin())
{
// fake the Content Manager role for an admin user
userrole = AVMUtil.ROLE_CONTENT_MANAGER;
}
else
{
final ServiceRegistry serviceRegistry = WebProject.getServiceRegistry();
final SearchService searchService = serviceRegistry.getSearchService();
final NodeService nodeService = serviceRegistry.getNodeService();
StringBuilder query = new StringBuilder(128);
query.append("+PARENT:\"").append(webProjectRef).append("\" ");
query.append("+TYPE:\"").append(WCMAppModel.TYPE_WEBUSER).append("\" ");
query.append("+@").append(NamespaceService.WCMAPP_MODEL_PREFIX).append("\\:username:\"");
query.append(currentUser.getUserName());
query.append("\"");
ResultSet resultSet = searchService.query(
Repository.getStoreRef(),
SearchService.LANGUAGE_LUCENE,
query.toString());
List<NodeRef> nodes = resultSet.getNodeRefs();
if (nodes.size() == 1)
{
userrole = (String)nodeService.getProperty(nodes.get(0), WCMAppModel.PROP_WEBUSERROLE);
}
else if (nodes.size() == 0)
{
LOGGER.warn("getWebProjectUserRole: user role not found for " + currentUser);
}
else
{
LOGGER.warn("getWebProjectUserRole: more than one user role found for " + currentUser);
}
}
if (LOGGER.isInfoEnabled())
{
LOGGER.info("getWebProjectUserRole: "+currentUser.getUserName()+" "+userrole+" in "+(System.currentTimeMillis()-start)+" ms");
}
return userrole;
}
/**
* Returns the default webapp for this web project.
*