- adding aspect to webapp nodes to differentiate them from ordinary folders in the avm_webapps directory

- refactoring of generate and regenerate calls to take a FormInstanceData object
- adding in support for overriding step title and description properties in wizards so as to be able to format them with parameters
- making the step descriptions in create form wizard reiterate the form name so as to give the user better context
- displaying avm task resources in the manage task screen.  still need to get actions working and clean this up a bit.
- making output path patterns sandbox relative
- refactored utility method for combining avm paths sensitive to webapp vs sandbox relative paths.
- adding a default description for generated renditions

todo:
- cleanup some usage of AVMNode from ManageTaskBean
- get actions to appear in manage task screen
- add a multi value property to the web project for all its webapps
- properly use overridden values for forms from the web project settings

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4687 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-12-21 20:34:00 +00:00
parent ef3b4f793c
commit 2190c4f29d
26 changed files with 544 additions and 267 deletions

View File

@@ -38,6 +38,32 @@ import org.springframework.web.jsf.FacesContextUtils;
*/
public final class AVMConstants
{
/////////////////////////////////////////////////////////////////////////////
public static enum PathRelation
{
SANDBOX_RELATIVE
{
@Override
protected Pattern pattern()
{
return AVMConstants.SANDBOX_RELATIVE_PATH_PATTERN;
}
},
WEBAPP_RELATIVE
{
@Override
protected Pattern pattern()
{
return AVMConstants.WEBAPP_RELATIVE_PATH_PATTERN;
}
};
protected abstract Pattern pattern();
}
/////////////////////////////////////////////////////////////////////////////
/**
* Private constructor
*/
@@ -208,7 +234,7 @@ public final class AVMConstants
Map<QName, PropertyValue> props = avmService.queryStorePropertyKey(store, QName.createQName(null, PROP_DNS + '%'));
if (props.size() == 1)
{
dns = props.entrySet().iterator().next().getKey().getLocalName().substring(PROP_DNS.length());
dns = props.keySet().iterator().next().getLocalName().substring(PROP_DNS.length());
}
return dns;
@@ -221,11 +247,13 @@ public final class AVMConstants
* is relative, otherwise used to extract the parent path portion up until
* the webapp directory.
* @param path a path relative to the parentAVMPath path, or if it is
* absolute, it is relative to the webapp used in the parentAVMPath.
* absolute, it is relative to the sandbox used in the parentAVMPath.
*
* @return an absolute path within the avm using the paths provided.
*/
public static String buildAbsoluteAVMPath(final String parentAVMPath, final String path)
public static String buildAVMPath(final String parentAVMPath,
final String path,
final PathRelation relation)
{
String parent = parentAVMPath;
if (path == null || path.length() == 0 ||
@@ -236,7 +264,7 @@ public final class AVMConstants
if (path.charAt(0) == '/')
{
final Matcher m = absoluteAVMPath.matcher(parent);
final Matcher m = relation.pattern().matcher(parent);
if (m.matches())
{
parent = m.group(1);
@@ -258,10 +286,63 @@ public final class AVMConstants
*/
public static String getWebappRelativePath(final String absoluteAVMPath)
{
final Matcher m = webappRelativePath.matcher(absoluteAVMPath);
return m.matches() && m.group(1).length() != 0 ? m.group(1) : "/";
final Matcher m = WEBAPP_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath);
return m.matches() && m.group(3).length() != 0 ? m.group(3) : "/";
}
/**
* Returns the webapp within the path
*
* @param absoluteAVMPath the path from which to extract the webapp name
*
* @return an the webapp name contained within the path or <tt>null</tt>.
*/
public static String getWebapp(final String absoluteAVMPath)
{
final Matcher m = WEBAPP_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath);
return m.matches() && m.group(2).length() != 0 ? m.group(2) : null;
}
/**
* Returns the path portion up the webap
*
* @param absoluteAVMPath the path from which to extract the webapp path
*
* @return an absolute avm path to the webapp contained within
* the path or <tt>null</tt>.
*/
public static String getWebappPath(final String absoluteAVMPath)
{
final Matcher m = WEBAPP_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath);
return m.matches() && m.group(1).length() != 0 ? m.group(1) : null;
}
/**
* Returns a path relative to the sandbox porition of the avm path.
*
* @param absoluteAVMPath an absolute path within the avm
* @return a relative path within the sandbox.
*/
public static String getSandboxRelativePath(final String absoluteAVMPath)
{
final Matcher m = SANDBOX_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath);
return m.matches() && m.group(2).length() != 0 ? m.group(2) : "/";
}
/**
* Returns the path portion up the sandbox
*
* @param absoluteAVMPath the path from which to extract the sandbox path
*
* @return an absolute avm path to the sandbox contained within
* the path or <tt>null</tt>.
*/
public static String getSandboxPath(final String absoluteAVMPath)
{
final Matcher m = SANDBOX_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath);
return m.matches() && m.group(1).length() != 0 ? m.group(1) : null;
}
/**
* @param path Path to match against
*
@@ -274,7 +355,7 @@ public final class AVMConstants
throw new IllegalArgumentException("Path value is mandatory.");
}
return webinfPathPattern.matcher(path).matches();
return WEB_INF_PATH_PATTERN.matcher(path).matches();
}
/**
@@ -351,14 +432,15 @@ public final class AVMConstants
private final static String PREVIEW_ASSET_URL = "http://www-{0}.{1}:{2}{3}";
// pattern for absolute AVM Path
private final static Pattern absoluteAVMPath = Pattern.compile(
"([^:]+:/" + AVMConstants.DIR_APPBASE + "/[^/]+/[^/]+).*");
private final static Pattern webappRelativePath = Pattern.compile(
"[^:]+:/" + AVMConstants.DIR_APPBASE +
"/" + AVMConstants.DIR_WEBAPPS + "/[^/]+(.*)");
private final static Pattern WEBAPP_RELATIVE_PATH_PATTERN =
Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE +
"/" + AVMConstants.DIR_WEBAPPS + "/([^/]+))(.*)");
private final static Pattern SANDBOX_RELATIVE_PATH_PATTERN =
Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE +
"/" + AVMConstants.DIR_WEBAPPS + ")(.*)");
// patterns for WEB-INF files that require virtualisation server reload
private final static Pattern webinfPathPattern = Pattern.compile(
private final static Pattern WEB_INF_PATH_PATTERN = Pattern.compile(
".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS +
"/.*/WEB-INF/((classes/.*)|(lib/.*)|(web.xml))",
Pattern.CASE_INSENSITIVE);

