Merged V2.0 to HEAD

5456: (From WCM_DEPLOY)

There were many pure conflicts on license headers, one conflict due to CR-LF and
some other smaller issues to resolve:
-----------------------------------------
Resolved (line endings not cr-lf):
   root\projects\repository\config\alfresco\public-services-context.xml

Reverted:
   root\projects\web-client\source\web\images\icons\ajax_anim.gif

Reverted or Resolved (License text conflicts):
   svn revert root\projects\jndi-client\source\java\org\alfresco\jndi\JndiTest.java
   svn resolved root\projects\jndi-client\source\java\org\alfresco\jndi\AVMFileDirContext.java
   svn revert root\projects\jndi-client\source\java\org\alfresco\jndi\AVMBulkLoader.java
   svn revert root\projects\jndi-client\source\java\org\alfresco\filter\CacheControlFilter.java
   svn revert root\projects\jndi-client\source\java\org\alfresco\filter\CacheControlFilterInfoBean.java
   svn revert -R root\projects\catalina-virtual\source\java\org\alfresco\mbeans
   svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\context\AVMStandardContext.java
   svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\loader\AVMWebappClassLoader.java
   svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\loader\AVMWebappLoader.java
   svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\AVMResourceBinding.java
   svn resolved root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\AVMHostConfig.java
      - why the change in method naming convention?
   svn resolved root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\AVMHost.java
   svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\DefaultAVMResourceBinding.java
   svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\valve\AVMUrlValveTest.java
   svn resolved root\projects\catalina-virtual\source\java\org\alfresco\catalina\valve\AVMUrlValve.java
   svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\AVMHostMatch.java

Modified:
   root\projects\web-client\source\java\org\alfresco\web\ui\wcm\component\UIDeployWebsite.java (Kevin to check line 330)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5484 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-04-12 01:41:14 +00:00
parent 1e854c1087
commit 69694b7ac0
86 changed files with 5283 additions and 1422 deletions

View File

@@ -98,7 +98,7 @@ public class CopyToWebProjectHandler extends BaseActionHandler
folder = avmPath.substring(avmPath.indexOf(AVMConstants.DIR_ROOT)+4);
// get the destination web project name
NodeRef webProjectNode = AVMConstants.getWebProjectNode(avmPath);
NodeRef webProjectNode = AVMConstants.getWebProjectNodeFromPath(avmPath);
webProject = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), webProjectNode);
}

View File

