diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 67a5e01457..06189df85b 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -988,7 +988,6 @@ website_details=Web Project Details create_website_step1_title=Step One - Web Project Details create_website_step1_desc=Enter the information about the web project. website_dnsname=DNS name -website_deployto=Deploy To validation_invalid_dns_name=Invalid website DNS name: only alpha-numeric and non-initial/final hyphen characters are allowed (max length < 64). website_webapp=Default Webapp website_createfrom=Create From Existing Web Project @@ -1018,22 +1017,25 @@ form_template_templates=Configure Templates form_template_templates_desc=Setup the Templates you want to use for the Web Form {0} in Web Project {1}. form_template_workflow=Configure Workflow form_template_workflow_desc=Configure the workflow defaults for this Web Project -create_website_step3_title=Step Three - Configure Web Content Forms -create_website_step3_desc=Select and configure web forms for generating site content. +create_website_step3_title=Step Three - Configure Deployment Servers +create_website_step3_desc=Configure deployment servers for the web project. +website_deployment=Configure Deployment Servers +create_website_step4_title=Step Four - Configure Web Content Forms +create_website_step4_desc=Select and configure web forms for generating site content. website_select_form=Select Web Forms website_select_templates=Select Templates website_selected_templates=Selected Templates website_settings=Configure Workflow -create_website_step4_title=Step Four - Configure Workflow -create_website_step4_desc=Select and configure workflow for non-form generated assets. +create_website_step5_title=Step Five - Configure Workflow +create_website_step5_desc=Select and configure workflow for non-form generated assets. website_select_workflows=Select Workflows website_selected_workflows=Selected Workflows website_invite=Add Users -create_website_step5_title=Step Five - Add Users -create_website_step5_desc=Select users and their roles. +create_website_step6_title=Step Six - Add Users +create_website_step6_desc=Select users and their roles. website_notify=Email Users -create_website_step6_title=Step Six - Email Users -create_website_step6_desc=Notify the website users. +create_website_step7_title=Step Seven - Email Users +create_website_step7_desc=Notify the website users. create_website_finish_instruction=To close this wizard and create your web project space click Finish. To review or change your selections click Back. create_website_summary_users=Users and Roles edit_website_title=Edit Web Project Wizard @@ -1045,6 +1047,12 @@ workflow_not_configured=Workflow not configured error_filename_pattern=Error with workflow filename pattern: {0} workflow_not_set=no workflow rendering_engines_selected=Templates Selected +edit_website_step2_title=Step Two - Configure Deployment Servers +edit_website_step2_desc=Configure deployment servers for the web project. +edit_website_step3_title=Step Three - Configure Web Content Forms +edit_website_step3_desc=Select and configure web forms for generating site content. +edit_website_step4_title=Step Four - Configure Workflow +edit_website_step4_desc=Select and configure workflow for non-form generated assets. # Invite web users wizard messages invite_website_users=Invite Web Project Users @@ -1211,6 +1219,23 @@ deploy_status_in_progress=IN PROGRESS deploy_status_live=LIVE deploy_status_failed=FAILED deploy_status_partial=PARTIAL FAILURE +deploy_add_alf_receiver=Add Alfresco Server Receiver (ASR) +deploy_add_file_receiver=Add File System Receiver (FSR) +deploy_server_type_live=Live Server +deploy_server_type_test=Test Server +deploy_server_type=Type +deploy_server_name=Name +deploy_server_host=Host +deploy_server_port=Port +deploy_server_username=Username +deploy_server_password=Password +deploy_server_url=URL +deploy_server_source_path=Source Path +deploy_server_target_name=Target Name +deploy_automatically=Auto Deploy +edit_deploy_server=Edit Deployment Server Details +delete_deploy_server=Delete Deployment Server +no_deploy_servers=No deployment servers have been configured. reason=Reason snapshot=Snapshot content_launch=Content Launch diff --git a/config/alfresco/web-client-config-wizards.xml b/config/alfresco/web-client-config-wizards.xml index ddc8656182..29751f5893 100644 --- a/config/alfresco/web-client-config-wizards.xml +++ b/config/alfresco/web-client-config-wizards.xml @@ -22,30 +22,36 @@ description-id="create_website_step2_desc" instruction-id="default_instruction" /> - - + - - + - - + - - + + + + - - + - + + + + diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java index a32002cccc..9276db5194 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java @@ -71,6 +71,7 @@ import org.alfresco.web.forms.FormNotFoundException; import org.alfresco.web.forms.FormsService; import org.alfresco.web.forms.RenderingEngineTemplate; 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.common.component.UISelectList; import org.alfresco.web.ui.wcm.WebResources; @@ -94,6 +95,7 @@ public class CreateWebsiteWizard extends BaseWizardBean // wizard step names (that are referenced) private static final String STEP_DETAILS = "details"; private static final String STEP_FORMS = "forms"; + private static final String STEP_DEPLOYMENT = "deployment"; private static final String MATCH_DEFAULT = ".*"; @@ -143,19 +145,25 @@ public class CreateWebsiteWizard extends BaseWizardBean /** datamodel for table of selected workflows */ transient private DataModel workflowsDataModel = null; - /** transient list of workflow UIListItem objects */ - transient private List workflowsList = null; - /** list of workflow wrapper objects */ protected List workflows = null; /** Current workflow for dialog context */ protected WorkflowConfiguration actionWorkflow = null; + /** Map and list of deployment servers */ + protected Map deployServersMap = null; + protected List deployServersList = null; + + /** Current state of deploy server editing */ + protected DeploymentServerConfig currentDeployServer = null; + protected Map editedDeployServerProps = null; + protected boolean inAddDeployServerMode = false; + protected String addDeployServerType = WCMAppModel.CONSTRAINT_FILEDEPLOY; + /** Data for virtualization server notification */ private SandboxInfo sandboxInfo; - // ------------------------------------------------------------------------------ // Wizard implementation @@ -171,7 +179,7 @@ public class CreateWebsiteWizard extends BaseWizardBean this.title = null; this.description = null; this.isSource = false; - clearFormsWorkflowsAndUsers(); + clearFormsWorkflowsDeploymentAndUsers(); this.createFrom = CREATE_EMPTY; // requry existing web projects list every 10 seconds this.webProjectsList = new ExpiringValueCache>(1000L*10L); @@ -180,13 +188,21 @@ public class CreateWebsiteWizard extends BaseWizardBean this.showAllSourceProjects = false; } - private void clearFormsWorkflowsAndUsers() + private void clearFormsWorkflowsDeploymentAndUsers() { this.formsDataModel = null; this.forms = new ArrayList(8); this.workflowsDataModel = null; this.workflows = new ArrayList(4); + // reset all deployment data + this.deployServersMap = new HashMap(4, 1.0f); + this.deployServersList = new ArrayList(4); + this.currentDeployServer = null; + this.editedDeployServerProps = new HashMap(12, 1.0f); + this.inAddDeployServerMode = false; + this.addDeployServerType = WCMAppModel.CONSTRAINT_FILEDEPLOY; + // init the dependant bean we are using for the invite users pages InviteWebsiteUsersWizard wiz = getInviteUsersWizard(); wiz.init(null); @@ -266,7 +282,8 @@ public class CreateWebsiteWizard extends BaseWizardBean // set the property on the node to reference the root AVM store getNodeService().setProperty(nodeRef, WCMAppModel.PROP_AVMSTORE, avmStore); - // persist the forms, templates, workflows and workflow defaults to the model for this web project + // persist the forms, templates, workflows, workflow defaults and deployment + // config to the model for this web project saveWebProjectModel(nodeRef); // navigate to the Websites folder so we can see the newly created folder @@ -311,7 +328,8 @@ public class CreateWebsiteWizard extends BaseWizardBean } /** - * Persist the forms, templates, workflows and workflow defaults to the model for this web project + * Persist the forms, templates, workflows, workflow defaults and deployment config + * to the model for this web project * * @param nodeRef NodeRef to the web project */ @@ -385,7 +403,7 @@ public class CreateWebsiteWizard extends BaseWizardBean } } - // finally walk each web project workflow definition and save defaults for each + // walk each web project workflow definition and save defaults for each for (WorkflowWrapper workflow : this.workflows) { props.clear(); @@ -410,11 +428,24 @@ public class CreateWebsiteWizard extends BaseWizardBean getNodeService().addAspect(workflowRef, WCMAppModel.ASPECT_FILENAMEPATTERN, props); } } + + // finally walk through the deployment config and save + for (DeploymentServerConfig server : this.deployServersList) + { + Map repoProps = server.getRepoProps(); + + getNodeService().createNode(nodeRef, WCMAppModel.ASSOC_DEPLOYMENTSERVER, + WCMAppModel.ASSOC_DEPLOYMENTSERVER, WCMAppModel.TYPE_DEPLOYMENTSERVER, + repoProps); + + if (logger.isDebugEnabled()) + logger.debug("Saved deploymentserver node using repo props: " + repoProps); + } } /** - * Restore the forms, templates and workflows from the model for a web project. Can also - * optional restore the basic node propetries and user details. + * Restore the forms, templates, workflows and deployment config from the model for a web project. + * Can also optionally restore the basic node propetries and user details. * * @param nodeRef NodeRef to the web project to load model from * @param loadProperties Load the basic properties such as name, title, DNS. @@ -541,6 +572,22 @@ public class CreateWebsiteWizard extends BaseWizardBean this.workflows.add(wfWrapper); } } + + // load the deployment server config objects + List serverRefs = getNodeService().getChildAssocs( + nodeRef, WCMAppModel.ASSOC_DEPLOYMENTSERVER, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef sChildRef : serverRefs) + { + NodeRef serverRef = sChildRef.getChildRef(); + DeploymentServerConfig server = new DeploymentServerConfig( + serverRef, getNodeService().getProperties(serverRef)); + + this.deployServersList.add(server); + this.deployServersMap.put(server.getId(), server); + + if (logger.isDebugEnabled()) + logger.debug("Loaded deploy server config: " + server); + } } @@ -895,9 +942,9 @@ public class CreateWebsiteWizard extends BaseWizardBean public String next() { String stepName = Application.getWizardManager().getCurrentStepName(); - if (STEP_FORMS.equals(stepName)) + if (STEP_DEPLOYMENT.equals(stepName)) { - // if we have just entered the Forms page and the Create From page data has changed + // if we have just entered the deployment page and the Create From page data has changed // then we need to pre-populate the Forms etc. from the template web project updateModelOnCreateFromChange(); } @@ -915,13 +962,13 @@ public class CreateWebsiteWizard extends BaseWizardBean { if (this.sourceWebProject != null && this.sourceWebProject.length != 0) { - clearFormsWorkflowsAndUsers(); + clearFormsWorkflowsDeploymentAndUsers(); loadWebProjectModel(new NodeRef(this.sourceWebProject[0]), false, true); } } else { - clearFormsWorkflowsAndUsers(); + clearFormsWorkflowsDeploymentAndUsers(); } this.createFromValueChanged = false; @@ -989,6 +1036,155 @@ public class CreateWebsiteWizard extends BaseWizardBean return result; } + // ------------------------------------------------------------------------------ + // Deployment server configuration + + /** + * @return Determines whether a deployment server is being added + */ + public boolean isInAddDeployServerMode() + { + return this.inAddDeployServerMode; + } + + /** + * @return The type of server receiver to add, either 'alfresco' or 'file' + */ + public String getAddDeployServerType() + { + return this.addDeployServerType; + } + + /** + * @return The deploy server currently being added or edited + */ + public DeploymentServerConfig getCurrentDeployServer() + { + return this.currentDeployServer; + } + + /** + * @return The properties of the deploy server currently being added or edited + */ + public Map getEditedDeployServerProperties() + { + return this.editedDeployServerProps; + } + + /** + * @return Map of the deployment servers currently configured for the web project + */ + public List getDeployServers() + { + return this.deployServersList; + } + + /** + * Sets up the wizard for adding a new Alfresco Server Receiver + * + * @return null outcome to stay on same page + */ + public String addAlfrescoServerReceiver() + { + this.addDeployServerType = WCMAppModel.CONSTRAINT_ALFDEPLOY; + this.inAddDeployServerMode = true; + + // create an empty server config + this.currentDeployServer = new DeploymentServerConfig(this.addDeployServerType); + this.editedDeployServerProps.clear(); + + // refresh the current page + return null; + } + + /** + * Sets up the wizard for adding a new File System Receiver + * + * @return null outcome to stay on same page + */ + public String addFileSystemReceiver() + { + this.addDeployServerType = WCMAppModel.CONSTRAINT_FILEDEPLOY; + this.inAddDeployServerMode = true; + + // create an empty server config + this.currentDeployServer = new DeploymentServerConfig(this.addDeployServerType); + this.editedDeployServerProps.clear(); + + // refresh the current page + return null; + } + + public void editDeploymentServerConfig(ActionEvent event) + { + UIActionLink link = (UIActionLink)event.getComponent(); + Map params = link.getParameterMap(); + String id = params.get("id"); + if (id != null && id.length() != 0) + { + this.inAddDeployServerMode = false; + + // setup the config object to edit + this.currentDeployServer = this.deployServersMap.get(id); + this.editedDeployServerProps.clear(); + this.editedDeployServerProps.putAll(this.currentDeployServer.getProperties()); + + if (logger.isDebugEnabled()) + logger.debug("Set current deploy server to: " + this.currentDeployServer); + } + } + + public void deleteDeploymentServerConfig(ActionEvent event) + { + UIActionLink link = (UIActionLink)event.getComponent(); + Map params = link.getParameterMap(); + String id = params.get("id"); + if (id != null && id.length() != 0) + { + this.currentDeployServer = null; + this.editedDeployServerProps.clear(); + this.inAddDeployServerMode = false; + + // remove the config object from the list and map + DeploymentServerConfig dsc = this.deployServersMap.get(id); + if (dsc != null) + { + this.deployServersList.remove(dsc); + this.deployServersMap.remove(dsc.getId()); + + if (logger.isDebugEnabled()) + logger.debug("Removed deploy server config with id: " + id); + } + } + } + + public String addDeploymentServerConfig() + { + // add the new config to the list and map + this.deployServersList.add(this.currentDeployServer); + this.deployServersMap.put(this.currentDeployServer.getId(), + this.currentDeployServer); + + // save the changes + return saveDeploymentServerConfig(); + } + + public String saveDeploymentServerConfig() + { + // set the edited properties + this.currentDeployServer.setProperties(this.editedDeployServerProps); + + if (logger.isDebugEnabled()) + logger.debug("Updated deploy server config: " + this.currentDeployServer); + + // reset state + this.currentDeployServer = null; + this.editedDeployServerProps.clear(); + this.inAddDeployServerMode = false; + + // refresh the current page + return null; + } // ------------------------------------------------------------------------------ // Define Web Content Workflows page @@ -1181,7 +1377,7 @@ public class CreateWebsiteWizard extends BaseWizardBean item.setImage(WebResources.IMAGE_WORKFLOW_32); items.add(item); } - this.workflowsList = items; + return items; } diff --git a/source/java/org/alfresco/web/bean/wcm/DeploymentServerConfig.java b/source/java/org/alfresco/web/bean/wcm/DeploymentServerConfig.java new file mode 100644 index 0000000000..cf9f8db2da --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/DeploymentServerConfig.java @@ -0,0 +1,248 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.web.bean.wcm; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.WCMAppModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; + +/** + * Object holding the configuration for a deployment server. + * + * @author Gavin Cornwell + */ +public final class DeploymentServerConfig implements Serializable +{ + public static final String PROP_TYPE = "type"; + public static final String PROP_NAME = "name"; + public static final String PROP_HOST = "host"; + public static final String PROP_PORT = "port"; + public static final String PROP_USER = "username"; + public static final String PROP_PASSWORD = "password"; + public static final String PROP_URL = "url"; + public static final String PROP_SOURCE_PATH = "sourcePath"; + public static final String PROP_TARGET_NAME = "targetName"; + public static final String PROP_ALLOCATED_TO = "allocatedTo"; + public static final String PROP_ON_APPROVAL = "onApproval"; + + protected String id; + protected NodeRef serverRef; + protected String deployType; + protected Map props; + + private static final long serialVersionUID = -8894113751463815194L; + + public DeploymentServerConfig(String deployType) + { + this.id = GUID.generate(); + this.deployType = deployType; + this.props = new HashMap(12, 1.0f); + } + + public DeploymentServerConfig(NodeRef serverRef, Map repoProps) + { + this.id = GUID.generate(); + this.serverRef = serverRef; + this.deployType = (String)repoProps.get(WCMAppModel.PROP_DEPLOYTYPE); + + populateFromRepoProps(repoProps); + } + + public String toString() + { + StringBuilder buffer = new StringBuilder(super.toString()); + buffer.append(" (id=").append(this.id); + buffer.append(" serverRef=").append(this.serverRef); + buffer.append(" deployType=").append(this.deployType); + buffer.append(" props=").append(this.props).append(")"); + return buffer.toString(); + } + + public String getId() + { + return this.id; + } + + public NodeRef getServerRef() + { + return this.serverRef; + } + + public String getDeployType() + { + return this.deployType; + } + + public Map getProperties() + { + return this.props; + } + + public void setProperties(Map props) + { + this.props = new HashMap(props.size()); + this.props.putAll(props); + } + + public Map getRepoProps() + { + Map repoProps = new HashMap(8); + + repoProps.put(WCMAppModel.PROP_DEPLOYTYPE, this.deployType); + repoProps.put(WCMAppModel.PROP_DEPLOYSERVERTYPE, (Serializable)this.props.get(PROP_TYPE)); + + if (this.props.get(PROP_HOST) != null && ((String)this.props.get(PROP_HOST)).length() > 0) + { + repoProps.put(WCMAppModel.PROP_DEPLOYSERVERHOST, (Serializable)this.props.get(PROP_HOST)); + } + + if (this.props.get(PROP_PORT) != null && ((String)this.props.get(PROP_PORT)).length() > 0) + { + repoProps.put(WCMAppModel.PROP_DEPLOYSERVERPORT, new Integer((String)this.props.get(PROP_PORT))); + } + + if (this.props.get(PROP_NAME) != null && ((String)this.props.get(PROP_NAME)).length() > 0) + { + repoProps.put(WCMAppModel.PROP_DEPLOYSERVERNAME, (Serializable)this.props.get(PROP_NAME)); + } + + if (this.props.get(PROP_USER) != null && ((String)this.props.get(PROP_USER)).length() > 0) + { + repoProps.put(WCMAppModel.PROP_DEPLOYSERVERUSERNAME, (Serializable)this.props.get(PROP_USER)); + } + + if (this.props.get(PROP_PASSWORD) != null && ((String)this.props.get(PROP_PASSWORD)).length() > 0) + { + repoProps.put(WCMAppModel.PROP_DEPLOYSERVERPASSWORD, (Serializable)this.props.get(PROP_PASSWORD)); + } + + if (this.props.get(PROP_URL) != null && ((String)this.props.get(PROP_URL)).length() > 0) + { + repoProps.put(WCMAppModel.PROP_DEPLOYSERVERURL, (Serializable)this.props.get(PROP_URL)); + } + + if (this.props.get(PROP_SOURCE_PATH) != null && ((String)this.props.get(PROP_SOURCE_PATH)).length() > 0) + { + repoProps.put(WCMAppModel.PROP_DEPLOYSOURCEPATH, (Serializable)this.props.get(PROP_SOURCE_PATH)); + } + + if (this.props.get(PROP_ALLOCATED_TO) != null && ((String)this.props.get(PROP_ALLOCATED_TO)).length() > 0) + { + repoProps.put(WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO, (Serializable)this.props.get(PROP_ALLOCATED_TO)); + } + + // only save the target if it's an FSR (File System Receiver) + if (WCMAppModel.CONSTRAINT_FILEDEPLOY.equals(this.deployType)) + { + if (this.props.get(PROP_TARGET_NAME) != null && ((String)this.props.get(PROP_TARGET_NAME)).length() > 0) + { + repoProps.put(WCMAppModel.PROP_DEPLOYSERVERTARGET, (Serializable)this.props.get(PROP_TARGET_NAME)); + } + } + + // only save the approval flag if the server type is a 'live' server + if (WCMAppModel.CONSTRAINT_LIVESERVER.equals(this.props.get(PROP_TYPE))) + { + if (this.props.get(PROP_ON_APPROVAL) != null) + { + repoProps.put(WCMAppModel.PROP_DEPLOYONAPPROVAL, (Serializable)this.props.get(PROP_ON_APPROVAL)); + } + } + + return repoProps; + } + + protected void populateFromRepoProps(Map repoProps) + { + this.props = new HashMap(repoProps.size()); + + this.props.put(PROP_TYPE, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERTYPE)); + this.props.put(PROP_HOST, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERHOST)); + + if (repoProps.get(WCMAppModel.PROP_DEPLOYSERVERNAME) != null) + { + this.props.put(PROP_NAME, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERNAME)); + } + + if (repoProps.get(WCMAppModel.PROP_DEPLOYSERVERPORT) != null) + { + Integer port = (Integer)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERPORT); + this.props.put(PROP_PORT, port.toString()); + } + + if (repoProps.get(WCMAppModel.PROP_DEPLOYSERVERUSERNAME) != null) + { + this.props.put(PROP_USER, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERUSERNAME)); + } + + if (repoProps.get(WCMAppModel.PROP_DEPLOYSERVERPASSWORD) != null) + { + this.props.put(PROP_PASSWORD, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERPASSWORD)); + } + + if (repoProps.get(WCMAppModel.PROP_DEPLOYSERVERURL) != null) + { + this.props.put(PROP_URL, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERURL)); + } + + if (repoProps.get(WCMAppModel.PROP_DEPLOYSOURCEPATH) != null) + { + this.props.put(PROP_SOURCE_PATH, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSOURCEPATH)); + } + + if (repoProps.get(WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO) != null) + { + this.props.put(PROP_ALLOCATED_TO, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO)); + } + + if (WCMAppModel.CONSTRAINT_FILEDEPLOY.equals(this.deployType)) + { + if (repoProps.get(WCMAppModel.PROP_DEPLOYSERVERTARGET) != null) + { + this.props.put(PROP_TARGET_NAME, (String)repoProps.get(WCMAppModel.PROP_DEPLOYSERVERTARGET)); + } + } + + if (WCMAppModel.CONSTRAINT_LIVESERVER.equals(this.props.get(PROP_TYPE))) + { + Boolean onApproval = null; + if (repoProps.get(WCMAppModel.PROP_DEPLOYONAPPROVAL) != null) + { + onApproval = (Boolean)repoProps.get(WCMAppModel.PROP_DEPLOYONAPPROVAL); + } + else + { + onApproval = Boolean.FALSE; + } + + this.props.put(PROP_ON_APPROVAL, onApproval); + } + } +} diff --git a/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java index a46df47f8b..ad43ed28d9 100644 --- a/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java @@ -88,8 +88,8 @@ public class EditWebsiteWizard extends CreateWebsiteWizard getNodeService().setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, this.description); getNodeService().setProperty(nodeRef, WCMAppModel.PROP_ISSOURCE, this.isSource); - // clear the existing settings for forms, template and workflows - then the existing methods - // can be used to apply the modified and previous settings from scratch + // clear the existing settings for forms, template, workflows and deployment - then + // the existing methods can be used to apply the modified and previous settings from scratch clearWebProjectModel(nodeRef); // change/create the root webapp name for the website @@ -106,7 +106,8 @@ public class EditWebsiteWizard extends CreateWebsiteWizard // TODO: allow change of dns name - via store rename functionality - // persist the forms, templates, workflows and workflow defaults to the model for this web project + // persist the forms, templates, workflows, workflow defaults and deployment config + // to the model for this web project saveWebProjectModel(nodeRef); return AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME; @@ -133,5 +134,12 @@ public class EditWebsiteWizard extends CreateWebsiteWizard { getNodeService().removeChild(nodeRef, ref.getChildRef()); } + + List serverRefs = getNodeService().getChildAssocs( + nodeRef, WCMAppModel.ASSOC_DEPLOYMENTSERVER, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef ref : serverRefs) + { + getNodeService().removeChild(nodeRef, ref.getChildRef()); + } } } 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 f87b79da88..88d6a166c7 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java @@ -436,6 +436,7 @@ public class UIDeployWebsite extends UIInput String contextPath = context.getExternalContext().getRequestContextPath(); Map props = nodeService.getProperties(server); + String deployType = (String)props.get(WCMAppModel.PROP_DEPLOYTYPE); String serverName = (String)props.get(WCMAppModel.PROP_DEPLOYSERVERNAME); if (serverName == null || serverName.length() == 0) { @@ -481,7 +482,9 @@ public class UIDeployWebsite extends UIInput out.write("
"); out.write("
"); + out.write("/images/icons/deploy_server_"); + out.write(deployType); + out.write(".gif' />"); out.write(""); diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java b/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java index 161afa71a1..7d582617a4 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.Serializable; import java.util.Date; import java.util.List; +import java.util.Map; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; @@ -36,6 +37,7 @@ import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMAppModel; +import org.alfresco.repo.avm.actions.AVMDeploySnapshotAction; import org.alfresco.repo.domain.PropertyValue; import org.alfresco.sandbox.SandboxConstants; import org.alfresco.service.cmr.avm.AVMService; @@ -44,6 +46,7 @@ import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; @@ -237,29 +240,42 @@ public class UIDeploymentReports extends SelfRenderingComponent context.getExternalContext().getRequestContextPath(), "innerwhite", "white"); // extract the information we need to display - String server = (String)nodeService.getProperty(deploymentReport, WCMAppModel.PROP_DEPLOYSERVER); - String creator = (String)nodeService.getProperty(deploymentReport, ContentModel.PROP_CREATOR); - Date startTime = (Date)nodeService.getProperty(deploymentReport, WCMAppModel.PROP_DEPLOYSTARTTIME); + Map serverProps = nodeService.getProperties(deploymentReport); + String server = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVER); + String serverName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERNAMEUSED); + if (serverName == null || serverName.length() == 0) + { + serverName = server; + } + + String deployType = WCMAppModel.CONSTRAINT_ALFDEPLOY; + if (server.startsWith(AVMDeploySnapshotAction.FILE_SERVER_PREFIX)) + { + deployType = WCMAppModel.CONSTRAINT_FILEDEPLOY; + } + + String creator = (String)serverProps.get(ContentModel.PROP_CREATOR); + Date startTime = (Date)serverProps.get(WCMAppModel.PROP_DEPLOYSTARTTIME); String started = null; if (startTime != null) { started = Utils.getDateTimeFormat(context).format(startTime); } - Date endTime = (Date)nodeService.getProperty(deploymentReport, WCMAppModel.PROP_DEPLOYENDTIME); + Date endTime = (Date)serverProps.get(WCMAppModel.PROP_DEPLOYENDTIME); String finished = null; if (endTime != null) { finished = Utils.getDateTimeFormat(context).format(endTime); } - Boolean success = (Boolean)nodeService.getProperty(deploymentReport, WCMAppModel.PROP_DEPLOYSUCCESSFUL); + Boolean success = (Boolean)serverProps.get(WCMAppModel.PROP_DEPLOYSUCCESSFUL); if (success == null) { success = Boolean.FALSE; } - String failReason = (String)nodeService.getProperty(deploymentReport, WCMAppModel.PROP_DEPLOYFAILEDREASON); + String failReason = (String)serverProps.get(WCMAppModel.PROP_DEPLOYFAILEDREASON); String content = ""; ContentReader reader = contentService.getReader(deploymentReport, ContentModel.PROP_CONTENT); if (reader != null) @@ -276,7 +292,7 @@ public class UIDeploymentReports extends SelfRenderingComponent } int snapshot = -1; - Serializable snapshotObj = nodeService.getProperty(deploymentReport, WCMAppModel.PROP_DEPLOYVERSION); + Serializable snapshotObj = serverProps.get(WCMAppModel.PROP_DEPLOYVERSION); if (snapshotObj != null && snapshotObj instanceof Integer) { snapshot = (Integer)snapshotObj; @@ -285,9 +301,11 @@ public class UIDeploymentReports extends SelfRenderingComponent out.write(""); out.write("
"); + out.write("/images/icons/deploy_server_"); + out.write(deployType); + out.write(".gif' />"); out.write("
"); - out.write(server); + out.write(serverName); out.write("
servers; + private DeploymentServerConfig currentServer; + private Boolean inAddMode; + private String addType; + + // ------------------------------------------------------------------------------ + // Component implementation + + /** + * Default constructor + */ + public UIDeploymentServers() + { + setRendererType(null); + } + + @Override + public String getFamily() + { + return "org.alfresco.faces.DeploymentServers"; + } + + @SuppressWarnings("unchecked") + @Override + public void restoreState(FacesContext context, Object state) + { + Object values[] = (Object[])state; + // standard component attributes are restored by the super class + super.restoreState(context, values[0]); + this.servers = (List)values[1]; + this.inAddMode = (Boolean)values[2]; + this.addType = (String)values[3]; + this.currentServer = (DeploymentServerConfig)values[4]; + } + + @Override + public Object saveState(FacesContext context) + { + Object values[] = new Object[5]; + // standard component attributes are saved by the super class + values[0] = super.saveState(context); + values[1] = this.servers; + values[2] = this.inAddMode; + values[3] = this.addType; + values[4] = this.currentServer; + return values; + } + + @SuppressWarnings("unchecked") + @Override + public void encodeBegin(FacesContext context) throws IOException + { + if (isRendered() == false) + { + return; + } + + // clear previously generated children + this.getChildren().clear(); + + ResponseWriter out = context.getResponseWriter(); + UserTransaction tx = null; + try + { + tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true); + tx.begin(); + + String contextPath = context.getExternalContext().getRequestContextPath(); + out.write("\n"); + out.write("
"); + + List servers = getValue(); + DeploymentServerConfig currentServer = getCurrentServer(); + for (DeploymentServerConfig server: servers) + { + if (currentServer != null && currentServer.getId().equals(server.getId())) + { + renderServerForm(context, out, server, true); + } + else + { + renderServer(context, out, server); + } + } + + if (getInAddMode()) + { + renderServerForm(context, out, null, false); + } + else + { + if (servers.size() == 0) + { + out.write("
 "); + out.write(Application.getMessage(context, MSG_NO_DEPLOY_SERVERS)); + out.write("
