From 14a172a3d02cc484b593d2f97af2c67140729fad Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Mon, 1 Sep 2008 13:56:46 +0000 Subject: [PATCH] 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 --- config/alfresco/messages/webclient.properties | 1 + .../web/bean/wcm/DeploymentServerConfig.java | 18 ++ .../alfresco/web/bean/wcm/SandboxFactory.java | 25 +- .../org/alfresco/web/bean/wcm/WebProject.java | 75 ++++-- .../DeploymentServerConfigComparator.java | 31 +++ .../web/ui/wcm/component/UIDeployWebsite.java | 235 ++++++++++++++++-- .../ui/wcm/component/UIDeploymentServers.java | 42 +++- .../web/ui/wcm/component/UIUserSandboxes.java | 34 +-- source/web/scripts/select-all.js | 75 ++++++ 9 files changed, 450 insertions(+), 86 deletions(-) create mode 100644 source/java/org/alfresco/web/ui/wcm/component/DeploymentServerConfigComparator.java create mode 100644 source/web/scripts/select-all.js diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 212752fa50..9ad5369915 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -1306,6 +1306,7 @@ deploy_server_type_test=Test Server deploy_server=Server deploy_server_type=Type deploy_server_name=Display Name +deploy_server_group=Display Group deploy_server_host=Host deploy_server_port=Port deploy_server_username=Username diff --git a/source/java/org/alfresco/web/bean/wcm/DeploymentServerConfig.java b/source/java/org/alfresco/web/bean/wcm/DeploymentServerConfig.java index de56971f5b..57a2c8ec90 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeploymentServerConfig.java +++ b/source/java/org/alfresco/web/bean/wcm/DeploymentServerConfig.java @@ -52,6 +52,7 @@ public final class DeploymentServerConfig implements Serializable public static final String PROP_EXCLUDES = "excludes"; public static final String PROP_ALLOCATED_TO = "allocatedTo"; public static final String PROP_ON_APPROVAL = "onApproval"; + public static final String PROP_GROUP = "group"; protected String id; 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; } @@ -265,5 +273,15 @@ public final class DeploymentServerConfig implements Serializable 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, ""); + } } } diff --git a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java index b004a89d15..62e9456e84 100644 --- a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java +++ b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java @@ -33,7 +33,6 @@ import org.alfresco.config.JNDIConstants; import org.alfresco.model.WCMAppModel; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.sandbox.SandboxConstants; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.avm.AVMService; @@ -48,6 +47,7 @@ import org.alfresco.util.DNSNameMangler; import org.alfresco.util.GUID; import org.alfresco.web.app.Application; 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.LogFactory; @@ -254,11 +254,9 @@ public final class SandboxFactory 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(); - NodeService nodeService = services.getNodeService(); - - String userName = AuthenticationUtil.getCurrentUserName(); String storeName = extractStagingAreaName(storeId); 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); - // Apply sepcific user permissions as set on the web project - List userInfoRefs = nodeService.getChildAssocs(webProjectNodeRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef ref : userInfoRefs) - { - 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; + User currentUser = Application.getCurrentUser(context); + String currentUserRole = WebProject.getWebProjectUserRole(webProjectNodeRef, currentUser); + return AVMUtil.ROLE_CONTENT_MANAGER.equals(currentUserRole); } else { diff --git a/source/java/org/alfresco/web/bean/wcm/WebProject.java b/source/java/org/alfresco/web/bean/wcm/WebProject.java index a5c82e9dda..ea2cdc2ef9 100644 --- a/source/java/org/alfresco/web/bean/wcm/WebProject.java +++ b/source/java/org/alfresco/web/bean/wcm/WebProject.java @@ -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 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 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. * diff --git a/source/java/org/alfresco/web/ui/wcm/component/DeploymentServerConfigComparator.java b/source/java/org/alfresco/web/ui/wcm/component/DeploymentServerConfigComparator.java new file mode 100644 index 0000000000..ca8ef5c2db --- /dev/null +++ b/source/java/org/alfresco/web/ui/wcm/component/DeploymentServerConfigComparator.java @@ -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{ + + 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; + } +} diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java b/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java index 4480201274..c96a0a1247 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java @@ -26,8 +26,12 @@ package org.alfresco.web.ui.wcm.component; import java.io.IOException; import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import javax.faces.component.UIInput; 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.wcm.AVMUtil; 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.ui.common.Utils; import org.apache.commons.logging.Log; 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 @@ -88,11 +94,51 @@ public class UIDeployWebsite extends UIInput public void decode(FacesContext context) { super.decode(context); - + + List selectedNodes = new LinkedList(); 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 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 selectedNodes, Map valuesMap, String key) + { + String[] values = (String[])valuesMap.get(key); + if (values != null) + { + for(String value : values) + { + selectedNodes.add(value); + } + } } @SuppressWarnings("unchecked") @@ -125,7 +171,6 @@ public class UIDeployWebsite extends UIInput return values; } - @SuppressWarnings("unchecked") @Override public void encodeBegin(FacesContext context) throws IOException { @@ -149,6 +194,10 @@ public class UIDeployWebsite extends UIInput NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); + out.write("\n"); + // add some before the panels out.write("\n
\n"); @@ -198,17 +247,36 @@ public class UIDeployWebsite extends UIInput NodeRef allocatedServer = DeploymentUtil.findAllocatedTestServer(getStore()); if (allocatedServer != null) { + // there is an allocated server renderAllocatedTestServer(context, out, nodeService, allocatedServer); } else { - List servers = DeploymentUtil.findTestServers(webProject, true); + // a test server needs to be selected - display the list of test servers + List refs = DeploymentUtil.findTestServers(webProject, true); + + // Resolve the unsorted list of NodeRef to a sorted list of DeploymentServerConfig. + List servers = toSortedDeploymentServerConfig(nodeService, refs); + + if (servers.size() > 0) { 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("

