diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 572fdfbea1..1cb25b6595 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -1087,7 +1087,8 @@ sandbox_snapshot=Create Snapshot sandbox_snapshot_info=Create a snaphost of this sandbox. sandbox_remove=Delete sandbox_refresh=Refresh -sandbox_deploy=Deploy & Preview +sandbox_deploy=Deploy +sandbox_release_test_server=Release Server import_website_content=Bulk Import title_browse_sandbox=Browse Sandbox sandbox_info=Use this view to browse the files and folders within the sandbox for a web project. @@ -1137,6 +1138,7 @@ pending_diff=Visual Comparison pending_promote=Submit Now pending_abort=Abort Submission task_done_resubmit_all=Task Done & Re-Submit All +reset_deploy_history=Reset Deployment History # Website actions and dialog messages title_import_content=Web Project Bulk Import @@ -1202,7 +1204,9 @@ revert_all_confirm=Are you sure you want to undo the changes to all files in the deploy_snapshot_title=Deploy Snapshot deploy_snapshot_desc=Select the servers to deploy to and click OK. deploy_sandbox_title=Deploy Sandbox -deploy_sandbox_desc=Select a test server to deploy to and click OK. +deploy_sandbox_desc=Select a test server to deploy to and click OK. This server will then be allocated to this sandbox. +redeploy_sandbox_title=Deploy Sandbox Changes +redeploy_sandbox_desc=Click OK to deploy any changes in the sandbox to your allocated test server. deploy_destination=Select the destination server(s) to deploy to deploy_status=Snapshot {0} is being deployed in the background, refresh this page until the ''View Deployment Report'' link appears. deploying=Deploying... @@ -1219,7 +1223,7 @@ deployment_report_title=View Deployment Report deployment_report_title_for=View Deployment Report For Snaphot {0} deployment_report_desc=View deployment details for each of the servers deployed to. monitor_deployment_title=Monitor Deployment -monitor_deployment_desc=Monitors the progress of a snapshot deployment to one or more servers. +monitor_deployment_desc=Monitors the progress of a deployment to one or more servers. deploy_status_in_progress=IN PROGRESS deploy_status_live=LIVE deploy_status_failed=FAILED @@ -1228,8 +1232,9 @@ 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=Server deploy_server_type=Type -deploy_server_name=Name +deploy_server_name=Display Name deploy_server_host=Host deploy_server_port=Port deploy_server_username=Username @@ -1238,6 +1243,8 @@ deploy_server_url=URL deploy_server_source_path=Source Path deploy_server_target_name=Target Name deploy_automatically=Auto Deploy +deploy_automatically_info=This will deploy the changes from this submission upon approval. +port_must_be_number=Port must contain a number. edit_deploy_server=Edit Deployment Server Details delete_deploy_server=Delete Deployment Server no_deploy_servers=No deployment servers have been configured. diff --git a/config/alfresco/web-client-config-dialogs.xml b/config/alfresco/web-client-config-dialogs.xml index ee3488fad4..d2145f3ab5 100644 --- a/config/alfresco/web-client-config-dialogs.xml +++ b/config/alfresco/web-client-config-dialogs.xml @@ -270,13 +270,8 @@ icon="/images/icons/revert_all_large.gif" title-id="revert_all_title" description-id="revert_all_desc" /> - - - + + @@ -528,6 +529,7 @@ + @@ -543,6 +545,7 @@ + @@ -571,6 +574,7 @@ + @@ -586,6 +590,7 @@ + @@ -601,6 +606,7 @@ + diff --git a/config/alfresco/web-client-config-wcm-actions.xml b/config/alfresco/web-client-config-wcm-actions.xml index df4bb29762..191488928b 100644 --- a/config/alfresco/web-client-config-wcm-actions.xml +++ b/config/alfresco/web-client-config-wcm-actions.xml @@ -279,6 +279,19 @@ + + + + Delete,Write,CreateChildren + + reset_deploy_history + /images/icons/remove_item.gif + #{AVMBrowseBean.resetDeploymentHistory} + #{BrowseBean.setupSpaceAction} + + #{actionContext.id} + + @@ -385,6 +398,7 @@ + diff --git a/source/java/org/alfresco/web/bean/generator/ChildAssociationGenerator.java b/source/java/org/alfresco/web/bean/generator/ChildAssociationGenerator.java index a1008ce308..83fb88255b 100644 --- a/source/java/org/alfresco/web/bean/generator/ChildAssociationGenerator.java +++ b/source/java/org/alfresco/web/bean/generator/ChildAssociationGenerator.java @@ -58,7 +58,7 @@ public class ChildAssociationGenerator extends BaseComponentGenerator // check disables the ok button if necessary, as the user // adds or removes items from the multi value list the // page will be refreshed and therefore re-check the status. - // Only so this however id the component is not read-only + // But only do this if the component is not read-only if (item.isReadOnly() == false) { diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index cfcc6c083e..f2588c7f01 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -50,6 +50,8 @@ import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.actions.AVMRevertStoreAction; import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction; import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.sandbox.SandboxConstants; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ActionService; @@ -113,8 +115,7 @@ public class AVMBrowseBean implements IContextListener private static final Log logger = LogFactory.getLog(AVMBrowseBean.class); - private static final String REQUEST_BEEN_DEPLOYED_KEY = "_alfBeenDeployedEvaluated"; - private static final String REQUEST_BEEN_DEPLOYED_RESULT = "_alfBeenDeployedResult"; + public static final String REQUEST_BEEN_DEPLOYED_RESULT = "_alfBeenDeployedResult"; private static final String MSG_REVERT_SUCCESS = "revert_success"; private static final String MSG_REVERT_SANDBOX = "revert_sandbox_success"; @@ -909,28 +910,28 @@ public class AVMBrowseBean implements IContextListener // expression in a 'rendered' attribute, we therefore cache the result // on a per request basis - List deployAttempts = null; + Boolean result = null; FacesContext context = FacesContext.getCurrentInstance(); Map request = context.getExternalContext().getRequestMap(); - if (request.get(REQUEST_BEEN_DEPLOYED_KEY) == null) + if (request.get(REQUEST_BEEN_DEPLOYED_RESULT) == null) { // see if there are any deployment attempts for the staging area NodeRef webProjectRef = this.getWebsite().getNodeRef(); String store = (String)nodeService.getProperty(webProjectRef, WCMAppModel.PROP_AVMSTORE); - deployAttempts = DeploymentUtil.findDeploymentAttempts(store); + List deployAttempts = DeploymentUtil.findDeploymentAttempts(store); // add a placeholder object in the request so we don't evaluate this again for this request - request.put(REQUEST_BEEN_DEPLOYED_KEY, Boolean.TRUE); - request.put(REQUEST_BEEN_DEPLOYED_RESULT, deployAttempts); + result = new Boolean(deployAttempts != null && deployAttempts.size() > 0); + request.put(REQUEST_BEEN_DEPLOYED_RESULT, result); } else { - deployAttempts = (List)request.get(REQUEST_BEEN_DEPLOYED_RESULT); + result = (Boolean)request.get(REQUEST_BEEN_DEPLOYED_RESULT); } - return (deployAttempts != null && deployAttempts.size() > 0); + return result.booleanValue(); } /** @@ -1421,6 +1422,125 @@ public class AVMBrowseBean implements IContextListener AVMUtil.updateVServerWebapp(webappPath, true); } + /** + * Releases the test server allocated to the store + */ + public void releaseTestServer(ActionEvent event) + { + UIActionLink link = (UIActionLink)event.getComponent(); + Map params = link.getParameterMap(); + String store = params.get("store"); + + if (store != null) + { + UserTransaction tx = null; + try + { + FacesContext context = FacesContext.getCurrentInstance(); + tx = Repository.getUserTransaction(context, false); + tx.begin(); + + NodeRef testServer = DeploymentUtil.findAllocatedTestServer(store); + if (testServer != null) + { + getNodeService().setProperty(testServer, + WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO, null); + + if (logger.isDebugEnabled()) + logger.debug("Released test server '" + testServer + "' from store: " + store); + } + + tx.commit(); + } + catch (Throwable err) + { + Utils.addErrorMessage(MessageFormat.format(Application.getMessage( + FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err); + try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} + } + } + } + + /** + * Removes all deploymentreport nodes associated with the web project + */ + public String resetDeploymentHistory() + { + FacesContext context = FacesContext.getCurrentInstance(); + RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(context); + RetryingTransactionCallback callback = new RetryingTransactionCallback() + { + @SuppressWarnings("unchecked") + public String execute() throws Throwable + { + // just in case there are any left, iterate through any old deploymentreport + // associations from the current web project and delete them. + List deployReportRefs = nodeService.getChildAssocs( + getWebsite().getNodeRef(), WCMAppModel.ASSOC_DEPLOYMENTREPORT, + RegexQNamePattern.MATCH_ALL); + int count = deployReportRefs.size(); + for (ChildAssociationRef ref : deployReportRefs) + { + NodeRef report = ref.getChildRef(); + if (report != null) + { + // remove the node + nodeService.deleteNode(report); + } + } + + // iterate through all deploymentattempt associations from the current + // web project and delete them. + List deployAttemptRefs = nodeService.getChildAssocs( + getWebsite().getNodeRef(), WCMAppModel.ASSOC_DEPLOYMENTATTEMPT, + RegexQNamePattern.MATCH_ALL); + count += deployAttemptRefs.size(); + for (ChildAssociationRef ref : deployAttemptRefs) + { + NodeRef attempt = ref.getChildRef(); + if (attempt != null) + { + // remove the node + nodeService.deleteNode(attempt); + } + } + + // remove the old properties in case they are still present + nodeService.removeProperty(getWebsite().getNodeRef(), + WCMAppModel.PROP_DEPLOYTO); + nodeService.removeProperty(getWebsite().getNodeRef(), + WCMAppModel.PROP_SELECTEDDEPLOYTO); + nodeService.removeProperty(getWebsite().getNodeRef(), + WCMAppModel.PROP_SELECTEDDEPLOYVERSION); + + // remove the hasBeenDeployed object from the session so it gets + // re-evaluated (and disappears) + Map request = FacesContext.getCurrentInstance(). + getExternalContext().getRequestMap(); + request.remove(REQUEST_BEEN_DEPLOYED_RESULT); + + if (logger.isDebugEnabled()) + logger.debug("Removed " + count + " previous deployment attempts"); + + return null; + } + }; + + try + { + // Execute + txnHelper.doInTransaction(callback); + } + catch (Exception err) + { + Utils.addErrorMessage(MessageFormat.format(Application.getMessage( + FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), + err.getMessage()), err); + } + + return "browseWebsite"; + } + /** * Undo changes to a single node */ diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java index 65c8021047..8d7982d1b9 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java @@ -1186,6 +1186,15 @@ public class CreateWebsiteWizard extends BaseWizardBean return null; } + public String cancelDeploymentServerConfig() + { + this.currentDeployServer = null; + this.editedDeployServerProps.clear(); + this.inAddDeployServerMode = false; + + return null; + } + // ------------------------------------------------------------------------------ // Define Web Content Workflows page diff --git a/source/java/org/alfresco/web/bean/wcm/DeployWebsiteDialog.java b/source/java/org/alfresco/web/bean/wcm/DeployWebsiteDialog.java index cbdded69df..274175baa0 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeployWebsiteDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/DeployWebsiteDialog.java @@ -30,6 +30,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import javax.faces.context.FacesContext; @@ -44,12 +45,17 @@ import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; +import org.alfresco.web.app.Application; import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.repository.Repository; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.jsf.FacesContextUtils; /** * Deploys a website to one or more remote servers. @@ -64,6 +70,7 @@ public class DeployWebsiteDialog extends BaseDialogBean protected String[] deployTo; protected String store; protected String deployMode; + protected String calledFromTaskDialog; protected NodeRef websiteRef; protected NodeRef webProjectRef; protected boolean updateTestServer; @@ -94,10 +101,22 @@ public class DeployWebsiteDialog extends BaseDialogBean this.versionToDeploy = -1; } + // get the store this.store = parameters.get("store"); String storeRoot = AVMUtil.buildSandboxRootPath(this.store); this.websiteRef = AVMNodeConverter.ToNodeRef(this.versionToDeploy, storeRoot); + // get the web project noderef + String webProject = parameters.get("webproject"); + if (webProject == null) + { + this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef(); + } + else + { + this.webProjectRef = new NodeRef(webProject); + } + this.deployMode = (this.versionToDeploy == -1) ? WCMAppModel.CONSTRAINT_TESTSERVER : WCMAppModel.CONSTRAINT_LIVESERVER; @@ -108,8 +127,8 @@ public class DeployWebsiteDialog extends BaseDialogBean this.updateTestServer = Boolean.parseBoolean(updateTestServerParam); } + this.calledFromTaskDialog = parameters.get("calledFromTaskDialog"); this.avmBrowseBean.getDeploymentMonitorIds().clear(); - this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef(); if (logger.isDebugEnabled()) logger.debug("Initialising dialog to deploy: " + this.websiteRef.toString()); @@ -124,6 +143,12 @@ public class DeployWebsiteDialog extends BaseDialogBean if (this.deployTo != null && this.deployTo.length > 0) { + // get the unprotected NodeService and PermissionService for this dialog otherwise + // 'AddChildren' permission would be required on the web project node for all users + WebApplicationContext wac = FacesContextUtils.getRequiredWebApplicationContext(context); + NodeService unprotectedNodeService = (NodeService)wac.getBean("nodeService"); + PermissionService unprotectedPermissionService = (PermissionService)wac.getBean("permissionService"); + List selectedDeployToNames = new ArrayList(); // create a deploymentattempt node to represent this deployment @@ -134,21 +159,26 @@ public class DeployWebsiteDialog extends BaseDialogBean props.put(WCMAppModel.PROP_DEPLOYATTEMPTSTORE, this.store); props.put(WCMAppModel.PROP_DEPLOYATTEMPTVERSION, this.versionToDeploy); props.put(WCMAppModel.PROP_DEPLOYATTEMPTTIME, new Date()); - NodeRef attempt = getNodeService().createNode(this.webProjectRef, + NodeRef attempt = unprotectedNodeService.createNode(this.webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTATTEMPT, WCMAppModel.ASSOC_DEPLOYMENTATTEMPT, WCMAppModel.TYPE_DEPLOYMENTATTEMPT, props).getChildRef(); + // allow anyone to add child nodes to the deploymentattempt node + unprotectedPermissionService.setPermission(attempt, PermissionService.ALL_AUTHORITIES, + PermissionService.ADD_CHILDREN, true); + // execute a deploy action for each of the selected remote servers asynchronously for (String targetServer : this.deployTo) { if (targetServer.length() > 0) { NodeRef serverRef = new NodeRef(targetServer); - if (getNodeService().exists(serverRef)) + if (unprotectedNodeService.exists(serverRef)) { // get all properties of the target server - Map serverProps = getNodeService().getProperties(serverRef); + Map serverProps = unprotectedNodeService.getProperties(serverRef); + String url = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERURL); String serverUri = AVMDeployWebsiteAction.calculateServerUri(serverProps); String serverName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERNAME); if (serverName == null || serverName.length() == 0) @@ -171,7 +201,7 @@ public class DeployWebsiteDialog extends BaseDialogBean } else { - getNodeService().setProperty(serverRef, WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO, + unprotectedNodeService.setProperty(serverRef, WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO, this.store); } } @@ -185,13 +215,13 @@ public class DeployWebsiteDialog extends BaseDialogBean // create a deployment monitor object, store in the session, // add to avm browse bean and pass to action DeploymentMonitor monitor = new DeploymentMonitor( - this.websiteRef, serverRef, versionToDeploy, serverName, attemptId); + this.websiteRef, serverRef, versionToDeploy, serverName, attemptId, url); context.getExternalContext().getSessionMap().put(monitor.getId(), monitor); this.avmBrowseBean.getDeploymentMonitorIds().add(monitor.getId()); // create and execute the action asynchronously Map args = new HashMap(1, 1.0f); - args.put(AVMDeployWebsiteAction.PARAM_WEBSITE, webProjectRef); + args.put(AVMDeployWebsiteAction.PARAM_WEBPROJECT, webProjectRef); args.put(AVMDeployWebsiteAction.PARAM_SERVER, serverRef); args.put(AVMDeployWebsiteAction.PARAM_ATTEMPT, attempt); args.put(AVMDeployWebsiteAction.PARAM_CALLBACK, monitor); @@ -206,7 +236,7 @@ public class DeployWebsiteDialog extends BaseDialogBean } // now we know the list of selected servers set the property on the attempt node - getNodeService().setProperty(attempt, WCMAppModel.PROP_DEPLOYATTEMPTSERVERS, + unprotectedNodeService.setProperty(attempt, WCMAppModel.PROP_DEPLOYATTEMPTSERVERS, (Serializable)selectedDeployToNames); // set the deploymentattempid property on the store this deployment was for @@ -215,6 +245,10 @@ public class DeployWebsiteDialog extends BaseDialogBean new PropertyValue(DataTypeDefinition.TEXT, attemptId)); // close this dialog and immediately open the monitorDeployment dialog + Map params = new HashMap(2); + params.put("webproject", this.webProjectRef.toString()); + params.put("calledFromTaskDialog", this.calledFromTaskDialog); + Application.getDialogManager().setupParameters(params); return "dialog:monitorDeployment"; } else @@ -238,10 +272,63 @@ public class DeployWebsiteDialog extends BaseDialogBean return super.getCancelButtonLabel(); } + @Override + public String getContainerDescription() + { + String desc = null; + + FacesContext context = FacesContext.getCurrentInstance(); + ResourceBundle bundle = Application.getBundle(context); + + if (WCMAppModel.CONSTRAINT_LIVESERVER.equals(this.deployMode)) + { + desc = bundle.getString("deploy_snapshot_desc"); + } + else + { + if (this.updateTestServer) + { + desc = bundle.getString("redeploy_sandbox_desc"); + } + else + { + desc = bundle.getString("deploy_sandbox_desc"); + } + } + + return desc; + } + + @Override + public String getContainerTitle() + { + String title = null; + + FacesContext context = FacesContext.getCurrentInstance(); + ResourceBundle bundle = Application.getBundle(context); + + if (WCMAppModel.CONSTRAINT_LIVESERVER.equals(this.deployMode)) + { + title = bundle.getString("deploy_snapshot_title"); + } + else + { + if (this.updateTestServer) + { + title = bundle.getString("redeploy_sandbox_title"); + } + else + { + title = bundle.getString("deploy_sandbox_title"); + } + } + + return title; + } // ------------------------------------------------------------------------------ // Bean getters and setters - + /** * @param avmBrowseBean The AVM BrowseBean to set */ diff --git a/source/java/org/alfresco/web/bean/wcm/DeploymentMonitor.java b/source/java/org/alfresco/web/bean/wcm/DeploymentMonitor.java index 531e78c567..57c87f6256 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeploymentMonitor.java +++ b/source/java/org/alfresco/web/bean/wcm/DeploymentMonitor.java @@ -51,6 +51,8 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable private NodeRef targetServer; private String targetServerName; private String deployAttemptId; + private String url; + private String reason; private int snapshotVersion; private boolean started = false; private boolean finished = false; @@ -63,7 +65,7 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable * Default constructor */ public DeploymentMonitor(NodeRef website, NodeRef server, int snapshotVersion, - String serverName, String deployAttemptId) + String serverName, String deployAttemptId, String url) { this.id = ID_PREFIX + Long.toString(System.currentTimeMillis()) + this.hashCode(); this.website = website; @@ -71,6 +73,7 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable this.snapshotVersion = snapshotVersion; this.targetServerName = serverName; this.deployAttemptId = deployAttemptId; + this.url = url; } // ------------------------------------------------------------------------------ @@ -104,8 +107,10 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable */ public void errorOccurred(Throwable err) { + this.reason = err.getMessage(); + if (logger.isDebugEnabled()) - logger.debug(this.targetServerName + ": ERROR: " + err.getMessage()); + logger.debug(this.targetServerName + ": ERROR: " + this.reason); this.successful = false; this.finished = true; @@ -121,6 +126,8 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable buffer.append(" targetServerName=").append(this.targetServerName); buffer.append(" snapshotVersion=").append(this.snapshotVersion); buffer.append(" deployAttemptId=").append(this.deployAttemptId); + buffer.append(" url=").append(this.url); + buffer.append(" reason=").append(this.reason); buffer.append(" started=").append(this.started); buffer.append(" finished=").append(this.finished); buffer.append(" successful=").append(this.successful).append(")"); @@ -140,6 +147,18 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable buffer.append("\" finished=\""); buffer.append(this.finished); buffer.append("\""); + if (this.url != null) + { + buffer.append(" url=\""); + buffer.append(this.url); + buffer.append("\""); + } + if (this.reason != null) + { + buffer.append(" reason=\""); + buffer.append(this.reason); + buffer.append("\""); + } if (this.finished) { buffer.append(" successful=\""); @@ -200,6 +219,22 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable { return this.deployAttemptId; } + + /** + * @return The URL of the server being deployed + */ + public String getUrl() + { + return this.url; + } + + /** + * @return The reason for the error, null if an error has not occurred + */ + public String getReason() + { + return this.reason; + } /** * @return true if the deployment has started diff --git a/source/java/org/alfresco/web/bean/wcm/DeploymentUtil.java b/source/java/org/alfresco/web/bean/wcm/DeploymentUtil.java index 5d6692f9c9..4e424aee69 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeploymentUtil.java +++ b/source/java/org/alfresco/web/bean/wcm/DeploymentUtil.java @@ -202,16 +202,16 @@ public final class DeploymentUtil * for the given web project. * * @param webProject Web project to get test servers for - * @param allocated true only returns those servers already allocated + * @param availableOnly if true only returns those servers still available for deployment * @return List of test servers */ - public static List findTestServers(NodeRef webProject, boolean allocated) + public static List findTestServers(NodeRef webProject, boolean availableOnly) { - return findServers(webProject, false, allocated); + return findServers(webProject, false, availableOnly); } - private static List findServers(NodeRef webProject, boolean live, boolean allocated) + private static List findServers(NodeRef webProject, boolean live, boolean availableOnly) { FacesContext context = FacesContext.getCurrentInstance(); NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); @@ -242,7 +242,7 @@ public final class DeploymentUtil query.append("\""); // if required filter the test servers - if (live == false && allocated == false) + if (live == false && availableOnly) { query.append(" AND ISNULL:\""); query.append(WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO.toString()); diff --git a/source/java/org/alfresco/web/bean/wcm/ManageLinkValidationTaskDialog.java b/source/java/org/alfresco/web/bean/wcm/ManageLinkValidationTaskDialog.java index a84703310e..be9e25dded 100644 --- a/source/java/org/alfresco/web/bean/wcm/ManageLinkValidationTaskDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/ManageLinkValidationTaskDialog.java @@ -25,14 +25,17 @@ package org.alfresco.web.bean.wcm; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.faces.context.FacesContext; import javax.transaction.UserTransaction; import org.alfresco.linkvalidation.LinkValidationReport; +import org.alfresco.model.WCMAppModel; import org.alfresco.repo.domain.PropertyValue; import org.alfresco.sandbox.SandboxConstants; +import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.workflow.ManageTaskDialog; @@ -52,6 +55,7 @@ public class ManageLinkValidationTaskDialog extends ManageTaskDialog protected String store; protected String webapp; + protected NodeRef webProjectRef; protected AVMBrowseBean avmBrowseBean; private static final Log logger = LogFactory.getLog(ManageLinkValidationTaskDialog.class); @@ -76,26 +80,30 @@ public class ManageLinkValidationTaskDialog extends ManageTaskDialog this.avmBrowseBean.setLinkValidationState(null); this.avmBrowseBean.setLinkValidationMonitor(null); - // try and retrieve the deployment report from the workflow + // try and retrieve the link validation report from the workflow // store, if present setup the validation state on AVMBrowseBean - String storeName = this.workflowPackage.getStoreRef().getIdentifier(); + this.store = this.workflowPackage.getStoreRef().getIdentifier(); + + // get the web project noderef for the workflow store + String stagingStore = AVMUtil.getStoreId(this.store); + this.webProjectRef = AVMUtil.getWebProjectNodeFromStore(stagingStore); if (logger.isDebugEnabled()) - logger.debug("Retrieving link validation report from store '" + storeName + "'"); + logger.debug("Retrieving link validation report from store '" + this.store + "'"); - PropertyValue val = this.getAvmService().getStoreProperty(storeName, + PropertyValue val = this.getAvmService().getStoreProperty(this.store, SandboxConstants.PROP_LINK_VALIDATION_REPORT); if (val != null) { LinkValidationReport report = (LinkValidationReport)val.getSerializableValue(); if (report != null) { - this.store = report.getStore(); + String reportStore = report.getStore(); this.webapp = report.getWebapp(); if (logger.isDebugEnabled()) logger.debug("Found link validation report for webapp '" + - AVMUtil.buildStoreWebappPath(this.store, this.webapp) + "'"); + AVMUtil.buildStoreWebappPath(reportStore, this.webapp) + "'"); LinkValidationState state = new LinkValidationState(report); this.avmBrowseBean.setLinkValidationState(state); @@ -125,7 +133,7 @@ public class ManageLinkValidationTaskDialog extends ManageTaskDialog logger.debug("Viewing link validation report for webapp '" + AVMUtil.buildStoreWebappPath(this.store, this.webapp) + "'"); - Map params = new HashMap(1); + Map params = new HashMap(3); params.put("store", this.store); params.put("webapp", this.webapp); params.put("compareToStaging", "true"); @@ -134,6 +142,29 @@ public class ManageLinkValidationTaskDialog extends ManageTaskDialog return "dialog:linkValidation"; } + public String deploy() + { + if (logger.isDebugEnabled()) + logger.debug("Deploying workflow store: " + this.store); + + Map params = new HashMap(4); + params.put("store", this.store); + params.put("webproject", this.webProjectRef.toString()); + params.put("calledFromTaskDialog", Boolean.TRUE.toString()); + + // if a test server has already been allocated inform the dialog + // that an update is needed + NodeRef testServer = DeploymentUtil.findAllocatedTestServer(this.store); + if (testServer != null) + { + params.put("updateTestServer", "true"); + } + + Application.getDialogManager().setupParameters(params); + + return "dialog:deployWebsite"; + } + // ------------------------------------------------------------------------------ // Getters and Setters @@ -144,4 +175,33 @@ public class ManageLinkValidationTaskDialog extends ManageTaskDialog { this.avmBrowseBean = avmBrowseBean; } + + /** + * @return Determines if there are any test servers configured for the + * web project this task belongs to + */ + @SuppressWarnings("unchecked") + public boolean getTestServersAvailable() + { + // NOTE: This method is called a lot as it is referenced as a value binding + // expression in a 'rendered' attribute, we therefore cache the result + // on a per request basis + + Boolean result = null; + + FacesContext context = FacesContext.getCurrentInstance(); + Map request = context.getExternalContext().getRequestMap(); + if (request.get(AVMBrowseBean.REQUEST_BEEN_DEPLOYED_RESULT) == null) + { + List testServers = DeploymentUtil.findTestServers(this.webProjectRef, false); + result = new Boolean(testServers != null && testServers.size() > 0); + request.put(AVMBrowseBean.REQUEST_BEEN_DEPLOYED_RESULT, result); + } + else + { + result = (Boolean)request.get(AVMBrowseBean.REQUEST_BEEN_DEPLOYED_RESULT); + } + + return result.booleanValue(); + } } diff --git a/source/java/org/alfresco/web/bean/wcm/MonitorDeploymentDialog.java b/source/java/org/alfresco/web/bean/wcm/MonitorDeploymentDialog.java index 139ec5d1ef..dab957d1cb 100644 --- a/source/java/org/alfresco/web/bean/wcm/MonitorDeploymentDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/MonitorDeploymentDialog.java @@ -43,6 +43,7 @@ public class MonitorDeploymentDialog extends BaseDialogBean { private static final long serialVersionUID = -2800892205678915972L; + protected String outcome; protected NodeRef webProjectRef; protected AVMBrowseBean avmBrowseBean; @@ -58,7 +59,27 @@ public class MonitorDeploymentDialog extends BaseDialogBean super.init(parameters); // setup context for dialog - this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef(); + String webProject = parameters.get("webproject"); + if (webProject == null) + { + this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef(); + } + else + { + this.webProjectRef = new NodeRef(webProject); + } + + // determine outcome required + String calledFromTaskDialog = parameters.get("calledFromTaskDialog"); + if (calledFromTaskDialog != null && + calledFromTaskDialog.equals(Boolean.TRUE.toString())) + { + outcome = "dialog:close:myalfresco"; + } + else + { + outcome = "dialog:close:browseWebsite"; + } if (logger.isDebugEnabled()) { @@ -76,7 +97,7 @@ public class MonitorDeploymentDialog extends BaseDialogBean @Override protected String getDefaultCancelOutcome() { - return "dialog:close:browseWebsite"; + return this.outcome; } @Override diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java index 4e1e847958..5016e1c4b1 100644 --- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java @@ -102,6 +102,7 @@ public class SubmitDialog extends BaseDialogBean private boolean enteringExpireDate = false; private boolean loadSelectedNodesFromBrowseBean = false; private boolean validateLinks = true; + private boolean autoDeploy = false; private Date defaultExpireDate; private Date launchDate; @@ -627,6 +628,8 @@ public class SubmitDialog extends BaseDialogBean this.workflowParams.put(WCMWorkflowModel.PROP_LAUNCH_DATE, this.launchDate); this.workflowParams.put(WCMWorkflowModel.PROP_VALIDATE_LINKS, new Boolean(this.validateLinks)); + this.workflowParams.put(WCMWorkflowModel.PROP_AUTO_DEPLOY, + new Boolean(this.autoDeploy)); this.workflowParams.put(WCMWorkflowModel.PROP_WEBAPP, this.avmBrowseBean.getWebapp()); this.workflowParams.put(WCMWorkflowModel.ASSOC_WEBPROJECT, @@ -847,10 +850,27 @@ public class SubmitDialog extends BaseDialogBean { this.validateLinks = validateLinks; } + + /** + * @return Flag to indicate whether the changes should be deployed upon approval + */ + public boolean isAutoDeploy() + { + return this.autoDeploy; + } + + /** + * @param autoDeploy Flag to indicate whether the changes should be deployed upon approval + */ + public void setAutoDeploy(boolean autoDeploy) + { + this.autoDeploy = autoDeploy; + } /** * @return List of UIListItem object representing the available workflows for the website */ + @SuppressWarnings("unchecked") public List getWorkflowList() { if (this.workflowItems == null) 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 63eb8a3cde..19b2123b19 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java @@ -26,7 +26,6 @@ package org.alfresco.web.ui.wcm.component; import java.io.IOException; import java.io.Serializable; -import java.text.MessageFormat; import java.util.List; import java.util.Map; @@ -181,7 +180,7 @@ public class UIDeployWebsite extends UIInput if (logger.isDebugEnabled()) logger.debug("Found deployment monitor: " + monitor); - renderServer(context, out, nodeService, monitor.getTargetServer(), false, true, id, true); + renderMonitoredServer(context, out, nodeService, monitor.getTargetServer(), id); } } } @@ -202,13 +201,13 @@ public class UIDeployWebsite extends UIInput } else { - List servers = DeploymentUtil.findTestServers(webProject, false); + List servers = DeploymentUtil.findTestServers(webProject, true); if (servers.size() > 0) { boolean first = true; for (NodeRef server : servers) { - renderServer(context, out, nodeService, server, first, false, null, false); + renderTestServer(context, out, nodeService, server, first); first = false; } } @@ -217,9 +216,14 @@ public class UIDeployWebsite extends UIInput // show the none available message out.write("
 "); + out.write("/images/icons/info_icon.gif' /> "); out.write(Application.getMessage(context, "deploy_test_server_not_available")); - out.write("