"); + } + } + + out.write("
"); + + out.write("\n"); + + tx.commit(); + } + catch (Throwable err) + { + try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} + throw new RuntimeException(err); + } + } + + // ------------------------------------------------------------------------------ + // Strongly typed component property accessors + + /** + * @return List of deployment servers to show + */ + @SuppressWarnings("unchecked") + public List getValue() + { + ValueBinding vb = getValueBinding("value"); + if (vb != null) + { + this.servers = (List)vb.getValue(getFacesContext()); + } + + return this.servers; + } + + /** + * @param value The list of deployment servers to show + */ + public void setValue(List value) + { + this.servers = value; + } + + /** + * @param server The current deployment server being added or edited + */ + public void setCurrentServer(DeploymentServerConfig server) + { + this.currentServer = server; + } + + /** + * @return Deployment server currently being edited or added + */ + @SuppressWarnings("unchecked") + public DeploymentServerConfig getCurrentServer() + { + ValueBinding vb = getValueBinding("currentServer"); + if (vb != null) + { + this.currentServer = (DeploymentServerConfig)vb.getValue(getFacesContext()); + } + + return this.currentServer; + } + + /** + * @return true if the component should show a form to add a new server + */ + public boolean getInAddMode() + { + ValueBinding vb = getValueBinding("inAddMode"); + if (vb != null) + { + this.inAddMode = (Boolean)vb.getValue(getFacesContext()); + } + + if (this.inAddMode == null) + { + this.inAddMode = Boolean.FALSE; + } + + return this.inAddMode.booleanValue(); + } + + /** + * @param inAddMode Determines whether a new server should be added + */ + public void setInAddMode(boolean inAddMode) + { + this.inAddMode = new Boolean(inAddMode); + } + + /** + * @return The type of reciever server to add + */ + public String getAddType() + { + ValueBinding vb = getValueBinding("addType"); + if (vb != null) + { + this.addType = (String)vb.getValue(getFacesContext()); + } + + if (this.addType == null) + { + this.addType = WCMAppModel.CONSTRAINT_FILEDEPLOY; + } + + return this.addType; + } + + /** + * @param value The type of server receiver to add + */ + public void setAddType(String value) + { + this.addType = value; + } + + // ------------------------------------------------------------------------------ + // Helpers + + protected void renderAddControls(FacesContext context, ResponseWriter out) + throws IOException + { + out.write(""); + + UICommand addAlfAction = aquireAddAlfReceiverAction(context); + Utils.encodeRecursive(context, addAlfAction); + + UICommand addFileAction = aquireAddFileReceiverAction(context); + Utils.encodeRecursive(context, addFileAction); + + out.write("
"); + } + + protected void renderServer(FacesContext context, ResponseWriter out, + DeploymentServerConfig server) throws IOException + { + String contextPath = context.getExternalContext().getRequestContextPath(); + ResourceBundle bundle = Application.getBundle(context); + + String serverName = (String)server.getProperties().get(DeploymentServerConfig.PROP_NAME); + if (serverName == null || serverName.length() == 0) + { + serverName = AVMDeploySnapshotAction.calculateServerUri(server.getRepoProps()); + } + + out.write("
"); + out.write("
"); + out.write(""); + + if (WCMAppModel.CONSTRAINT_FILEDEPLOY.equals(server.getDeployType())) + { + out.write(""); + } + + if (WCMAppModel.CONSTRAINT_LIVESERVER.equals( + server.getProperties().get(DeploymentServerConfig.PROP_TYPE))) + { + out.write(""); + } + + out.write("
"); + out.write(serverName); + out.write(""); + Utils.encodeRecursive(context, aquireEditServerAction(context, server.getId())); + Utils.encodeRecursive(context, aquireDeleteServerAction(context, server.getId())); + out.write("
"); + out.write(bundle.getString(MSG_HOST)); + out.write(":"); + if (server.getProperties().get(DeploymentServerConfig.PROP_HOST) != null) + { + out.write((String)server.getProperties().get(DeploymentServerConfig.PROP_HOST)); + } + + out.write(" "); + out.write(bundle.getString(MSG_PORT)); + out.write(":"); + if (server.getProperties().get(DeploymentServerConfig.PROP_PORT) != null) + { + out.write((String)server.getProperties().get(DeploymentServerConfig.PROP_PORT)); + } + + out.write("
"); + out.write(bundle.getString(MSG_TYPE)); + out.write(":"); + if (server.getProperties().get(DeploymentServerConfig.PROP_TYPE) != null) + { + String type = (String)server.getProperties().get(DeploymentServerConfig.PROP_TYPE); + if (WCMAppModel.CONSTRAINT_LIVESERVER.equals(type)) + { + out.write(Application.getMessage(context, MSG_LIVE_SERVER)); + } + else if (WCMAppModel.CONSTRAINT_TESTSERVER.equals(type)) + { + out.write(Application.getMessage(context, MSG_TEST_SERVER)); + } + } + out.write(" "); + out.write(bundle.getString(MSG_URL)); + out.write(":"); + if (server.getProperties().get(DeploymentServerConfig.PROP_URL) != null) + { + out.write((String)server.getProperties().get(DeploymentServerConfig.PROP_URL)); + } + out.write("
"); + out.write(bundle.getString(MSG_USER)); + out.write(":"); + if (server.getProperties().get(DeploymentServerConfig.PROP_USER) != null) + { + out.write((String)server.getProperties().get(DeploymentServerConfig.PROP_USER)); + } + out.write(" "); + out.write(bundle.getString(MSG_SOURCE)); + out.write(":"); + if (server.getProperties().get(DeploymentServerConfig.PROP_SOURCE_PATH) != null) + { + out.write((String)server.getProperties().get(DeploymentServerConfig.PROP_SOURCE_PATH)); + } + out.write("
"); + out.write(bundle.getString(MSG_TARGET)); + out.write(":"); + if (server.getProperties().get(DeploymentServerConfig.PROP_TARGET_NAME) != null) + { + out.write((String)server.getProperties().get(DeploymentServerConfig.PROP_TARGET_NAME)); + } + out.write("
"); + out.write(bundle.getString(MSG_AUTO_DEPLOY)); + out.write(":"); + if (server.getProperties().get(DeploymentServerConfig.PROP_ON_APPROVAL) != null) + { + Object obj = server.getProperties().get(DeploymentServerConfig.PROP_ON_APPROVAL); + if (obj instanceof Boolean && ((Boolean)obj).booleanValue()) + { + out.write(bundle.getString("yes")); + } + else + { + out.write(bundle.getString("no")); + } + } + out.write("
"); + } + + @SuppressWarnings("unchecked") + protected void renderServerForm(FacesContext context, ResponseWriter out, + DeploymentServerConfig server, boolean edit) throws IOException + { + String contextPath = context.getExternalContext().getRequestContextPath(); + ResourceBundle bundle = Application.getBundle(context); + + out.write("
"); + out.write(""); + out.write("
"); + + // create the server type drop down + out.write(""); + + // create the server name field + out.write(""); + + // create the server host field + out.write(""); + + // create the server port field + out.write(""); + + // create the server username field + out.write(""); + + // create the server password field + out.write(""); + + // create the server url field + out.write(""); + + // create the source path field + out.write(""); + + if ((edit == false && WCMAppModel.CONSTRAINT_FILEDEPLOY.equals(getAddType())) || + (edit && WCMAppModel.CONSTRAINT_FILEDEPLOY.equals(server.getDeployType()))) + { + // create the target field + out.write(""); + } + + // create the auto deploy checkbox + out.write(""); + + if (edit) + { + // create the done button + out.write(""); + } + else + { + // create the add button + out.write(""); + } + + // finish off tables and div + out.write("
"); + out.write(bundle.getString(MSG_TYPE)); + out.write(":"); + UIComponent type = context.getApplication().createComponent( + UISelectOne.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, type, "deployServerType"); + type.getAttributes().put("styleClass", "inputField"); + type.getAttributes().put("onchange", + "javascript:Alfresco.deployServerTypeChanged();"); + ValueBinding vbType = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_TYPE + "}"); + type.setValueBinding("value", vbType); + UISelectItems itemsComponent = (UISelectItems)context.getApplication(). + createComponent(UISelectItems.COMPONENT_TYPE); + List items = new ArrayList(2); + + items.add(new SelectItem(WCMAppModel.CONSTRAINT_LIVESERVER, + Application.getMessage(context, MSG_LIVE_SERVER))); + items.add(new SelectItem(WCMAppModel.CONSTRAINT_TESTSERVER, + Application.getMessage(context, MSG_TEST_SERVER))); + + itemsComponent.setValue(items); + type.getChildren().add(itemsComponent); + this.getChildren().add(type); + Utils.encodeRecursive(context, type); + out.write("
"); + out.write(bundle.getString(MSG_NAME)); + out.write(":"); + UIComponent name = context.getApplication().createComponent( + UIInput.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, name, null); + name.getAttributes().put("styleClass", "inputField"); + ValueBinding vbName = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_NAME + "}"); + name.setValueBinding("value", vbName); + this.getChildren().add(name); + Utils.encodeRecursive(context, name); + out.write("
"); + out.write(bundle.getString(MSG_HOST)); + out.write(":"); + UIComponent host = context.getApplication().createComponent( + UIInput.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, host, null); + host.getAttributes().put("styleClass", "inputField"); + ValueBinding vbHost = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_HOST + "}"); + host.setValueBinding("value", vbHost); + this.getChildren().add(host); + Utils.encodeRecursive(context, host); + out.write("
"); + out.write(bundle.getString(MSG_PORT)); + out.write(":"); + UIComponent port = context.getApplication().createComponent( + UIInput.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, port, null); + port.getAttributes().put("styleClass", "inputField"); + ValueBinding vbPort = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_PORT + "}"); + port.setValueBinding("value", vbPort); + this.getChildren().add(port); + Utils.encodeRecursive(context, port); + out.write("
"); + out.write(bundle.getString(MSG_USER)); + out.write(":"); + UIComponent username = context.getApplication().createComponent( + UIInput.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, username, null); + username.getAttributes().put("styleClass", "inputField"); + ValueBinding vbUser = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_USER + "}"); + username.setValueBinding("value", vbUser); + this.getChildren().add(username); + Utils.encodeRecursive(context, username); + out.write("
"); + out.write(bundle.getString(MSG_PWD)); + out.write(":"); + UIComponent pwd = context.getApplication().createComponent( + UIInput.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, pwd, null); + pwd.setRendererType("javax.faces.Secret"); + pwd.getAttributes().put("styleClass", "inputField"); + ValueBinding vbPwd = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_PASSWORD + "}"); + pwd.setValueBinding("value", vbPwd); + this.getChildren().add(pwd); + Utils.encodeRecursive(context, pwd); + out.write("
"); + out.write(bundle.getString(MSG_URL)); + out.write(":"); + UIComponent url = context.getApplication().createComponent( + UIInput.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, url, null); + url.getAttributes().put("styleClass", "inputField"); + ValueBinding vbUrl = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_URL + "}"); + url.setValueBinding("value", vbUrl); + this.getChildren().add(url); + Utils.encodeRecursive(context, url); + out.write("
"); + out.write(bundle.getString(MSG_SOURCE)); + out.write(":"); + UIComponent source = context.getApplication().createComponent( + UIInput.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, source, null); + source.getAttributes().put("styleClass", "inputField"); + ValueBinding vbSource = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_SOURCE_PATH + "}"); + source.setValueBinding("value", vbSource); + this.getChildren().add(source); + Utils.encodeRecursive(context, source); + out.write("
"); + out.write(bundle.getString(MSG_TARGET)); + out.write(":"); + UIComponent target = context.getApplication().createComponent( + UIInput.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, target, null); + target.getAttributes().put("styleClass", "inputField"); + ValueBinding vbTarget = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_TARGET_NAME + "}"); + target.setValueBinding("value", vbTarget); + this.getChildren().add(target); + Utils.encodeRecursive(context, target); + out.write("
"); + out.write(bundle.getString(MSG_AUTO_DEPLOY)); + out.write(":"); + UIComponent auto = context.getApplication().createComponent( + UISelectBoolean.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, auto, "autoDeployCheckbox"); + ValueBinding vbAuto = context.getApplication().createValueBinding( + "#{WizardManager.bean.editedDeployServerProperties." + + DeploymentServerConfig.PROP_ON_APPROVAL + "}"); + auto.setValueBinding("value", vbAuto); + this.getChildren().add(auto); + Utils.encodeRecursive(context, auto); + out.write("
"); + UICommand saveButton = (UICommand)context.getApplication().createComponent( + UICommand.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, saveButton, null); + saveButton.setValue(bundle.getString("save")); + MethodBinding binding = context.getApplication().createMethodBinding( + "#{WizardManager.bean.saveDeploymentServerConfig}", new Class[] {}); + saveButton.setAction(binding); + this.getChildren().add(saveButton); + Utils.encodeRecursive(context, saveButton); + out.write("
"); + UICommand addButton = (UICommand)context.getApplication().createComponent( + UICommand.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, addButton, null); + addButton.setValue(bundle.getString("add")); + MethodBinding binding = context.getApplication().createMethodBinding( + "#{WizardManager.bean.addDeploymentServerConfig}", new Class[] {}); + addButton.setAction(binding); + this.getChildren().add(addButton); + Utils.encodeRecursive(context, addButton); + out.write("
"); + } + + @SuppressWarnings("unchecked") + protected UIActionLink aquireAddAlfReceiverAction(FacesContext context) + { + UIActionLink action = null; + String actionId = "add_alf_receiver"; + + // try find the action as a child of this component + for (UIComponent component : (List)getChildren()) + { + if (actionId.equals(component.getId())) + { + action = (UIActionLink)component; + break; + } + } + + if (action == null) + { + // create the action and add as a child component + javax.faces.application.Application facesApp = context.getApplication(); + action = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK); + action.setId(actionId); + action.setValue(Application.getMessage(context, MSG_ALF_SERVER)); + action.setImage("/images/icons/plus.gif"); + MethodBinding binding = facesApp.createMethodBinding( + "#{WizardManager.bean.addAlfrescoServerReceiver}", new Class[] {}); + action.setAction(binding); + this.getChildren().add(action); + } + + return action; + } + + @SuppressWarnings("unchecked") + protected UIActionLink aquireAddFileReceiverAction(FacesContext context) + { + UIActionLink action = null; + String actionId = "add_file_receiver"; + + // try find the action as a child of this component + for (UIComponent component : (List)getChildren()) + { + if (actionId.equals(component.getId())) + { + action = (UIActionLink)component; + break; + } + } + + if (action == null) + { + // create the action and add as a child component + javax.faces.application.Application facesApp = context.getApplication(); + action = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK); + action.setId(actionId); + action.setValue(Application.getMessage(context, MSG_FILE_SYSTEM)); + action.setImage("/images/icons/plus.gif"); + MethodBinding binding = facesApp.createMethodBinding( + "#{WizardManager.bean.addFileSystemReceiver}", new Class[] {}); + action.setAction(binding); + this.getChildren().add(action); + } + + return action; + } + + @SuppressWarnings("unchecked") + protected UIActionLink aquireEditServerAction(FacesContext context, String serverId) + { + UIActionLink action = null; + String actionId = "edit_" + serverId; + + // try find the action as a child of this component + for (UIComponent component : (List)getChildren()) + { + if (actionId.equals(component.getId())) + { + action = (UIActionLink)component; + break; + } + } + + if (action == null) + { + // create the action and add as a child component + javax.faces.application.Application facesApp = context.getApplication(); + action = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK); + action.setId(actionId); + action.setValue(Application.getMessage(context, MSG_EDIT)); + action.setImage("/images/icons/edit_icon.gif"); + action.setShowLink(false); + action.setActionListener(facesApp.createMethodBinding( + "#{WizardManager.bean.editDeploymentServerConfig}", + UIActions.ACTION_CLASS_ARGS)); + + // add server id param + UIParameter param = (UIParameter)facesApp.createComponent(ComponentConstants.JAVAX_FACES_PARAMETER); + param.setId(actionId + "_1"); + param.setName("id"); + param.setValue(serverId); + action.getChildren().add(param); + + this.getChildren().add(action); + } + + return action; + } + + @SuppressWarnings("unchecked") + protected UIActionLink aquireDeleteServerAction(FacesContext context, String serverId) + { + UIActionLink action = null; + String actionId = "delete_" + serverId; + + // try find the action as a child of this component + for (UIComponent component : (List)getChildren()) + { + if (actionId.equals(component.getId())) + { + action = (UIActionLink)component; + break; + } + } + + if (action == null) + { + // create the action and add as a child component + javax.faces.application.Application facesApp = context.getApplication(); + action = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK); + action.setId(actionId); + action.setValue(Application.getMessage(context, MSG_DELETE)); + action.setImage("/images/icons/delete.gif"); + action.setShowLink(false); + action.setActionListener(facesApp.createMethodBinding( + "#{WizardManager.bean.deleteDeploymentServerConfig}", + UIActions.ACTION_CLASS_ARGS)); + + // add server id param + UIParameter param = (UIParameter)facesApp.createComponent(ComponentConstants.JAVAX_FACES_PARAMETER); + param.setId(actionId + "_1"); + param.setName("id"); + param.setValue(serverId); + action.getChildren().add(param); + + this.getChildren().add(action); + } + + return action; + } + + /** + * @return Options for the type of deployment server i.e. test or live + */ + public List getDeployServerTypes() + { + List items = new ArrayList(2); + + UIListItem live = new UIListItem(); + live.setValue(WCMAppModel.CONSTRAINT_LIVESERVER); + live.setLabel(Application.getMessage(FacesContext.getCurrentInstance(), MSG_LIVE_SERVER)); + + UIListItem test = new UIListItem(); + test.setValue(WCMAppModel.CONSTRAINT_TESTSERVER); + test.setLabel(Application.getMessage(FacesContext.getCurrentInstance(), MSG_TEST_SERVER)); + + items.add(live); + items.add(test); + + return items; + } +} diff --git a/source/java/org/alfresco/web/ui/wcm/tag/DeploymentServersTag.java b/source/java/org/alfresco/web/ui/wcm/tag/DeploymentServersTag.java new file mode 100644 index 0000000000..034f73f30d --- /dev/null +++ b/source/java/org/alfresco/web/ui/wcm/tag/DeploymentServersTag.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing + */ +package org.alfresco.web.ui.wcm.tag; + +import javax.faces.component.UIComponent; + +import org.alfresco.web.ui.common.tag.BaseComponentTag; + +/** + * Tag class that allows the DeploymentServers component to be used on a JSP page. + * + * @author gavinc + */ +public class DeploymentServersTag extends BaseComponentTag +{ + private String value; + private String currentServer; + private String inAddMode; + private String addType; + + /** + * @see javax.faces.webapp.UIComponentTag#getComponentType() + */ + public String getComponentType() + { + return "org.alfresco.faces.DeploymentServers"; + } + + /** + * @see javax.faces.webapp.UIComponentTag#getRendererType() + */ + public String getRendererType() + { + return null; + } + + /** + * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent) + */ + protected void setProperties(UIComponent component) + { + super.setProperties(component); + + setStringProperty(component, "value", this.value); + setStringProperty(component, "currentServer", this.currentServer); + setStringProperty(component, "addType", this.addType); + setBooleanProperty(component, "inAddMode", this.inAddMode); + } + + /** + * @see org.alfresco.web.ui.common.tag.HtmlComponentTag#release() + */ + public void release() + { + super.release(); + this.value = null; + this.currentServer = null; + this.addType = null; + this.inAddMode = null; + } + + /** + * @param value the value (the list of servers to show) + */ + public void setValue(String value) + { + this.value = value; + } + + /** + * @param currentServer The server being edited or added + */ + public void setCurrentServer(String currentServer) + { + this.currentServer = currentServer; + } + + /** + * @param inAddMode Flag to determine whether a new server should be added + */ + public void setInAddMode(String inAddMode) + { + this.inAddMode = inAddMode; + } + + /** + * @param addType The type of server receiver to add + */ + public void setAddType(String addType) + { + this.addType = addType; + } +} diff --git a/source/web/WEB-INF/faces-config-wcm.xml b/source/web/WEB-INF/faces-config-wcm.xml index f385d9be5f..1f6034f1df 100644 --- a/source/web/WEB-INF/faces-config-wcm.xml +++ b/source/web/WEB-INF/faces-config-wcm.xml @@ -34,6 +34,11 @@ org.alfresco.web.ui.wcm.component.UIDeployWebsite + + org.alfresco.faces.DeploymentServers + org.alfresco.web.ui.wcm.component.UIDeploymentServers + + org.alfresco.faces.PendingSubmissions org.alfresco.web.ui.wcm.component.UIPendingSubmissions diff --git a/source/web/WEB-INF/wcm.tld b/source/web/WEB-INF/wcm.tld index 6e873af69e..0fbd82ae0a 100644 --- a/source/web/WEB-INF/wcm.tld +++ b/source/web/WEB-INF/wcm.tld @@ -210,6 +210,56 @@ + + deploymentServers + org.alfresco.web.ui.wcm.tag.DeploymentServersTag + JSP + Deployment Servers + + Renders a list of deployment servers and allows new ones to be + added and existing servers to be edited and removed + + + + id + false + true + The component identifier for this component + + + + value + true + true + The list of deployment servers to show + + + + rendered + false + true + + + + currentServer + false + true + The deployment server currently being added or edited + + + + inAddMode + false + true + + + + addType + false + true + + + deployWebsite org.alfresco.web.ui.wcm.tag.DeployWebsiteTag diff --git a/source/web/css/main.css b/source/web/css/main.css index 2c456a1fd3..007e2df162 100644 --- a/source/web/css/main.css +++ b/source/web/css/main.css @@ -701,6 +701,83 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited font-weight: normal; font-size:12px; } + +.deployAddServerConfig +{ + margin: 4px; +} + +.deployAddServerConfig a +{ + margin-right: 30px; +} + +.deployAddServerConfig img +{ + border: none; + vertical-align: -4px; + margin-right: 2px; +} + +.deployConfig +{ + padding: 4px; +} + +.deployNoServers +{ + margin-top: 26px; + margin-bottom: 10px; +} + +.deployNoServers img +{ + vertical-align: -6px; +} + +.deployConfigServer +{ + margin-top: 14px; + border: 1px solid #555; + background-color: #f9f9f9; + -moz-border-radius: 8px; +} + +.deployConfigServerIcon +{ + margin: 8px 0px 0px 8px; +} + +.deployConfigServer td +{ + padding: 5px; +} + +.deployConfigServerDetails +{ + padding-left: 10px; +} + +.deployConfigServerDetails td +{ + padding: 2px; +} + +.deployConfigServerDetails img +{ + border: none; + margin-left: 3px; +} + +.deployConfigServerForm +{ + padding-left: 15px; +} + +.deployConfigServerForm .inputField +{ + width: 200px; +} .deployPanelCheckbox { diff --git a/source/web/images/icons/deploy_server_alfresco.gif b/source/web/images/icons/deploy_server_alfresco.gif new file mode 100644 index 0000000000..015be97a08 Binary files /dev/null and b/source/web/images/icons/deploy_server_alfresco.gif differ diff --git a/source/web/images/icons/deploy_server_file.gif b/source/web/images/icons/deploy_server_file.gif new file mode 100644 index 0000000000..c8648475c4 Binary files /dev/null and b/source/web/images/icons/deploy_server_file.gif differ diff --git a/source/web/jsp/wcm/create-website-wizard/deployment.jsp b/source/web/jsp/wcm/create-website-wizard/deployment.jsp new file mode 100644 index 0000000000..24be252d9e --- /dev/null +++ b/source/web/jsp/wcm/create-website-wizard/deployment.jsp @@ -0,0 +1,47 @@ +<%-- + * Copyright (C) 2005-2007 Alfresco Software Limited. + + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" +--%> +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> +<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> +<%@ taglib uri="/WEB-INF/wcm.tld" prefix="w" %> + +<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %> +<%@ page isELIgnored="false" %> + + + + + + + + \ No newline at end of file diff --git a/source/web/scripts/ajax/deployment.js b/source/web/scripts/ajax/deployment.js new file mode 100644 index 0000000000..534bf31b89 --- /dev/null +++ b/source/web/scripts/ajax/deployment.js @@ -0,0 +1,36 @@ +Alfresco.deployServerTypeChanged = function() +{ + var typeDropDown = document.getElementById('wizard:wizard-body:deployServerType'); + if (typeDropDown != null) + { + var selectedType = typeDropDown.options[typeDropDown.selectedIndex].value; + + // show or hide the label + var autoDeployLabel = document.getElementById('autoDeployLabel'); + if (autoDeployLabel != null) + { + if (selectedType == "test") + { + autoDeployLabel.style.display = "none"; + } + else + { + autoDeployLabel.style.display = "block"; + } + } + + // show or hide the checkbox + var autoDeployCheckbox = document.getElementById('wizard:wizard-body:autoDeployCheckbox'); + if (autoDeployCheckbox != null) + { + if (selectedType == "test") + { + autoDeployCheckbox.style.display = "none"; + } + else + { + autoDeployCheckbox.style.display = "block"; + } + } + } +} \ No newline at end of file