Files
alfresco-community-repo/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java
Ariel Backenroth 15733b9771 putting jon's change from last night back in and fixing mostly everything (i know of) that it broke
- added utility methods to AVMConstants to extract information about stores from their names.  this has to be reimplemented to look at store properties rather than inferring things from their names - but it works for now.  this also centralizes all the usage of the store name to infer data about it so it'll make it easier later.
- made the problematic constants jon changed private to avoid having this problem happen again
- checked pretty much every usage of buildAVM<bla> to ensure that nothing else was broken.  in the process removed the AVM part from the buildAVM<bla> part of the method to shorten it and since it's redundant with the classname AVMConstants in which their contained.

creating workflow sandboxes in a manner consistent with user sandboxes
- added a method to SandboxFactory to create workflow sandboxes. they're created with the name <storeId>--workflow-<guid>
- centralized workflow package creation code in AVMWorkflowUtil.
- refactored sandbox creation code to use new utility methods in AVMConstants and so that at some point it can be further refactored.
 
getting avm actions to show up in manage task screen for avm workflows
- modified the model to use different packageItemActionGroups for wcm workflows
- modified the AVMWorkflowEvaluator to allow all actions for items in a workflow package
- added some debug output to various classes
- made wcm navigation ids exposed throughout the app since they are now called from workflow jsps.

things that now work that didn't before:
- virtualization now works again with jon's new naming scheme
- some actions from the manage task screen.