"); + out.write("\n"); + out.write("\n"); } } } @@ -233,7 +237,7 @@ public class UIDeployWebsite extends UIInput // TODO: determine if the server has already been successfully deployed to boolean selected = true; - renderServer(context, out, nodeService, server, selected, false, null, true); + renderLiveServer(context, out, nodeService, server, selected); } } } @@ -416,69 +420,20 @@ public class UIDeployWebsite extends UIInput int pollFreq = AVMUtil.getRemoteDeploymentPollingFrequency() * 1000; // render the script to handle the progress monitoring - out.write("\n"); + + out.write("\n"); } - private void renderServer(FacesContext context, ResponseWriter out, NodeService nodeService, - NodeRef server, boolean selected, boolean monitoring, String monitorId, - boolean liveServer) throws IOException + private void renderLiveServer(FacesContext context, ResponseWriter out, NodeService nodeService, + NodeRef server, boolean selected) throws IOException { String contextPath = context.getExternalContext().getRequestContextPath(); + renderPanelStart(out, contextPath); + + out.write("
"); + out.write("
"); + + renderPanelMiddle(out, contextPath, nodeService, server, true); + + if (selected == false) + { + out.write("
 "); + out.write(Application.getMessage(context, "deploy_server_not_selected")); + out.write("
"); + } + + renderPanelEnd(out, contextPath); + } + + private void renderTestServer(FacesContext context, ResponseWriter out, NodeService nodeService, + NodeRef server, boolean selected) throws IOException + { + String contextPath = context.getExternalContext().getRequestContextPath(); + + renderPanelStart(out, contextPath); + + out.write("
"); + out.write("
"); + + renderPanelMiddle(out, contextPath, nodeService, server, true); + renderPanelEnd(out, contextPath); + } + + private void renderAllocatedTestServer(FacesContext context, ResponseWriter out, NodeService nodeService, + NodeRef server) throws IOException + { + String contextPath = context.getExternalContext().getRequestContextPath(); + + renderPanelStart(out, contextPath); + + //out.write("
"); + + renderPanelMiddle(out, contextPath, nodeService, server, false); + + String url = (String)nodeService.getProperty(server, WCMAppModel.PROP_DEPLOYSERVERURL); + if (url != null && url.length() > 0) + { + out.write(""); + } + + renderPanelEnd(out, contextPath); + + // render a hidden field with the value of the allocated test server + out.write(""); + } + + private void renderMonitoredServer(FacesContext context, ResponseWriter out, NodeService nodeService, + NodeRef server, String monitorId) throws IOException + { + String contextPath = context.getExternalContext().getRequestContextPath(); + + renderPanelStart(out, contextPath); + + out.write("
"); + out.write(""); + out.write("
"); + + renderPanelMiddle(out, contextPath, nodeService, server, true); + + out.write("
"); + out.write(Application.getMessage(context, "deploying")); + out.write("
"); + + out.write("
"); + out.write("
"); + + renderPanelEnd(out, contextPath); + } + + private void renderPanelStart(ResponseWriter out, String contextPath) throws IOException + { + // render start of panel + out.write(""); + out.write(""); + out.write(""); + // create the server host field + out.write(""); + + // create the server port field + 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 and add the cancel button + out.write(""); + } else { // create the add button - out.write(""); } // finish off tables and div - out.write("
"); + } + + private void renderPanelMiddle(ResponseWriter out, String contextPath, + NodeService nodeService, NodeRef server, boolean showSeparator) throws IOException + { Map props = nodeService.getProperties(server); String deployType = (String)props.get(WCMAppModel.PROP_DEPLOYTYPE); String serverName = (String)props.get(WCMAppModel.PROP_DEPLOYSERVERNAME); @@ -501,48 +583,13 @@ public class UIDeployWebsite extends UIInput serverName = AVMDeployWebsiteAction.calculateServerUri(props); } - out.write(""); - out.write(""); - out.write(""); + if (showSeparator) { - out.write("
"); - out.write(""); + out.write("/images/parts/deploy_panel_separator.gif' />"); } - else - { - out.write("
"); - out.write(""); - } - out.write("
"); out.write("
"); - if (monitoring) + out.write(""); @@ -558,22 +605,11 @@ public class UIDeployWebsite extends UIInput out.write("
"); out.write(serverName); out.write("
"); - if (monitoring) - { - out.write("
"); - out.write(Application.getMessage(context, "deploying")); - out.write("
"); - } - else if (selected == false && liveServer == true) - { - out.write("
 "); - out.write(Application.getMessage(context, "deploy_server_not_selected")); - out.write("