@@ -41,6 +41,7 @@ import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import javax.transaction.UserTransaction;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.actions.AVMRevertStoreAction;
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
@@ -49,13 +50,17 @@ import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.Pair;
import org.alfresco.util.VirtServerUtils;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.IContextListener;
import org.alfresco.web.app.context.UIContextService;
@@ -67,7 +72,6 @@ import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User;
import org.alfresco.web.bean.wizard.WizardManager;
import org.alfresco.web.config.ClientConfigElement;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.IBreadcrumbHandler;
import org.alfresco.web.ui.common.component.UIActionLink;
@@ -80,8 +84,6 @@ import org.alfresco.web.ui.wcm.component.UIUserSandboxes;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.alfresco.util.VirtServerUtils;
/**
* Bean backing up the AVM specific browse screens
*
@@ -93,6 +95,9 @@ 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";
private static final String MSG_REVERT_SUCCESS = "revert_success";
private static final String MSG_REVERT_SANDBOX = "revert_sandbox_success";
private static final String MSG_SANDBOXTITLE = "sandbox_title";
@@ -100,9 +105,9 @@ public class AVMBrowseBean implements IContextListener
private static final String MSG_CREATED_ON = "store_created_on";
private static final String MSG_CREATED_BY = "store_created_by";
private static final String MSG_WORKING_USERS = "store_working_users";
private static final String MSG_SUBMIT_SUCCESS = "submit_success";
private static final String MSG_SUBMITALL_SUCCESS = "submitall_success";
private static final String MSG_SUBMITSELECTED_SUCCESS = "submitselected_success";
// private static final String MSG_SUBMIT_SUCCESS = "submit_success";
// private static final String MSG_SUBMITALL_SUCCESS = "submitall_success";
// private static final String MSG_SUBMITSELECTED_SUCCESS = "submitselected_success";
/** Component id the status messages are tied too */
static final String COMPONENT_SANDBOXESPANEL = "sandboxes-panel";
@@ -135,6 +140,9 @@ public class AVMBrowseBean implements IContextListener
/** flag to indicate that all items in the sandbox are involved in the current action */
private boolean allItemsAction = false;
/** list of the deployment monitor ids currently executing */
private List<String> deploymentMonitorIds = new ArrayList<String>();
/* component references */
private UIRichList foldersRichList;
private UIRichList filesRichList;
@@ -429,6 +437,22 @@ public class AVMBrowseBean implements IContextListener
this.webapp = webapp;
}
/**
* @return Returns the list of deployment monitor ids currently executing
*/
public List<String> getDeploymentMonitorIds()
{
return this.deploymentMonitorIds;
}
/**
* @param deploymentMonitorIds Sets the list of deployment monitor ids
*/
public void setDeploymentMonitorIds(List<String> deploymentMonitorIds)
{
this.deploymentMonitorIds = deploymentMonitorIds;
}
/**
* @return list of available root webapp folders for this Web project
*/
@@ -639,6 +663,39 @@ public class AVMBrowseBean implements IContextListener
return this.getWebProject().isManager(user);
}
/**
* @return true if the website has had a deployment attempt
*/
@SuppressWarnings("unchecked")
public boolean getHasDeployBeenAttempted()
{
// 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
List<ChildAssociationRef> deployReportRefs = null;
FacesContext context = FacesContext.getCurrentInstance();
Map request = context.getExternalContext().getRequestMap();
if (request.get(REQUEST_BEEN_DEPLOYED_KEY) == null)
{
// see if there are any deployment reports for the site
NodeRef webProjectRef = this.getWebsite().getNodeRef();
deployReportRefs = this.nodeService.getChildAssocs(webProjectRef,
WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL);
// 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, deployReportRefs);
}
else
{
deployReportRefs = (List<ChildAssociationRef>)request.get(REQUEST_BEEN_DEPLOYED_RESULT);
}
return (deployReportRefs != null && deployReportRefs.size() > 0);
}
/**
* @return Map of avm node objects representing the folders with the current website space
*/
@@ -675,8 +732,6 @@ public class AVMBrowseBean implements IContextListener
tx = Repository.getUserTransaction(context, true);
tx.begin();
int rootPathIndex = AVMConstants.buildSandboxRootPath(getSandbox()).length();
Map<String, AVMNodeDescriptor> nodes = this.avmService.getDirectoryListing(-1, getCurrentPath());
this.files = new ArrayList<Map>(nodes.size());
this.folders = new ArrayList<Map>(nodes.size());
@@ -1006,8 +1061,6 @@ public class AVMBrowseBean implements IContextListener
*/
public void createFormContent(ActionEvent event)
{
UIActionLink link = (UIActionLink)event.getComponent();
// setup the correct sandbox for the create action
setupSandboxAction(event);
@@ -1106,6 +1159,7 @@ public class AVMBrowseBean implements IContextListener
/**
* Class to handle breadcrumb interaction for AVM page
*/
@SuppressWarnings("serial")
private class AVMBreadcrumbHandler implements IBreadcrumbHandler
{
private String path;
@@ -1115,6 +1169,7 @@ public class AVMBrowseBean implements IContextListener
this.path = path;
}
@SuppressWarnings("unchecked")
public String navigationOutcome(UIBreadcrumb breadcrumb)
{
setCurrentPath(path);

View File

@@ -25,7 +25,6 @@
package org.alfresco.web.bean.wcm;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import java.util.regex.Matcher;
@@ -33,19 +32,19 @@ import java.util.regex.Pattern;
import javax.faces.context.FacesContext;
import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigService;
import org.alfresco.config.JNDIConstants;
import org.alfresco.mbeans.VirtServerRegistry;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.util.VirtServerUtils;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
@@ -276,6 +275,175 @@ public final class AVMConstants
return (otherStore + ':' + AVMConstants.getStoreRelativePath(avmPath));
}
/**
* Returns the username to connect as on the remote machine being deployed to
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @return Username for remote machine
*/
public static String getRemoteDeploymentUsername()
{
String username = "admin";
ConfigElement deploymentConfig = getDeploymentConfig();
if (deploymentConfig != null)
{
ConfigElement elem = deploymentConfig.getChild("remote-username");
if (elem != null)
{
username = elem.getValue();
}
}
return username;
}
/**
* Returns the password to use on the remote machine being deployed to
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @return Password for remote machine
*/
public static String getRemoteDeploymentPassword()
{
String password = "admin";
ConfigElement deploymentConfig = getDeploymentConfig();
if (deploymentConfig != null)
{
ConfigElement elem = deploymentConfig.getChild("remote-password");
if (elem != null)
{
password = elem.getValue();
}
}
return password;
}
/**
* Returns the number of seconds between each call back to the server to
* obtain the latest status of an in progress deployment.
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @return Number of seconds between each call to the server (in seconds).
* The default is 5.
*/
public static int getRemoteDeploymentPollingFrequency()
{
int pollFreq = 5;
ConfigElement deploymentConfig = getDeploymentConfig();
if (deploymentConfig != null)
{
ConfigElement elem = deploymentConfig.getChild("progress-polling-frequency");
if (elem != null)
{
try
{
int value = Integer.parseInt(elem.getValue());
if (value > 0)
{
pollFreq = value;
}
}
catch (NumberFormatException nfe)
{
// do nothing, just use the default
}
}
}
return pollFreq;
}
/**
* Returns the default RMI registry port to use when one is not supplied
* for target deployment servers.
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @return The remote RMI registry port to use for deployments.
* The default is 50500.
*/
public static int getRemoteRMIRegistryPort()
{
int rmiPort = 50500;
ConfigElement deploymentConfig = getDeploymentConfig();
if (deploymentConfig != null)
{
ConfigElement elem = deploymentConfig.getChild("remote-rmi-port");
if (elem != null)
{
try
{
int value = Integer.parseInt(elem.getValue());
if (value > 0)
{
rmiPort = value;
}
}
catch (NumberFormatException nfe)
{
// do nothing, just use the default
}
}
}
return rmiPort;
}
/**
* Returns the delay (in seconds) to apply to the start of a deployment
* operation (mainly for demo and testing purposes).
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @return The delay to use at the start of a deployment.
* The default is 30.
*/
public static int getRemoteDeploymentDelay()
{
int delay = 30;
ConfigElement deploymentConfig = getDeploymentConfig();
if (deploymentConfig != null)
{
ConfigElement elem = deploymentConfig.getChild("delay");
if (elem != null)
{
try
{
int value = Integer.parseInt(elem.getValue());
if (value > 0)
{
delay = value;
}
}
catch (NumberFormatException nfe)
{
// do nothing, just use the default
}
}
}
return delay;
}
/**
* Returns the main staging store name for the specified store id.
*
@@ -435,8 +603,17 @@ public final class AVMConstants
config.getWCMPort());
}
public static String buildWebappUrl(final String store,
final String webapp)
public static String buildWebappUrl(final String avmPath)
{
if (avmPath == null || avmPath.length() == 0)
{
throw new IllegalArgumentException("AVM path is mandatory.");
}
return AVMConstants.buildWebappUrl(AVMConstants.getStoreName(avmPath),
AVMConstants.getWebapp(avmPath));
}
public static String buildWebappUrl(final String store, final String webapp)
{
if (webapp == null || webapp.length() == 0)
{
@@ -485,9 +662,11 @@ public final class AVMConstants
{
throw new IllegalArgumentException("Asset path is mandatory.");
}
if (assetPath.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + JNDIConstants.DIR_DEFAULT_APPBASE))
if (assetPath.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW +
'/' + JNDIConstants.DIR_DEFAULT_APPBASE))
{
assetPath = assetPath.substring(('/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + JNDIConstants.DIR_DEFAULT_APPBASE).length());
assetPath = assetPath.substring(('/' + JNDIConstants.DIR_DEFAULT_WWW +
'/' + JNDIConstants.DIR_DEFAULT_APPBASE).length());
}
if (assetPath.startsWith('/' + DIR_ROOT))
{
@@ -639,19 +818,27 @@ public final class AVMConstants
* @return The NodeRef representing the Web Project the path is from or null
* if it could not be determined
*/
public static NodeRef getWebProjectNode(final String absoluteAVMPath)
public static NodeRef getWebProjectNodeFromPath(final String absoluteAVMPath)
{
return getWebProjectNodeFromStore(AVMConstants.getStoreName(absoluteAVMPath));
}
/**
* Returns the NodeRef that represents the given avm store
*
* @param storeName The store name from which to determine the Web Project
* @return The NodeRef representing the Web Project the store is from or null
* if it could not be determined
*/
public static NodeRef getWebProjectNodeFromStore(final String storeName)
{
// get services
FacesContext fc = FacesContext.getCurrentInstance();
SearchService searchService = Repository.getServiceRegistry(fc).getSearchService();
// get the store name
String storeName = AVMConstants.getStoreName(absoluteAVMPath);
String storeId = AVMConstants.getStoreId(storeName);
// construct the query
String path = Application.getRootPath(fc) + "/" + Application.getWebsitesFolderName(fc) + "/*";
String query = "PATH:\"/" + path + "\" AND @wca\\:avmstore:\"" + storeId + "\"";
String query = "PATH:\"/" + path + "\" AND @wca\\:avmstore:\"" + storeName + "\"";
NodeRef webProjectNode = null;
ResultSet results = null;
@@ -725,16 +912,15 @@ public final class AVMConstants
{
if (force || VirtServerUtils.requiresUpdateNotification(path))
{
VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry();
int webappIndex = path.indexOf( '/',
path.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE) +
JNDIConstants.DIR_DEFAULT_APPBASE.length() + 1);
final int webappIndex = path.indexOf('/',
path.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE) +
JNDIConstants.DIR_DEFAULT_APPBASE.length() + 1);
if (webappIndex != -1)
{
path = path.substring(0, webappIndex);
}
final VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry();
vServerRegistry.updateAllWebapps(-1, path, true);
}
}
@@ -749,15 +935,15 @@ public final class AVMConstants
{
if (force || VirtServerUtils.requiresUpdateNotification(path))
{
VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry();
int webappIndex = path.indexOf( '/', path.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE) +
JNDIConstants.DIR_DEFAULT_APPBASE.length() + 1);
final int webappIndex = path.indexOf('/',
path.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE) +
JNDIConstants.DIR_DEFAULT_APPBASE.length() + 1);
if (webappIndex != -1)
{
path = path.substring(0, webappIndex);
}
final VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry();
vServerRegistry.removeAllWebapps(-1, path, true);
}
}
@@ -769,6 +955,20 @@ public final class AVMConstants
return (VirtServerRegistry)ac.getBean(BEAN_VIRT_SERVER_REGISTRY);
}
private static ConfigElement getDeploymentConfig()
{
if (deploymentConfig == null)
{
ConfigService cfgService = Application.getConfigService(FacesContext.getCurrentInstance());
ConfigElement wcmCfg = cfgService.getGlobalConfig().getConfigElement("wcm");
if (wcmCfg != null)
{
deploymentConfig = wcmCfg.getChild("deployment");
}
}
return deploymentConfig;
}
// Component Separator.
private static final String STORE_SEPARATOR = "--";
@@ -820,4 +1020,6 @@ public final class AVMConstants
private final static Pattern SANDBOX_RELATIVE_PATH_PATTERN =
Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW +
"/" + JNDIConstants.DIR_DEFAULT_APPBASE + ")(.*)");
private static ConfigElement deploymentConfig = null;
}