View File

@@ -45,6 +45,7 @@ import org.alfresco.web.bean.CheckinCheckoutBean;
import org.alfresco.web.bean.FileUploadBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.FormInstanceDataImpl;
import org.alfresco.web.forms.FormProcessor;
import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.Rendition;
@@ -409,8 +410,8 @@ public class AVMEditBean
// regenerate form content
if (nodeService.hasAspect(avmRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{
formsService.regenerateRenditions(avmRef);
NodeRef[] uploadedFiles = this.formProcessorSession.getUploadedFiles();
formsService.regenerateRenditions(new FormInstanceDataImpl(avmRef));
final NodeRef[] uploadedFiles = this.formProcessorSession.getUploadedFiles();
final List<AVMDifference> diffList = new ArrayList<AVMDifference>(uploadedFiles.length);
for (NodeRef uploadedFile : uploadedFiles)
{

View File

@@ -18,6 +18,7 @@ package org.alfresco.web.bean.wcm;
import java.io.File;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.*;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
@@ -366,19 +367,41 @@ public class CreateFormWizard
// wizard implementations don't have to worry about
// checking step numbers
boolean disabled = false;
final int step = Application.getWizardManager().getCurrentStep();
switch(step)
{
case 1:
{
disabled = (this.getSchemaFileName() == null ||
this.getSchemaFileName().length() == 0);
break;
}
case 1:
{
return (this.getSchemaFileName() == null ||
this.getSchemaFileName().length() == 0);
}
default:
{
return false;
}
}
}
@Override
public String getStepDescription()
{
final ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
final String stepName = Application.getWizardManager().getCurrentStepName();
if ("configure_rendering_engine_templates".equals(stepName))
{
return MessageFormat.format(bundle.getString("create_form_configure_rendering_engine_templates_desc"),
this.getFormName());
}
else if ("select_default_workflow".equals(stepName))
{
return MessageFormat.format(bundle.getString("create_form_select_default_workflow_desc"),
this.getFormName());
}
else
{
return super.getContainerDescription();
}
return disabled;
}
/**

View File

@@ -306,11 +306,16 @@ public class CreateWebContentWizard extends BaseContentWizard
// reset all paths and structures to the main store
this.createdPath = this.createdPath.replaceFirst(AVMConstants.STORE_PREVIEW,
AVMConstants.STORE_MAIN);
LOGGER.debug("reset path " + this.createdPath + " to main store");
boolean form = (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null);
if (form)
{
this.formInstanceData = new FormInstanceDataImpl(AVMNodeConverter.ToNodeRef(-1, this.createdPath));
this.renditions = this.formInstanceData.getRenditions();
LOGGER.debug("reset form instance data " + this.formInstanceData.getName() +
" and " + this.renditions.size() + " to main store");
}
if (this.startWorkflow)
{
@@ -378,6 +383,8 @@ public class CreateWebContentWizard extends BaseContentWizard
// create package paths (layered to user sandbox area as target)
String stagingPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getStagingStore());
String packagesPath = AVMWorkflowUtil.createAVMLayeredPackage(this.avmService, stagingPath);
LOGGER.debug("created layered package " + packagesPath +
" above " + stagingPath);
List<AVMDifference> diffs = new ArrayList<AVMDifference>(8);
// construct diffs for selected items for submission
@@ -484,7 +491,10 @@ public class CreateWebContentWizard extends BaseContentWizard
path = path.replaceFirst(AVMConstants.STORE_MAIN, AVMConstants.STORE_PREVIEW);
if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null)
{
path = this.getForm().getOutputPathForFormInstanceData(path, fileName, this.instanceDataDocument);
path = this.getForm().getOutputPathForFormInstanceData(this.instanceDataDocument,
fileName,
path,
this.avmBrowseBean.getWebapp());
this.content = FormsService.getInstance().writeXMLToString(this.instanceDataDocument);
final String[] sb = AVMNodeConverter.SplitBase(path);
path = sb[0];
@@ -505,7 +515,7 @@ public class CreateWebContentWizard extends BaseContentWizard
new ByteArrayInputStream((this.content == null ? "" : this.content).getBytes()));
// remember the created path
this.createdPath = path + '/' + fileName;
this.createdPath = AVMNodeConverter.ExtendAVMPath(path, fileName);
// add titled aspect for the read/edit properties screens
final NodeRef formInstanceDataNodeRef = AVMNodeConverter.ToNodeRef(-1, this.createdPath);
@@ -517,7 +527,7 @@ public class CreateWebContentWizard extends BaseContentWizard
{
this.formInstanceData = new FormInstanceDataImpl(formInstanceDataNodeRef);
this.getForm().registerFormInstanceData(formInstanceDataNodeRef);
this.renditions = FormsService.getInstance().generateRenditions(formInstanceDataNodeRef);
this.renditions = FormsService.getInstance().generateRenditions(this.formInstanceData);
}
else
{
@@ -706,7 +716,7 @@ public class CreateWebContentWizard extends BaseContentWizard
{
if (this.formProcessorSession == null)
{
return Collections.emptyList();
return Collections.EMPTY_LIST;
}
NodeRef[] uploadedFiles = this.formProcessorSession.getUploadedFiles();
@@ -727,6 +737,15 @@ public class CreateWebContentWizard extends BaseContentWizard
return result;
}
/**
* Returns the number of submittable files which is the total number of
* uploaded files, renditions, and the form instance data.
*/
public int getNumberOfSubmittableFiles()
{
return 1 + this.getUploadedFiles().size() + this.getRenditions().size();
}
public boolean getFormSelectDisabled()
{
return this.formSelectDisabled;

View File

@@ -20,8 +20,10 @@ import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.repo.domain.PropertyValue;
/**
* Bean implementation for the AVM "Create Webapp Folder" dialog.
@@ -39,15 +41,18 @@ public class CreateWebappDialog extends CreateFolderDialog
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
String parent = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getStagingStore());
final String parent = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getStagingStore());
this.avmService.createDirectory(parent, this.name);
String path = parent + '/' + this.name;
NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, path);
this.nodeService.addAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS, null);
final String path = AVMNodeConverter.ExtendAVMPath(parent, this.name);
this.avmService.addAspect(path, ApplicationModel.ASPECT_UIFACETS);
this.avmService.addAspect(path, WCMAppModel.ASPECT_WEBAPP);
if (this.description != null && this.description.length() != 0)
{
this.nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, this.description);
this.avmService.setNodeProperty(path,
ContentModel.PROP_DESCRIPTION,
new PropertyValue(DataTypeDefinition.TEXT,
this.description));
}
return outcome;

View File

@@ -33,6 +33,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -186,8 +187,12 @@ public class CreateWebsiteWizard extends BaseWizardBean
SandboxFactory.createStagingSandbox(avmStore, wiz.getManagers());
// create the default webapp folder under the hidden system folders
String stagingStore = AVMConstants.buildAVMStagingStoreName(avmStore);
this.avmService.createDirectory(AVMConstants.buildAVMStoreRootPath(stagingStore), webapp);
final String stagingStore = AVMConstants.buildAVMStagingStoreName(avmStore);
final String stagingStoreRoot = AVMConstants.buildAVMStoreRootPath(stagingStore);
this.avmService.createDirectory(stagingStoreRoot, webapp);
this.avmService.addAspect(AVMNodeConverter.ExtendAVMPath(stagingStoreRoot,
webapp),
WCMAppModel.ASPECT_WEBAPP);
// set the property on the node to reference the root AVM store
this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_AVMSTORE, avmStore);

View File

@@ -44,6 +44,16 @@ public abstract class BaseWizardBean extends BaseDialogBean implements IWizardBe
{
return Application.getMessage(FacesContext.getCurrentInstance(), "finish_button");
}
public String getStepTitle()
{
return null;
}
public String getStepDescription()
{
return null;
}
/**
* Build summary table from the specified list of Labels and Values

View File

@@ -43,4 +43,22 @@ public interface IWizardBean extends IDialogBean
* @return true if the button should be disabled
*/
public boolean getNextButtonDisabled();
/**
* Returns the title to be used for the current step
* <p>If this returns <tt>null</tt> the WizardManager will
* lookup the title via the dialog configuration</p>
*
* @return The title or <tt>null</tt> if the title is to be acquired via configuration
*/
public String getStepTitle();
/**
* Returns the description to be used for the current step
* <p>If this returns <tt>null</tt> the WizardManager will
* lookup the description via the dialog configuration</p>
*
* @return The decsription or <tt>null</tt> if the title is to be acquired via configuration
*/
public String getStepDescription();
}

View File

@@ -206,7 +206,6 @@ public final class WizardManager
{
// try and get the description directly from the dialog
String desc = this.currentWizardState.getWizard().getContainerDescription();
if (desc == null)
{
// try and get the description via a message bundle key
@@ -324,18 +323,15 @@ public final class WizardManager
*/
public String getStepTitle()
{
String title = this.currentWizardState.getCurrentPageCfg().getTitleId();
if (title != null)
String result = this.currentWizardState.getWizard().getStepTitle();
if (result == null)
{
title = Application.getMessage(FacesContext.getCurrentInstance(), title);
result = this.currentWizardState.getCurrentPageCfg().getTitleId();
result = (result != null
? Application.getMessage(FacesContext.getCurrentInstance(), result)
: this.currentWizardState.getCurrentPageCfg().getTitle());
}
else
{
title = this.currentWizardState.getCurrentPageCfg().getTitle();
}
return title;
return result;
}
/**
@@ -345,18 +341,15 @@ public final class WizardManager
*/
public String getStepDescription()
{
String desc = this.currentWizardState.getCurrentPageCfg().getDescriptionId();
if (desc != null)
String result = this.currentWizardState.getWizard().getStepDescription();
if (result == null)
{
desc = Application.getMessage(FacesContext.getCurrentInstance(), desc);
result = this.currentWizardState.getCurrentPageCfg().getDescriptionId();
result = (result != null
? Application.getMessage(FacesContext.getCurrentInstance(), result)
: this.currentWizardState.getCurrentPageCfg().getDescription());
}
else
{
desc = this.currentWizardState.getCurrentPageCfg().getDescription();
}
return desc;
return result;
}
/**
@@ -397,14 +390,8 @@ public final class WizardManager
*/
public boolean getNextButtonDisabled()
{
if (this.currentWizardState.getCurrentStep() == this.currentWizardState.getSteps().size())
{
return true;
}
else
{
return this.currentWizardState.getWizard().getNextButtonDisabled();
}
return (this.currentWizardState.getCurrentStep() == this.currentWizardState.getSteps().size() ||
this.currentWizardState.getWizard().getNextButtonDisabled());
}
/**
@@ -424,14 +411,7 @@ public final class WizardManager
*/
public boolean getBackButtonDisabled()
{
if (this.currentWizardState.getCurrentStep() == 1)
{
return true;
}
else
{
return false;
}
return this.currentWizardState.getCurrentStep() == 1;
}
/**
@@ -461,14 +441,8 @@ public final class WizardManager
*/
public boolean getFinishButtonDisabled()
{
if (this.currentWizardState.getCurrentStep() == this.currentWizardState.getSteps().size())
{
return false;
}
else
{
return this.currentWizardState.getWizard().getFinishButtonDisabled();
}
return (this.currentWizardState.getCurrentStep() != this.currentWizardState.getSteps().size() &&
this.currentWizardState.getWizard().getFinishButtonDisabled());
}
/**

View File

@@ -34,6 +34,8 @@ import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.NodePropertyResolver;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.TransientNode;
import org.alfresco.web.bean.wcm.AVMConstants;
import org.alfresco.web.bean.wcm.AVMNode;
import org.alfresco.web.config.DialogsConfigElement.DialogButtonConfig;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIActionLink;
@@ -41,6 +43,14 @@ import org.alfresco.web.ui.common.component.data.UIRichList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.alfresco.web.bean.wcm.AVMWorkflowUtil;
import org.alfresco.model.WCMModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
/**
* Bean implementation for the "Manage Task" dialog.
*
@@ -49,6 +59,8 @@ import org.apache.commons.logging.LogFactory;
public class ManageTaskDialog extends BaseDialogBean
{
protected WorkflowService workflowService;
protected AVMService avmService;
protected AVMSyncService avmSyncService;
protected Node taskNode;
protected WorkflowTask task;
protected WorkflowInstance workflowInstance;
@@ -62,7 +74,7 @@ public class ManageTaskDialog extends BaseDialogBean
protected String[] itemsToAdd;
protected boolean isItemBeingAdded = false;
protected final Log logger = LogFactory.getLog(getClass());
private final static Log LOGGER = LogFactory.getLog(ManageTaskDialog.class);
protected static final String ID_PREFIX = "transition_";
protected static final String CLIENT_ID_PREFIX = AlfrescoNavigationHandler.DIALOG_PREFIX + ID_PREFIX;
@@ -109,11 +121,11 @@ public class ManageTaskDialog extends BaseDialogBean
// setup the workflow package for the task
this.workflowPackage = (NodeRef)this.task.properties.get(WorkflowModel.ASSOC_PACKAGE);
if (logger.isDebugEnabled())
if (LOGGER.isDebugEnabled())
{
logger.debug("Task: " + this.task);
logger.debug("Trasient node: " + this.taskNode);
logger.debug("Workflow package: " + this.workflowPackage );
LOGGER.debug("Task: " + this.task);
LOGGER.debug("Trasient node: " + this.taskNode);
LOGGER.debug("Workflow package: " + this.workflowPackage );
}
}
}
@@ -133,14 +145,14 @@ public class ManageTaskDialog extends BaseDialogBean
protected String finishImpl(FacesContext context, String outcome)
throws Exception
{
if (logger.isDebugEnabled())
logger.debug("Saving task: " + this.task.id);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Saving task: " + this.task.id);
// prepare the edited parameters for saving
Map<QName, Serializable> params = WorkflowUtil.prepareTaskParams(this.taskNode);
if (logger.isDebugEnabled())
logger.debug("Saving task with parameters: " + params);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Saving task with parameters: " + params);
// remove any items the user selected to remove
if (this.workflowPackage != null && this.packageItemsToRemove != null &&
@@ -232,8 +244,8 @@ public class ManageTaskDialog extends BaseDialogBean
{
String outcome = getDefaultFinishOutcome();
if (logger.isDebugEnabled())
logger.debug("Transitioning task: " + this.task.id);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Transitioning task: " + this.task.id);
// to find out which transition button was pressed we need
// to look for the button's id in the request parameters,
@@ -263,8 +275,8 @@ public class ManageTaskDialog extends BaseDialogBean
// prepare the edited parameters for saving
Map<QName, Serializable> params = WorkflowUtil.prepareTaskParams(this.taskNode);
if (logger.isDebugEnabled())
logger.debug("Transitioning task with parameters: " + params);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Transitioning task with parameters: " + params);
// update the task with the updated parameters
this.workflowService.updateTask(this.task.id, params, null, null);
@@ -275,8 +287,8 @@ public class ManageTaskDialog extends BaseDialogBean
// commit the changes
tx.commit();
if (logger.isDebugEnabled())
logger.debug("Ended task with transition: " + selectedTransition);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Ended task with transition: " + selectedTransition);
}
catch (Throwable e)
{
@@ -333,15 +345,15 @@ public class ManageTaskDialog extends BaseDialogBean
{
this.packageItemsToRemove.remove(item);
if (logger.isDebugEnabled())
logger.debug("Removed item from the removed list: " + item);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Removed item from the removed list: " + item);
}
else
{
this.packageItemsToAdd.add(item);
if (logger.isDebugEnabled())
logger.debug("Added item to the added list: " + item);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Added item to the added list: " + item);
}
}
@@ -369,8 +381,8 @@ public class ManageTaskDialog extends BaseDialogBean
// remove the item from the added list if it was added in this dialog session
this.packageItemsToAdd.remove(nodeRef);
if (logger.isDebugEnabled())
logger.debug("Removed item from the added list: " + nodeRef);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Removed item from the added list: " + nodeRef);
}
else
{
@@ -382,8 +394,8 @@ public class ManageTaskDialog extends BaseDialogBean
this.packageItemsToRemove.add(nodeRef);
if (logger.isDebugEnabled())
logger.debug("Added item to the removed list: " + nodeRef);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Added item to the removed list: " + nodeRef);
}
// reset the rich list so it re-renders
@@ -523,54 +535,82 @@ public class ManageTaskDialog extends BaseDialogBean
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context, true);
tx.begin();
// get existing workflow package items
List<ChildAssociationRef> childRefs = this.nodeService.getChildAssocs(
if ((Boolean)this.nodeService.getProperty(this.workflowPackage,
WorkflowModel.PROP_IS_SYSTEM_PACKAGE))
{
final NodeRef stagingNodeRef = (NodeRef)
this.nodeService.getProperty(this.workflowPackage,
WCMModel.PROP_AVM_DIR_INDIRECTION);
final String fromAvmPath = (String)this.task.properties.get(AVMWorkflowUtil.PROP_FROM_PATH);
final String stagingAvmPath = AVMNodeConverter.ToAVMVersionPath(stagingNodeRef).getSecond();
final String packageAvmPath = AVMNodeConverter.ToAVMVersionPath(this.workflowPackage).getSecond();
LOGGER.debug("comparing " + packageAvmPath +
" with " + stagingAvmPath);
for (AVMDifference d : this.avmSyncService.compare(-1, packageAvmPath,
-1, stagingAvmPath,
null))
{
LOGGER.debug("got difference " + d);
if (d.getDifferenceCode() == AVMDifference.NEWER ||
d.getDifferenceCode() == AVMDifference.CONFLICT)
{
this.addAVMNode(new AVMNode(this.avmService.lookup(d.getSourceVersion(),
d.getSourcePath(),
true)));
}
}
}
else
{
// get existing workflow package items
List<ChildAssociationRef> childRefs = this.nodeService.getChildAssocs(
this.workflowPackage, ContentModel.ASSOC_CONTAINS,
RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref: childRefs)
{
// create our Node representation from the NodeRef
NodeRef nodeRef = ref.getChildRef();
if (this.nodeService.exists(nodeRef))
for (ChildAssociationRef ref: childRefs)
{
// find it's type so we can see if it's a node we are interested in
QName type = this.nodeService.getType(nodeRef);
// make sure the type is defined in the data dictionary
TypeDefinition typeDef = this.dictionaryService.getType(type);
if (typeDef != null)
// create our Node representation from the NodeRef
NodeRef nodeRef = ref.getChildRef();
if (!this.nodeService.exists(nodeRef))
{
// look for content nodes or links to content
// NOTE: folders within workflow packages are ignored for now
if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) ||
ApplicationModel.TYPE_FILELINK.equals(type))
{
// if the node is not in the removed list then add create the
// client side representation and add to the list
if (this.packageItemsToRemove == null ||
this.packageItemsToRemove.contains(nodeRef.toString()) == false)
{
createAndAddNode(nodeRef);
}
}
if (LOGGER.isDebugEnabled())
LOGGER.debug("Ignoring " + nodeRef + " as it has been removed from the repository");
}
else
{
if (logger.isWarnEnabled())
logger.warn("Found invalid object in database: id = " + nodeRef + ", type = " + type);
// find it's type so we can see if it's a node we are interested in
QName type = this.nodeService.getType(nodeRef);
// make sure the type is defined in the data dictionary
TypeDefinition typeDef = this.dictionaryService.getType(type);
if (typeDef == null)
{
if (LOGGER.isWarnEnabled())
LOGGER.warn("Found invalid object in database: id = " + nodeRef +
", type = " + type);
}
else
{
// look for content nodes or links to content
// NOTE: folders within workflow packages are ignored for now
if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) ||
ApplicationModel.TYPE_FILELINK.equals(type))
{
// if the node is not in the removed list then add create the
// client side representation and add to the list
if (this.packageItemsToRemove == null ||
this.packageItemsToRemove.contains(nodeRef.toString()) == false)
{
createAndAddNode(nodeRef);
}
}
}
}
}
else
{
if (logger.isDebugEnabled())
logger.debug("Ignoring " + nodeRef + " as it has been removed from the repository");
}
}
// now iterate through the items to add list and add them to the list of resources
if (this.packageItemsToAdd != null)
{
@@ -585,8 +625,8 @@ public class ManageTaskDialog extends BaseDialogBean
}
else
{
if (logger.isDebugEnabled())
logger.debug("Ignoring " + nodeRef + " as it has been removed from the repository");
if (LOGGER.isDebugEnabled())
LOGGER.debug("Ignoring " + nodeRef + " as it has been removed from the repository");
}
}
}
@@ -602,9 +642,9 @@ public class ManageTaskDialog extends BaseDialogBean
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
else if (logger.isDebugEnabled())
else if (LOGGER.isDebugEnabled())
{
logger.debug("Failed to find workflow package for task: " + this.task.id);
LOGGER.debug("Failed to find workflow package for task: " + this.task.id);
}
return this.resources;
@@ -621,8 +661,65 @@ public class ManageTaskDialog extends BaseDialogBean
this.workflowService = workflowService;
}
/**
* Sets the avm service to use
*
* @param avmService
* AvmService instance
*/
public void setAvmService(final AVMService avmService)
{
this.avmService = avmService;
}
/**
* Sets the avm sync service to use
*
* @param avmSyncService
* AvmSycService instance
*/
public void setAvmSyncService(final AVMSyncService avmSyncService)
{
this.avmSyncService = avmSyncService;
}
// ------------------------------------------------------------------------------
// Helper methods
protected void addAVMNode(AVMNode node)
{
LOGGER.debug("adding node " + node);
node.getProperties().put("taskId", this.task.id);
this.browseBean.setupCommonBindingProperties(node);
final String packagePath = AVMNodeConverter.ToAVMVersionPath(this.workflowPackage).getSecond();
NodePropertyResolver resolverPath = new NodePropertyResolver()
{
public Object get(Node node)
{
Path result = new Path();
String s = node.getPath();
s = s.substring(packagePath.length());
for (final String s2 : s.split("/"))
{
if (s2.length() != 0)
{
result.append(new Path.Element()
{
public String getElementString() { return s2; }
});
}
}
return result;
}
};
node.remove("path");
node.addPropertyResolver("path", resolverPath);
node.addPropertyResolver("displayPath", resolverPath);
LOGGER.debug("created mapnode " + node);
this.resources.add(node);
}
protected void createAndAddNode(NodeRef nodeRef)
{