known bugs introduced or remaining as a consequence of this change (i'll filed jira issues for these as soon as i commit this):
- i'm inaccurately counting the number of users in a sandbox since it's harder now to differentiate between user main sandboxes and all the other ones that are being created
- preview does not work on assets within the workflow sandboxes
- review and approve workflow does not appear to actually submit once approved.  not sure if it did before
- lots of actions still do not work from manage tasks, though edit does appear to.
- i commented out the location column in the manage task screen since the path link was causing me troubles - need to put that back in.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4692 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2006-12-23 01:44:19 +00:00

223 lines
9.5 KiB
Java

/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.RenderingEngineTemplate;
/**
* Backing bean for the Edit Web Project wizard.
*
* @author Kevin Roast
*/
public class EditWebsiteWizard extends CreateWebsiteWizard
{
// ------------------------------------------------------------------------------
// Wizard implementation
/**
* Initialises the wizard
*/
public void init(Map<String, String> parameters)
{
super.init(parameters);
// the editMode flag is used to disabled some wizard fields
this.editMode = true;
NodeRef websiteRef = this.browseBean.getActionSpace().getNodeRef();
if (websiteRef == null)
{
throw new IllegalArgumentException("Edit Web Project wizard requires action node context.");
}
loadWebProjectModel(websiteRef);
}
/**
* Restore the forms, templates and workflows from the model for this web project
*
* @param nodeRef NodeRef to the web project
*/
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);
// load the form templates
List<ChildAssociationRef> webFormRefs = this.nodeService.getChildAssocs(
nodeRef, WCMAppModel.ASSOC_WEBFORM, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : webFormRefs)
{
NodeRef formRef = ref.getChildRef();
String name = (String)this.nodeService.getProperty(formRef, WCMAppModel.PROP_FORMNAME);
Form formImpl = FormsService.getInstance().getForm(name);
if (formImpl != null)
{
FormWrapper form = new FormWrapper(formImpl);
form.setTitle((String)this.nodeService.getProperty(formRef, ContentModel.PROP_TITLE));
form.setDescription((String)this.nodeService.getProperty(formRef, ContentModel.PROP_DESCRIPTION));
form.setFilenamePattern((String)this.nodeService.getProperty(formRef, WCMAppModel.PROP_FILENAMEPATTERN));
// the single workflow attached to the form
List<ChildAssociationRef> workflowRefs = this.nodeService.getChildAssocs(
formRef, WCMAppModel.ASSOC_WORKFLOWDEFAULTS, RegexQNamePattern.MATCH_ALL);
if (workflowRefs.size() == 1)
{
NodeRef wfRef = workflowRefs.get(0).getChildRef();
String wfName = (String)this.nodeService.getProperty(wfRef, WCMAppModel.PROP_WORKFLOW_NAME);
WorkflowDefinition wfDef = this.workflowService.getDefinitionByName(wfName);
if (wfDef != null)
{
WorkflowWrapper wfWrapper = new WorkflowWrapper(wfName, wfDef.getTitle(), wfDef.getDescription());
wfWrapper.setParams((Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams(wfRef));
if (wfDef.startTaskDefinition != null)
{
wfWrapper.setType(wfDef.startTaskDefinition.metadata.getName());
}
form.setWorkflow(wfWrapper);
}
}
// 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)
{
NodeRef templateRef = tChildRef.getChildRef();
NodeRef engineRef = (NodeRef)this.nodeService.getProperty(templateRef, WCMAppModel.PROP_ENGINE);
for (RenderingEngineTemplate ret : engineTemplates)
{
if (engineRef.equals(ret.getNodeRef()))
{
String filenamePattern = (String)this.nodeService.getProperty(templateRef,
WCMAppModel.PROP_FILENAMEPATTERN);
PresentationTemplate template = new PresentationTemplate(ret, filenamePattern);
form.addTemplate(template);
break;
}
}
}
this.forms.add(form);
}
}
// load the workflows associated with the website
List<ChildAssociationRef> workflowRefs = this.nodeService.getChildAssocs(
nodeRef, WCMAppModel.ASSOC_WEBWORKFLOWDEFAULTS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef wChildRef : workflowRefs)
{
NodeRef wfRef = wChildRef.getChildRef();
String wfName = (String)this.nodeService.getProperty(wfRef, WCMAppModel.PROP_WORKFLOW_NAME);
WorkflowDefinition wfDef = this.workflowService.getDefinitionByName(wfName);
if (wfDef != null)
{
WorkflowWrapper wfWrapper = new WorkflowWrapper(wfName, wfDef.getTitle(), wfDef.getDescription());
wfWrapper.setParams((Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams(wfRef));
wfWrapper.setFilenamePattern((String)this.nodeService.getProperty(
wfRef, WCMAppModel.PROP_FILENAMEPATTERN));
if (wfDef.startTaskDefinition != null)
{
wfWrapper.setType(wfDef.startTaskDefinition.metadata.getName());
}
this.workflows.add(wfWrapper);
}
}
}
/**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
*/
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
NodeRef nodeRef = this.browseBean.getActionSpace().getNodeRef();
// apply the name, title and description props
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);
// 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
clearWebProjectModel(nodeRef);
// change/create the root webapp name for the website
if (this.webapp != null && this.webapp.length() != 0)
{
String stagingStore = AVMConstants.buildStagingStoreName(this.dnsName);
String webappPath = AVMConstants.buildStoreWebappPath(stagingStore, this.webapp);
if (this.avmService.lookup(-1, webappPath) == null)
{
this.avmService.createDirectory(AVMConstants.buildSandboxRootPath(stagingStore), this.webapp);
}
this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_DEFAULTWEBAPP, this.webapp);
}
// TODO: allow change of dns name - via store rename functionality
// persist the forms, templates, workflows and workflow defaults to the model for this web project
saveWebProjectModel(nodeRef);
return AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME;
}
/**
* Cascade delete the existing Form and Workflow defs attached to the specified Web Project node
*
* @param nodeRef Web project node
*/
private void clearWebProjectModel(NodeRef nodeRef)
{
List<ChildAssociationRef> webFormRefs = nodeService.getChildAssocs(
nodeRef, WCMAppModel.ASSOC_WEBFORM, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : webFormRefs)
{
// cascade delete will take case of child-child relationships
this.nodeService.removeChild(nodeRef, ref.getChildRef());
}
List<ChildAssociationRef> wfRefs = nodeService.getChildAssocs(
nodeRef, WCMAppModel.ASSOC_WEBWORKFLOWDEFAULTS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : wfRefs)
{
this.nodeService.removeChild(nodeRef, ref.getChildRef());
}
}
}