View File

@@ -414,7 +414,8 @@ public class CreateFormWizard
case 1:
{
return (this.getSchemaFileName() == null ||
this.getSchemaFileName().length() == 0);
this.getSchemaFileName().length() == 0 ||
this.getSchemaRootElementNameChoices().size() == 0);
}
default:
{

View File

@@ -25,6 +25,7 @@
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -75,10 +76,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class CreateWebsiteWizard extends BaseWizardBean
{
private static final String MSG_DESCRIPTION = "description";
private static final String MSG_NAME = "name";
private static final String MSG_USERROLES = "create_website_summary_users";
private static final String MSG_NONE = "workflow_not_set";
private static final String COMPONENT_FORMLIST = "form-list";
private static final String COMPONENT_WORKFLOWLIST = "workflow-list";
@@ -96,6 +94,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
protected String name;
protected String description;
protected String webapp = WEBAPP_DEFAULT;
protected List<String> deployTo;
protected String websitesFolderId = null;
@@ -145,6 +144,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.dnsName = null;
this.title = null;
this.description = null;
this.deployTo = null;
this.formsDataModel = null;
this.forms = new ArrayList<FormWrapper>(8);
this.workflowsDataModel = null;
@@ -187,6 +187,9 @@ public class CreateWebsiteWizard extends BaseWizardBean
String webapp = (this.webapp != null && this.webapp.length() != 0) ? this.webapp : WEBAPP_DEFAULT;
this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_DEFAULTWEBAPP, webapp);
// set the list of servers to deploy to
this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_DEPLOYTO, (Serializable)this.deployTo);
// call a delegate wizard bean to provide invite user functionality
InviteWebsiteUsersWizard wiz = getInviteUsersWizard();
wiz.setNode(new Node(nodeRef));
@@ -469,10 +472,39 @@ public class CreateWebsiteWizard extends BaseWizardBean
{
this.webapp = webapp;
}
/**
* @return The comma separated list of servers to deploy to
*/
public List<String> getDeployTo()
{
return this.deployTo;
}
/**
* @param deployTo The comma separated list of servers to deploy to
*/
public void setDeployTo(List<String> deployTo)
{
this.deployTo = deployTo;
}
/**
* @return the deploy to help text that gets displayed if the user
* clicks the Help icon
*/
public String getDeployToHelp()
{
String pattern = Application.getMessage(FacesContext.getCurrentInstance(),
"deploy_to_help");
String defaultPort = Integer.toString(AVMConstants.getRemoteRMIRegistryPort());
return MessageFormat.format(pattern, new Object[] {defaultPort});
}
/**
* @return summary text for the wizard
*/
@SuppressWarnings("unchecked")
public String getSummary()
{
FacesContext fc = FacesContext.getCurrentInstance();
@@ -506,6 +538,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
/**
* @return the invited users for the project - as UserWrapper instances
*/
@SuppressWarnings("unchecked")
public List<UserWrapper> getInvitedUsers()
{
final FacesContext fc = FacesContext.getCurrentInstance();

View File

@@ -0,0 +1,243 @@
/*
* 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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.actions.AVMDeploySnapshotAction;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Deploys a web project snapshot to one or more remote servers.
*
* @author gavinc
*/
public class DeploySnapshotDialog extends BaseDialogBean
{
protected int versionToDeploy;
protected String[] deployTo;
protected NodeRef websiteRef;
protected NodeRef webProjectRef;
protected AVMBrowseBean avmBrowseBean;
protected ActionService actionService;
private static final Log logger = LogFactory.getLog(DeploySnapshotDialog.class);
// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// setup context for dialog
this.deployTo = null;
this.versionToDeploy = Integer.parseInt(parameters.get("version"));
this.avmBrowseBean.getDeploymentMonitorIds().clear();
this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef();
String stagingStore = AVMConstants.buildSandboxRootPath(this.avmBrowseBean.getStagingStore());
this.websiteRef = AVMNodeConverter.ToNodeRef(this.versionToDeploy, stagingStore);
if (logger.isDebugEnabled())
logger.debug("Initialising dialog to deploy version " + this.versionToDeploy +
" of " + this.websiteRef.toString());
}
@SuppressWarnings("unchecked")
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// put all the selected servers to deploy to into a list
List<String> selectedDeployTo = new ArrayList<String>();
if (this.deployTo != null)
{
for (int x = 0; x < this.deployTo.length; x++)
{
selectedDeployTo.add(this.deployTo[x].trim());
}
}
if (logger.isDebugEnabled())
logger.debug("Executing deployment of " + this.websiteRef.toString() +
" to servers: " + selectedDeployTo);
if (selectedDeployTo.size() > 0)
{
// TODO: move any existing deployment reports to a node representing the
// snapshot, we can then keep a history of deployment attempts on a
// per snapshot basis.
NodeRef webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef();
List<String> allDeployToServers = (List<String>)nodeService.getProperty(webProjectRef,
WCMAppModel.PROP_DEPLOYTO);
List<ChildAssociationRef> deployReportRefs = nodeService.getChildAssocs(
webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : deployReportRefs)
{
NodeRef report = ref.getChildRef();
String server = (String)this.nodeService.getProperty(report, WCMAppModel.PROP_DEPLOYSERVER);
int version = (Integer)this.nodeService.getProperty(report, WCMAppModel.PROP_DEPLOYVERSION);
if ((version == this.versionToDeploy && selectedDeployTo.contains(server)) ||
(version != this.versionToDeploy) || (allDeployToServers.contains(server) == false))
{
// cascade delete will take care of child-child relationships
this.nodeService.removeChild(webProjectRef, report);
if (logger.isDebugEnabled())
logger.debug("Removed exisiting deployment report for server: " + server);
}
}
// update the selecteddeployto property with list of servers selected
this.nodeService.setProperty(webProjectRef, WCMAppModel.PROP_SELECTEDDEPLOYTO,
(Serializable)selectedDeployTo);
// update the selecteddeployversion property with the selected snapshot version
this.nodeService.setProperty(webProjectRef, WCMAppModel.PROP_SELECTEDDEPLOYVERSION,
this.versionToDeploy);
// execute a deploy action for each of the selected remote servers asynchronously
for (String targetServer : selectedDeployTo)
{
if (targetServer.length() > 0)
{
// create a deployment monitor object, store in the session,
// add to avm browse bean and pass to action
DeploymentMonitor monitor = new DeploymentMonitor(
this.websiteRef, targetServer, versionToDeploy);
context.getExternalContext().getSessionMap().put(monitor.getId(), monitor);
this.avmBrowseBean.getDeploymentMonitorIds().add(monitor.getId());
// create the action
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put(AVMDeploySnapshotAction.PARAM_WEBSITE, webProjectRef);
args.put(AVMDeploySnapshotAction.PARAM_TARGET_SERVER, targetServer);
args.put(AVMDeploySnapshotAction.PARAM_DEFAULT_RMI_PORT,
AVMConstants.getRemoteRMIRegistryPort());
args.put(AVMDeploySnapshotAction.PARAM_REMOTE_USERNAME,
AVMConstants.getRemoteDeploymentUsername());
args.put(AVMDeploySnapshotAction.PARAM_REMOTE_PASSWORD,
AVMConstants.getRemoteDeploymentPassword());
args.put(AVMDeploySnapshotAction.PARAM_CALLBACK, monitor);
args.put(AVMDeploySnapshotAction.PARAM_DELAY,
AVMConstants.getRemoteDeploymentDelay());
Action action = this.actionService.createAction(AVMDeploySnapshotAction.NAME, args);
this.actionService.executeAction(action, this.websiteRef, false, true);
}
}
// close this dialog and immediately open the monitorDeployment dialog
return "dialog:monitorDeployment";
}
else
{
return outcome;
}
}
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
@Override
public String getCancelButtonLabel()
{
return super.getCancelButtonLabel();
}
// ------------------------------------------------------------------------------
// Bean getters and setters
/**
* @param avmBrowseBean The AVM BrowseBean to set
*/
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
{
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param actionService The actionService to set.
*/
public void setActionService(ActionService actionService)
{
this.actionService = actionService;
}
/**
* Sets the list of remote servers to deploy to
*
* @param deployTo String array of servers to deploy to
*/
public void setDeployTo(String[] deployTo)
{
this.deployTo = deployTo;
}
/**
* Returns the remote servers to deploy to as an array
*
* @return String array of servers to deploy to
*/
public String[] getDeployTo()
{
return this.deployTo;
}
/**
* @return The NodeRef of the web project the deployment reports are being shown for
*/
public NodeRef getWebProjectRef()
{
return this.webProjectRef;
}
/**
* @return The version of the snapshot to deploy
*/
public int getSnapshotVersion()
{
return this.versionToDeploy;
}
}

View File

@@ -0,0 +1,199 @@
/*
* 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 org.alfresco.service.cmr.avm.deploy.DeploymentCallback;
import org.alfresco.service.cmr.avm.deploy.DeploymentEvent;
import org.alfresco.service.cmr.avm.deploy.DeploymentEvent.Type;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Object used to monitor the deployment of a snapshot to a remote
* server. These objects are typically stored in the HTTP session
* and accessed by an AJAX callback to provide progress feedback
* for the deployment.
*
* @author gavinc
*/
@SuppressWarnings("serial")
public class DeploymentMonitor implements DeploymentCallback, Serializable
{
private String id;
private NodeRef website;
private String targetServer;
private int snapshotVersion;
private boolean started = false;
private boolean finished = false;
private boolean successful = false;
private static Log logger = LogFactory.getLog(DeploymentMonitor.class);
private static final String ID_PREFIX = "_depmon_";
/**
* Default constructor
*/
public DeploymentMonitor(NodeRef website, String targetServer, int snapshotVersion)
{
this.id = ID_PREFIX + Long.toString(System.currentTimeMillis()) + this.hashCode();
this.website = website;
this.targetServer = targetServer;
this.snapshotVersion = snapshotVersion;
}
// ------------------------------------------------------------------------------
// DeploymentCallback implementation
public void eventOccurred(DeploymentEvent event)
{
// we're only interested in the start and end event for the time
// being, we'll add support for returning item by item progress
// at a later date.
if (event.getType().equals(Type.START))
{
this.started = true;
}
else if (event.getType().equals(Type.END))
{
// if we get the END event the deployment was successful
this.successful = true;
this.finished = true;
}
if (logger.isDebugEnabled())
logger.debug(this.targetServer + ": " + event.getType() +
" " + event.getDestination());
}
/**
* Informs the monitor an error occurred during deployment
*
* @param err The error that caused the deployment to fail
*/
public void errorOccurred(Throwable err)
{
if (logger.isDebugEnabled())
logger.debug(this.targetServer + ": ERROR: " + err.getMessage());
this.successful = false;
this.finished = true;
}
@Override
public String toString()
{
StringBuilder buffer = new StringBuilder(super.toString());
buffer.append(" (id=").append(this.id);
buffer.append(" website=").append(this.website);
buffer.append(" targetServer=").append(this.targetServer);
buffer.append(" snapshotVersion=").append(this.snapshotVersion);
buffer.append(" started=").append(this.started);
buffer.append(" finished=").append(this.finished);
buffer.append(" successful=").append(this.successful).append(")");
return buffer.toString();
}
public String toXML()
{
StringBuilder buffer = new StringBuilder("<target-server id=\"");
buffer.append(this.getId());
buffer.append("\" name=\"");
buffer.append(this.targetServer);
buffer.append("\" finished=\"");
buffer.append(this.finished);
buffer.append("\"");
if (this.finished)
{
buffer.append(" successful=\"");
buffer.append(this.successful);
buffer.append("\"");
}
buffer.append("/>");
return buffer.toString();
}
// ------------------------------------------------------------------------------
// Getters and setters
/**
* @return The id for this deployment monitor
*/
public String getId()
{
return this.id;
}
/**
* @return The NodeRef representation of the website being deployed
*/
public NodeRef getWebsite()
{
return this.website;
}
/**
* @return The target server for this deployment
*/
public String getTargetServer()
{
return this.targetServer;
}
/**
* @return The snapshot version being deployed
*/
public int getSnapshotVersion()
{
return this.snapshotVersion;
}
/**
* @return true if the deployment has started
*/
public boolean isStarted()
{
return this.started;
}
/**
* @return true if the deployment has finished
*/
public boolean isFinished()
{
return this.finished;
}
/**
* @return true if the deployment was successful,
* only reliable once isFinished returns true.
*/
public boolean isSuccessful()
{
return this.successful;
}
}

View File

@@ -0,0 +1,96 @@
/*
* 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.IOException;
import java.util.Map;
import java.util.StringTokenizer;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Bean used by the AJAX callback from the monitor deployment dialog
* to track progress of deployments.
*
* @author gavinc
*/
public class DeploymentProgressBean
{
private static Log logger = LogFactory.getLog(DeploymentProgressBean.class);
public void getStatus() throws IOException
{
FacesContext context = FacesContext.getCurrentInstance();
ResponseWriter out = context.getResponseWriter();
Map params = context.getExternalContext().getRequestParameterMap();
String monitorIds = (String)params.get("ids");
if (logger.isDebugEnabled())
logger.debug("Retrieving progress status for ids: " + monitorIds);
if (monitorIds != null && monitorIds.length() > 0)
{
StringBuilder xml = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>");
xml.append("<deployment-progess>");
StringTokenizer tokenizer = new StringTokenizer(monitorIds, ",");
while (tokenizer.hasMoreTokens())
{
String id = tokenizer.nextToken().trim();
// try and find the deployment monitor object in the session
DeploymentMonitor monitor = (DeploymentMonitor)context.getExternalContext().
getSessionMap().get(id);
if (monitor != null)
{
if (logger.isDebugEnabled())
logger.debug("Found monitor object for id '" + id + "': " + monitor);
xml.append(monitor.toXML());
// cleanup the monitor object from the session if it has completed
if (monitor.isFinished())
{
context.getExternalContext().getSessionMap().remove(id);
}
}
}
xml.append("</deployment-progess>");
// send the generated XML back to the tree
out.write(xml.toString());
if (logger.isDebugEnabled())
logger.debug("returning XML: " + xml.toString());
}
}
}

View File

@@ -67,6 +67,7 @@ public class EditWebsiteWizard extends CreateWebsiteWizard
{
throw new IllegalArgumentException("Edit Web Project wizard requires action node context.");
}
loadWebProjectModel(websiteRef);
}
@@ -78,11 +79,13 @@ public class EditWebsiteWizard extends CreateWebsiteWizard
private void loadWebProjectModel(NodeRef nodeRef)
{
// simple properties
this.name = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
this.title = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE);
this.description = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION);
this.dnsName = (String)this.nodeService.getProperty(nodeRef, WCMAppModel.PROP_AVMSTORE);
this.webapp = (String)this.nodeService.getProperty(nodeRef, WCMAppModel.PROP_DEFAULTWEBAPP);
Map<QName, Serializable> props = this.nodeService.getProperties(nodeRef);
this.name = (String)props.get(ContentModel.PROP_NAME);
this.title = (String)props.get(ContentModel.PROP_TITLE);
this.description = (String)props.get(ContentModel.PROP_DESCRIPTION);
this.dnsName = (String)props.get(WCMAppModel.PROP_AVMSTORE);
this.webapp = (String)props.get(WCMAppModel.PROP_DEFAULTWEBAPP);
this.deployTo = (List<String>)props.get(WCMAppModel.PROP_DEPLOYTO);
// load the form templates
List<ChildAssociationRef> webFormRefs = this.nodeService.getChildAssocs(
@@ -121,7 +124,6 @@ public class EditWebsiteWizard extends CreateWebsiteWizard
}
// the templates attached to the form
List<RenderingEngineTemplate> engineTemplates = formImpl.getRenderingEngineTemplates();
List<ChildAssociationRef> templateRefs = this.nodeService.getChildAssocs(
formRef, WCMAppModel.ASSOC_WEBFORMTEMPLATE, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef tChildRef : templateRefs)
@@ -178,6 +180,7 @@ public class EditWebsiteWizard extends CreateWebsiteWizard
this.nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, this.name);
this.nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, this.title);
this.nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, this.description);
this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_DEPLOYTO, (Serializable)this.deployTo);
// 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