"); - } + } + + private void renderPanelEnd(ResponseWriter out, String contextPath) throws IOException + { + // render end of panel out.write("
"); @@ -581,45 +617,4 @@ public class UIDeployWebsite extends UIInput // add some padding under each panel out.write("\n
\n"); } - - private void renderAllocatedTestServer(FacesContext context, ResponseWriter out, NodeService nodeService, - NodeRef server) throws IOException - { - Map serverProps = nodeService.getProperties(server); - String serverName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERNAME); - if (serverName == null || serverName.length() == 0) - { - serverName = AVMDeployWebsiteAction.calculateServerUri(serverProps); - } - - String pattern = Application.getMessage(context, "deploy_test_server_allocated"); - String msg = MessageFormat.format(pattern, serverName); - - out.write("
 "); - out.write(msg); - - String url = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERURL); - if (url != null && url.length() > 0) - { - out.write(""); - } - - out.write("
"); - - // render a hidden field with the value of the allocated test server - 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 7f3053465e..247fc649b7 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java @@ -150,7 +150,9 @@ public class UIDeploymentReports extends SelfRenderingComponent if (attempt != null) { // render the supporting JavaScript - renderScript(context, out); + out.write("\n"); // iterate through each deployment report List deployReportRefs = nodeService.getChildAssocs( @@ -202,28 +204,6 @@ public class UIDeploymentReports extends SelfRenderingComponent // ------------------------------------------------------------------------------ // Helpers - private void renderScript(FacesContext context, ResponseWriter out) - throws IOException - { - out.write("\n"); - } - private void renderReport(FacesContext context, ResponseWriter out, NodeRef deploymentReport, NodeService nodeService, ContentService contentService) throws IOException @@ -236,15 +216,17 @@ public class UIDeploymentReports extends SelfRenderingComponent // start the surrounding panel PanelGenerator.generatePanelStart(out, - context.getExternalContext().getRequestContextPath(), "innerwhite", "white"); + context.getExternalContext().getRequestContextPath(), "lightstorm", "#eaeff2"); // extract the information we need to display Map serverProps = nodeService.getProperties(deploymentReport); String server = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVER); + boolean showServerAddress = true; String serverName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERNAMEUSED); if (serverName == null || serverName.length() == 0) { serverName = server; + showServerAddress = false; } String deployType = WCMAppModel.CONSTRAINT_ALFDEPLOY; @@ -255,14 +237,14 @@ public class UIDeploymentReports extends SelfRenderingComponent String creator = (String)serverProps.get(ContentModel.PROP_CREATOR); Date startTime = (Date)serverProps.get(WCMAppModel.PROP_DEPLOYSTARTTIME); - String started = null; + String started = ""; if (startTime != null) { started = Utils.getDateTimeFormat(context).format(startTime); } Date endTime = (Date)serverProps.get(WCMAppModel.PROP_DEPLOYENDTIME); - String finished = null; + String finished = ""; if (endTime != null) { finished = Utils.getDateTimeFormat(context).format(endTime); @@ -274,7 +256,12 @@ public class UIDeploymentReports extends SelfRenderingComponent success = Boolean.FALSE; } + String url = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERURLUSED); + String username = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERUSERNAMEUSED); + String source = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSOURCEPATHUSED); + String target = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERTARGETUSED); String failReason = (String)serverProps.get(WCMAppModel.PROP_DEPLOYFAILEDREASON); + String content = ""; ContentReader reader = contentService.getReader(deploymentReport, ContentModel.PROP_CONTENT); if (reader != null) @@ -305,7 +292,7 @@ public class UIDeploymentReports extends SelfRenderingComponent out.write(".gif' />
"); out.write("
"); out.write(serverName); - out.write("
"); - out.write(Application.getMessage(context, "snapshot")); - out.write(": "); - out.write(Integer.toString(snapshot)); - out.write("
"); - out.write("
"); - out.write(Application.getMessage(context, "deploy_started")); - out.write(": "); - out.write(started); - out.write("
"); - out.write("
"); - out.write(Application.getMessage(context, "deploy_finished")); - out.write(": "); - out.write(finished); - out.write("
"); - out.write("
"); - out.write(Application.getMessage(context, "deployed_by")); - out.write(": "); - out.write(creator); - out.write("
"); + if (success.booleanValue() == false && failReason != null && failReason.length() > 0) { out.write("
"); @@ -354,11 +322,83 @@ public class UIDeploymentReports extends SelfRenderingComponent out.write(failReason); out.write("
"); } + + if (showServerAddress) + { + out.write("
"); + out.write(Application.getMessage(context, "deploy_server")); + out.write(": "); + out.write(server); + out.write("
"); + } + + out.write("
"); + out.write(Application.getMessage(context, "snapshot")); + out.write(": "); + out.write(Integer.toString(snapshot)); + out.write("
"); + + out.write("
"); + out.write(Application.getMessage(context, "deploy_started")); + out.write(": "); + out.write(started); + out.write("
"); + + out.write("
"); + out.write(Application.getMessage(context, "deploy_finished")); + out.write(": "); + out.write(finished); + out.write("
"); + + out.write("
"); + out.write(Application.getMessage(context, "deployed_by")); + out.write(": "); + out.write(creator); + out.write("
"); + + if (username != null) + { + out.write("
"); + out.write(Application.getMessage(context, "deploy_server_username")); + out.write(": "); + out.write(username); + out.write("
"); + } + + if (source != null) + { + out.write("
"); + out.write(Application.getMessage(context, "deploy_server_source_path")); + out.write(": "); + out.write(source); + out.write("
"); + } + + if (target != null) + { + out.write("
"); + out.write(Application.getMessage(context, "deploy_server_target_name")); + out.write(": "); + out.write(target); + out.write("
"); + } + + if (success.booleanValue() == true && url != null && url.length() > 0) + { + out.write("
"); + out.write(Application.getMessage(context, "deploy_server_url")); + out.write(": "); + out.write(url); + out.write("
"); + } + if (content.length() > 0) { out.write("
 "); out.write(Application.getMessage(context, "details")); @@ -374,6 +414,6 @@ public class UIDeploymentReports extends SelfRenderingComponent // finish the surrounding panel PanelGenerator.generatePanelEnd(out, - context.getExternalContext().getRequestContextPath(), "innerwhite"); + context.getExternalContext().getRequestContextPath(), "lightstorm"); } } 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 6704015e73..25e3fd8e7e 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentServers.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentServers.java @@ -63,8 +63,6 @@ import org.alfresco.web.ui.repo.component.UIActions; */ public class UIDeploymentServers extends UIInput { - private static final String MSG_ALF_SERVER = "deploy_add_alf_receiver"; - private static final String MSG_FILE_SYSTEM = "deploy_add_file_receiver"; private static final String MSG_LIVE_SERVER = "deploy_server_type_live"; private static final String MSG_TEST_SERVER = "deploy_server_type_test"; private static final String MSG_TYPE = "deploy_server_type"; @@ -149,7 +147,9 @@ public class UIDeploymentServers extends UIInput tx.begin(); String contextPath = context.getExternalContext().getRequestContextPath(); - out.write("\n\n"); out.write("
