location = null;
@@ -158,7 +158,6 @@ public class AVMBrowseBean implements IContextListener
/** Action service bean reference */
protected ActionService actionService;
-
/**
* Default Constructor
*/
@@ -236,7 +235,7 @@ public class AVMBrowseBean implements IContextListener
final ResourceBundle msg = Application.getBundle(fc);
final String stagingStore = this.getStagingStore();
final AVMStoreDescriptor store = this.avmService.getStore(stagingStore);
- final String storeId = (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE);
+ final String storeId = (String)this.getWebProject().getStoreId();
if (store != null)
{
summary.append(msg.getString(MSG_CREATED_ON)).append(": ")
@@ -245,9 +244,7 @@ public class AVMBrowseBean implements IContextListener
summary.append(msg.getString(MSG_CREATED_BY)).append(": ")
.append(store.getCreator())
.append("");
- final int numUsers = this.getRelatedStoreNames(storeId,
- AVMConstants.PROP_SANDBOX_AUTHOR_MAIN).size();
-
+ final int numUsers = this.getRelatedStoreNames(storeId, AVMConstants.PROP_SANDBOX_AUTHOR_MAIN).size();
summary.append(MessageFormat.format(msg.getString(MSG_WORKING_USERS), numUsers));
}
@@ -288,8 +285,7 @@ public class AVMBrowseBean implements IContextListener
*/
public String getStagingStore()
{
- String storeRoot = (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE);
- return AVMConstants.buildStagingStoreName(storeRoot);
+ return this.getWebProject().getStagingStore();
}
/**
@@ -395,7 +391,7 @@ public class AVMBrowseBean implements IContextListener
{
if (this.webapp == null)
{
- this.webapp = (String)getWebsite().getProperties().get(WCMAppModel.PROP_DEFAULTWEBAPP);
+ this.webapp = this.getWebProject().getDefaultWebapp();
}
return this.webapp;
}
@@ -481,14 +477,27 @@ public class AVMBrowseBean implements IContextListener
public Node getWebsite()
{
// check to see if the website we are browsing has changed since the last time
- if (this.navigator.getCurrentNodeId().equals(this.lastWebsiteId) == false)
+ if (!this.navigator.getCurrentNodeId().equals(this.lastWebsiteId))
{
// clear context when we are browsing a new website
this.lastWebsiteId = this.navigator.getCurrentNodeId();
this.webapp = null;
+ this.webProject = null;
}
return this.navigator.getCurrentNode();
}
+
+ /**
+ * @return the web project the view is currently within
+ */
+ public WebProject getWebProject()
+ {
+ if (this.webProject == null)
+ {
+ this.webProject = new WebProject(this.getWebsite().getNodeRef());
+ }
+ return this.webProject;
+ }
/**
* @return Returns the current AVM node action context.
@@ -584,32 +593,8 @@ public class AVMBrowseBean implements IContextListener
*/
public boolean getIsManagerRole()
{
- boolean isManager = false;
-
- User user = Application.getCurrentUser(FacesContext.getCurrentInstance());
- if (user.isAdmin() == false)
- {
- String currentUser = user.getUserName();
- List userInfoRefs = this.nodeService.getChildAssocs(
- getWebsite().getNodeRef(), WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
- for (ChildAssociationRef ref : userInfoRefs)
- {
- NodeRef userInfoRef = ref.getChildRef();
- String username = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
- String userrole = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
- if (currentUser.equals(username) && ROLE_CONTENT_MANAGER.equals(userrole))
- {
- isManager = true;
- break;
- }
- }
- }
- else
- {
- isManager = true;
- }
-
- return isManager;
+ final User user = Application.getCurrentUser(FacesContext.getCurrentInstance());
+ return this.getWebProject().isManager(user);
}
/**
@@ -773,8 +758,7 @@ public class AVMBrowseBean implements IContextListener
else
{
// get the staging store from the current website node
- setSandbox(AVMConstants.buildStagingStoreName(
- (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE)));
+ setSandbox(this.getStagingStore());
}
// update UI state ready for return to the previous screen
@@ -943,8 +927,6 @@ public class AVMBrowseBean implements IContextListener
public void createFormContent(ActionEvent event)
{
UIActionLink link = (UIActionLink)event.getComponent();
- Map params = link.getParameterMap();
- String id = params.get(UIUserSandboxes.PARAM_FORM_ID);
// setup the correct sandbox for the create action
setupSandboxAction(event);
diff --git a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java
index f407840a9c..59bab2f60b 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java
@@ -18,6 +18,7 @@ package org.alfresco.web.bean.wcm;
import java.text.MessageFormat;
import java.util.Map;
+import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -25,7 +26,9 @@ import javax.faces.context.FacesContext;
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.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.ServiceRegistry;
@@ -37,6 +40,7 @@ import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.jsf.FacesContextUtils;
/**
+ * @author Ariel Backenroth
* @author Kevin Roast
*/
public final class AVMConstants
@@ -368,9 +372,9 @@ 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))
{
@@ -516,6 +520,44 @@ public final class AVMConstants
return m.matches() && m.group(1).length() != 0 ? m.group(1) : null;
}
+ /**
+ * Creates all directories for a path if they do not already exist.
+ */
+ public static void makeAllDirectories(final String avmDirectoryPath)
+ {
+ final ServiceRegistry serviceRegistry =
+ Repository.getServiceRegistry(FacesContext.getCurrentInstance());
+ final AVMService avmService = serviceRegistry.getAVMService();
+ // LOGGER.debug("mkdir -p " + avmDirectoryPath);
+ String s = avmDirectoryPath;
+ final Stack dirNames = new Stack();
+ while (s != null)
+ {
+ try
+ {
+ if (avmService.lookup(-1, s) != null)
+ {
+ // LOGGER.debug("path " + s + " exists");
+ break;
+ }
+ }
+ catch (AVMNotFoundException avmfe)
+ {
+ }
+ final String[] sb = AVMNodeConverter.SplitBase(s);
+ s = sb[0];
+ // LOGGER.debug("pushing " + sb[1]);
+ dirNames.push(sb);
+ }
+
+ while (!dirNames.isEmpty())
+ {
+ final String[] sb = dirNames.pop();
+ // LOGGER.debug("creating " + sb[1] + " in " + sb[0]);
+ avmService.createDirectory(sb[0], sb[1]);
+ }
+ }
+
/**
* @param path Path to match against
*
@@ -628,18 +670,16 @@ public final class AVMConstants
private final static Pattern STORE_RELATIVE_PATH_PATTERN =
Pattern.compile("[^:]+:(.+)");
private final static Pattern WEBAPP_RELATIVE_PATH_PATTERN =
- Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW +
- "/" + JNDIConstants.DIR_DEFAULT_APPBASE + "/([^/]+))(.*)");
+ Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW +
+ "/" + JNDIConstants.DIR_DEFAULT_APPBASE + "/([^/]+))(.*)");
private final static Pattern SANDBOX_RELATIVE_PATH_PATTERN =
- Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW +
- "/" + JNDIConstants.DIR_DEFAULT_APPBASE + ")(.*)");
+ Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW +
+ "/" + JNDIConstants.DIR_DEFAULT_APPBASE + ")(.*)");
// patterns for WEB-INF files that require virtualisation server reload
private final static Pattern WEB_INF_PATH_PATTERN =
- Pattern.compile( ".*:/" +
- JNDIConstants.DIR_DEFAULT_WWW + "/" +
- JNDIConstants.DIR_DEFAULT_APPBASE + "/" +
- ".*/WEB-INF/((classes/.*)|(lib/.*)|(web.xml))",
- Pattern.CASE_INSENSITIVE
- );
+ Pattern.compile(".*:/" + JNDIConstants.DIR_DEFAULT_WWW +
+ "/" + JNDIConstants.DIR_DEFAULT_APPBASE + "/" +
+ ".*/WEB-INF/((classes/.*)|(lib/.*)|(web.xml))",
+ Pattern.CASE_INSENSITIVE);
}
diff --git a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java
index a2d0fdb672..8b5e62e9d2 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java
@@ -45,11 +45,12 @@ 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.FormInstanceData;
import org.alfresco.web.forms.FormInstanceDataImpl;
import org.alfresco.web.forms.FormProcessor;
-import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.Rendition;
import org.alfresco.web.forms.RenditionImpl;
+import org.alfresco.web.forms.XMLUtil;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -232,11 +233,10 @@ public class AVMEditBean
*/
public Form getForm()
{
- final NodeRef ttNodeRef = (NodeRef)
+ final String formName = (String)
this.nodeService.getProperty(this.getAvmNode().getNodeRef(),
- WCMAppModel.PROP_PARENT_FORM);
- final FormsService ts = FormsService.getInstance();
- return ts.getForm(ttNodeRef);
+ WCMAppModel.PROP_PARENT_FORM_NAME);
+ return this.avmBrowseBean.getWebProject().getForm(formName);
}
/**
@@ -247,18 +247,17 @@ public class AVMEditBean
{
if (this.instanceDataDocument == null)
{
- final FormsService fs = FormsService.getInstance();
final String content = this.getEditorOutput();
try
{
this.instanceDataDocument = (content != null
- ? fs.parseXML(content)
- : fs.newDocument());
+ ? XMLUtil.parse(content)
+ : XMLUtil.newDocument());
}
catch (Exception e)
{
Utils.addErrorMessage("error parsing document", e);
- return fs.newDocument();
+ return XMLUtil.newDocument();
}
}
return this.instanceDataDocument;
@@ -292,21 +291,19 @@ public class AVMEditBean
this.avmBrowseBean.setupContentAction(event);
// retrieve the content reader for this node
- NodeRef avmRef = AVMNodeConverter.ToNodeRef(-1, getAvmNode().getPath());
- if (this.nodeService.hasAspect(avmRef, WCMAppModel.ASPECT_RENDITION))
+ String avmPath = getAvmNode().getPath();
+ if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_RENDITION))
{
if (LOGGER.isDebugEnabled())
- LOGGER.debug(avmRef + " is a rendition, editing primary rendition instead");
- avmRef = new RenditionImpl(avmRef).getPrimaryFormInstanceData().getNodeRef();
+ LOGGER.debug(avmPath + " is a rendition, editing primary rendition instead");
+ avmPath = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, avmPath)).getPrimaryFormInstanceData().getPath();
- final Pair p = AVMNodeConverter.ToAVMVersionPath(avmRef);
if (LOGGER.isDebugEnabled())
- LOGGER.debug("Editing primary form instance data " + p.getSecond() + " version " + p.getFirst());
- final AVMNode avmNode = new AVMNode(this.avmService.lookup(p.getFirst(), p.getSecond()));
- this.avmBrowseBean.setAvmActionNode(avmNode);
+ LOGGER.debug("Editing primary form instance data " + avmPath);
+ this.avmBrowseBean.setAvmActionNode(new AVMNode(this.avmService.lookup(-1, avmPath)));
}
- if (this.nodeService.hasAspect(avmRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
+ if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{
// reset the preview layer
String storeName = AVMConstants.getStoreName(this.avmBrowseBean.getCurrentPath());
@@ -318,8 +315,8 @@ public class AVMEditBean
}
if (LOGGER.isDebugEnabled())
- LOGGER.debug("Editing AVM node: " + avmRef.toString());
- ContentReader reader = contentService.getReader(avmRef, ContentModel.PROP_CONTENT);
+ LOGGER.debug("Editing AVM node: " + avmPath);
+ ContentReader reader = this.avmService.getContentReader(-1, avmPath);
if (reader != null)
{
String mimetype = reader.getMimetype();
@@ -335,7 +332,7 @@ public class AVMEditBean
// navigate to appropriate screen
outcome = ((MimetypeMap.MIMETYPE_XML.equals(mimetype) &&
- this.nodeService.hasAspect(avmRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
+ this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
? "dialog:editAvmXmlInline"
: "dialog:editAvmTextInline");
}
@@ -389,18 +386,18 @@ public class AVMEditBean
return null;
}
- final FormsService formsService = FormsService.getInstance();
- final NodeRef avmRef = AVMNodeConverter.ToNodeRef(-1, avmNode.getPath());
+ final String avmPath = avmNode.getPath();
+ LOGGER.debug("saving " + avmPath);
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
tx.begin();
// get an updating writer that we can use to modify the content on the current node
- ContentWriter writer = this.contentService.getWriter(avmRef, ContentModel.PROP_CONTENT, true);
- if (nodeService.hasAspect(avmRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
+ final ContentWriter writer = this.avmService.getContentWriter(avmPath);
+ if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{
- this.editorOutput = formsService.writeXMLToString(this.instanceDataDocument);
+ this.editorOutput = XMLUtil.toString(this.instanceDataDocument);
}
writer.putContent(this.editorOutput);
@@ -408,10 +405,27 @@ public class AVMEditBean
tx.commit();
// regenerate form content
- if (nodeService.hasAspect(avmRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
+ if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{
- formsService.regenerateRenditions(new FormInstanceDataImpl(avmRef));
+ final FormInstanceData fid = new FormInstanceDataImpl(AVMNodeConverter.ToNodeRef(-1, avmPath))
+ {
+ @Override
+ public Form getForm() { return AVMEditBean.this.getForm(); }
+ };
+ LOGGER.debug("regenerating renditions of " + fid);
+ for (Rendition rendition : fid.getRenditions())
+ {
+ try
+ {
+ rendition.regenerate(fid);
+ }
+ catch (Throwable t)
+ {
+ LOGGER.error(t, t);
+ }
+ }
final NodeRef[] uploadedFiles = this.formProcessorSession.getUploadedFiles();
+ LOGGER.debug("updating " + uploadedFiles.length + " uploaded files");
final List diffList = new ArrayList(uploadedFiles.length);
for (NodeRef uploadedFile : uploadedFiles)
{
diff --git a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java
index 02b5623df5..778e5afe04 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java
@@ -112,7 +112,9 @@ public class AVMWorkflowUtil extends WorkflowUtil
oos.close();
// write the serialized Map as a binary content stream - like database blob!
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
- ContentWriter writer = cs.getWriter(workflowRef, WCMAppModel.PROP_WORKFLOWDEFAULTS, true);
+ ContentWriter writer = cs.getWriter(workflowRef,
+ WCMAppModel.PROP_WORKFLOW_DEFAULT_PROPERTIES,
+ true);
writer.setMimetype(MimetypeMap.MIMETYPE_BINARY);
writer.putContent(new ByteArrayInputStream(baos.toByteArray()));
}
@@ -136,7 +138,7 @@ public class AVMWorkflowUtil extends WorkflowUtil
// restore the serialized Map from a binary content stream - like database blob!
Serializable params = null;
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
- ContentReader reader = cs.getReader(workflowRef, WCMAppModel.PROP_WORKFLOWDEFAULTS);
+ ContentReader reader = cs.getReader(workflowRef, WCMAppModel.PROP_WORKFLOW_DEFAULT_PROPERTIES);
if (reader != null)
{
ObjectInputStream ois = new ObjectInputStream(reader.getContentInputStream());
diff --git a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java
index 0cdf8fb99c..e84a17e7a6 100644
--- a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java
+++ b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java
@@ -52,6 +52,7 @@ import org.alfresco.web.ui.wcm.WebResources;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xerces.xs.*;
+import org.apache.commons.io.FilenameUtils;
import org.w3c.dom.Document;
/**
@@ -65,8 +66,6 @@ public class CreateFormWizard
/////////////////////////////////////////////////////////////////////////////
- private static final String NO_DEFAULT_WORKFLOW_SELECTED = "no_default_workflow_selected";
-
/**
* Simple wrapper class to represent a form data renderer
*/
@@ -76,6 +75,7 @@ public class CreateFormWizard
private final String fileName;
private final NodeRef nodeRef;
private final File file;
+ private final String name;
private final String title;
private final String description;
private final String mimetypeForRendition;
@@ -85,8 +85,9 @@ public class CreateFormWizard
public RenderingEngineTemplateData(final RenderingEngineTemplate ret)
{
this.file = null;
- this.nodeRef = ret.getNodeRef();
+ this.nodeRef = ((RenderingEngineTemplateImpl)ret).getNodeRef();
this.fileName = ret.getName();
+ this.name = ret.getName();
this.title = ret.getTitle();
this.description = ret.getDescription();
this.outputPathPatternForRendition = ret.getOutputPathPattern();
@@ -96,6 +97,7 @@ public class CreateFormWizard
public RenderingEngineTemplateData(final String fileName,
final File file,
+ final String name,
final String title,
final String description,
final String outputPathPatternForRendition,
@@ -105,6 +107,7 @@ public class CreateFormWizard
this.nodeRef = null;
this.fileName = fileName;
this.file = file;
+ this.name = name;
this.title = title;
this.description = description;
this.outputPathPatternForRendition = outputPathPatternForRendition;
@@ -137,6 +140,11 @@ public class CreateFormWizard
return this.nodeRef;
}
+ public String getName()
+ {
+ return this.name;
+ }
+
public String getTitle()
{
return this.title;
@@ -176,6 +184,7 @@ public class CreateFormWizard
private final static Log LOGGER = LogFactory.getLog(CreateFormWizard.class);
protected String defaultWorkflowName = null;
+ protected boolean applyDefaultWorkflow = true;
protected List renderingEngineTemplates = null;
protected transient XSModel schema;
protected String schemaFileName;
@@ -188,6 +197,7 @@ public class CreateFormWizard
private String formTitle = null;
private String formDescription = null;
private String outputPathPatternForFormInstanceData = null;
+ private String renderingEngineTemplateName = null;
private String renderingEngineTemplateTitle = null;
private String renderingEngineTemplateDescription = null;
@@ -198,6 +208,7 @@ public class CreateFormWizard
private String mimetypeForRendition = null;
private transient List mimetypeChoices = null;
private transient List schemaRootElementNameChoices = null;
+ private transient List defaultWorkflowChoices = null;
// ------------------------------------------------------------------------------
// Wizard implementation
@@ -211,9 +222,8 @@ public class CreateFormWizard
LOGGER.debug("creating form " + this.getFormName());
}
- final FormsService ts = FormsService.getInstance();
// get the node ref of the node that will contain the content
- final NodeRef contentFormsNodeRef = ts.getContentFormsNodeRef();
+ final NodeRef contentFormsNodeRef = FormsService.getInstance().getContentFormsNodeRef();
final FileInfo folderInfo =
this.fileFolderService.create(contentFormsNodeRef,
@@ -224,32 +234,41 @@ public class CreateFormWizard
this.getSchemaFileName(),
ContentModel.TYPE_CONTENT);
// get a writer for the content and put the file
- ContentWriter writer = this.contentService.getWriter(fileInfo.getNodeRef(),
- ContentModel.PROP_CONTENT,
- true);
+ final ContentWriter writer = this.contentService.getWriter(fileInfo.getNodeRef(),
+ ContentModel.PROP_CONTENT,
+ true);
// set the mimetype and encoding
writer.setMimetype(MimetypeMap.MIMETYPE_XML);
writer.setEncoding("UTF-8");
writer.putContent(this.getSchemaFile());
// apply the titled aspect - title and description
- Map props = new HashMap(2, 1.0f);
+ final Map props = new HashMap(2, 1.0f);
props.put(ContentModel.PROP_TITLE, this.getFormTitle());
props.put(ContentModel.PROP_DESCRIPTION, this.getFormDescription());
this.nodeService.addAspect(folderInfo.getNodeRef(), ContentModel.ASPECT_TITLED, props);
- props = new HashMap(3, 1.0f);
+ props.clear();
props.put(WCMAppModel.PROP_XML_SCHEMA, fileInfo.getNodeRef());
props.put(WCMAppModel.PROP_XML_SCHEMA_ROOT_ELEMENT_NAME,
this.getSchemaRootElementName());
- props.put(WCMAppModel.PROP_OUTPUT_PATH_PATTERN_FORM_INSTANCE_DATA,
- this.getOutputPathPatternForFormInstanceData());
- if (this.defaultWorkflowName != null)
- {
- props.put(WCMAppModel.PROP_DEFAULT_WORKFLOW_NAME, this.defaultWorkflowName);
- }
this.nodeService.addAspect(folderInfo.getNodeRef(), WCMAppModel.ASPECT_FORM, props);
-
+ if (this.applyDefaultWorkflow)
+ {
+ props.clear();
+ props.put(WCMAppModel.PROP_WORKFLOW_NAME, this.getDefaultWorkflowName());
+ this.nodeService.createNode(folderInfo.getNodeRef(),
+ WCMAppModel.ASSOC_FORM_WORKFLOW_DEFAULTS,
+ WCMAppModel.ASSOC_FORM_WORKFLOW_DEFAULTS,
+ WCMAppModel.TYPE_WORKFLOW_DEFAULTS,
+ props);
+ }
+
+ props.clear();
+ props.put(WCMAppModel.PROP_OUTPUT_PATH_PATTERN,
+ this.getOutputPathPatternForFormInstanceData());
+ this.nodeService.addAspect(folderInfo.getNodeRef(),
+ WCMAppModel.ASPECT_OUTPUT_PATH_PATTERN, props);
for (RenderingEngineTemplateData retd : this.renderingEngineTemplates)
{
this.saveRenderingEngineTemplate(retd, folderInfo.getNodeRef());
@@ -265,17 +284,17 @@ public class CreateFormWizard
" to form " + this.getFormName());
NodeRef renderingEngineTemplateNodeRef =
- this.fileFolderService.searchSimple(formNodeRef, retd.getFileName());
- HashMap props;
+ this.fileFolderService.searchSimple(formNodeRef, retd.getName());
+ final HashMap props = new HashMap();
if (renderingEngineTemplateNodeRef == null)
{
try
{
final FileInfo fileInfo = this.fileFolderService.create(formNodeRef,
- retd.getFileName(),
+ retd.getName(),
ContentModel.TYPE_CONTENT);
if (LOGGER.isDebugEnabled())
- LOGGER.debug("Created file node for file: " + retd.getFileName());
+ LOGGER.debug("Created file node for file: " + retd.getName());
renderingEngineTemplateNodeRef = fileInfo.getNodeRef();
}
catch (final FileExistsException fee)
@@ -298,7 +317,7 @@ public class CreateFormWizard
this.nodeService.createAssociation(formNodeRef,
renderingEngineTemplateNodeRef,
WCMAppModel.ASSOC_RENDERING_ENGINE_TEMPLATES);
- props = new HashMap(2, 1.0f);
+ props.clear();
props.put(WCMAppModel.PROP_PARENT_RENDERING_ENGINE_NAME,
retd.getRenderingEngine().getName());
props.put(WCMAppModel.PROP_FORM_SOURCE, formNodeRef);
@@ -307,7 +326,7 @@ public class CreateFormWizard
props);
// apply the titled aspect - title and description
- props = new HashMap(2, 1.0f);
+ props.clear();
props.put(ContentModel.PROP_TITLE, retd.getTitle());
props.put(ContentModel.PROP_DESCRIPTION, retd.getDescription());
this.nodeService.addAspect(renderingEngineTemplateNodeRef,
@@ -316,16 +335,19 @@ public class CreateFormWizard
}
LOGGER.debug("adding rendition properties to " + renderingEngineTemplateNodeRef);
- props = new HashMap(2, 1.0f);
- props.put(WCMAppModel.PROP_OUTPUT_PATH_PATTERN_RENDITION,
- retd.getOutputPathPatternForRendition());
+ props.clear();
props.put(WCMAppModel.PROP_MIMETYPE_FOR_RENDITION,
retd.getMimetypeForRendition());
- this.nodeService.createNode(renderingEngineTemplateNodeRef,
- WCMAppModel.ASSOC_RENDITION_PROPERTIES,
- WCMAppModel.ASSOC_RENDITION_PROPERTIES,
- WCMAppModel.TYPE_RENDITION_PROPERTIES,
- props);
+
+ final NodeRef rpNodeRef = this.nodeService.createNode(renderingEngineTemplateNodeRef,
+ WCMAppModel.ASSOC_RENDITION_PROPERTIES,
+ WCMAppModel.ASSOC_RENDITION_PROPERTIES,
+ WCMAppModel.TYPE_RENDITION_PROPERTIES,
+ props).getChildRef();
+ props.clear();
+ props.put(WCMAppModel.PROP_OUTPUT_PATH_PATTERN,
+ retd.getOutputPathPatternForRendition());
+ this.nodeService.addAspect(rpNodeRef, WCMAppModel.ASPECT_OUTPUT_PATH_PATTERN, props);
}
@Override
@@ -342,6 +364,7 @@ public class CreateFormWizard
this.formName = null;
this.formTitle = null;
this.formDescription = null;
+ this.renderingEngineTemplateName = null;
this.renderingEngineTemplateTitle = null;
this.renderingEngineTemplateDescription = null;
this.renderingEngine = null;
@@ -350,6 +373,8 @@ public class CreateFormWizard
this.outputPathPatternForRendition = null;
this.mimetypeForRendition = null;
this.defaultWorkflowName = null;
+ this.defaultWorkflowChoices = null;
+ this.applyDefaultWorkflow = true;
}
@Override
@@ -469,10 +494,17 @@ public class CreateFormWizard
*/
public void addSelectedRenderingEngineTemplate(final ActionEvent event)
{
+ final String name = this.getRenderingEngineTemplateName();
final String opp = this.getOutputPathPatternForRendition();
final String mimetype = this.getMimetypeForRendition();
for (RenderingEngineTemplateData retd : this.renderingEngineTemplates)
{
+ if (name.equals(retd.getName()))
+ {
+ Utils.addErrorMessage("A rendering engine template with the name " + name +
+ " already exists");
+ return;
+ }
if (opp.equals(retd.getOutputPathPatternForRendition()) &&
opp.indexOf(DEFAULT_EXTENSION_PATTERN) >= 0 &&
mimetype.equals(retd.getMimetypeForRendition()))
@@ -485,6 +517,7 @@ public class CreateFormWizard
final RenderingEngineTemplateData data =
this.new RenderingEngineTemplateData(this.getRenderingEngineTemplateFileName(),
this.getRenderingEngineTemplateFile(),
+ this.getRenderingEngineTemplateName(),
this.getRenderingEngineTemplateTitle(),
this.getRenderingEngineTemplateDescription(),
opp,
@@ -495,6 +528,7 @@ public class CreateFormWizard
this.renderingEngine = null;
this.outputPathPatternForRendition = null;
this.mimetypeForRendition = null;
+ this.renderingEngineTemplateName = null;
this.renderingEngineTemplateTitle = null;
this.renderingEngineTemplateDescription = null;
}
@@ -560,8 +594,7 @@ public class CreateFormWizard
{
try
{
- final FormsService formsService = FormsService.getInstance();
- final Document d = formsService.parseXML(this.getSchemaFile());
+ final Document d = XMLUtil.parse(this.getSchemaFile());
this.schema = SchemaUtil.parseSchema(d);
}
catch (Exception e)
@@ -809,7 +842,7 @@ public class CreateFormWizard
public String getFormName()
{
return (this.formName == null && this.getSchemaFileName() != null
- ? this.getSchemaFileName().replaceAll("(.+)\\..*", "$1")
+ ? FilenameUtils.removeExtension(this.getSchemaFileName())
: this.formName);
}
/**
@@ -846,7 +879,7 @@ public class CreateFormWizard
public String getFormTitle()
{
return (this.formTitle == null && this.getSchemaFileName() != null
- ? this.getSchemaFileName().replaceAll("(.+)\\..*", "$1")
+ ? FilenameUtils.removeExtension(this.getSchemaFileName())
: this.formTitle);
}
@@ -866,6 +899,23 @@ public class CreateFormWizard
return this.formDescription;
}
+ /**
+ * Sets the name for this renderingEngineTemplate.
+ */
+ public void setRenderingEngineTemplateName(final String renderingEngineTemplateName)
+ {
+ this.renderingEngineTemplateName = renderingEngineTemplateName;
+ }
+
+ /**
+ * @return the name for this renderingEngineTemplate.
+ */
+ public String getRenderingEngineTemplateName()
+ {
+ return (this.renderingEngineTemplateName == null && this.getRenderingEngineTemplateFileName() != null
+ ? FilenameUtils.removeExtension(this.getRenderingEngineTemplateFileName())
+ : this.renderingEngineTemplateName);
+ }
/**
* Sets the title for this renderingEngineTemplate.
*/
@@ -880,7 +930,7 @@ public class CreateFormWizard
public String getRenderingEngineTemplateTitle()
{
return (this.renderingEngineTemplateTitle == null && this.getRenderingEngineTemplateFileName() != null
- ? this.getRenderingEngineTemplateFileName().replaceAll("(.+)\\..*", "$1")
+ ? FilenameUtils.removeExtension(this.getRenderingEngineTemplateFileName())
: this.renderingEngineTemplateTitle);
}
@@ -900,56 +950,61 @@ public class CreateFormWizard
return this.renderingEngineTemplateDescription;
}
- public void setDefaultWorkflowName(final String[] defaultWorkflowName)
- {
- assert defaultWorkflowName.length == 1;
- this.defaultWorkflowName = (NO_DEFAULT_WORKFLOW_SELECTED.equals(defaultWorkflowName[0])
- ? null
- : defaultWorkflowName[0]);
- }
-
public WorkflowDefinition getDefaultWorkflowDefinition()
{
- return (this.defaultWorkflowName == null
+ return (this.defaultWorkflowName == null || !this.applyDefaultWorkflow
? null
: this.workflowService.getDefinitionByName(this.defaultWorkflowName));
}
- public String[] getDefaultWorkflowName()
+ public void setDefaultWorkflowName(final String[] defaultWorkflowName)
{
- return new String[] {
- (this.defaultWorkflowName == null
- ? NO_DEFAULT_WORKFLOW_SELECTED
- : this.defaultWorkflowName)
- };
+ assert defaultWorkflowName.length == 1;
+ this.defaultWorkflowName = defaultWorkflowName[0];
}
+ public String[] getDefaultWorkflowName()
+ {
+ if (this.defaultWorkflowName == null && this.getDefaultWorkflowChoices().size() != 0)
+ {
+ this.defaultWorkflowName = (String)this.getDefaultWorkflowChoices().get(0).getValue();
+ }
+ return new String[] { this.defaultWorkflowName };
+ }
+
+ public void setApplyDefaultWorkflow(final boolean applyDefaultWorkflow)
+ {
+ this.applyDefaultWorkflow = applyDefaultWorkflow;
+ }
+
+ public boolean getApplyDefaultWorkflow()
+ {
+ return this.applyDefaultWorkflow;
+ }
+
/**
* @return List of UI items to represent the available Workflows for all websites
*/
public List getDefaultWorkflowChoices()
{
- // TODO: add list of workflows from config
- // @see org.alfresco.web.wcm.FormDetailsDialog#getWorkflowList()
- final List workflowDefs = this.workflowService.getDefinitions();
- final List result = new ArrayList(workflowDefs.size() + 1);
-
- UIListItem item = new UIListItem();
- item.setValue(NO_DEFAULT_WORKFLOW_SELECTED);
- item.setLabel("None");
- item.setImage(WebResources.IMAGE_WORKFLOW_32);
- result.add(item);
-
- for (WorkflowDefinition workflowDef : workflowDefs)
+ if (this.defaultWorkflowChoices == null)
{
- item = new UIListItem();
- item.setValue(workflowDef.getName());
- item.setLabel(workflowDef.getTitle());
- item.setDescription(workflowDef.getDescription());
- item.setImage(WebResources.IMAGE_WORKFLOW_32);
- result.add(item);
+ // TODO: add list of workflows from config
+ // @see org.alfresco.web.wcm.FormDetailsDialog#getWorkflowList()
+ final List workflowDefs = this.workflowService.getDefinitions();
+ this.defaultWorkflowChoices = new ArrayList(workflowDefs.size() + 1);
+
+ for (WorkflowDefinition workflowDef : workflowDefs)
+ {
+ final UIListItem item = new UIListItem();
+ item.setValue(workflowDef.getName());
+ item.setLabel(workflowDef.getTitle());
+ item.setDescription(workflowDef.getDescription());
+ item.setImage(WebResources.IMAGE_WORKFLOW_32);
+ this.defaultWorkflowChoices.add(item);
+ }
}
- return result;
+ return this.defaultWorkflowChoices;
}
// ------------------------------------------------------------------------------
diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java
index d87ceab150..caff23f41a 100644
--- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java
+++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
@@ -63,7 +64,9 @@ import org.alfresco.web.forms.FormInstanceData;
import org.alfresco.web.forms.FormInstanceDataImpl;
import org.alfresco.web.forms.FormProcessor;
import org.alfresco.web.forms.FormsService;
+import org.alfresco.web.forms.RenderingEngineTemplate;
import org.alfresco.web.forms.Rendition;
+import org.alfresco.web.forms.XMLUtil;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.wcm.component.UIUserSandboxes;
@@ -170,13 +173,11 @@ public class CreateWebContentWizard extends BaseContentWizard
this.formSelectDisabled = false;
// check for a form ID being passed in as a parameter
- if (this.parameters.get(UIUserSandboxes.PARAM_FORM_ID) != null)
+ if (this.parameters.get(UIUserSandboxes.PARAM_FORM_NAME) != null)
{
// it is used to init the dialog to a specific template
- String webFormId = parameters.get(UIUserSandboxes.PARAM_FORM_ID);
- NodeRef webFormRef = new NodeRef(Repository.getStoreRef(), webFormId);
- String formName = (String)this.nodeService.getProperty(webFormRef, WCMAppModel.PROP_FORMNAME);
- Form form = FormsService.getInstance().getForm(formName);
+ final String formName = parameters.get(UIUserSandboxes.PARAM_FORM_NAME);
+ final Form form = this.avmBrowseBean.getWebProject().getForm(formName);
if (form != null)
{
this.formName = form.getName();
@@ -225,17 +226,13 @@ public class CreateWebContentWizard extends BaseContentWizard
LOGGER.debug("clearing form instance data");
if (this.formInstanceData != null)
{
- final NodeRef nr = this.formInstanceData.getNodeRef();
- final String path = AVMNodeConverter.ToAVMVersionPath(nr).getSecond();
- this.avmService.removeNode(path);
+ this.avmService.removeNode(this.formInstanceData.getPath());
}
if (this.renditions != null)
{
for (Rendition r : this.renditions)
{
- final NodeRef nr = r.getNodeRef();
- final String path = AVMNodeConverter.ToAVMVersionPath(nr).getSecond();
- this.avmService.removeNode(path);
+ this.avmService.removeNode(r.getPath());
}
}
this.formInstanceData = null;
@@ -277,7 +274,7 @@ public class CreateWebContentWizard extends BaseContentWizard
AVMDifference.NEWER));
for (Rendition rendition : this.renditions)
{
- final String path = AVMNodeConverter.ToAVMVersionPath(rendition.getNodeRef()).getSecond();
+ final String path = rendition.getPath();
diffList.add(new AVMDifference(-1, path,
-1, AVMConstants.getCorrespondingPathInMainStore(path),
AVMDifference.NEWER));
@@ -315,48 +312,8 @@ public class CreateWebContentWizard extends BaseContentWizard
}
if (this.startWorkflow)
{
- WorkflowDefinition wd = null;
- Map parameters = null;
-
- // get the workflow definition and parameters
- final Node website = this.avmBrowseBean.getWebsite();
- final List webFormRefs = this.nodeService.getChildAssocs(
- website.getNodeRef(), WCMAppModel.ASSOC_WEBFORM, RegexQNamePattern.MATCH_ALL);
- for (ChildAssociationRef ref : webFormRefs)
- {
- final String formName = (String)
- this.nodeService.getProperty(ref.getChildRef(), WCMAppModel.PROP_FORMNAME);
- if (formName.equals(this.getForm().getName()))
- {
- if (LOGGER.isDebugEnabled())
- LOGGER.debug("loading workflowRefs for " + formName);
-
- final List workflowRefs =
- this.nodeService.getChildAssocs(ref.getChildRef(),
- WCMAppModel.ASSOC_WORKFLOWDEFAULTS,
- RegexQNamePattern.MATCH_ALL);
- if (workflowRefs.size() == 0)
- {
- throw new AlfrescoRuntimeException("no workflow parameters found for form " + formName);
- }
- if (workflowRefs.size() > 1)
- {
- throw new AlfrescoRuntimeException("found more than one workflow parameters node for " + formName);
- }
-
- final NodeRef workflowRef = workflowRefs.get(0).getChildRef();
- final String workflowName = (String)this.nodeService.getProperty(workflowRef, WCMAppModel.PROP_WORKFLOW_NAME);
-
- if (LOGGER.isDebugEnabled())
- LOGGER.debug("using workflow " + workflowName + " for form " + formName);
- wd = this.workflowService.getDefinitionByName(workflowName);
-
- // deserialize the workflow parameters
- parameters = (Map)AVMWorkflowUtil.deserializeWorkflowParams(workflowRef);
-
- break;
- }
- }
+ final WorkflowDefinition wd = this.getForm().getDefaultWorkflow();
+ final Map parameters = this.getForm().getDefaultWorkflowParameters();
if (LOGGER.isDebugEnabled())
LOGGER.debug("starting workflow " + wd + " with parameters " + parameters);
@@ -385,11 +342,9 @@ public class CreateWebContentWizard extends BaseContentWizard
// collect diffs for form data instance and all renditions
for (Rendition rendition : this.getRenditions())
{
- final String renditionPath = AVMNodeConverter.ToAVMVersionPath(rendition.getNodeRef()).getSecond();
- srcPaths.add(AVMConstants.getCorrespondingPath(renditionPath, sandboxName));
+ srcPaths.add(AVMConstants.getCorrespondingPath(rendition.getPath(), sandboxName));
}
- final String instancePath = AVMNodeConverter.ToAVMVersionPath(this.formInstanceData.getNodeRef()).getSecond();
- srcPaths.add(AVMConstants.getCorrespondingPath(instancePath, sandboxName));
+ srcPaths.add(AVMConstants.getCorrespondingPath(this.formInstanceData.getPath(), sandboxName));
}
else
{
@@ -454,7 +409,6 @@ public class CreateWebContentWizard extends BaseContentWizard
protected void saveContent()
throws Exception
{
- final FormsService fs = FormsService.getInstance();
// get the parent path of the location to save the content
String fileName = this.fileName;
if (LOGGER.isDebugEnabled())
@@ -462,13 +416,16 @@ public class CreateWebContentWizard extends BaseContentWizard
String path = this.avmBrowseBean.getCurrentPath();
path = AVMConstants.getCorrespondingPathInPreviewStore(path);
- if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null)
+ final Form form = (MimetypeMap.MIMETYPE_XML.equals(this.mimeType)
+ ? this.getForm()
+ : null);
+ if (form != null)
{
- path = this.getForm().getOutputPathForFormInstanceData(this.instanceDataDocument,
- fileName,
- path,
- this.avmBrowseBean.getWebapp());
- this.content = FormsService.getInstance().writeXMLToString(this.instanceDataDocument);
+ path = form.getOutputPathForFormInstanceData(this.instanceDataDocument,
+ fileName,
+ path,
+ this.avmBrowseBean.getWebapp());
+ this.content = XMLUtil.toString(this.instanceDataDocument);
final String[] sb = AVMNodeConverter.SplitBase(path);
path = sb[0];
fileName = sb[1];
@@ -477,7 +434,7 @@ public class CreateWebContentWizard extends BaseContentWizard
if (LOGGER.isDebugEnabled())
LOGGER.debug("creating all directories in path " + path);
- fs.makeAllDirectories(path);
+ AVMConstants.makeAllDirectories(path);
if (LOGGER.isDebugEnabled())
LOGGER.debug("creating file " + fileName + " in " + path);
@@ -492,15 +449,26 @@ public class CreateWebContentWizard extends BaseContentWizard
// add titled aspect for the read/edit properties screens
final NodeRef formInstanceDataNodeRef = AVMNodeConverter.ToNodeRef(-1, this.createdPath);
- Map titledProps = new HashMap(1, 1.0f);
- titledProps.put(ContentModel.PROP_TITLE, fileName);
- this.nodeService.addAspect(formInstanceDataNodeRef, ContentModel.ASPECT_TITLED, titledProps);
+ final Map props = new HashMap(1, 1.0f);
+ props.put(ContentModel.PROP_TITLE, fileName);
+ this.nodeService.addAspect(formInstanceDataNodeRef, ContentModel.ASPECT_TITLED, props);
- if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null)
+ if (form != null)
{
- this.formInstanceData = new FormInstanceDataImpl(formInstanceDataNodeRef);
- this.getForm().registerFormInstanceData(formInstanceDataNodeRef);
- this.renditions = FormsService.getInstance().generateRenditions(this.formInstanceData);
+ this.formInstanceData = new FormInstanceDataImpl(formInstanceDataNodeRef)
+ {
+ @Override
+ public Form getForm() { return form; }
+ };
+ props.clear();
+ props.put(WCMAppModel.PROP_PARENT_FORM_NAME, form.getName());
+ this.nodeService.addAspect(formInstanceDataNodeRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA, props);
+
+ this.renditions = new LinkedList();
+ for (RenderingEngineTemplate ret : form.getRenderingEngineTemplates())
+ {
+ this.renditions.add(ret.render(this.formInstanceData));
+ }
}
else
{
@@ -533,23 +501,11 @@ public class CreateWebContentWizard extends BaseContentWizard
*/
public List getFormChoices()
{
- final Node website = this.avmBrowseBean.getWebsite();
- if (website == null)
+ final List