View File

@@ -0,0 +1,104 @@
/*
* 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.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Monitors the deployment of a web project snapshot to one or more remote servers.
*
* @author gavinc
*/
public class MonitorDeploymentDialog extends BaseDialogBean
{
protected NodeRef webProjectRef;
protected AVMBrowseBean avmBrowseBean;
private static final Log logger = LogFactory.getLog(MonitorDeploymentDialog.class);
// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// setup context for dialog
this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef();
if (logger.isDebugEnabled())
{
logger.debug("Initialising dialog to monitor deployment of " +
this.webProjectRef.toString());
}
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return outcome;
}
@Override
protected String getDefaultCancelOutcome()
{
return "dialog:close:browseWebsite";
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "close");
}
// ------------------------------------------------------------------------------
// Bean getters and setters
/**
* @param avmBrowseBean The AVM BrowseBean to set
*/
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
{
this.avmBrowseBean = avmBrowseBean;
}
/**
* @return The NodeRef of the web project the deployment reports are being shown for
*/
public NodeRef getWebProjectRef()
{
return this.webProjectRef;
}
}

View File

@@ -0,0 +1,96 @@
/*
* 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.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Views the deployment reports created as a result of the last deployment attempt
*
* @author gavinc
*/
public class ViewDeploymentReportDialog extends BaseDialogBean
{
protected NodeRef webProjectRef;
protected Integer deployedVersion;
protected AVMBrowseBean avmBrowseBean;
private static final Log logger = LogFactory.getLog(ViewDeploymentReportDialog.class);
// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef();
if (logger.isDebugEnabled())
logger.debug("Initialising dialog to view deployment report for " +
this.avmBrowseBean.getStagingStore());
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "close");
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return outcome;
}
// ------------------------------------------------------------------------------
// Bean getters and setters
/**
* @return The NodeRef of the web project the deployment reports are being shown for
*/
public NodeRef getWebProjectRef()
{
return this.webProjectRef;
}
/**
* @param avmBrowseBean The AVM BrowseBean instance to use
*/
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
{
this.avmBrowseBean = avmBrowseBean;
}
}