"); @@ -164,7 +164,7 @@ public class UIDeploymentServers extends UIInput { if (servers.size() == 0) { - out.write("
 "); out.write(Application.getMessage(context, MSG_NO_DEPLOY_SERVERS)); @@ -188,7 +188,7 @@ public class UIDeploymentServers extends UIInput out.write("
"); out.write("\n"); tx.commit(); @@ -510,6 +510,46 @@ public class UIDeploymentServers extends UIInput Utils.encodeRecursive(context, type); out.write("
"); + out.write(bundle.getString(MSG_HOST)); + out.write(":"); + UIComponent host = context.getApplication().createComponent( + UIInput.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, host, "deployServerHost"); + host.getAttributes().put("styleClass", "inputField"); + host.getAttributes().put("onkeyup", + "javascript:Alfresco.checkDeployConfigButtonState();"); + host.getAttributes().put("onchange", + "javascript:Alfresco.checkDeployConfigButtonState();"); + 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, "deployServerPort"); + 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_NAME)); @@ -526,38 +566,6 @@ public class UIDeploymentServers extends UIInput 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)); @@ -658,39 +666,50 @@ public class UIDeploymentServers extends UIInput Utils.encodeRecursive(context, auto); out.write("
"); + UICommand cancelButton = (UICommand)context.getApplication().createComponent( + UICommand.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, cancelButton, null); + cancelButton.setValue(bundle.getString("cancel")); + MethodBinding cancelBinding = context.getApplication().createMethodBinding( + "#{WizardManager.bean.cancelDeploymentServerConfig}", new Class[] {}); + cancelButton.setAction(cancelBinding); + this.getChildren().add(cancelButton); + Utils.encodeRecursive(context, cancelButton); + out.write("  "); + if (edit) { // create the done button - out.write("
"); UICommand saveButton = (UICommand)context.getApplication().createComponent( UICommand.COMPONENT_TYPE); - FacesHelper.setupComponentId(context, saveButton, null); + FacesHelper.setupComponentId(context, saveButton, "deployActionButton"); saveButton.setValue(bundle.getString("save")); - MethodBinding binding = context.getApplication().createMethodBinding( + MethodBinding saveBinding = context.getApplication().createMethodBinding( "#{WizardManager.bean.saveDeploymentServerConfig}", new Class[] {}); - saveButton.setAction(binding); + saveButton.setAction(saveBinding); this.getChildren().add(saveButton); Utils.encodeRecursive(context, saveButton); - out.write("
"); UICommand addButton = (UICommand)context.getApplication().createComponent( UICommand.COMPONENT_TYPE); - FacesHelper.setupComponentId(context, addButton, null); + FacesHelper.setupComponentId(context, addButton, "deployActionButton"); addButton.setValue(bundle.getString("add")); - MethodBinding binding = context.getApplication().createMethodBinding( + MethodBinding addBinding = context.getApplication().createMethodBinding( "#{WizardManager.bean.addDeploymentServerConfig}", new Class[] {}); - addButton.setAction(binding); + addButton.setAction(addBinding); this.getChildren().add(addButton); Utils.encodeRecursive(context, addButton); out.write("
"); + out.write(""); PanelGenerator.generatePanelEnd(out, contextPath, "lightstorm"); out.write(""); } diff --git a/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java b/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java index 1d9f013558..5318589db4 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java @@ -230,15 +230,14 @@ public class UISandboxSnapshots extends SelfRenderingComponent // determine whether the deploy action should be shown boolean showDeployAction = false; NodeRef webProjectRef = AVMUtil.getWebProjectNodeFromStore(sandbox); - NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); - List deployToServers = nodeService.getChildAssocs( - webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTSERVER, RegexQNamePattern.MATCH_ALL); + List deployToServers = DeploymentUtil.findLiveServers(webProjectRef); if (deployToServers != null && deployToServers.size() > 0) { showDeployAction = true; } // determine the deployment status for the website + NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); determineDeploymentStatus(context, webProjectRef, sandbox, nodeService, avmService); Map requestMap = context.getExternalContext().getRequestMap(); @@ -299,7 +298,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent params.put("version", "#{" + REQUEST_SNAPVERSION + "}"); params.put("store", sandbox); action = createAction(context, sandbox, ACT_SNAPSHOT_DEPLOY, "/images/icons/deploy.gif", - "#{DialogManager.setupParameters}", "dialog:deploySnapshot", null, params); + "#{DialogManager.setupParameters}", "dialog:deployWebsite", null, params); } Utils.encodeRecursive(context, action); 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 51942f90f6..791ea146ce 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java @@ -79,6 +79,7 @@ import org.alfresco.web.ui.common.PanelGenerator; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.SelfRenderingComponent; import org.alfresco.web.ui.common.component.UIActionLink; +import org.alfresco.web.ui.common.component.UIMenu; import org.alfresco.web.ui.common.converter.ByteSizeConverter; import org.alfresco.web.ui.repo.component.UIActions; import org.alfresco.web.ui.wcm.WebResources; @@ -119,6 +120,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa private static final String ACT_SANDBOX_REFRESH = "sandbox_refresh"; private static final String ACT_SANDBOX_DEPLOY = "sandbox_deploy"; private static final String ACT_SANDBOX_DEPLOY_REPORT = "deployment_report_action"; + private static final String ACT_SANDBOX_RELEASE_SERVER = "sandbox_release_test_server"; private static final String ACTIONS_FILE = "avm_file_modified"; private static final String ACTIONS_FOLDER = "avm_folder_modified"; @@ -197,6 +199,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa return "org.alfresco.faces.UserSandboxes"; } + @SuppressWarnings("unchecked") public void restoreState(FacesContext context, Object state) { Object values[] = (Object[])state; @@ -244,6 +247,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa /** * @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext) */ + @SuppressWarnings("unchecked") public void decode(FacesContext context) { Map requestMap = context.getExternalContext().getRequestParameterMap(); @@ -323,8 +327,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa // determine whether the deploy action should be shown boolean deployServersConfigured = false; - List deployToServers = nodeService.getChildAssocs( - websiteRef, WCMAppModel.ASSOC_DEPLOYMENTSERVER, RegexQNamePattern.MATCH_ALL); + List deployToServers = DeploymentUtil.findTestServers(websiteRef, false); if (deployToServers != null && deployToServers.size() > 0) { deployServersConfigured = true; @@ -360,6 +363,14 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa if (logger.isDebugEnabled()) logger.debug("Building sandbox view for user store: " + mainStore); + // determine if the sandbox has an allocated test server for deployment + NodeRef testServer = DeploymentUtil.findAllocatedTestServer(mainStore); + boolean hasAllocatedTestServer = (testServer != null); + + // determine if there are any previous deployment attempts + List deployAttempts = DeploymentUtil.findDeploymentAttempts(mainStore); + boolean hasPreviousDeployments = (deployAttempts.size() > 0); + // for each user sandbox, generate an outer panel table PanelGenerator.generatePanelStart(out, context.getExternalContext().getRequestContextPath(), @@ -391,25 +402,15 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa } out.write(" ("); out.write(bundle.getString(userrole)); - out.write(")"); + out.write(")"); + // clear current menu actions then add relevant ones + menu.getChildren().clear(); + + // Check Links action + Map params = new HashMap(6); + params.put("store", mainStore); + params.put("username", username); + params.put("webapp", this.getWebapp()); + params.put("mode", "runReport"); + params.put("compareToStaging", "true"); + UIActionLink checkLinks = createAction(context, mainStore, username, + ACT_SANDBOX_CHECK_LINKS, "/images/icons/run_link_validation.gif", + "#{DialogManager.setupParameters}", "dialog:linkValidation", + null, params, false); + menu.getChildren().add(checkLinks); + + // Deploy action + if (deployServersConfigured) + { + Map dialogParams = new HashMap(6); + dialogParams.put("store", mainStore); + dialogParams.put("username", username); + requestMap.put(REQUEST_UPDATE_TEST_SERVER, Boolean.toString(hasAllocatedTestServer)); + dialogParams.put("updateTestServer", "#{" + REQUEST_UPDATE_TEST_SERVER + "}"); + UIActionLink deploy = createAction(context, mainStore, username, + ACT_SANDBOX_DEPLOY, "/images/icons/deploy.gif", + "#{DialogManager.setupParameters}", "dialog:deployWebsite", + null, dialogParams, false); + menu.getChildren().add(deploy); + } + + // View deployment report action + if (hasPreviousDeployments) + { + UIActionLink reports = createAction(context, mainStore, username, + ACT_SANDBOX_DEPLOY_REPORT, "/images/icons/deployment_report.gif", + "#{DialogManager.setupParameters}", "dialog:viewDeploymentReport", + null, null, false); + menu.getChildren().add(reports); + } + + // Release Test Server action + if (hasAllocatedTestServer) + { + UIActionLink releaseServer = createAction(context, mainStore, username, + ACT_SANDBOX_RELEASE_SERVER, "/images/icons/deploy_server.gif", + "#{AVMBrowseBean.releaseTestServer}", null, null, null, false); + menu.getChildren().add(releaseServer); + } + + // Refresh Sandbox action + UIActionLink refresh = createAction(context, mainStore, username, + ACT_SANDBOX_REFRESH, "/images/icons/reset.gif", + "#{AVMBrowseBean.refreshSandbox}", null, null, null, false); + menu.getChildren().add(refresh); + + // Delete Sandbox action + if (AVMUtil.ROLE_CONTENT_MANAGER.equals(currentUserRole)) + { + UIActionLink delete = createAction(context, mainStore, username, + ACT_REMOVE_SANDBOX, "/images/icons/delete_sandbox.gif", + "#{AVMBrowseBean.setupSandboxAction}", "dialog:deleteSandbox", + null, null, false); + menu.getChildren().add(delete); + } + + // render the menu + Utils.encodeRecursive(context, menu); + + out.write("
"); // Direct actions for a sandbox... - Map params = new HashMap(6); - params.put("store", mainStore); - params.put("username", username); - params.put("webapp", this.getWebapp()); - params.put("mode", "runReport"); - params.put("compareToStaging", "true"); - Utils.encodeRecursive(context, aquireAction( - context, mainStore, username, ACT_SANDBOX_CHECK_LINKS, "/images/icons/run_link_validation.gif", - "#{DialogManager.setupParameters}", "dialog:linkValidation", null, params)); - out.write("  "); // Browse Sandbox Utils.encodeRecursive(context, aquireAction( context, mainStore, username, ACT_SANDBOX_BROWSE, "/images/icons/space_small.gif", "#{AVMBrowseBean.setupSandboxAction}", "browseSandbox")); - out.write("  "); + out.write(""); // Preview Website String websiteUrl = AVMUtil.buildWebappUrl(mainStore, getWebapp()); @@ -419,67 +420,101 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa context, mainStore, username, ACT_SANDBOX_PREVIEW, "/images/icons/preview_website.gif", null, null, "#{" + REQUEST_PREVIEW_REF + "}", null)); requestMap.remove(REQUEST_PREVIEW_REF); - out.write("  "); - - // Deployment actions - if (deployServersConfigured) - { - // if a deployment has already occurred then the next - // deployment will be an update (this informs the dialog - // that test server allocation checks are not needed). - PropertyValue val = avmService.getStoreProperty(mainStore, - SandboxConstants.PROP_LAST_DEPLOYMENT_ID); - - boolean reDeploy = (val != null); - - Map dialogParams = new HashMap(6); - dialogParams.put("store", mainStore); - dialogParams.put("username", username); - requestMap.put(REQUEST_UPDATE_TEST_SERVER, Boolean.toString(reDeploy)); - dialogParams.put("updateTestServer", "#{" + REQUEST_UPDATE_TEST_SERVER + "}"); - Utils.encodeRecursive(context, aquireAction( - context, mainStore, username, ACT_SANDBOX_DEPLOY, "/images/icons/deploy.gif", - "#{DialogManager.setupParameters}", "dialog:deploySandbox", null, dialogParams)); - out.write("  "); - } - - // View deployment report (if there are any) - List attempts = DeploymentUtil.findDeploymentAttempts(mainStore); - if (attempts != null && attempts.size() > 0) - { - Utils.encodeRecursive(context, aquireAction( - context, mainStore, username, ACT_SANDBOX_DEPLOY_REPORT, "/images/icons/deployment_report.gif", - "#{DialogManager.setupParameters}", "dialog:viewDeploymentReport")); - out.write("  "); - } - - // Refresh Sandbox - Utils.encodeRecursive(context, aquireAction( - context, mainStore, username, ACT_SANDBOX_REFRESH, "/images/icons/reset.gif", - "#{AVMBrowseBean.refreshSandbox}", null)); - out.write("  "); - + out.write(""); + // Submit All Items Utils.encodeRecursive(context, aquireAction( context, mainStore, username, ACT_SANDBOX_SUBMITALL, "/images/icons/submit_all.gif", "#{AVMBrowseBean.setupAllItemsAction}", "dialog:submitSandboxItems")); - out.write("  "); + out.write(""); // Revert All Items Utils.encodeRecursive(context, aquireAction( context, mainStore, username, ACT_SANDBOX_REVERTALL, "/images/icons/revert_all.gif", "#{AVMBrowseBean.setupAllItemsAction}", "dialog:revertAllItems")); - out.write("  "); + out.write(""); - // Delete Sandbox - if (AVMUtil.ROLE_CONTENT_MANAGER.equals(currentUserRole)) + // More Actions menu + UIMenu menu = findMenu(mainStore); + if (menu == null) { - Utils.encodeRecursive(context, aquireAction( - context, mainStore, username, ACT_REMOVE_SANDBOX, "/images/icons/delete_sandbox.gif", - "#{AVMBrowseBean.setupSandboxAction}", "dialog:deleteSandbox")); + // create the menu, then the actions + menu = createMenu(context, mainStore); + + // add the menu to this component + this.getChildren().add(menu); } - out.write("
"); // modified items panel out.write(""); @@ -881,11 +916,11 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa * * @throws IOException */ + @SuppressWarnings("unchecked") private void renderContentForms( FacesContext fc, ResponseWriter out, NodeRef websiteRef, String username, String storeRoot) throws IOException { - NodeService nodeService = getNodeService(fc); Map requestMap = fc.getExternalContext().getRequestMap(); String userStorePrefix = AVMUtil.buildUserMainStoreName(storeRoot, username); @@ -941,9 +976,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa ACT_CREATE_FORM_CONTENT, "/images/icons/new_content.gif", "#{AVMBrowseBean.createFormContent}", - null, - null, - params); + null, null, params, true); } Utils.encodeRecursive(fc, action); @@ -965,8 +998,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa "/images/icons/search_icon.gif", "#{AVMBrowseBean.searchFormContent}", "browseSandbox", - null, - params); + null, params, true); } Utils.encodeRecursive(fc, action); @@ -1006,6 +1038,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa * * @return UIActions component */ + @SuppressWarnings("unchecked") private UIActions aquireUIActions(String id, String store) { UIActions uiActions = null; @@ -1079,7 +1112,8 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa UIActionLink action = findAction(name, store); if (action == null) { - action = createAction(fc, store, username, name, icon, actionListener, outcome, url, params); + action = createAction(fc, store, username, name, icon, actionListener, + outcome, url, params, true); } return action; } @@ -1093,6 +1127,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa * * @return UIActionLink component if found, else null if not created yet */ + @SuppressWarnings("unchecked") private UIActionLink findAction(String name, String store) { UIActionLink action = null; @@ -1119,16 +1154,19 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa * @param store Root store name for the user sandbox * @param username Username of the user for the action * @param name Action name - will be used for I18N message lookup - * @param icon Icon to display for the actio n + * @param icon Icon to display for the action * @param actionListener Actionlistener for the action * @param outcome Navigation outcome for the action * @param url HREF URL for the action * @param params Parameters name/values for the action listener args + * @param addAsChild true to add the action as a child of this component * * @return UIActionLink child component */ + @SuppressWarnings("unchecked") private UIActionLink createAction(FacesContext fc, String store, String username, String name, - String icon, String actionListener, String outcome, String url, Map params) + String icon, String actionListener, String outcome, String url, Map params, + boolean addAsChild) { javax.faces.application.Application facesApp = fc.getApplication(); UIActionLink control = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK); @@ -1202,11 +1240,69 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa control.setTarget("new"); } - this.getChildren().add(control); + if (addAsChild) + { + this.getChildren().add(control); + } return control; } + /** + * Locate a child UIMenu component by name. + * + * @param store Store the action component is tied to + * + * @return UIMenu component if found, else null if not created yet + */ + @SuppressWarnings("unchecked") + private UIMenu findMenu(String store) + { + UIMenu menu = null; + String menuId = "menu_" + FacesHelper.makeLegalId(store); + + if (logger.isDebugEnabled()) + logger.debug("Finding action Id: " + menuId); + + for (UIComponent component : (List)getChildren()) + { + if (menuId.equals(component.getId())) + { + menu = (UIMenu)component; + + if (logger.isDebugEnabled()) + logger.debug("...found action Id: " + menuId); + + break; + } + } + + return menu; + } + + /** + * Creates a menu component to hold the 'more actions' for a sandbox + * + * @param context FacesContext + * @param store The store to create the menu for + * @return The UIMenu component (with no children) + */ + @SuppressWarnings("unchecked") + private UIMenu createMenu(FacesContext context, String store) + { + UIMenu menu = (UIMenu)context.getApplication().createComponent("org.alfresco.faces.Menu"); + + String id = "menu_" + FacesHelper.makeLegalId(store); + menu.setId(id); + menu.setLabel(Application.getMessage(context, "more_actions") + " "); + menu.getAttributes().put("itemSpacing", 4); + menu.getAttributes().put("image", "/images/icons/menu.gif"); + menu.getAttributes().put("menuStyleClass", "moreActionsMenu"); + menu.getAttributes().put("style", "white-space:nowrap; margin-left: 4px;"); + + return menu; + } + private AVMService getAVMService(FacesContext fc) { return (AVMService)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("AVMLockingAwareService"); diff --git a/source/web/css/main.css b/source/web/css/main.css index d8f9c32424..76c6699c90 100644 --- a/source/web/css/main.css +++ b/source/web/css/main.css @@ -766,6 +766,16 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited width: 200px; } +.deployNoConfigServers +{ + margin: 26px 5px 16px 3px; +} + +.deployNoConfigServers img +{ + vertical-align: -6px; +} + .deployServersInfo { margin: 10px 5px 16px 5px; @@ -782,6 +792,12 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited padding-left: 6px; padding-right: 16px; } + +.deployPanelNoControl +{ + padding-left: 21px; + padding-right: 21px; +} .deployPanelStatusIcon { @@ -794,6 +810,15 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited padding-left: 12px; padding-right: 12px; } + +.deployPanelServerStatus +{ +} + +.deployPanelServerMsg +{ + margin-top: 3px; +} .deployPanelServerName { diff --git a/source/web/jsp/wcm/manage-review-task-dialog.jsp b/source/web/jsp/wcm/manage-review-task-dialog.jsp index 60d7f64028..a6a38ecb4b 100644 --- a/source/web/jsp/wcm/manage-review-task-dialog.jsp +++ b/source/web/jsp/wcm/manage-review-task-dialog.jsp @@ -65,6 +65,11 @@ + + + + - - - + - + + + + + diff --git a/source/web/scripts/ajax/deployment.js b/source/web/scripts/ajax/deployment.js index 534bf31b89..7c6918a884 100644 --- a/source/web/scripts/ajax/deployment.js +++ b/source/web/scripts/ajax/deployment.js @@ -1,3 +1,158 @@ +Alfresco.DeploymentMonitor = function(ids, pollingFreq, failedMsg, successMsg) +{ + this.ids = ids; + this.url = getContextPath() + "/ajax/invoke/DeploymentProgressBean.getStatus?ids=" + this.ids; + this.pollingFreq = pollingFreq; + this.failedMsg = failedMsg; + this.successMsg = successMsg; +} + +Alfresco.DeploymentMonitor.prototype = +{ + ids: null, + url: null, + pollingFreq: 5, + failedMsg: null, + successMsg: null, + + retrieveDeploymentStatus: function() + { + YAHOO.util.Connect.asyncRequest('GET', this.url, + { + success: this.processResults, + failure: this.handleError, + scope: this + }, + null); + }, + + processResults: function(ajaxResponse) + { + var xml = ajaxResponse.responseXML.documentElement; + var statuses = xml.getElementsByTagName('target-server'); + var noInProgress = statuses.length; + if (noInProgress > 0) + { + for (var x = 0; x < noInProgress; x++) + { + var target = statuses[x]; + var id = target.getAttribute('id'); + var finished = target.getAttribute('finished'); + var url = target.getAttribute('url'); + var reason = target.getAttribute('reason'); + if (finished == 'true') + { + var successful = target.getAttribute('successful'); + var icon = document.getElementById(id + '_icon'); + if (icon != null) + { + var image = (successful == 'true') ? 'successful' : 'failed'; + icon.src = '/alfresco/images/icons/deploy_' + image + '.gif'; + } + + var statusElem = document.getElementById(id + '_status'); + if (statusElem != null) + { + var msg = (successful == 'true') ? this.successMsg : this.failedMsg; + statusElem.innerHTML = msg; + } + + var msgElem = document.getElementById(id + '_msg'); + if (msgElem != null) + { + if (successful == 'true') + { + if (url != null && url.length > 0) + { + msgElem.innerHTML = "" + url + ""; + } + } + else + { + if (reason != null && reason.length > 0) + { + msgElem.innerHTML = "" + reason + ""; + } + } + } + } + } + + // there are still outstanding deployments, refresh in a few seconds + setTimeout('Alfresco.monitor.retrieveDeploymentStatus()', this.pollingFreq); + } + }, + + handleError: function(ajaxResponse) + { + handleErrorYahoo(ajaxResponse.status + ' ' + ajaxResponse.statusText); + } +} + +var deployActionButtonPressed = false; + +Alfresco.checkDeployConfigPage = function() +{ + // make sure the relevant fields are visible for current deploy type + Alfresco.deployServerTypeChanged(); + + // make sure add/edit button is disabled if no host has been supplied + Alfresco.checkDeployConfigButtonState(); + + var button = document.getElementById('wizard:wizard-body:deployActionButton'); + if (button != null) + { + document.getElementById("wizard").onsubmit = Alfresco.validateDeployConfig; + button.onclick = function() {deployActionButtonPressed = true; clear_wizard();} + document.getElementById('wizard:wizard-body:deployServerHost').focus(); + } +} + +Alfresco.checkDeployConfigButtonState = function() +{ + var host = document.getElementById('wizard:wizard-body:deployServerHost'); + var button = document.getElementById('wizard:wizard-body:deployActionButton'); + + if (button != null) + { + if (host != null && host.value.length == 0) + { + button.disabled = true; + } + else + { + button.disabled = false; + } + } +} + +Alfresco.validateDeployConfig = function() +{ + if (deployActionButtonPressed) + { + deployActionButtonPressed = false; + + var valid = true; + var port = document.getElementById('wizard:wizard-body:deployServerPort'); + + if (port != null && port.value.length > 0) + { + if (isNaN(port.value)) + { + alert(MSG_PORT_MUST_BE_NUMBER); + port.focus(); + valid = false; + } + } + + return valid; + } + else + { + return true; + } +} + Alfresco.deployServerTypeChanged = function() { var typeDropDown = document.getElementById('wizard:wizard-body:deployServerType'); @@ -33,4 +188,29 @@ Alfresco.deployServerTypeChanged = function() } } } -} \ No newline at end of file +} + +Alfresco.toggleDeploymentDetails = function(icon, server) +{ + var currentState = icon.className; + var detailsDiv = document.getElementById(server + '-deployment-details'); + if (currentState == 'collapsed') + { + icon.src = getContextPath() + '/images/icons/expanded.gif'; + icon.className = 'expanded'; + if (detailsDiv != null) + { + detailsDiv.style.display = 'block'; + } + } + else + { + icon.src = getContextPath() + '/images/icons/collapsed.gif'; + icon.className = 'collapsed'; + if (detailsDiv != null) + { + detailsDiv.style.display = 'none'; + } + } +} +