mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -1306,6 +1306,7 @@ deploy_server_type_test=Test Server
|
|||||||
deploy_server=Server
|
deploy_server=Server
|
||||||
deploy_server_type=Type
|
deploy_server_type=Type
|
||||||
deploy_server_name=Display Name
|
deploy_server_name=Display Name
|
||||||
|
deploy_server_group=Display Group
|
||||||
deploy_server_host=Host
|
deploy_server_host=Host
|
||||||
deploy_server_port=Port
|
deploy_server_port=Port
|
||||||
deploy_server_username=Username
|
deploy_server_username=Username
|
||||||
|
@@ -52,6 +52,7 @@ public final class DeploymentServerConfig implements Serializable
|
|||||||
public static final String PROP_EXCLUDES = "excludes";
|
public static final String PROP_EXCLUDES = "excludes";
|
||||||
public static final String PROP_ALLOCATED_TO = "allocatedTo";
|
public static final String PROP_ALLOCATED_TO = "allocatedTo";
|
||||||
public static final String PROP_ON_APPROVAL = "onApproval";
|
public static final String PROP_ON_APPROVAL = "onApproval";
|
||||||
|
public static final String PROP_GROUP = "group";
|
||||||
|
|
||||||
protected String id;
|
protected String id;
|
||||||
protected NodeRef serverRef;
|
protected NodeRef serverRef;
|
||||||
@@ -192,6 +193,13 @@ public final class DeploymentServerConfig implements Serializable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.props.get(PROP_GROUP) != null && ((String)this.props.get(PROP_GROUP)).length() > 0)
|
||||||
|
{
|
||||||
|
repoProps.put(WCMAppModel.PROP_DEPLOYSERVERGROUP, (Serializable)this.props.get(PROP_GROUP));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return repoProps;
|
return repoProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,5 +273,15 @@ public final class DeploymentServerConfig implements Serializable
|
|||||||
|
|
||||||
this.props.put(PROP_ON_APPROVAL, onApproval);
|
this.props.put(PROP_ON_APPROVAL, onApproval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (repoProps.get(WCMAppModel.PROP_DEPLOYSERVERGROUP) != null)
|
||||||
|
{
|
||||||
|
this.props.put(PROP_GROUP, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERGROUP));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Default the group to blank
|
||||||
|
this.props.put(PROP_GROUP, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,6 @@ import org.alfresco.config.JNDIConstants;
|
|||||||
import org.alfresco.model.WCMAppModel;
|
import org.alfresco.model.WCMAppModel;
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.sandbox.SandboxConstants;
|
import org.alfresco.sandbox.SandboxConstants;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
@@ -48,6 +47,7 @@ import org.alfresco.util.DNSNameMangler;
|
|||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.bean.repository.Repository;
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
|
import org.alfresco.web.bean.repository.User;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
@@ -254,11 +254,9 @@ public final class SandboxFactory
|
|||||||
|
|
||||||
public static boolean isContentManager(String storeId)
|
public static boolean isContentManager(String storeId)
|
||||||
{
|
{
|
||||||
ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
|
FacesContext context = FacesContext.getCurrentInstance();
|
||||||
|
ServiceRegistry services = Repository.getServiceRegistry(context);
|
||||||
AVMService avmService = services.getAVMService();
|
AVMService avmService = services.getAVMService();
|
||||||
NodeService nodeService = services.getNodeService();
|
|
||||||
|
|
||||||
String userName = AuthenticationUtil.getCurrentUserName();
|
|
||||||
|
|
||||||
String storeName = extractStagingAreaName(storeId);
|
String storeName = extractStagingAreaName(storeId);
|
||||||
PropertyValue pValue = avmService.getStoreProperty(storeName, SandboxConstants.PROP_WEB_PROJECT_NODE_REF);
|
PropertyValue pValue = avmService.getStoreProperty(storeName, SandboxConstants.PROP_WEB_PROJECT_NODE_REF);
|
||||||
@@ -267,20 +265,9 @@ public final class SandboxFactory
|
|||||||
{
|
{
|
||||||
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
|
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
|
||||||
|
|
||||||
// Apply sepcific user permissions as set on the web project
|
User currentUser = Application.getCurrentUser(context);
|
||||||
List<ChildAssociationRef> userInfoRefs = nodeService.getChildAssocs(webProjectNodeRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
String currentUserRole = WebProject.getWebProjectUserRole(webProjectNodeRef, currentUser);
|
||||||
for (ChildAssociationRef ref : userInfoRefs)
|
return AVMUtil.ROLE_CONTENT_MANAGER.equals(currentUserRole);
|
||||||
{
|
|
||||||
NodeRef userInfoRef = ref.getChildRef();
|
|
||||||
String user = (String) nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
|
|
||||||
String role = (String) nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
|
|
||||||
|
|
||||||
if(userName.equals(user) && role.equals(AVMUtil.ROLE_CONTENT_MANAGER))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -48,7 +48,6 @@ import org.alfresco.service.cmr.search.ResultSetRow;
|
|||||||
import org.alfresco.service.cmr.search.SearchParameters;
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.app.servlet.FacesHelper;
|
import org.alfresco.web.app.servlet.FacesHelper;
|
||||||
@@ -343,26 +342,64 @@ public class WebProject implements Serializable
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ServiceRegistry serviceRegistry = this.getServiceRegistry();
|
String userrole = WebProject.getWebProjectUserRole(nodeRef, user);
|
||||||
final NodeService nodeService = serviceRegistry.getNodeService();
|
return AVMUtil.ROLE_CONTENT_MANAGER.equals(userrole);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
* Returns the default webapp for this web project.
|
||||||
*
|
*
|
||||||
|
@@ -0,0 +1,31 @@
|
|||||||
|
package org.alfresco.web.ui.wcm.component;
|
||||||
|
|
||||||
|
import org.alfresco.web.bean.wcm.DeploymentServerConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comparator to compare the values of a property on a DeploymentServrtConfig.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DeploymentServerConfigComparator implements java.util.Comparator<DeploymentServerConfig>{
|
||||||
|
|
||||||
|
public DeploymentServerConfigComparator(String propertyName) {
|
||||||
|
this.propertyName = propertyName;
|
||||||
|
}
|
||||||
|
private String propertyName;
|
||||||
|
|
||||||
|
public int compare(DeploymentServerConfig o1, DeploymentServerConfig o2) {
|
||||||
|
String prop1 = (String)o1.getProperties().get(propertyName);
|
||||||
|
String prop2 = (String)o2.getProperties().get(propertyName);
|
||||||
|
|
||||||
|
if(prop1 != null) {
|
||||||
|
int result = prop1.compareTo(prop2);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if(prop2 != null){
|
||||||
|
// prop1 is null, prop2 is something
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// both prop1 and prop2 are null
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@@ -26,8 +26,12 @@ package org.alfresco.web.ui.wcm.component;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.faces.component.UIInput;
|
import javax.faces.component.UIInput;
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
@@ -44,10 +48,12 @@ import org.alfresco.web.app.Application;
|
|||||||
import org.alfresco.web.bean.repository.Repository;
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||||
import org.alfresco.web.bean.wcm.DeploymentMonitor;
|
import org.alfresco.web.bean.wcm.DeploymentMonitor;
|
||||||
|
import org.alfresco.web.bean.wcm.DeploymentServerConfig;
|
||||||
import org.alfresco.web.bean.wcm.DeploymentUtil;
|
import org.alfresco.web.bean.wcm.DeploymentUtil;
|
||||||
import org.alfresco.web.ui.common.Utils;
|
import org.alfresco.web.ui.common.Utils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.util.comparator.CompoundComparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSF component that allows a user to select which servers to deploy a
|
* JSF component that allows a user to select which servers to deploy a
|
||||||
@@ -88,11 +94,51 @@ public class UIDeployWebsite extends UIInput
|
|||||||
public void decode(FacesContext context)
|
public void decode(FacesContext context)
|
||||||
{
|
{
|
||||||
super.decode(context);
|
super.decode(context);
|
||||||
|
|
||||||
|
List<String> selectedNodes = new LinkedList<String>();
|
||||||
Map valuesMap = context.getExternalContext().getRequestParameterValuesMap();
|
Map valuesMap = context.getExternalContext().getRequestParameterValuesMap();
|
||||||
String[] values = (String[])valuesMap.get(this.getClientId(context));
|
|
||||||
|
// Non grouped checkboxes have the name of the clientId
|
||||||
|
addValues(selectedNodes, valuesMap, this.getClientId(context));
|
||||||
|
|
||||||
|
// If we have been grouping the checkboxes then the name will have been generated as follows
|
||||||
|
// name = this.getClientId(context) + ":group1:child";
|
||||||
|
Set<String> keys = valuesMap.keySet();
|
||||||
|
for( String key : keys)
|
||||||
|
{
|
||||||
|
// Check whether the key matches the pattern for a child checkbox
|
||||||
|
if(key.matches(this.getClientId(context) + ParentChildCheckboxHelper.helperChildPattern))
|
||||||
|
{
|
||||||
|
// Key does matches the pattern for a child
|
||||||
|
addValues(selectedNodes, valuesMap, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setSubmittedValue(values);
|
// Need to convert between between Object[] and String[] otherwise we get a class cast exception in the
|
||||||
|
// bowels of JSF.
|
||||||
|
String[] retVal = new String[selectedNodes.size()];
|
||||||
|
java.lang.System.arraycopy(selectedNodes.toArray(), 0 , retVal, 0, selectedNodes.size());
|
||||||
|
|
||||||
|
// These are the selected nodeIds of the servers which have been selected
|
||||||
|
setSubmittedValue(retVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the values from a map into a list
|
||||||
|
* @param selectedNodes list to add to
|
||||||
|
* @param valuesMap map of values
|
||||||
|
* @param key key into map
|
||||||
|
*/
|
||||||
|
private void addValues(List<String> selectedNodes, Map<String, String[]> valuesMap, String key)
|
||||||
|
{
|
||||||
|
String[] values = (String[])valuesMap.get(key);
|
||||||
|
if (values != null)
|
||||||
|
{
|
||||||
|
for(String value : values)
|
||||||
|
{
|
||||||
|
selectedNodes.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -125,7 +171,6 @@ public class UIDeployWebsite extends UIInput
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public void encodeBegin(FacesContext context) throws IOException
|
public void encodeBegin(FacesContext context) throws IOException
|
||||||
{
|
{
|
||||||
@@ -149,6 +194,10 @@ public class UIDeployWebsite extends UIInput
|
|||||||
|
|
||||||
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
|
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
|
||||||
|
|
||||||
|
out.write("<script type='text/javascript' src='");
|
||||||
|
out.write(context.getExternalContext().getRequestContextPath());
|
||||||
|
out.write("/scripts/select-all.js'></script>\n");
|
||||||
|
|
||||||
// add some before the panels
|
// add some before the panels
|
||||||
out.write("\n<div style='padding-top:4px;'></div>\n");
|
out.write("\n<div style='padding-top:4px;'></div>\n");
|
||||||
|
|
||||||
@@ -198,17 +247,36 @@ public class UIDeployWebsite extends UIInput
|
|||||||
NodeRef allocatedServer = DeploymentUtil.findAllocatedTestServer(getStore());
|
NodeRef allocatedServer = DeploymentUtil.findAllocatedTestServer(getStore());
|
||||||
if (allocatedServer != null)
|
if (allocatedServer != null)
|
||||||
{
|
{
|
||||||
|
// there is an allocated server
|
||||||
renderAllocatedTestServer(context, out, nodeService, allocatedServer);
|
renderAllocatedTestServer(context, out, nodeService, allocatedServer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<NodeRef> servers = DeploymentUtil.findTestServers(webProject, true);
|
// a test server needs to be selected - display the list of test servers
|
||||||
|
List<NodeRef> refs = DeploymentUtil.findTestServers(webProject, true);
|
||||||
|
|
||||||
|
// Resolve the unsorted list of NodeRef to a sorted list of DeploymentServerConfig.
|
||||||
|
List<DeploymentServerConfig> servers = toSortedDeploymentServerConfig(nodeService, refs);
|
||||||
|
|
||||||
|
|
||||||
if (servers.size() > 0)
|
if (servers.size() > 0)
|
||||||
{
|
{
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (NodeRef server : servers)
|
String currentDisplayGroup = "";
|
||||||
|
|
||||||
|
for (DeploymentServerConfig server: servers)
|
||||||
{
|
{
|
||||||
renderTestServer(context, out, nodeService, server, first);
|
// Write the display group title if it is a new title
|
||||||
|
String displayGroup = (String)server.getProperties().get(DeploymentServerConfig.PROP_GROUP);
|
||||||
|
if(!currentDisplayGroup.equalsIgnoreCase(displayGroup))
|
||||||
|
{
|
||||||
|
// yes title has changed - write out the new displayGroup
|
||||||
|
out.write("<p class='mainSubTitle'>");
|
||||||
|
out.write(displayGroup);
|
||||||
|
out.write("</p>");
|
||||||
|
currentDisplayGroup = displayGroup;
|
||||||
|
}
|
||||||
|
renderTestServer(context, out, nodeService, server.getServerRef(), first);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,15 +298,56 @@ public class UIDeployWebsite extends UIInput
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Display live servers not test servers
|
||||||
|
|
||||||
// TODO: get a list of the servers that have been successfully deployed to
|
// TODO: get a list of the servers that have been successfully deployed to
|
||||||
|
|
||||||
List<NodeRef> servers = DeploymentUtil.findLiveServers(webProject);
|
List<NodeRef> refs = DeploymentUtil.findLiveServers(webProject);
|
||||||
for (NodeRef server : servers)
|
|
||||||
|
// Resolve the unsorted list of NodeRef to a sorted list of DeploymentServerConfig.
|
||||||
|
List<DeploymentServerConfig> servers = toSortedDeploymentServerConfig(nodeService, refs);
|
||||||
|
|
||||||
|
ParentChildCheckboxHelper helper = new ParentChildCheckboxHelper(this.getClientId(context));
|
||||||
|
|
||||||
|
// Now display the servers
|
||||||
|
for (DeploymentServerConfig server : servers)
|
||||||
{
|
{
|
||||||
// TODO: determine if the server has already been successfully deployed to
|
// TODO: determine if the server has already been successfully deployed to
|
||||||
boolean selected = true;
|
boolean selected = true;
|
||||||
|
|
||||||
|
// Get the display group
|
||||||
|
String displayGroup = (String)server.getProperties().get(DeploymentServerConfig.PROP_GROUP);
|
||||||
|
|
||||||
renderLiveServer(context, out, nodeService, server, selected);
|
helper.setCurrentDisplayGroup(displayGroup);
|
||||||
|
if(helper.newGroup)
|
||||||
|
{
|
||||||
|
out.write("<p class='mainSubTitle'>");
|
||||||
|
out.write("<input type='checkbox' id='");
|
||||||
|
out.write(helper.groupParentId);
|
||||||
|
out.write("' value='");
|
||||||
|
out.write(displayGroup);
|
||||||
|
out.write("'");
|
||||||
|
out.write(" checked='checked' ");
|
||||||
|
|
||||||
|
out.write("onClick=\"select_all(\'");
|
||||||
|
out.write(helper.groupChildName);
|
||||||
|
out.write("\', this.checked);\" ");
|
||||||
|
out.write(" /> ");
|
||||||
|
|
||||||
|
out.write(displayGroup);
|
||||||
|
out.write("</p>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(helper.groupParentId.length() > 0)
|
||||||
|
{
|
||||||
|
// render the live server with a child checkbox
|
||||||
|
renderLiveServer(context, out, nodeService, server.getServerRef(), selected, helper.groupChildName, helper.groupParentId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// render the live server without a parent checkbox
|
||||||
|
renderLiveServer(context, out, nodeService, server.getServerRef(), selected, this.getClientId(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,16 +553,39 @@ public class UIDeployWebsite extends UIInput
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void renderLiveServer(FacesContext context, ResponseWriter out, NodeService nodeService,
|
private void renderLiveServer(FacesContext context, ResponseWriter out, NodeService nodeService,
|
||||||
NodeRef server, boolean selected) throws IOException
|
NodeRef server, boolean selected, String checkBoxName) throws IOException
|
||||||
|
{
|
||||||
|
renderLiveServer(context, out, nodeService, server, selected, checkBoxName, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderLiveServer(FacesContext context, ResponseWriter out, NodeService nodeService,
|
||||||
|
NodeRef server, boolean selected, String checkBoxName, String parentId) throws IOException
|
||||||
{
|
{
|
||||||
String contextPath = context.getExternalContext().getRequestContextPath();
|
String contextPath = context.getExternalContext().getRequestContextPath();
|
||||||
|
|
||||||
renderPanelStart(out, contextPath);
|
renderPanelStart(out, contextPath);
|
||||||
|
|
||||||
out.write("<div class='deployPanelControl'>");
|
out.write("<div class='deployPanelControl'>");
|
||||||
out.write("<input type='checkbox' name='");
|
out.write("<input type='checkbox' ");
|
||||||
out.write(this.getClientId(context));
|
if(checkBoxName != null && checkBoxName.length() > 0)
|
||||||
out.write("' value='");
|
{
|
||||||
|
out.write("name='");
|
||||||
|
out.write(checkBoxName);
|
||||||
|
out.write("' ");
|
||||||
|
|
||||||
|
// If there is a parent checkbox
|
||||||
|
// generate java script of the form
|
||||||
|
// onClick="select_one('xxx', 'area');"
|
||||||
|
if(parentId != null && parentId.length() > 0 )
|
||||||
|
{
|
||||||
|
out.write("onClick=\"select_one(\'");
|
||||||
|
out.write(parentId);
|
||||||
|
out.write("\', \'");
|
||||||
|
out.write(checkBoxName);
|
||||||
|
out.write("');\" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.write("value='");
|
||||||
out.write(server.toString());
|
out.write(server.toString());
|
||||||
out.write("'");
|
out.write("'");
|
||||||
if (selected)
|
if (selected)
|
||||||
@@ -606,6 +738,7 @@ public class UIDeployWebsite extends UIInput
|
|||||||
out.write("</div>");
|
out.write("</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void renderPanelEnd(ResponseWriter out, String contextPath) throws IOException
|
private void renderPanelEnd(ResponseWriter out, String contextPath) throws IOException
|
||||||
{
|
{
|
||||||
// render end of panel
|
// render end of panel
|
||||||
@@ -616,4 +749,76 @@ public class UIDeployWebsite extends UIInput
|
|||||||
// add some padding under each panel
|
// add some padding under each panel
|
||||||
out.write("\n<div style='padding-top:8px;'></div>\n");
|
out.write("\n<div style='padding-top:8px;'></div>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to read the details of the deployment nodes
|
||||||
|
* @param nodeService the node service
|
||||||
|
* @param refs a list of NodeRefs
|
||||||
|
*
|
||||||
|
* @return a sorted list of DeploymentServerConfig objects.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<DeploymentServerConfig> toSortedDeploymentServerConfig(NodeService nodeService, List<NodeRef> refs) {
|
||||||
|
// Resolve the list of NodeRef to a list of DeploymentServerConfig.
|
||||||
|
List<DeploymentServerConfig> servers = new ArrayList<DeploymentServerConfig>();
|
||||||
|
for (NodeRef ref : refs)
|
||||||
|
{
|
||||||
|
DeploymentServerConfig server = new DeploymentServerConfig(ref, nodeService.getProperties(ref));
|
||||||
|
servers.add(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort the deployment servers by display group then display name
|
||||||
|
CompoundComparator comp = new CompoundComparator();
|
||||||
|
comp.addComparator(new DeploymentServerConfigComparator(DeploymentServerConfig.PROP_GROUP));
|
||||||
|
comp.addComparator(new DeploymentServerConfigComparator(DeploymentServerConfig.PROP_NAME));
|
||||||
|
Collections.sort(servers, comp);
|
||||||
|
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ParentChildCheckboxHelper
|
||||||
|
{
|
||||||
|
private String clientId;
|
||||||
|
String currentDisplayGroup = "";
|
||||||
|
String groupChildName = "";
|
||||||
|
String groupParentId = "";
|
||||||
|
String groupName = "";
|
||||||
|
int groupNumber = 1;
|
||||||
|
boolean newGroup = false;
|
||||||
|
|
||||||
|
public ParentChildCheckboxHelper(String clientId)
|
||||||
|
{
|
||||||
|
this.clientId = clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentDisplayGroup(String currentDisplayGroup)
|
||||||
|
{
|
||||||
|
this.newGroup = !this.currentDisplayGroup.equalsIgnoreCase(currentDisplayGroup);
|
||||||
|
this.currentDisplayGroup = currentDisplayGroup;
|
||||||
|
if(this.newGroup)
|
||||||
|
{
|
||||||
|
changeGroup(currentDisplayGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String getCurrentDisplayGroup()
|
||||||
|
{
|
||||||
|
return currentDisplayGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeGroup(String newGroupName)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Examples of HTML naming scheme
|
||||||
|
// jsp17:group1:parent, jsp17:group1:child
|
||||||
|
// jsp17:group2:parent, jsp17:group2:child
|
||||||
|
groupName = clientId + ":group" + Integer.toString(groupNumber++);
|
||||||
|
groupChildName = groupName + ":child";
|
||||||
|
groupParentId = groupName + ":parent";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regex pattern for child checkbox names - matches implementation within changeGroup method of this class
|
||||||
|
*/
|
||||||
|
static final String helperChildPattern = ":group[\\d]+:child";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,7 @@ package org.alfresco.web.ui.wcm.component;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ import org.alfresco.web.ui.common.Utils;
|
|||||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||||
import org.alfresco.web.ui.common.component.UIListItem;
|
import org.alfresco.web.ui.common.component.UIListItem;
|
||||||
import org.alfresco.web.ui.repo.component.UIActions;
|
import org.alfresco.web.ui.repo.component.UIActions;
|
||||||
|
import org.springframework.util.comparator.CompoundComparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSF component that allows deployment servers to be added, edited and removed.
|
* JSF component that allows deployment servers to be added, edited and removed.
|
||||||
@@ -68,6 +70,7 @@ public class UIDeploymentServers extends UIInput
|
|||||||
private static final String MSG_TEST_SERVER = "deploy_server_type_test";
|
private static final String MSG_TEST_SERVER = "deploy_server_type_test";
|
||||||
private static final String MSG_TYPE = "deploy_server_type";
|
private static final String MSG_TYPE = "deploy_server_type";
|
||||||
private static final String MSG_NAME = "deploy_server_name";
|
private static final String MSG_NAME = "deploy_server_name";
|
||||||
|
private static final String MSG_GROUP = "deploy_server_group";
|
||||||
private static final String MSG_HOST = "deploy_server_host";
|
private static final String MSG_HOST = "deploy_server_host";
|
||||||
private static final String MSG_PORT = "deploy_server_port";
|
private static final String MSG_PORT = "deploy_server_port";
|
||||||
private static final String MSG_USER = "deploy_server_username";
|
private static final String MSG_USER = "deploy_server_username";
|
||||||
@@ -160,6 +163,12 @@ public class UIDeploymentServers extends UIInput
|
|||||||
|
|
||||||
List<DeploymentServerConfig> servers = getValue();
|
List<DeploymentServerConfig> servers = getValue();
|
||||||
|
|
||||||
|
// Sort the deployment servers by display group then display name
|
||||||
|
CompoundComparator comp = new CompoundComparator();
|
||||||
|
comp.addComparator(new DeploymentServerConfigComparator(DeploymentServerConfig.PROP_GROUP));
|
||||||
|
comp.addComparator(new DeploymentServerConfigComparator(DeploymentServerConfig.PROP_NAME));
|
||||||
|
Collections.sort(servers, comp);
|
||||||
|
|
||||||
if (getInAddMode())
|
if (getInAddMode())
|
||||||
{
|
{
|
||||||
renderServerForm(context, out, null, false);
|
renderServerForm(context, out, null, false);
|
||||||
@@ -177,10 +186,24 @@ public class UIDeploymentServers extends UIInput
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeploymentServerConfig currentServer = getCurrentServer();
|
DeploymentServerConfig currentServer = getCurrentServer();
|
||||||
|
String currentDisplayGroup = "";
|
||||||
|
|
||||||
for (DeploymentServerConfig server: servers)
|
for (DeploymentServerConfig server: servers)
|
||||||
{
|
{
|
||||||
|
// Write the display group title if it is a new title
|
||||||
|
String displayGroup = (String)server.getProperties().get(DeploymentServerConfig.PROP_GROUP);
|
||||||
|
if(!currentDisplayGroup.equalsIgnoreCase(displayGroup))
|
||||||
|
{
|
||||||
|
// yes title has changed - write out the new displayGroup
|
||||||
|
out.write("<p class='mainSubTitle'>");
|
||||||
|
out.write(displayGroup);
|
||||||
|
out.write("</p>");
|
||||||
|
currentDisplayGroup = displayGroup;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentServer != null && currentServer.getId().equals(server.getId()))
|
if (currentServer != null && currentServer.getId().equals(server.getId()))
|
||||||
{
|
{
|
||||||
|
// This is the server in edit mode
|
||||||
renderServerForm(context, out, server, true);
|
renderServerForm(context, out, server, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -638,7 +661,7 @@ public class UIDeploymentServers extends UIInput
|
|||||||
Utils.encodeRecursive(context, port);
|
Utils.encodeRecursive(context, port);
|
||||||
out.write("</td></tr>");
|
out.write("</td></tr>");
|
||||||
|
|
||||||
// create the server name field
|
// create the server display name field
|
||||||
out.write("<tr><td align='right'>");
|
out.write("<tr><td align='right'>");
|
||||||
out.write(bundle.getString(MSG_NAME));
|
out.write(bundle.getString(MSG_NAME));
|
||||||
out.write(":</td><td>");
|
out.write(":</td><td>");
|
||||||
@@ -654,6 +677,22 @@ public class UIDeploymentServers extends UIInput
|
|||||||
Utils.encodeRecursive(context, name);
|
Utils.encodeRecursive(context, name);
|
||||||
out.write("</td></tr>");
|
out.write("</td></tr>");
|
||||||
|
|
||||||
|
// create the display group name field
|
||||||
|
out.write("<tr><td align='right'>");
|
||||||
|
out.write(bundle.getString(MSG_GROUP));
|
||||||
|
out.write(":</td><td>");
|
||||||
|
UIComponent group = context.getApplication().createComponent(
|
||||||
|
UIInput.COMPONENT_TYPE);
|
||||||
|
FacesHelper.setupComponentId(context, group, null);
|
||||||
|
group.getAttributes().put("styleClass", "inputField");
|
||||||
|
ValueBinding vbGroup = context.getApplication().createValueBinding(
|
||||||
|
"#{WizardManager.bean.editedDeployServerProperties." +
|
||||||
|
DeploymentServerConfig.PROP_GROUP + "}");
|
||||||
|
group.setValueBinding("value", vbGroup);
|
||||||
|
this.getChildren().add(group);
|
||||||
|
Utils.encodeRecursive(context, group);
|
||||||
|
out.write("</td></tr>");
|
||||||
|
|
||||||
// create the server username field
|
// create the server username field
|
||||||
out.write("<tr><td align='right'>");
|
out.write("<tr><td align='right'>");
|
||||||
out.write(bundle.getString(MSG_USER));
|
out.write(bundle.getString(MSG_USER));
|
||||||
@@ -922,4 +961,5 @@ public class UIDeploymentServers extends UIInput
|
|||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -321,7 +321,8 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
|
|||||||
websiteRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
websiteRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
||||||
User currentUser = Application.getCurrentUser(context);
|
User currentUser = Application.getCurrentUser(context);
|
||||||
String currentUserName = currentUser.getUserName();
|
String currentUserName = currentUser.getUserName();
|
||||||
String currentUserRole = getWebProjectUserRole(nodeService, websiteRef, currentUser, userInfoRefs);
|
|
||||||
|
String currentUserRole = WebProject.getWebProjectUserRole(websiteRef, currentUser);
|
||||||
|
|
||||||
// sort the user list alphabetically and insert the current user at the top of the list
|
// sort the user list alphabetically and insert the current user at the top of the list
|
||||||
List<UserRoleWrapper> userRoleWrappers = buildSortedUserRoles(nodeService, currentUserName, userInfoRefs);
|
List<UserRoleWrapper> userRoleWrappers = buildSortedUserRoles(nodeService, currentUserName, userInfoRefs);
|
||||||
@@ -644,37 +645,6 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
|
|||||||
return wrappers;
|
return wrappers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the role of this user in the current Web Project, or null for no assigned role
|
|
||||||
*/
|
|
||||||
private static String getWebProjectUserRole(
|
|
||||||
NodeService nodeService, NodeRef websiteRef, User currentUser, List<ChildAssociationRef> userInfoRefs)
|
|
||||||
{
|
|
||||||
String userrole = null;
|
|
||||||
|
|
||||||
if (currentUser.isAdmin())
|
|
||||||
{
|
|
||||||
// fake the Content Manager role for an admin user
|
|
||||||
userrole = AVMUtil.ROLE_CONTENT_MANAGER;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (ChildAssociationRef ref : userInfoRefs)
|
|
||||||
{
|
|
||||||
NodeRef userInfoRef = ref.getChildRef();
|
|
||||||
String username = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
|
|
||||||
String role = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
|
|
||||||
if (currentUser.getUserName().equals(username))
|
|
||||||
{
|
|
||||||
userrole = role;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return userrole;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the list of user modified files/folders in the layered sandbox area.
|
* Render the list of user modified files/folders in the layered sandbox area.
|
||||||
*
|
*
|
||||||
|
75
source/web/scripts/select-all.js
Normal file
75
source/web/scripts/select-all.js
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
//
|
||||||
|
// Select All JS
|
||||||
|
//
|
||||||
|
// Java script utilities to support "select all" checkboxes.
|
||||||
|
// which consist of a parent checkbox and a collection of one or more
|
||||||
|
// child checkboxes.
|
||||||
|
// Clicking the parent checkbox sets the children.
|
||||||
|
// Clicking the children may affect the parent.
|
||||||
|
//
|
||||||
|
// select_all is called to set or reset all child checkboxes.
|
||||||
|
//
|
||||||
|
// select_child is called when a child is selected and may set or
|
||||||
|
// reset the parent depending upon whether all its siblings are set.
|
||||||
|
//
|
||||||
|
// prepare_select_all initialises this package
|
||||||
|
//
|
||||||
|
var formblock;
|
||||||
|
var forminputs;
|
||||||
|
|
||||||
|
function prepare_select_all() {
|
||||||
|
formblock= document.getElementById('dialog');
|
||||||
|
forminputs = formblock.getElementsByTagName('input');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* call after a child to set the value of the parent.
|
||||||
|
* @param parentId the id of the parent
|
||||||
|
* @param childname the name of the child checkbox
|
||||||
|
*/
|
||||||
|
function select_one(parentId, childname) {
|
||||||
|
var isSelected = true;
|
||||||
|
for (i = 0; i < forminputs.length; i++) {
|
||||||
|
var regex = new RegExp(childname, "i");
|
||||||
|
var x = forminputs[i];
|
||||||
|
if (regex.test(x.getAttribute('name'))) {
|
||||||
|
if(x.getAttribute('type') == 'checkbox') {
|
||||||
|
if(x.checked == false) {
|
||||||
|
isSelected = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var parent = document.getElementById(parentId);
|
||||||
|
parent.checked = isSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after the parent is clicked to set the value of the children.
|
||||||
|
* @param childname the name of the child checkboxes.
|
||||||
|
* @param value the value to set.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
function select_all(childname, value) {
|
||||||
|
for (i = 0; i < forminputs.length; i++) {
|
||||||
|
if(childname == forminputs[i].getAttribute('name')) {
|
||||||
|
if (value == '1') {
|
||||||
|
forminputs[i].checked = true;
|
||||||
|
} else {
|
||||||
|
forminputs[i].checked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.addEventListener) {
|
||||||
|
window.addEventListener("load", prepare_select_all, false);
|
||||||
|
} else if (window.attachEvent) {
|
||||||
|
window.attachEvent("onload", prepare_select_all)
|
||||||
|
} else if (document.getElementById) {
|
||||||
|
window.onload = prepare_select_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user