"); + out.write(displayGroup); + out.write("

"); + currentDisplayGroup = displayGroup; + } + renderTestServer(context, out, nodeService, server.getServerRef(), first); first = false; } } @@ -230,15 +298,56 @@ public class UIDeployWebsite extends UIInput } else { + // Display live servers not test servers + // TODO: get a list of the servers that have been successfully deployed to - List servers = DeploymentUtil.findLiveServers(webProject); - for (NodeRef server : servers) + List refs = DeploymentUtil.findLiveServers(webProject); + + // Resolve the unsorted list of NodeRef to a sorted list of DeploymentServerConfig. + List 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 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("

"); + out.write(" "); + + out.write(displayGroup); + out.write("

"); + } + + 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, - 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(); - + renderPanelStart(out, contextPath); out.write("
"); - out.write(" 0) + { + 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("'"); if (selected) @@ -606,6 +738,7 @@ public class UIDeployWebsite extends UIInput out.write("
"); } + private void renderPanelEnd(ResponseWriter out, String contextPath) throws IOException { // render end of panel @@ -616,4 +749,76 @@ public class UIDeployWebsite extends UIInput // add some padding under each panel out.write("\n
\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 toSortedDeploymentServerConfig(NodeService nodeService, List refs) { + // Resolve the list of NodeRef to a list of DeploymentServerConfig. + List servers = new ArrayList(); + 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"; + } } diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentServers.java b/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentServers.java index e16bdd2011..2a6bf1c418 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentServers.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentServers.java @@ -26,6 +26,7 @@ package org.alfresco.web.ui.wcm.component; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; 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.UIListItem; 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. @@ -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_TYPE = "deploy_server_type"; 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_PORT = "deploy_server_port"; private static final String MSG_USER = "deploy_server_username"; @@ -160,6 +163,12 @@ public class UIDeploymentServers extends UIInput List 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()) { renderServerForm(context, out, null, false); @@ -177,10 +186,24 @@ public class UIDeploymentServers extends UIInput } DeploymentServerConfig currentServer = getCurrentServer(); + String currentDisplayGroup = ""; + 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("

"); + out.write(displayGroup); + out.write("

"); + currentDisplayGroup = displayGroup; + } + if (currentServer != null && currentServer.getId().equals(server.getId())) { + // This is the server in edit mode renderServerForm(context, out, server, true); } else @@ -638,7 +661,7 @@ public class UIDeploymentServers extends UIInput Utils.encodeRecursive(context, port); out.write(""); - // create the server name field + // create the server display name field out.write(""); out.write(bundle.getString(MSG_NAME)); out.write(":"); @@ -654,6 +677,22 @@ public class UIDeploymentServers extends UIInput Utils.encodeRecursive(context, name); out.write(""); + // create the display group name field + out.write(""); + out.write(bundle.getString(MSG_GROUP)); + out.write(":"); + 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(""); + // create the server username field out.write(""); out.write(bundle.getString(MSG_USER)); @@ -922,4 +961,5 @@ public class UIDeploymentServers extends UIInput return items; } + } diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java index c780be6a48..99038f1e1f 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java @@ -321,7 +321,8 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa websiteRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); User currentUser = Application.getCurrentUser(context); 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 List userRoleWrappers = buildSortedUserRoles(nodeService, currentUserName, userInfoRefs); @@ -644,37 +645,6 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa 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 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. * diff --git a/source/web/scripts/select-all.js b/source/web/scripts/select-all.js new file mode 100644 index 0000000000..dcd05a9314 --- /dev/null +++ b/source/web/scripts/select-all.js @@ -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; + } + + \ No newline at end of file