diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index c25c34d157..faf79f0b81 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -696,6 +696,7 @@ import_error_info=If this option is selected the import will be performed in the edit_file_title=Edit file edit_file_prompt=To edit the file ''{0}'', click the link below and if asked select Save. edit_download_complete=When the download is complete, click Close. +edit_using_web_form=To edit this file using a Web Form, click here. checkout_file_title=Check out file checkout_you_may_want=You may want to check out this file to lock it and prevent other users from editing it. checkout_hint1=Hint: When you check out a file a copy is made for you to work with. @@ -985,11 +986,11 @@ website_workflow=Workflow website_workflow_info=Use the following workflow website_forms=Configure Web Forms form_template_details=Web Form Details -form_template_details_desc=Edit the details of this Web Form +form_template_details_desc=Edit the details of Web Form {0} in Web Project {1}. form_template_conf_workflow=Configure Workflow form_template_select_templates=Configure Templates form_template_templates=Configure Templates -form_template_templates_desc=Setup the Templates you want to use for the Web Content Form. +form_template_templates_desc=Setup the Templates you want to use for the Web Form {0} in Web Project {1}. form_template_workflow=Configure Workflow form_template_workflow_desc=Configure the workflow defaults for this Web Project create_website_step2_title=Step Two - Configure Web Content Forms @@ -1219,7 +1220,12 @@ rerun_report=Run Report Again update_status=Update Status fixed_items=Items you have fixed no_items=No items to display - +prompt_for_web_form=Select Web Form +prompt_for_web_form_info=Select the Web Form to use for editing this file +prompt_for_web_form_form_not_found_error_in_web_project=Unable to find Web Form {0} associated with {1} in Web Project {2}. +prompt_for_web_form_form_not_found_error=Unable to find Web Form {0} associated with {1}. +prompt_for_web_form_explanation=Select the Web Form to use for {0}. +prompt_for_web_form_continue_msg=To edit {0} using the selected Web Form, click ok. If {0} is not a Web Form generated asset and should be treated as regular content, click cancel. # New User Wizard messages new_user_title=New User Wizard new_user_title_edit=Edit User Wizard diff --git a/config/alfresco/web-client-application-context.xml b/config/alfresco/web-client-application-context.xml index 11f536f5c7..48a4d753d3 100644 --- a/config/alfresco/web-client-application-context.xml +++ b/config/alfresco/web-client-application-context.xml @@ -254,7 +254,7 @@ - + diff --git a/config/alfresco/web-client-config-dialogs.xml b/config/alfresco/web-client-config-dialogs.xml index e54bdae42d..2bd775c272 100644 --- a/config/alfresco/web-client-config-dialogs.xml +++ b/config/alfresco/web-client-config-dialogs.xml @@ -161,11 +161,26 @@ + + + + + + diff --git a/config/alfresco/web-client-config-wcm-actions.xml b/config/alfresco/web-client-config-wcm-actions.xml index 70613ff1bb..2d96198888 100644 --- a/config/alfresco/web-client-config-wcm-actions.xml +++ b/config/alfresco/web-client-config-wcm-actions.xml @@ -11,7 +11,7 @@ org.alfresco.web.action.evaluator.WCMWorkflowEvaluator edit /images/icons/edit_icon.gif - #{AVMEditBean.setupEditAction} + #{AVMBrowseBean.setupEditAction} #{actionContext.id} diff --git a/source/java/org/alfresco/web/app/AlfrescoNavigationHandler.java b/source/java/org/alfresco/web/app/AlfrescoNavigationHandler.java index 5ba7aabb51..1090030301 100644 --- a/source/java/org/alfresco/web/app/AlfrescoNavigationHandler.java +++ b/source/java/org/alfresco/web/app/AlfrescoNavigationHandler.java @@ -684,29 +684,7 @@ public class AlfrescoNavigationHandler extends NavigationHandler if (logger.isDebugEnabled()) logger.debug("Popped item from the top of the view stack: " + topOfStack); - String newViewId = null; - - if (topOfStack instanceof String) - { - newViewId = (String)topOfStack; - } - else if (topOfStack instanceof DialogState) - { - // restore the dialog state and get the dialog container viewId - Application.getDialogManager().restoreState((DialogState)topOfStack); - newViewId = getDialogContainer(context); - } - else if (topOfStack instanceof WizardState) - { - // restore the wizard state and get the wizard container viewId - Application.getWizardManager().restoreState((WizardState)topOfStack); - newViewId = getWizardContainer(context); - } - else - { - if (logger.isWarnEnabled()) - logger.warn("Invalid object found on view stack: " + topOfStack); - } + String newViewId = getViewIdFromStackObject(context, topOfStack); // go to the appropraite page goToView(context, newViewId); @@ -714,7 +692,10 @@ public class AlfrescoNavigationHandler extends NavigationHandler else { // we also need to empty the dialog stack if we have been given - // an overidden outcome as we could be going anywhere in the app + // an overidden outcome as we could be going anywhere in the app. + // grab the current top item first though in case we need to open + // another dialog or wizard + String previousViewId = getViewIdFromStackObject(context, getViewStack(context).peek()); getViewStack(context).clear(); if (logger.isDebugEnabled()) @@ -723,7 +704,18 @@ public class AlfrescoNavigationHandler extends NavigationHandler // if the override is calling another dialog or wizard come back through // the navigation handler from the beginning if (isDialog(overriddenOutcome) || isWizard(overriddenOutcome)) - { + { + // set the view id to the page at the top of the stack so when + // the new dialog or wizard closes it goes back to the correct page + context.getViewRoot().setViewId(previousViewId); + + if (logger.isDebugEnabled()) + { + logger.debug("view stack: " + getViewStack(context)); + logger.debug("Opening '" + overriddenOutcome + "' after " + closingItem + + " close using view id: " + previousViewId); + } + this.handleNavigation(context, fromAction, overriddenOutcome); } else @@ -745,6 +737,42 @@ public class AlfrescoNavigationHandler extends NavigationHandler } } + /** + * Returns the view id of the given item retrieved from the view stack. + * + * @param context FacesContext + * @param topOfStack The object retrieved from the view stack + * @return The view id + */ + protected String getViewIdFromStackObject(FacesContext context, Object topOfStack) + { + String viewId = null; + + if (topOfStack instanceof String) + { + viewId = (String)topOfStack; + } + else if (topOfStack instanceof DialogState) + { + // restore the dialog state and get the dialog container viewId + Application.getDialogManager().restoreState((DialogState)topOfStack); + viewId = getDialogContainer(context); + } + else if (topOfStack instanceof WizardState) + { + // restore the wizard state and get the wizard container viewId + Application.getWizardManager().restoreState((WizardState)topOfStack); + viewId = getWizardContainer(context); + } + else + { + if (logger.isWarnEnabled()) + logger.warn("Invalid object found on view stack: " + topOfStack); + } + + return viewId; + } + /** * Adds the current view to the stack (if required). * If the current view is already the top of the stack it is not added again diff --git a/source/java/org/alfresco/web/app/servlet/command/EditWebContentCommand.java b/source/java/org/alfresco/web/app/servlet/command/EditWebContentCommand.java index 8bb2586dd2..1b12975b3a 100644 --- a/source/java/org/alfresco/web/app/servlet/command/EditWebContentCommand.java +++ b/source/java/org/alfresco/web/app/servlet/command/EditWebContentCommand.java @@ -41,7 +41,6 @@ import org.alfresco.web.app.servlet.BaseServlet; import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.bean.NavigationBean; import org.alfresco.web.bean.wcm.AVMBrowseBean; -import org.alfresco.web.bean.wcm.AVMEditBean; import org.alfresco.web.bean.wizard.WizardManager; import org.alfresco.web.ui.wcm.component.UIUserSandboxes; @@ -73,7 +72,6 @@ public class EditWebContentCommand extends BaseUIActionCommand ServletResponse res = (ServletResponse)properties.get(PROP_RESPONSE); FacesContext fc = FacesHelper.getFacesContext(req, res, sc); AVMBrowseBean avmBrowseBean = (AVMBrowseBean)FacesHelper.getManagedBean(fc, AVMBrowseBean.BEAN_NAME); - AVMEditBean avmEditBean = (AVMEditBean)FacesHelper.getManagedBean(fc, AVMEditBean.BEAN_NAME); NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); // setup context from url args in properties map @@ -86,7 +84,7 @@ public class EditWebContentCommand extends BaseUIActionCommand navigator.setCurrentNodeId(webProjectId); avmBrowseBean.setSandbox(sandbox); // navigation handler is called directly in this method - avmEditBean.setupEditAction(path); + avmBrowseBean.setupEditAction(path); String viewId = fc.getViewRoot().getViewId(); try diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index 583764865a..2e6478556d 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -24,6 +24,7 @@ */ package org.alfresco.web.bean.wcm; +import java.io.FileNotFoundException; import java.io.Serializable; import java.text.MessageFormat; import java.util.ArrayList; @@ -148,7 +149,7 @@ public class AVMBrowseBean implements IContextListener private List deploymentMonitorIds = new ArrayList(); /** List of expired paths to submit */ - private List expiredNodes = Collections.emptyList(); + private List nodesForSubmit = Collections.emptyList(); /** Object used by link validation service to monitor the status of a link check */ private HrefValidationProgress linkValidationMonitor; @@ -194,6 +195,9 @@ public class AVMBrowseBean implements IContextListener /** Action service bean reference */ protected ActionService actionService; + + /** The FormsService reference */ + protected FormsService formsService; /** * Default Constructor @@ -266,6 +270,14 @@ public class AVMBrowseBean implements IContextListener this.actionService = actionService; } + /** + * @param formsService The FormsService to set. + */ + public void setFormsService(final FormsService formsService) + { + this.formsService = formsService; + } + /** * Summary text for the staging store: * Created On: xx/yy/zz @@ -499,23 +511,17 @@ public class AVMBrowseBean implements IContextListener } /** - * Returns the list of expired nodes. Used by the submit dialog to retrieve - * nodes to potentially submit when a user completes a change request - * task dealing with content expiration. - * - * @return The list of expired nodes */ - public List getExpiredNodes() + public List getNodesForSubmit() { - return this.expiredNodes; + return this.nodesForSubmit; } /** - * @param expiredNodes List of nodes in the users sandbox that have expired */ - public void setExpiredNodes(List expiredNodes) + public void setNodesForSubmit(final List nodesForSubmit) { - this.expiredNodes = expiredNodes; + this.nodesForSubmit = nodesForSubmit; } /** @@ -1001,6 +1007,88 @@ public class AVMBrowseBean implements IContextListener } } + /** + * Action handler called to calculate which editing screen to display based on the mimetype + * of a document. If appropriate, the in-line editing screen will be shown. + */ + public void setupEditAction(final ActionEvent event) + { + final UIActionLink link = (UIActionLink)event.getComponent(); + final Map params = link.getParameterMap(); + this.setupEditAction(params.get("id")); + } + + /** + * Action handler called to calculate which editing screen to display based on the mimetype + * of a document. If appropriate, the in-line editing screen will be shown. + */ + public void setupEditAction(final String path) + { + this.setupContentAction(path, true); + + // retrieve the content reader for this node + String avmPath = this.getAvmActionNode().getPath(); + if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_RENDITION)) + { + if (LOGGER.isDebugEnabled()) + LOGGER.debug(avmPath + " is a rendition, editing primary rendition instead"); + + try + { + final FormInstanceData fid = this.formsService.getRendition(-1, avmPath).getPrimaryFormInstanceData(); + avmPath = fid.getPath(); + + if (LOGGER.isDebugEnabled()) + LOGGER.debug("Editing primary form instance data " + avmPath); + + this.setAvmActionNode(new AVMNode(this.avmService.lookup(-1, avmPath))); + } + catch (FileNotFoundException fnfe) + { + this.avmService.removeAspect(avmPath, WCMAppModel.ASPECT_RENDITION); + this.avmService.removeAspect(avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA); + Utils.addErrorMessage(fnfe.getMessage(), fnfe); + } + } + + if (LOGGER.isDebugEnabled()) + LOGGER.debug("Editing AVM node: " + avmPath); + String outcome = null; + // calculate which editor screen to display + if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) + { + // make content available to the editing screen + try + { + // make sure the form association works before proceeding to the + // edit web content wizard + this.formsService.getFormInstanceData(-1, avmPath).getForm(); + // navigate to appropriate screen + outcome = "wizard:editWebContent"; + } + catch (FormNotFoundException fnfe) + { + LOGGER.debug(fnfe.getMessage(), fnfe); + final Map params = new HashMap(2, 1.0f); + params.put("finishOutcome", "wizard:editWebContent"); + params.put("cancelOutcome", "dialog:editAvmFile"); + Application.getDialogManager().setupParameters(params); + + outcome = "dialog:promptForWebForm"; + } + } + else + { + // normal downloadable document + outcome = "dialog:editAvmFile"; + } + + LOGGER.debug("outcome " + outcome + " for path " + path); + + final FacesContext fc = FacesContext.getCurrentInstance(); + fc.getApplication().getNavigationHandler().handleNavigation(fc, null, outcome); + } + /** * Action handler for all nodes from user sandbox */ @@ -1049,11 +1137,11 @@ public class AVMBrowseBean implements IContextListener FormInstanceData fid = null; if (this.avmService.hasAspect(-1, path, WCMAppModel.ASPECT_RENDITION)) { - fid = new RenditionImpl(-1, path).getPrimaryFormInstanceData(); + fid = this.formsService.getRendition(-1, path).getPrimaryFormInstanceData(); } else if (this.avmService.hasAspect(-1, path, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) { - fid = new FormInstanceDataImpl(-1, path); + fid = this.formsService.getFormInstanceData(-1, path); } List> versionPaths = new ArrayList>(); if (fid != null) @@ -1166,15 +1254,14 @@ public class AVMBrowseBean implements IContextListener /** * Create web content from a specific Form via the User Sandbox 'Available Forms' panel */ - public void createFormContent(ActionEvent event) + public void createFormContent(final ActionEvent event) { // setup the correct sandbox for the create action - setupSandboxAction(event); + this.setupSandboxAction(event); // pass form ID to the wizard - to be picked up in init() - FacesContext fc = FacesContext.getCurrentInstance(); - WizardManager manager = (WizardManager)FacesHelper.getManagedBean(fc, WizardManager.BEAN_NAME); - manager.setupParameters(event); + Application.getWizardManager().setupParameters(event); + final FacesContext fc = FacesContext.getCurrentInstance(); fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "wizard:createWebContent"); } diff --git a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java index ef61ed54d3..5d93807b46 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java @@ -45,12 +45,11 @@ 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.FormNotFoundException; 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.RenditionImpl; import org.alfresco.web.forms.XMLUtil; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.UIActionLink; @@ -66,28 +65,17 @@ import org.w3c.dom.Document; */ public class AVMEditBean { - public static final String BEAN_NAME = "AVMEditBean"; - private static final Log LOGGER = LogFactory.getLog(AVMEditBean.class); private static final String MSG_ERROR_UPDATE = "error_update"; private static final String MSG_UPLOAD_SUCCESS = "file_upload_success"; - private String documentContent = null; - private Document instanceDataDocument = null; - private String editorOutput = null; - private File file = null; private String fileName = null; - /** AVM service bean reference */ protected AVMService avmService; - - /** AVM sync service bean reference */ - protected AVMSyncService avmSyncService; - - /** AVM Browse Bean reference */ protected AVMBrowseBean avmBrowseBean; + protected FormsService formsService; // ------------------------------------------------------------------------------ // Bean property getters and setters @@ -100,14 +88,6 @@ public class AVMEditBean this.avmService = avmService; } - /** - * @param avmSyncService The AVMSyncService to set. - */ - public void setAvmSyncService(final AVMSyncService avmSyncService) - { - this.avmSyncService = avmSyncService; - } - /** * @param avmBrowseBean The AVMBrowseBean to set. */ @@ -116,6 +96,14 @@ public class AVMEditBean this.avmBrowseBean = avmBrowseBean; } + /** + * @param formsService The FormsService to set. + */ + public void setFormsService(final FormsService formsService) + { + this.formsService = formsService; + } + /** * @return Returns the current AVM node context. */ @@ -140,47 +128,6 @@ public class AVMEditBean return Utils.getFileTypeImage(getAvmNode().getName(), true); } - /** - * @return Content URL for current AVM node - */ - public String getUrl() - { - return DownloadContentServlet.generateDownloadURL(AVMNodeConverter.ToNodeRef(-1, getAvmNode().getPath()), - getAvmNode().getName()); - } - - /** - * @return Returns the document content used for HTML in-line editing. - */ - public String getDocumentContent() - { - return this.documentContent; - } - - /** - * @param documentContent The document content for HTML in-line editing. - */ - public void setDocumentContent(String documentContent) - { - this.documentContent = documentContent; - } - - /** - * @return Returns output from the in-line editor page. - */ - public String getEditorOutput() - { - return this.editorOutput; - } - - /** - * @param editorOutput The output from the in-line editor page - */ - public void setEditorOutput(String editorOutput) - { - this.editorOutput = editorOutput; - } - /** * @return Returns the name of the file */ @@ -212,113 +159,6 @@ public class AVMEditBean // ------------------------------------------------------------------------------ // Action event handlers - /** - * Action handler called to calculate which editing screen to display based on the mimetype - * of a document. If appropriate, the in-line editing screen will be shown. - */ - public void setupEditAction(final ActionEvent event) - { - final UIActionLink link = (UIActionLink)event.getComponent(); - final Map params = link.getParameterMap(); - this.setupEditAction(params.get("id")); - } - - /** - * Action handler called to calculate which editing screen to display based on the mimetype - * of a document. If appropriate, the in-line editing screen will be shown. - */ - public void setupEditAction(String path) - { - this.avmBrowseBean.setupContentAction(path, true); - - // retrieve the content reader for this node - String avmPath = getAvmNode().getPath(); - if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_RENDITION)) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug(avmPath + " is a rendition, editing primary rendition instead"); - - try - { - final FormInstanceData fid = - new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, avmPath)).getPrimaryFormInstanceData(); - avmPath = fid.getPath(); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("Editing primary form instance data " + avmPath); - - this.avmBrowseBean.setAvmActionNode(new AVMNode(this.avmService.lookup(-1, avmPath))); - } - catch (FileNotFoundException fnfe) - { - this.avmService.removeAspect(avmPath, WCMAppModel.ASPECT_RENDITION); - this.avmService.removeAspect(avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA); - Utils.addErrorMessage(fnfe.getMessage(), fnfe); - } - } - - if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) - { - // reset the preview layer - String storeName = AVMUtil.getStoreName(avmPath); - storeName = AVMUtil.getCorrespondingPreviewStoreName(storeName); - final String rootPath = AVMUtil.buildStoreRootPath(storeName); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("reseting layer " + rootPath); - - this.avmSyncService.resetLayer(rootPath); - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("Editing AVM node: " + avmPath); - - ContentReader reader = this.avmService.getContentReader(-1, avmPath); - if (reader != null) - { - String mimetype = reader.getMimetype(); - String outcome = null; - // calculate which editor screen to display - if (MimetypeMap.MIMETYPE_XML.equals(mimetype) && - this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) - { - // make content available to the editing screen - this.setEditorOutput(reader.getContentString()); - - // navigate to appropriate screen - outcome = "wizard:editWebContent"; - } - else - { - // normal downloadable document - outcome = "dialog:editAvmFile"; - } - - final FacesContext fc = FacesContext.getCurrentInstance(); - fc.getApplication().getNavigationHandler().handleNavigation(fc, null, outcome); - } - } - - /** - * Action called upon completion of the Edit File download page - */ - public String editFileOK() - { - String outcome = null; - - AVMNode node = getAvmNode(); - if (node != null) - { - // Possibly notify virt server - AVMUtil.updateVServerWebapp(node.getPath(), false); - - resetState(); - outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME; - } - - return outcome; - } - /** * Action called upon completion of the Update File page */ @@ -386,8 +226,6 @@ public class AVMEditBean { // clean up and clear action context clearUpload(); - setDocumentContent(null); - setEditorOutput(null); } /** @@ -413,24 +251,7 @@ public class AVMEditBean throws FormNotFoundException { final String avmPath = this.getAvmNode().getPath(); - final FormInstanceData fid = new FormInstanceDataImpl(-1, avmPath) - { - @Override - public Form getForm() - throws FormNotFoundException - { - final WebProject wp = new WebProject(this.getPath()); - Form f = super.getForm(); - try - { - return wp.getForm(f.getName()); - } - catch (FormNotFoundException fnfe) - { - throw new FormNotFoundException(f, wp, this); - } - } - }; + final FormInstanceData fid = this.formsService.getFormInstanceData(-1, avmPath); final List result = fid.regenerateRenditions(); for (FormInstanceData.RegenerateResult rr : result) { diff --git a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java index 40048fa990..9f76e3e46e 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java @@ -32,6 +32,7 @@ import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.StringTokenizer; @@ -91,13 +92,29 @@ public class AVMWorkflowUtil extends WorkflowUtil final WorkflowService workflowService, final NodeService nodeService) { + // create package paths (layered to user sandbox area as target) final String workflowMainStoreName = sandboxInfo.getMainStoreName(); final String packagesPath = AVMUtil.buildStoreRootPath(workflowMainStoreName); - + + final String stagingStoreName = AVMUtil.getStoreId(workflowMainStoreName); + final HashSet directoriesAdded = new HashSet(); final List diffs = new ArrayList(srcPaths.size()); for (final String srcPath : srcPaths) { + // add all newly created directories + String parentPath = AVMNodeConverter.SplitBase(srcPath)[0]; + while (!directoriesAdded.contains(parentPath) && + avmService.lookup(-1, AVMUtil.getCorrespondingPath(parentPath, stagingStoreName)) == null) + { + diffs.add(new AVMDifference(-1, parentPath, + -1, AVMUtil.getCorrespondingPath(parentPath, workflowMainStoreName), + AVMDifference.NEWER)); + avmSubmittedAspect.markSubmitted(-1, parentPath, path.instance.id); + directoriesAdded.add(parentPath); + parentPath = AVMNodeConverter.SplitBase(parentPath)[0]; + } + diffs.add(new AVMDifference(-1, srcPath, -1, AVMUtil.getCorrespondingPath(srcPath, workflowMainStoreName), AVMDifference.NEWER)); @@ -118,7 +135,6 @@ public class AVMWorkflowUtil extends WorkflowUtil final ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance()); final PermissionService permissionService = services.getPermissionService(); permissionService.setPermission(packageNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS, true); - return packageNodeRef; } diff --git a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java index f6a7a1ac8e..9d6d67ff3c 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java @@ -203,6 +203,7 @@ public class CreateFormWizard protected ContentService contentService; protected MimetypeService mimetypeService; protected WorkflowService workflowService; + protected FormsService formsService; private String schemaRootElementName = null; private String formName = null; @@ -234,7 +235,7 @@ public class CreateFormWizard LOGGER.debug("creating form " + this.getFormName()); // get the node ref of the node that will contain the content - final NodeRef contentFormsNodeRef = FormsService.getInstance().getContentFormsNodeRef(); + final NodeRef contentFormsNodeRef = this.formsService.getContentFormsNodeRef(); final FileInfo folderInfo = this.fileFolderService.create(contentFormsNodeRef, @@ -518,7 +519,12 @@ public class CreateFormWizard final String name = this.getRenderingEngineTemplateName(); if (name == null || name.length() == 0) { - Utils.addErrorMessage("Please provide a name for the rendering engine template"); + Utils.addErrorMessage("Please provide a name for the rendering engine template."); + return; + } + if (this.renderingEngine == null) + { + Utils.addErrorMessage("Please select the rendering engine to use."); return; } final String opp = this.getOutputPathPatternForRendition(); @@ -712,9 +718,8 @@ public class CreateFormWizard if (this.renderingEngine == null && this.getRenderingEngineTemplateFileName() != null) { - final FormsService fs = FormsService.getInstance(); this.renderingEngine = - fs.guessRenderingEngine(this.getRenderingEngineTemplateFileName()); + this.formsService.guessRenderingEngine(this.getRenderingEngineTemplateFileName()); } return (this.renderingEngine == null ? null @@ -726,10 +731,9 @@ public class CreateFormWizard */ public void setRenderingEngineName(final String renderingEngineName) { - final FormsService fs = FormsService.getInstance(); this.renderingEngine = (renderingEngineName == null ? null - : fs.getRenderingEngine(renderingEngineName)); + : this.formsService.getRenderingEngine(renderingEngineName)); } /** @@ -737,9 +741,8 @@ public class CreateFormWizard */ public List getRenderingEngineChoices() { - final FormsService fs = FormsService.getInstance(); final List result = new LinkedList(); - for (RenderingEngine re : fs.getRenderingEngines()) + for (RenderingEngine re : this.formsService.getRenderingEngines()) { result.add(new SelectItem(re.getName(), re.getName())); } @@ -1097,6 +1100,14 @@ public class CreateFormWizard { this.workflowService = workflowService; } + + /** + * @param formsService The FormsService to set. + */ + public void setFormsService(final FormsService formsService) + { + this.formsService = formsService; + } // ------------------------------------------------------------------------------ // Helper Methods diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java index 8e500b9ffa..650bb6436a 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java @@ -64,6 +64,7 @@ import org.alfresco.service.cmr.workflow.WorkflowTask; import org.alfresco.service.cmr.workflow.WorkflowTaskState; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.Application; import org.alfresco.web.bean.content.BaseContentWizard; import org.alfresco.web.bean.repository.Node; @@ -72,7 +73,6 @@ import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.QuickSort; import org.alfresco.web.forms.Form; import org.alfresco.web.forms.FormInstanceData; -import org.alfresco.web.forms.FormInstanceDataImpl; import org.alfresco.web.forms.FormNotFoundException; import org.alfresco.web.forms.FormProcessor; import org.alfresco.web.forms.FormsService; @@ -106,24 +106,13 @@ public class CreateWebContentWizard extends BaseContentWizard protected boolean formSelectDisabled = false; protected boolean startWorkflow = false; - /** AVM service bean reference */ protected AVMService avmService; - - /** AVM sync service bean reference */ protected AVMSyncService avmSyncService; - - /** AVM Browse Bean reference */ protected AVMBrowseBean avmBrowseBean; - - /** AVM Submitted Aspect reference */ protected AVMSubmittedAspect avmSubmittedAspect; - - /** Workflow service bean reference */ - protected WorkflowService workflowService; - - /** The FilePickerBean reference */ protected FilePickerBean filePickerBean; - + protected FormsService formsService; + /** * @param avmService The AVMService to set. */ @@ -148,15 +137,6 @@ public class CreateWebContentWizard extends BaseContentWizard this.avmSubmittedAspect = avmSubmittedAspect; } - /** - * @param workflowService The WorkflowService to set. - */ - public void setWorkflowService(WorkflowService workflowService) - { - this.workflowService = workflowService; - } - - /** * @param avmBrowseBean The AVMBrowseBean to set. */ @@ -172,8 +152,15 @@ public class CreateWebContentWizard extends BaseContentWizard { this.filePickerBean = filePickerBean; } - - + + /** + * @param formsService The FormsService to set. + */ + public void setFormsService(final FormsService formsService) + { + this.formsService = formsService; + } + // ------------------------------------------------------------------------------ // Wizard implementation @@ -295,7 +282,7 @@ public class CreateWebContentWizard extends BaseContentWizard } @Override - protected String finishImpl(final FacesContext context, final String outcome) + protected String finishImpl(final FacesContext context, String outcome) throws Exception { final NodeRef[] uploadedFiles = this.filePickerBean.getUploadedFiles(); @@ -331,105 +318,23 @@ public class CreateWebContentWizard extends BaseContentWizard if (this.startWorkflow) { - final WorkflowDefinition wd = this.getForm().getDefaultWorkflow(); - if (wd == null) + final List submitNodes = + new ArrayList(1 + + this.getUploadedFiles().size() + + this.getRenditions().size()); + for (final AVMDifference d : diffList) { - throw new AlfrescoRuntimeException(Application.getMessage(context, "submit_no_workflow_warning")); - } - - final Map parameters = this.getForm().getDefaultWorkflowParameters(); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("starting workflow " + wd + " with parameters " + parameters); - - if (parameters == null) - { - throw new AlfrescoRuntimeException(Application.getMessage(context, "submit_workflow_config_error")); - } - - // start the workflow to get access to the start task - WorkflowPath path = this.workflowService.startWorkflow(wd.id, null); - if (path != null) - { - // extract the start task - List tasks = this.workflowService.getTasksForWorkflowPath(path.id); - if (tasks.size() == 1) - { - WorkflowTask startTask = tasks.get(0); - - if (startTask.state == WorkflowTaskState.IN_PROGRESS) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("creating workflow package"); - // create package paths (layered to user sandbox area as target) - final String storeId = this.avmBrowseBean.getStagingStore(); - final List srcPaths = new ArrayList(); - // construct diffs for selected items for submission - final String sandboxName = this.avmBrowseBean.getSandbox(); - if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null) - { - // collect diffs for form data instance and all renditions - for (Rendition rendition : this.getRenditions()) - { - srcPaths.add(AVMUtil.getCorrespondingPath(rendition.getPath(), sandboxName)); - } - for (NodeRef uploadedFile : uploadedFiles) - { - final String uploadPath = AVMNodeConverter.ToAVMVersionPath(uploadedFile).getSecond(); - srcPaths.add(AVMUtil.getCorrespondingPath(uploadPath, sandboxName)); - } - - srcPaths.add(AVMUtil.getCorrespondingPath(this.formInstanceData.getPath(), sandboxName)); - } - else - { - // diff for txt or html content - srcPaths.add(AVMUtil.getCorrespondingPath(this.createdPath, sandboxName)); - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("creating workflow package with " + srcPaths.size() + " files: {"); - for (final String srcPath : srcPaths) - { - LOGGER.debug("-- " + srcPath + ","); - } - LOGGER.debug("}"); - } - - // Create workflow sandbox for workflow package - final SandboxInfo sandboxInfo = SandboxFactory.createWorkflowSandbox(storeId); - - final NodeRef packageNodeRef = - AVMWorkflowUtil.createWorkflowPackage(srcPaths, - sandboxInfo, - path, - avmSubmittedAspect, - this.avmSyncService, - this.avmService, - this.workflowService, - this.nodeService); - - parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef); - parameters.put(WCMWorkflowModel.ASSOC_WEBPROJECT, - this.avmBrowseBean.getWebsite().getNodeRef()); - // TODO: capture label and comment? - parameters.put(WCMWorkflowModel.PROP_LABEL, - MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null - ? this.formInstanceData.getName() - : this.getFileName()); - parameters.put(WCMWorkflowModel.PROP_FROM_PATH, AVMUtil.buildStoreRootPath(sandboxName)); - - // update start task with submit parameters - this.workflowService.updateTask(startTask.id, parameters, null, null); - - // end the start task to trigger the first 'proper' task in the workflow - this.workflowService.endTask(startTask.id, null); - } - } + submitNodes.add(this.avmService.lookup(-1, d.getDestinationPath())); } + this.avmBrowseBean.setNodesForSubmit(submitNodes); + final Map dialogParams = new HashMap(1); + dialogParams.put(SubmitDialog.PARAM_LOAD_SELECTED_NODES_FROM_BROWSE_BEAN, + Boolean.TRUE.toString()); + Application.getDialogManager().setupParameters(dialogParams); + outcome = (outcome + + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + + AlfrescoNavigationHandler.DIALOG_PREFIX + "submitSandboxItems"); } - if (this.formProcessorSession != null) { this.formProcessorSession.destroy(); @@ -450,7 +355,7 @@ public class CreateWebContentWizard extends BaseContentWizard if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null) { - this.formInstanceData = new FormInstanceDataImpl(-1, this.createdPath); + this.formInstanceData = this.formsService.getFormInstanceData(-1, this.createdPath); this.renditions = this.formInstanceData.getRenditions(); if (LOGGER.isDebugEnabled()) LOGGER.debug("reset form instance data " + this.formInstanceData.getName() + @@ -536,16 +441,12 @@ public class CreateWebContentWizard extends BaseContentWizard if (form != null) { - this.formInstanceData = new FormInstanceDataImpl(formInstanceDataNodeRef) - { - @Override - public Form getForm() { return form; } - }; props.clear(); props.put(WCMAppModel.PROP_PARENT_FORM_NAME, form.getName()); props.put(WCMAppModel.PROP_ORIGINAL_PARENT_PATH, cwd); this.nodeService.addAspect(formInstanceDataNodeRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA, props); + this.formInstanceData = this.formsService.getFormInstanceData(formInstanceDataNodeRef); this.renditions = new LinkedList(); for (RenderingEngineTemplate ret : form.getRenderingEngineTemplates()) { @@ -674,6 +575,9 @@ public class CreateWebContentWizard extends BaseContentWizard return this.createMimeTypes; } + /** + * @return the current seleted form's name or null. + */ public String getFormName() { return this.formName; diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java index cccca82ce7..749269097c 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java @@ -86,7 +86,7 @@ public class CreateWebsiteWizard extends BaseWizardBean private static final String WEBAPP_DEFAULT = "ROOT"; - private static Log logger = LogFactory.getLog(CreateWebsiteWizard.class); + protected final static Log LOGGER = LogFactory.getLog(CreateWebsiteWizard.class); protected boolean editMode = false; protected String dnsName; @@ -101,6 +101,7 @@ public class CreateWebsiteWizard extends BaseWizardBean protected WorkflowService workflowService; protected PersonService personService; protected AVMLockingService avmLockingService; + protected FormsService formsService; /** datamodel for table of selected forms */ protected DataModel formsDataModel = null; @@ -170,8 +171,8 @@ public class CreateWebsiteWizard extends BaseWizardBean WCMAppModel.TYPE_AVMWEBFOLDER); NodeRef nodeRef = fileInfo.getNodeRef(); - if (logger.isDebugEnabled()) - logger.debug("Created website folder node with name: " + this.name); + if (LOGGER.isDebugEnabled()) + LOGGER.debug("Created website folder node with name: " + this.name); // TODO: check that this dns is unique by querying existing store properties for a match String avmStore = DNSNameMangler.MakeDNSName(this.dnsName); @@ -384,6 +385,14 @@ public class CreateWebsiteWizard extends BaseWizardBean this.avmLockingService = avmLockingService; } + /** + * @param formsService The FormsService to set. + */ + public void setFormsService(final FormsService formsService) + { + this.formsService = formsService; + } + // ------------------------------------------------------------------------------ // Bean getters and setters @@ -614,7 +623,7 @@ public class CreateWebsiteWizard extends BaseWizardBean */ public List getFormsList() { - Collection
forms = FormsService.getInstance().getForms(); + Collection forms = this.formsService.getForms(); List items = new ArrayList(forms.size()); for (Form form : forms) { diff --git a/source/java/org/alfresco/web/bean/wcm/DeleteFileDialog.java b/source/java/org/alfresco/web/bean/wcm/DeleteFileDialog.java index a60eba05aa..4cf870db1c 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeleteFileDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/DeleteFileDialog.java @@ -51,8 +51,8 @@ public class DeleteFileDialog extends BaseDialogBean protected AVMService avmService; protected AVMBrowseBean avmBrowseBean; - - + protected FormsService formsService; + /** * @param avmBrowseBean The avmBrowseBean to set. */ @@ -68,7 +68,14 @@ public class DeleteFileDialog extends BaseDialogBean { this.avmService = avmService; } - + + /** + * @param formsService The FormsService to set. + */ + public void setFormsService(final FormsService formsService) + { + this.formsService = formsService; + } // ------------------------------------------------------------------------------ // Dialog implementation @@ -79,7 +86,11 @@ public class DeleteFileDialog extends BaseDialogBean { // get the content to delete final AVMNode node = this.avmBrowseBean.getAvmActionNode(); - if (node != null) + if (node == null) + { + logger.warn("WARNING: delete called without a current AVM Node!"); + } + else { if (logger.isDebugEnabled()) logger.debug("Trying to delete AVM node: " + node.getPath()); @@ -88,7 +99,7 @@ public class DeleteFileDialog extends BaseDialogBean { try { - fid = new RenditionImpl(node.getNodeRef()).getPrimaryFormInstanceData(); + fid = this.formsService.getRendition(node.getNodeRef()).getPrimaryFormInstanceData(); } catch (FileNotFoundException fnfe) { @@ -97,7 +108,7 @@ public class DeleteFileDialog extends BaseDialogBean } else if (node.hasAspect(WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) { - fid = new FormInstanceDataImpl(node.getNodeRef()); + fid = this.formsService.getFormInstanceData(node.getNodeRef()); } if (fid != null) { @@ -117,11 +128,6 @@ public class DeleteFileDialog extends BaseDialogBean AVMNodeConverter.SplitBase(node.getPath())[1]); } } - else - { - logger.warn("WARNING: delete called without a current AVM Node!"); - } - return outcome; } @@ -160,7 +166,7 @@ public class DeleteFileDialog extends BaseDialogBean { try { - final FormInstanceData fid = new RenditionImpl(node.getNodeRef()).getPrimaryFormInstanceData(); + final FormInstanceData fid = this.formsService.getRendition(node.getNodeRef()).getPrimaryFormInstanceData(); return MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), "delete_rendition_confirm"), node.getName(), @@ -175,12 +181,11 @@ public class DeleteFileDialog extends BaseDialogBean } else if (node.hasAspect(WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) { - final FormInstanceData fid = new FormInstanceDataImpl(node.getNodeRef()); + final FormInstanceData fid = this.formsService.getFormInstanceData(node.getNodeRef()); return MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), "delete_form_instance_data_confirm"), fid.getName(), fid.getRenditions().size()); - } return MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), "delete_avm_file_confirm"), diff --git a/source/java/org/alfresco/web/bean/wcm/EditAvmFileDialog.java b/source/java/org/alfresco/web/bean/wcm/EditAvmFileDialog.java new file mode 100644 index 0000000000..2adb318079 --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/EditAvmFileDialog.java @@ -0,0 +1,141 @@ +/* + * 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.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.faces.context.FacesContext; +import javax.faces.model.SelectItem; + +import org.alfresco.model.WCMAppModel; +import org.alfresco.repo.avm.AVMNodeConverter; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.web.app.AlfrescoNavigationHandler; +import org.alfresco.web.app.Application; +import org.alfresco.web.app.servlet.DownloadContentServlet; +import org.alfresco.web.bean.dialog.BaseDialogBean; +import org.alfresco.web.bean.repository.Node; +import org.alfresco.web.ui.common.Utils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author arielb + */ +public class EditAvmFileDialog + extends BaseDialogBean +{ + private static final Log LOGGER = LogFactory.getLog(EditAvmFileDialog.class); + + /** AVM service reference */ + protected AVMService avmService; + + /** AVM Browse Bean reference */ + protected AVMBrowseBean avmBrowseBean; + + // ------------------------------------------------------------------------------ + // Bean property getters and setters + + /** + * @param avmService The avmService to set. + */ + public void setAvmService(AVMService avmService) + { + this.avmService = avmService; + } + + /** + * @param avmBrowseBean The AVMBrowseBean to set. + */ + public void setAvmBrowseBean(final AVMBrowseBean avmBrowseBean) + { + this.avmBrowseBean = avmBrowseBean; + } + + /** + * @return Returns the current AVM node context. + */ + public AVMNode getAvmNode() + { + return this.avmBrowseBean.getAvmActionNode(); + } + + /** + * @return Large file icon for current AVM node + */ + public String getFileType32() + { + return Utils.getFileTypeImage(getAvmNode().getName(), false); + } + + /** + * @return Content URL for current AVM node + */ + public String getUrl() + { + return DownloadContentServlet.generateDownloadURL(AVMNodeConverter.ToNodeRef(-1, getAvmNode().getPath()), + getAvmNode().getName()); + } + + // ------------------------------------------------------------------------------ + // Dialog implementation + + @Override + public void init(final Map parameters) + { + super.init(parameters); + + } + + @Override + protected String finishImpl(final FacesContext context, String outcome) + throws Exception + { + AVMNode node = getAvmNode(); + if (node != null) + { + // Possibly notify virt server + AVMUtil.updateVServerWebapp(node.getPath(), false); + outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME; + } + + return outcome; + } + + @Override + public String getContainerTitle() + { + return this.getAvmNode().getName(); + } + + @Override + public String getCancelButtonLabel() + { + return Application.getMessage(FacesContext.getCurrentInstance(), "close"); + } +} \ No newline at end of file diff --git a/source/java/org/alfresco/web/bean/wcm/EditFormWizard.java b/source/java/org/alfresco/web/bean/wcm/EditFormWizard.java index edae99cf3e..7ff5d0d8dc 100644 --- a/source/java/org/alfresco/web/bean/wcm/EditFormWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/EditFormWizard.java @@ -19,7 +19,8 @@ * 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" */ + * http://www.alfresco.com/legal/licensing + */ package org.alfresco.web.bean.wcm; import java.io.Serializable; @@ -80,7 +81,7 @@ public class EditFormWizard throw new IllegalArgumentException("Edit Form wizard requires action node context."); } - final Form form = FormsService.getInstance().getForm(formNodeRef); + final Form form = this.formsService.getForm(formNodeRef); // simple properties this.setFormName(form.getName()); this.setFormTitle(form.getTitle()); @@ -141,7 +142,8 @@ public class EditFormWizard * @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String) */ @Override - protected String finishImpl(FacesContext context, String outcome) + protected String finishImpl(final FacesContext context, + final String outcome) throws Exception { final NodeRef formNodeRef = this.browseBean.getActionSpace().getNodeRef(); @@ -225,7 +227,7 @@ public class EditFormWizard this.saveRenderingEngineTemplate(retd, formNodeRef); } } - return AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME; + return outcome; } /** diff --git a/source/java/org/alfresco/web/bean/wcm/EditWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/EditWebContentWizard.java index 51004b7123..801a8bc041 100644 --- a/source/java/org/alfresco/web/bean/wcm/EditWebContentWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/EditWebContentWizard.java @@ -74,7 +74,6 @@ import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.QuickSort; import org.alfresco.web.forms.Form; import org.alfresco.web.forms.FormInstanceData; -import org.alfresco.web.forms.FormInstanceDataImpl; import org.alfresco.web.forms.FormNotFoundException; import org.alfresco.web.forms.FormProcessor; import org.alfresco.web.forms.FormsService; @@ -113,7 +112,7 @@ public class EditWebContentWizard extends CreateWebContentWizard } LOGGER.debug("path is " + this.avmNode.getPath()); this.createdPath = AVMUtil.getCorrespondingPathInPreviewStore(this.avmNode.getPath()); - this.formInstanceData = new FormInstanceDataImpl(-1, this.createdPath); + this.formInstanceData = this.formsService.getFormInstanceData(-1, this.createdPath); final WebProject webProject = new WebProject(this.createdPath); try { @@ -152,15 +151,8 @@ public class EditWebContentWizard extends CreateWebContentWizard final ContentWriter writer = this.avmService.getContentWriter(this.createdPath); this.content = XMLUtil.toString(this.instanceDataDocument, false); writer.putContent(this.content); - this.formInstanceData = new FormInstanceDataImpl(-1, this.createdPath) - { - @Override - public Form getForm() - throws FormNotFoundException - { - return EditWebContentWizard.this.getForm(); - } - }; + // XXXarielb might not need to do this reload + this.formInstanceData = this.formsService.getFormInstanceData(-1, this.createdPath); final List result = this.formInstanceData.regenerateRenditions(); this.renditions = new LinkedList(); for (FormInstanceData.RegenerateResult rr : result) diff --git a/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java index b74469a635..0ad9243523 100644 --- a/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java @@ -98,7 +98,7 @@ public class EditWebsiteWizard extends CreateWebsiteWizard String name = (String)this.nodeService.getProperty(formRef, WCMAppModel.PROP_FORMNAME); try { - final Form formImpl = FormsService.getInstance().getForm(name); + final Form formImpl = this.formsService.getForm(name); 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)); @@ -147,6 +147,7 @@ public class EditWebsiteWizard extends CreateWebsiteWizard catch (FormNotFoundException fnfe) { //ignore + LOGGER.debug(fnfe.getMessage(), fnfe); } } diff --git a/source/java/org/alfresco/web/bean/wcm/FormDetailsDialog.java b/source/java/org/alfresco/web/bean/wcm/FormDetailsDialog.java index 44d896c855..d085976a16 100644 --- a/source/java/org/alfresco/web/bean/wcm/FormDetailsDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/FormDetailsDialog.java @@ -24,6 +24,7 @@ */ package org.alfresco.web.bean.wcm; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -34,6 +35,7 @@ import javax.faces.model.SelectItem; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.workflow.WorkflowDefinition; import org.alfresco.service.cmr.workflow.WorkflowService; +import org.alfresco.web.app.Application; import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.wcm.CreateWebsiteWizard.FormWrapper; import org.alfresco.web.bean.wcm.CreateWebsiteWizard.WorkflowWrapper; @@ -74,6 +76,14 @@ public class FormDetailsDialog extends BaseDialogBean this.outputPathPattern = null; this.workflowSelectedValue = null; } + + @Override + public String getContainerDescription() + { + return MessageFormat.format(Application.getBundle(FacesContext.getCurrentInstance()).getString("form_template_details_desc"), + this.getActionForm().getName(), + this.websiteWizard.getName()); + } /** * @param avmService The avmService to set. diff --git a/source/java/org/alfresco/web/bean/wcm/FormTemplatesDialog.java b/source/java/org/alfresco/web/bean/wcm/FormTemplatesDialog.java index 07cfdd049f..3534a823df 100644 --- a/source/java/org/alfresco/web/bean/wcm/FormTemplatesDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/FormTemplatesDialog.java @@ -24,6 +24,7 @@ */ package org.alfresco.web.bean.wcm; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -34,6 +35,7 @@ import javax.faces.model.DataModel; import javax.faces.model.ListDataModel; import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.web.app.Application; import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.wcm.CreateWebsiteWizard.FormWrapper; import org.alfresco.web.bean.wcm.CreateWebsiteWizard.PresentationTemplate; @@ -96,6 +98,14 @@ public class FormTemplatesDialog extends BaseDialogBean this.templates = new ArrayList(getActionForm().getTemplates().size()); this.templates.addAll(getActionForm().getTemplates()); } + + @Override + public String getContainerDescription() + { + return MessageFormat.format(Application.getBundle(FacesContext.getCurrentInstance()).getString("form_template_templates_desc"), + this.getActionForm().getName(), + this.websiteWizard.getName()); + } /** * @return an object representing the form for the current action diff --git a/source/java/org/alfresco/web/bean/wcm/ManageChangeRequestTaskDialog.java b/source/java/org/alfresco/web/bean/wcm/ManageChangeRequestTaskDialog.java index 3cfe68616a..2303813323 100644 --- a/source/java/org/alfresco/web/bean/wcm/ManageChangeRequestTaskDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/ManageChangeRequestTaskDialog.java @@ -234,9 +234,10 @@ public class ManageChangeRequestTaskDialog extends ManageTaskDialog Application.getCurrentUser(context).getUserName()); // setup the context for the submit dialog and initialise it - this.avmBrowseBean.setExpiredNodes(submitNodes); + this.avmBrowseBean.setNodesForSubmit(submitNodes); Map dialogParams = new HashMap(1); - dialogParams.put(SubmitDialog.PARAM_STARTED_FROM_WORKFLOW, Boolean.TRUE.toString()); + dialogParams.put(SubmitDialog.PARAM_LOAD_SELECTED_NODES_FROM_BROWSE_BEAN, + Boolean.TRUE.toString()); Application.getDialogManager().setupParameters(dialogParams); } } diff --git a/source/java/org/alfresco/web/bean/wcm/PromptForWebFormDialog.java b/source/java/org/alfresco/web/bean/wcm/PromptForWebFormDialog.java new file mode 100644 index 0000000000..af3366be0d --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/PromptForWebFormDialog.java @@ -0,0 +1,236 @@ +/* + * 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.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.faces.context.FacesContext; +import javax.faces.model.SelectItem; + +import org.alfresco.model.WCMAppModel; +import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.web.app.AlfrescoNavigationHandler; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.dialog.BaseDialogBean; +import org.alfresco.web.bean.repository.Node; +import org.alfresco.web.data.IDataContainer; +import org.alfresco.web.data.QuickSort; +import org.alfresco.web.forms.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author arielb + */ +public class PromptForWebFormDialog + extends BaseDialogBean +{ + private static final Log LOGGER = LogFactory.getLog(PromptForWebFormDialog.class); + + /** AVM service reference */ + protected AVMService avmService; + + /** AVM Browse Bean reference */ + protected AVMBrowseBean avmBrowseBean; + + /** The FormsService reference */ + protected FormsService formsService; + + private transient List formChoices; + + private String formName; + private String cancelOutcome; + private String finishOutcome; + + // ------------------------------------------------------------------------------ + // Bean property getters and setters + + /** + * @param avmService The avmService to set. + */ + public void setAvmService(AVMService avmService) + { + this.avmService = avmService; + } + + /** + * @param avmBrowseBean The AVMBrowseBean to set. + */ + public void setAvmBrowseBean(final AVMBrowseBean avmBrowseBean) + { + this.avmBrowseBean = avmBrowseBean; + } + /** + * @param formsService The FormsService to set. + */ + public void setFormsService(final FormsService formsService) + { + this.formsService = formsService; + } + + /** + * @return Returns the current AVM node context. + */ + public AVMNode getAvmNode() + { + return this.avmBrowseBean.getAvmActionNode(); + } + + // ------------------------------------------------------------------------------ + // Dialog implementation + + @Override + public void init(final Map parameters) + { + super.init(parameters); + this.cancelOutcome = (this.parameters.containsKey("cancelOutcome") + ? this.parameters.get("cancelOutcome") + : "dialog:editAvmFile"); + this.finishOutcome = (this.parameters.containsKey("finishOutcome") + ? this.parameters.get("finishOutcome") + : "wizard:editWebContent"); + this.formName = null; + this.formChoices = null; + final String avmPath = this.getAvmNode().getPath(); + if (this.avmService.hasAspect(this.getAvmNode().getVersion(), + avmPath, + WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) + { + // build a status message if this is an error case + final FormInstanceData fid = this.formsService.getFormInstanceData(this.getAvmNode().getVersion(), avmPath); + try + { + final Form f = fid.getForm(); + this.formName = f.getName(); + // strange case... this should throw an exception if we're here... + LOGGER.debug(avmPath + ".getForm() did not throw a form not found. why are we here?"); + } + catch (final FormNotFoundException fnfe) + { + String msg = (fnfe.getWebProject() != null + ? "prompt_for_web_form_form_not_found_error_in_web_project" + : "prompt_for_web_form_form_not_found_error"); + msg = Application.getMessage(FacesContext.getCurrentInstance(), msg); + msg = (fnfe.getWebProject() != null + ? MessageFormat.format(msg, + fnfe.getFormName(), + fid.getName(), + fnfe.getWebProject().getName()) + : MessageFormat.format(msg, + fnfe.getFormName(), + fid.getName())); + this.avmBrowseBean.displayStatusMessage(FacesContext.getCurrentInstance(), msg); + } + } + } + + @Override + protected String finishImpl(final FacesContext context, String outcome) + throws Exception + { + LOGGER.debug("configuring " + this.getAvmNode().getPath() + + " to use form " + this.getFormName()); + + this.avmService.setNodeProperty(this.getAvmNode().getPath(), + WCMAppModel.PROP_PARENT_FORM_NAME, + new PropertyValue(DataTypeDefinition.TEXT, this.getFormName())); + + if (!this.avmService.hasAspect(this.getAvmNode().getVersion(), + this.getAvmNode().getPath(), + WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) + { + this.avmService.addAspect(this.getAvmNode().getPath(), WCMAppModel.ASPECT_FORM_INSTANCE_DATA); + } + return outcome; + } + + @Override + public boolean getFinishButtonDisabled() + { + return this.getFormChoices().size() == 0; + } + + @Override + protected String getDefaultCancelOutcome() + { + return (super.getDefaultCancelOutcome() + + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + + this.cancelOutcome); + } + + @Override + protected String getDefaultFinishOutcome() + { + return (super.getDefaultFinishOutcome() + + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + + this.finishOutcome); + } + + // ------------------------------------------------------------------------------ + // Bean Getters and Setters + + /** + * @return the available forms from this web project that can be created. + */ + public List getFormChoices() + { + if (this.formChoices == null) + { + final WebProject wp = new WebProject(this.getAvmNode().getPath()); + final List forms = wp.getForms(); + this.formChoices = new ArrayList(forms.size()); + for (final Form f : forms) + { + this.formChoices.add(new SelectItem(f.getName(), f.getTitle())); + } + + final QuickSort sorter = new QuickSort(this.formChoices, "label", true, IDataContainer.SORT_CASEINSENSITIVE); + sorter.sort(); + + } + return this.formChoices; + } + + /** + * @return the currently selected form + */ + public String getFormName() + { + return this.formName; + } + + /** + * @param form Sets the currently selected form + */ + public void setFormName(final String formName) + { + this.formName = formName; + } +} diff --git a/source/java/org/alfresco/web/bean/wcm/RegenerateRenditionsWizard.java b/source/java/org/alfresco/web/bean/wcm/RegenerateRenditionsWizard.java index 1961e926a8..5fd2c6a8f5 100644 --- a/source/java/org/alfresco/web/bean/wcm/RegenerateRenditionsWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/RegenerateRenditionsWizard.java @@ -89,6 +89,7 @@ public class RegenerateRenditionsWizard private AVMSyncService avmSyncService; private ContentService contentService; private SearchService searchService; + private FormsService formsService; private WebProject selectedWebProject; private String[] selectedForms; private String[] selectedRenderingEngineTemplates; @@ -394,6 +395,14 @@ public class RegenerateRenditionsWizard { this.searchService = searchService; } + + /** + * @param formsService The FormsService to set. + */ + public void setFormsService(final FormsService formsService) + { + this.formsService = formsService; + } // ------------------------------------------------------------------------------ // Helper Methods @@ -418,24 +427,7 @@ public class RegenerateRenditionsWizard { final String avmPath = AVMNodeConverter.ToAVMVersionPath(row.getNodeRef()).getSecond(); final String previewAvmPath = AVMUtil.getCorrespondingPathInPreviewStore(avmPath); - final FormInstanceDataImpl fid = new FormInstanceDataImpl(-1, previewAvmPath) - { - @Override - public Form getForm() - throws FormNotFoundException - { - final Form f = super.getForm(); - try - { - return RegenerateRenditionsWizard.this.selectedWebProject.getForm(f.getName()); - } - catch (FormNotFoundException fnfe) - { - throw new FormNotFoundException(f, RegenerateRenditionsWizard.this.selectedWebProject, this); - } - } - }; - result.add(fid); + result.add(this.formsService.getFormInstanceData(-1, previewAvmPath)); } return result; } @@ -454,13 +446,12 @@ public class RegenerateRenditionsWizard LOGGER.debug("running query " + query); sp.setQuery(query.toString()); final ResultSet rs = this.searchService.query(sp); - final List result = new ArrayList(rs.length()); + final List result = new ArrayList(rs.length()); for (final ResultSetRow row : rs) { final String avmPath = AVMNodeConverter.ToAVMVersionPath(row.getNodeRef()).getSecond(); final String previewAvmPath = AVMUtil.getCorrespondingPathInPreviewStore(avmPath); - final Rendition r = new RenditionImpl(-1, previewAvmPath); - result.add(r); + result.add(this.formsService.getRendition(-1, previewAvmPath)); } return result; } @@ -540,24 +531,7 @@ public class RegenerateRenditionsWizard if (this.regenerateScope.equals(REGENERATE_SCOPE_ALL) || this.regenerateScope.equals(REGENERATE_SCOPE_FORM)) { - final FormInstanceDataImpl fid = new FormInstanceDataImpl(-1, previewAvmPath) - { - @Override - public Form getForm() - throws FormNotFoundException - { - final Form f = super.getForm(); - try - { - return RegenerateRenditionsWizard.this.selectedWebProject.getForm(f.getName()); - } - catch (FormNotFoundException fnfe) - { - throw new FormNotFoundException(f, RegenerateRenditionsWizard.this.selectedWebProject, this); - } - } - }; - + final FormInstanceData fid = this.formsService.getFormInstanceData(-1, previewAvmPath); try { final List regenResults = fid.regenerateRenditions(); @@ -582,7 +556,7 @@ public class RegenerateRenditionsWizard } else { - final Rendition r = new RenditionImpl(-1, previewAvmPath); + final Rendition r = this.formsService.getRendition(-1, previewAvmPath); try { r.regenerate(); diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java index 03dae31deb..44cc146115 100644 --- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java @@ -75,7 +75,7 @@ import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.config.ClientConfigElement; import org.alfresco.web.forms.FormInstanceData; -import org.alfresco.web.forms.FormInstanceDataImpl; +import org.alfresco.web.forms.FormsService; import org.alfresco.web.forms.Rendition; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.UIListItem; @@ -89,7 +89,7 @@ import org.apache.commons.logging.LogFactory; */ public class SubmitDialog extends BaseDialogBean { - public static final String PARAM_STARTED_FROM_WORKFLOW = "startedFromWorkflow"; + public static final String PARAM_LOAD_SELECTED_NODES_FROM_BROWSE_BEAN = "loadSelectedNodesFromBrowseBean"; private static final String SPACE_ICON = "/images/icons/" + BrowseBean.SPACE_SMALL_DEFAULT + ".gif"; private static final String MSG_DELETED_ITEM = "avm_node_deleted"; private static final String MSG_ERR_WORKFLOW_CONFIG = "submit_workflow_config_error"; @@ -98,7 +98,7 @@ public class SubmitDialog extends BaseDialogBean private String label; private String[] workflowSelectedValue; private boolean enteringExpireDate = false; - private boolean startedFromWorkflow = false; + private boolean loadSelectedNodesFromBrowseBean = false; private boolean validateLinks = true; private Date defaultExpireDate; private Date launchDate; @@ -106,7 +106,7 @@ public class SubmitDialog extends BaseDialogBean private List submitItems; private List warningItems; private HashSet workflows; - private Map formWorkflowMap; +// private Map formWorkflowMap; private Map expirationDates; private List workflowItems; private Map workflowParams; @@ -130,11 +130,12 @@ public class SubmitDialog extends BaseDialogBean protected AVMSyncService avmSyncService; protected AVMLockingService avmLockingService; protected NameMatcher nameMatcher; + protected FormsService formsService; /** Current workflow for dialog context */ protected WorkflowConfiguration actionWorkflow = null; - private static Log logger = LogFactory.getLog(SubmitDialog.class); + private static final Log LOGGER = LogFactory.getLog(SubmitDialog.class); /** * @param avmService The AVM Service to set. @@ -192,6 +193,14 @@ public class SubmitDialog extends BaseDialogBean this.nameMatcher = nameMatcher; } + /** + * @param formsService The FormsService to set. + */ + public void setFormsService(final FormsService formsService) + { + this.formsService = formsService; + } + /** * @see org.alfresco.web.bean.dialog.BaseDialogBean#init(java.util.Map) */ @@ -216,29 +225,7 @@ public class SubmitDialog extends BaseDialogBean this.virtUpdatePath = null; // determine if the dialog has been started from a workflow - Boolean bool = new Boolean(this.parameters.get(PARAM_STARTED_FROM_WORKFLOW)); - this.startedFromWorkflow = bool; - - // walk all the web forms attached the website, and lookup the workflow defaults for each - NodeRef websiteRef = this.avmBrowseBean.getWebsite().getNodeRef(); - List webFormRefs = this.nodeService.getChildAssocs( - websiteRef, WCMAppModel.ASSOC_WEBFORM, RegexQNamePattern.MATCH_ALL); - this.formWorkflowMap = new HashMap(webFormRefs.size(), 1.0f); - for (ChildAssociationRef ref : webFormRefs) - { - NodeRef webFormRef = ref.getChildRef(); - String form = (String)this.nodeService.getProperty(webFormRef, WCMAppModel.PROP_FORMNAME); - List wfRefs = this.nodeService.getChildAssocs( - webFormRef, WCMAppModel.TYPE_WORKFLOW_DEFAULTS, RegexQNamePattern.MATCH_ALL); - if (wfRefs.size() == 1) - { - NodeRef wfDefaultsRef = wfRefs.get(0).getChildRef(); - String wfName = (String)this.nodeService.getProperty(wfDefaultsRef, WCMAppModel.PROP_WORKFLOW_NAME); - Map params = (Map)AVMWorkflowUtil.deserializeWorkflowParams( - wfDefaultsRef); - this.formWorkflowMap.put(form, new FormWorkflowWrapper(wfName, params)); - } - } + this.loadSelectedNodesFromBrowseBean = Boolean.valueOf(this.parameters.get(PARAM_LOAD_SELECTED_NODES_FROM_BROWSE_BEAN)); } @Override @@ -637,7 +624,7 @@ public class SubmitDialog extends BaseDialogBean catch (Throwable e) { // not much we can do now, just log the error to inform admins - logger.error("Failed to cleanup workflow sandbox after workflow failure", e); + LOGGER.error("Failed to cleanup workflow sandbox after workflow failure", e); } } @@ -873,7 +860,7 @@ public class SubmitDialog extends BaseDialogBean // add first workflow as default selection if (workflowSelectedValue == null) { - workflowSelectedValue = new String[]{workflowDef.getName()}; + workflowSelectedValue = new String[]{ workflowDef.getName() }; } } this.workflowItems = items; @@ -946,132 +933,110 @@ public class SubmitDialog extends BaseDialogBean tx.begin(); List selected; - if (this.startedFromWorkflow) + if (this.loadSelectedNodesFromBrowseBean) { // if the dialog was started from a workflow the AVM browse bean should // have the list of nodes that need submitting - selected = this.avmBrowseBean.getExpiredNodes(); + selected = this.avmBrowseBean.getNodesForSubmit(); + } + // if the dialog was started from the UI determine what nodes the user selected to submit + else if (this.avmBrowseBean.getAllItemsAction()) + { + String webapp = this.avmBrowseBean.getWebapp(); + String userStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getSandbox(), webapp); + String stagingStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getStagingStore(), webapp); + List diffs = this.avmSyncService.compare(-1, userStore, -1, stagingStore, nameMatcher); + selected = new ArrayList(diffs.size()); + for (AVMDifference diff : diffs) + { + selected.add(this.avmService.lookup(-1, diff.getSourcePath(), true)); + } + } + else if (this.avmBrowseBean.getAvmActionNode() == null) + { + // multiple items selected + selected = this.avmBrowseBean.getSelectedSandboxItems(); } else { - // if the dialog was started from the UI determine what nodes the user selected to submit - if (this.avmBrowseBean.getAllItemsAction()) - { - String webapp = this.avmBrowseBean.getWebapp(); - String userStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getSandbox(), webapp); - String stagingStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getStagingStore(), webapp); - List diffs = this.avmSyncService.compare(-1, userStore, -1, stagingStore, nameMatcher); - selected = new ArrayList(diffs.size()); - for (AVMDifference diff : diffs) - { - AVMNodeDescriptor node = this.avmService.lookup(-1, diff.getSourcePath(), true); - selected.add(node); - } - } - else if (this.avmBrowseBean.getAvmActionNode() == null) - { - // multiple items selected - selected = this.avmBrowseBean.getSelectedSandboxItems(); - } - else - { - // single item selected - AVMNodeDescriptor node = - this.avmService.lookup(-1, this.avmBrowseBean.getAvmActionNode().getPath(), true); - selected = new ArrayList(1); - selected.add(node); - } + // single item selected + selected = new ArrayList(1); + selected.add(this.avmService.lookup(-1, this.avmBrowseBean.getAvmActionNode().getPath(), true)); } - if (selected != null) + if (selected == null) + { + this.submitItems = Collections.emptyList(); + this.warningItems = Collections.emptyList(); + } + else { Set submittedPaths = new HashSet(selected.size()); this.submitItems = new ArrayList(selected.size()); this.warningItems = new ArrayList(selected.size() >> 1); for (AVMNodeDescriptor node : selected) { - if (this.avmService.hasAspect(-1, node.getPath(), AVMSubmittedAspect.ASPECT) == false) + if (this.avmService.hasAspect(-1, node.getPath(), AVMSubmittedAspect.ASPECT)) { - NodeRef ref = AVMNodeConverter.ToNodeRef(-1, node.getPath()); - if (submittedPaths.contains(node.getPath()) == false) - { - if (node.isDeleted() == false) - { - // lookup if this item was created via a form - then lookup the workflow defaults - // for that form and store into the list of available workflows - if (this.nodeService.hasAspect(ref, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) - { - NodeRef formInstanceDataRef = ref; - - // check if this is a rendition - as they also have the forminstancedata aspect - if (this.nodeService.hasAspect(ref, WCMAppModel.ASPECT_RENDITION)) - { - // found a generated rendition asset - locate the parent form instance data file - // and use this to find all generated assets that are appropriate - // NOTE: this path value is store relative - String strFormInstance = (String)this.nodeService.getProperty( - ref, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA); - strFormInstance = this.avmBrowseBean.getSandbox() + ':' + strFormInstance; - formInstanceDataRef = AVMNodeConverter.ToNodeRef(-1, strFormInstance); - } - - // add the form instance data file to the list for submission - AVMNodeDescriptor formInstanceNode = this.avmService.lookup( - -1, AVMNodeConverter.ToAVMVersionPath(formInstanceDataRef).getSecond()); - if (submittedPaths.contains(formInstanceNode.getPath()) == false) - { - this.submitItems.add(new ItemWrapper(formInstanceNode)); - submittedPaths.add(formInstanceNode.getPath()); - } - - // locate renditions for this form instance data file and add to list for submission - FormInstanceData formImpl = new FormInstanceDataImpl(formInstanceDataRef); - for (Rendition rendition : formImpl.getRenditions()) - { - String renditionPath = rendition.getPath(); - if (submittedPaths.contains(renditionPath) == false) - { - AVMNodeDescriptor renditionNode = this.avmService.lookup(-1, renditionPath); - this.submitItems.add(new ItemWrapper(renditionNode)); - submittedPaths.add(renditionPath); - } - } - - // lookup the associated Form workflow from the parent form property - String formName = (String)this.nodeService.getProperty( - formInstanceDataRef, WCMAppModel.PROP_PARENT_FORM_NAME); - FormWorkflowWrapper wrapper = this.formWorkflowMap.get(formName); - if (wrapper != null) - { - // found a workflow attached to the form - this.workflows.add(wrapper); - } - } - else - { - this.submitItems.add(new ItemWrapper(node)); - submittedPaths.add(node.getPath()); - } - } - else - { - // found a deleted node for submit - this.submitItems.add(new ItemWrapper(node)); - submittedPaths.add(node.getPath()); - } - } + this.warningItems.add(new ItemWrapper(node)); + continue; + } + NodeRef ref = AVMNodeConverter.ToNodeRef(-1, node.getPath()); + if (submittedPaths.contains(node.getPath())) + { + continue; + } + if (node.isDeleted()) + { + // found a deleted node for submit + this.submitItems.add(new ItemWrapper(node)); + submittedPaths.add(node.getPath()); + } + // lookup if this item was created via a form - then lookup the workflow defaults + // for that form and store into the list of available workflows + else if (! this.nodeService.hasAspect(ref, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) + { + this.submitItems.add(new ItemWrapper(node)); + submittedPaths.add(node.getPath()); } else { - this.warningItems.add(new ItemWrapper(node)); + FormInstanceData fid = null; + // check if this is a rendition - as they also have the forminstancedata aspect + if (this.nodeService.hasAspect(ref, WCMAppModel.ASPECT_RENDITION)) + { + // found a generated rendition asset - locate the parent form instance data file + // and use this to find all generated assets that are appropriate + // NOTE: this path value is store relative + fid = this.formsService.getRendition(ref).getPrimaryFormInstanceData(); + } + else + { + fid = this.formsService.getFormInstanceData(ref); + } + + // add the form instance data file to the list for submission + if (!submittedPaths.contains(fid.getPath())) + { + this.submitItems.add(new ItemWrapper(this.avmService.lookup(-1, fid.getPath()))); + submittedPaths.add(fid.getPath()); + } + + // locate renditions for this form instance data file and add to list for submission + for (final Rendition rendition : fid.getRenditions()) + { + final String renditionPath = rendition.getPath(); + if (!submittedPaths.contains(renditionPath)) + { + this.submitItems.add(new ItemWrapper(this.avmService.lookup(-1, renditionPath))); + submittedPaths.add(renditionPath); + } + } + this.workflows.add(new FormWorkflowWrapper(fid.getForm().getDefaultWorkflow().getName(), + fid.getForm().getDefaultWorkflowParameters())); } } } - else - { - this.submitItems = Collections.emptyList(); - this.warningItems = Collections.emptyList(); - } tx.commit(); } @@ -1092,22 +1057,23 @@ public class SubmitDialog extends BaseDialogBean // if an expiration date has been set for this item we need to // add the expires aspect and the date supplied Date expirationDate = this.expirationDates.get(srcPath); - if (expirationDate != null) + if (expirationDate == null) { - // make sure the aspect is present - if (this.avmService.hasAspect(-1, srcPath, WCMAppModel.ASPECT_EXPIRES) == false) - { - this.avmService.addAspect(srcPath, WCMAppModel.ASPECT_EXPIRES); - } - - // set the expiration date - this.avmService.setNodeProperty(srcPath, WCMAppModel.PROP_EXPIRATIONDATE, - new PropertyValue(DataTypeDefinition.DATETIME, expirationDate)); - - if (logger.isDebugEnabled()) - logger.debug("Set expiration date of " + expirationDate + - " for " + srcPath); + return; } + // make sure the aspect is present + if (this.avmService.hasAspect(-1, srcPath, WCMAppModel.ASPECT_EXPIRES) == false) + { + this.avmService.addAspect(srcPath, WCMAppModel.ASPECT_EXPIRES); + } + + // set the expiration date + this.avmService.setNodeProperty(srcPath, WCMAppModel.PROP_EXPIRATIONDATE, + new PropertyValue(DataTypeDefinition.DATETIME, expirationDate)); + + if (LOGGER.isDebugEnabled()) + LOGGER.debug("Set expiration date of " + expirationDate + + " for " + srcPath); } /** @@ -1115,15 +1081,16 @@ public class SubmitDialog extends BaseDialogBean */ public void setupConfigureWorkflow(ActionEvent event) { - if (this.workflowSelectedValue != null) + if (this.workflowSelectedValue == null) { - String workflowName = this.workflowSelectedValue[0]; - for (WorkflowConfiguration wrapper : this.workflows) + return; + } + String workflowName = this.workflowSelectedValue[0]; + for (WorkflowConfiguration wrapper : this.workflows) + { + if (wrapper.getName().equals(workflowName)) { - if (wrapper.getName().equals(workflowName)) - { - setActionWorkflow(wrapper); - } + setActionWorkflow(wrapper); } } } @@ -1151,8 +1118,8 @@ public class SubmitDialog extends BaseDialogBean */ public void applyDefaultExpireDateToAll(ActionEvent event) { - if (logger.isDebugEnabled()) - logger.debug("applying default expiration date of " + this.defaultExpireDate + " to all modified items"); + if (LOGGER.isDebugEnabled()) + LOGGER.debug("applying default expiration date of " + this.defaultExpireDate + " to all modified items"); List items = this.getSubmitItems(); for (ItemWrapper item : items) @@ -1241,14 +1208,8 @@ public class SubmitDialog extends BaseDialogBean boolean matchesPath(String path) { - if (filenamePattern != null) - { - return filenamePattern.matcher(path).matches(); - } - else - { - return false; - } + return (filenamePattern != null && + filenamePattern.matcher(path).matches()); } @Override @@ -1260,14 +1221,8 @@ public class SubmitDialog extends BaseDialogBean @Override public boolean equals(Object obj) { - if (obj instanceof FormWorkflowWrapper) - { - return this.name.equals( ((FormWorkflowWrapper)obj).name ); - } - else - { - return false; - } + return (obj instanceof FormWorkflowWrapper && + this.name.equals(((FormWorkflowWrapper)obj).name)); } } @@ -1376,14 +1331,8 @@ public class SubmitDialog extends BaseDialogBean @Override public boolean equals(Object obj) { - if (obj instanceof ItemWrapper) - { - return ((ItemWrapper)obj).descriptor.getPath().equals(descriptor.getPath()); - } - else - { - return false; - } + return (obj instanceof ItemWrapper && + ((ItemWrapper)obj).descriptor.getPath().equals(descriptor.getPath())); } @Override diff --git a/source/java/org/alfresco/web/bean/wcm/WebProject.java b/source/java/org/alfresco/web/bean/wcm/WebProject.java index 7829c7bd41..2c95611b0a 100644 --- a/source/java/org/alfresco/web/bean/wcm/WebProject.java +++ b/source/java/org/alfresco/web/bean/wcm/WebProject.java @@ -51,6 +51,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.web.app.Application; +import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.User; import org.alfresco.web.data.IDataContainer; @@ -85,9 +86,11 @@ public class WebProject private Form baseForm; private NodeRef defaultWorkflowNodeRef; - private FormWrapper(final Form form, final NodeRef formNodeRef) + private FormWrapper(final Form form, + final NodeRef formNodeRef, + final FormsService formsService) { - super(((FormImpl)form).getNodeRef()); + super(((FormImpl)form).getNodeRef(), formsService); this.formNodeRef = formNodeRef; } @@ -160,7 +163,8 @@ public class WebProject allRets.get(renderingEngineTemplateName); result.put(ret.getName(), new RenderingEngineTemplateImpl(ret.getNodeRef(), - ret.getRenditionPropertiesNodeRef()) + ret.getRenditionPropertiesNodeRef(), + this.formsService) { @Override public String getOutputPathPattern() @@ -308,8 +312,14 @@ public class WebProject throw new NullPointerException(); } final Form result = this.getFormsImpl().get(name); - if (result == null) + if (result == null || !name.equals(result.getName())) { + if (result != null) + { + LOGGER.debug("removing " + name + + " from cache as it doesn't match mapped form " + result.getName()); + this.getFormsImpl().remove(name); + } throw new FormNotFoundException(name, this); } return result; @@ -420,7 +430,7 @@ public class WebProject { final ServiceRegistry serviceRegistry = this.getServiceRegistry(); final NodeService nodeService = serviceRegistry.getNodeService(); - final FormsService formsService = FormsService.getInstance(); + final FormsService formsService = WebProject.getFormsService(); final List formRefs = nodeService.getChildAssocs(this.nodeRef, WCMAppModel.ASSOC_WEBFORM, @@ -433,16 +443,23 @@ public class WebProject try { final Form baseForm = formsService.getForm(formName); - result.put(formName, new FormWrapper(baseForm, ref.getChildRef())); + result.put(formName, new FormWrapper(baseForm, ref.getChildRef(), formsService)); } catch (FormNotFoundException fnfe) { - LOGGER.debug(fnfe); + LOGGER.debug("got exception " + fnfe.getMessage() + + " while loading web forms for project " + this.getName()); } } return result; } + private static FormsService getFormsService() + { + return (FormsService)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), + "FormsService"); + } + private static ServiceRegistry getServiceRegistry() { final FacesContext fc = FacesContext.getCurrentInstance(); diff --git a/source/java/org/alfresco/web/forms/FormImpl.java b/source/java/org/alfresco/web/forms/FormImpl.java index 722b2e6e30..85768aac36 100644 --- a/source/java/org/alfresco/web/forms/FormImpl.java +++ b/source/java/org/alfresco/web/forms/FormImpl.java @@ -64,6 +64,7 @@ public class FormImpl private static final Log LOGGER = LogFactory.getLog(FormImpl.class); private final NodeRef folderNodeRef; + protected final FormsService formsService; private transient Map renderingEngineTemplates; private final static LinkedList PROCESSORS = @@ -73,9 +74,25 @@ public class FormImpl FormImpl.PROCESSORS.add(new XFormsProcessor()); } - public FormImpl(final NodeRef folderNodeRef) + protected FormImpl(final NodeRef folderNodeRef, + final FormsService formsService) { + if (folderNodeRef == null) + { + throw new NullPointerException(); + } + if (formsService == null) + { + throw new NullPointerException(); + } + final NodeService nodeService = this.getServiceRegistry().getNodeService(); + if (!nodeService.hasAspect(folderNodeRef, WCMAppModel.ASPECT_FORM)) + { + throw new IllegalArgumentException("node " + folderNodeRef + + " does not have aspect " + WCMAppModel.ASPECT_FORM); + } this.folderNodeRef = folderNodeRef; + this.formsService = formsService; } public String getName() @@ -304,7 +321,7 @@ public class FormImpl final NodeRef renditionPropertiesNodeRef = assoc2.getChildRef(); final RenderingEngineTemplate ret = - new RenderingEngineTemplateImpl(retNodeRef, renditionPropertiesNodeRef); + new RenderingEngineTemplateImpl(retNodeRef, renditionPropertiesNodeRef, this.formsService); LOGGER.debug("loaded rendering engine template " + ret); result.put(ret.getName(), ret); } diff --git a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java index d6eb849f0a..867cba0c13 100644 --- a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java +++ b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java @@ -48,26 +48,41 @@ import org.xml.sax.SAXException; * * @author Ariel Backenroth */ -public class FormInstanceDataImpl +/* package */ class FormInstanceDataImpl implements FormInstanceData { private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class); private final NodeRef nodeRef; + private final FormsService formsService; - public FormInstanceDataImpl(final NodeRef nodeRef) + /* package */ FormInstanceDataImpl(final NodeRef nodeRef, + final FormsService formsService) { if (nodeRef == null) { throw new NullPointerException(); } + if (formsService == null) + { + throw new NullPointerException(); + } + final NodeService nodeService = this.getServiceRegistry().getNodeService(); + if (!nodeService.hasAspect(nodeRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) + { + throw new IllegalArgumentException("node " + nodeRef + + " does not have aspect " + WCMAppModel.ASPECT_FORM_INSTANCE_DATA); + } this.nodeRef = nodeRef; + this.formsService = formsService; } - public FormInstanceDataImpl(final int version, final String avmPath) + /* package */ FormInstanceDataImpl(final int version, + final String avmPath, + final FormsService formsService) { - this(AVMNodeConverter.ToNodeRef(version, avmPath)); + this(AVMNodeConverter.ToNodeRef(version, avmPath), formsService); } /** the name of this rendition */ @@ -106,7 +121,7 @@ public class FormInstanceDataImpl final String parentFormName = this.getParentFormName(); try { - return FormsService.getInstance().getForm(parentFormName); + return this.formsService.getForm(parentFormName); } catch (FormNotFoundException fnfe) { @@ -194,7 +209,8 @@ public class FormInstanceDataImpl { if (avmService.lookup(-1, storeName + ':' + (String)path) != null) { - final Rendition r = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, storeName + ':' + (String)path)); + final Rendition r = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, storeName + ':' + (String)path), + this.formsService); if (r.getRenderingEngineTemplate() != null) { result.add(r); diff --git a/source/java/org/alfresco/web/forms/FormNotFoundException.java b/source/java/org/alfresco/web/forms/FormNotFoundException.java index 68b5735060..4f3f63c6e0 100644 --- a/source/java/org/alfresco/web/forms/FormNotFoundException.java +++ b/source/java/org/alfresco/web/forms/FormNotFoundException.java @@ -107,4 +107,14 @@ public class FormNotFoundException this.webProject = webProject; this.fid = fid; } + + public String getFormName() + { + return this.formName; + } + + public WebProject getWebProject() + { + return this.webProject; + } } diff --git a/source/java/org/alfresco/web/forms/FormsService.java b/source/java/org/alfresco/web/forms/FormsService.java index 9dbed72eb7..4f3053cee9 100644 --- a/source/java/org/alfresco/web/forms/FormsService.java +++ b/source/java/org/alfresco/web/forms/FormsService.java @@ -19,7 +19,8 @@ * 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" */ + * http://www.alfresco.com/legal/licensing + */ package org.alfresco.web.forms; import java.io.*; @@ -58,6 +59,7 @@ import org.alfresco.util.ISO9075; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.wcm.AVMUtil; +import org.alfresco.web.bean.wcm.WebProject; import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.QuickSort; import org.apache.commons.logging.Log; @@ -76,10 +78,6 @@ public final class FormsService { private static final Log LOGGER = LogFactory.getLog(FormsService.class); - /** the single instance initialized using spring */ - private static FormsService INSTANCE; - - private static final RenderingEngine[] RENDERING_ENGINES = new RenderingEngine[] { new FreeMarkerRenderingEngine(), @@ -104,16 +102,8 @@ public final class FormsService this.nodeService = nodeService; this.namespaceService = namespaceService; this.searchService = searchService; - if (INSTANCE == null) - INSTANCE = this; } - /** Provides the forms service instance, loads config if necessary */ - public static FormsService getInstance() - { - return FormsService.INSTANCE; - } - /** * Provides all registered rendering engines. */ @@ -213,24 +203,9 @@ public final class FormsService public Form getForm(final String name) throws FormNotFoundException { - final SearchParameters sp = new SearchParameters(); - sp.addStore(Repository.getStoreRef()); - sp.setLanguage(SearchService.LANGUAGE_LUCENE); - sp.setQuery("ASPECT:\"" + WCMAppModel.ASPECT_FORM + - "\" AND QNAME:\"cm:" + ISO9075.encode(QName.createValidLocalName(name)) + "\""); - if (LOGGER.isDebugEnabled()) - LOGGER.debug("running query [" + sp.getQuery() + "]"); - final ResultSet rs = this.searchService.query(sp); - NodeRef result = null; - for (ResultSetRow row : rs) - { - final NodeRef nr = row.getNodeRef(); - if (this.nodeService.getProperty(nr, ContentModel.PROP_NAME).equals(name)) - { - result = nr; - break; - } - } + final NodeRef result = this.nodeService.getChildByName(this.getContentFormsNodeRef(), + ContentModel.ASSOC_CONTAINS, + name); if (result == null) { throw new FormNotFoundException(name); @@ -251,9 +226,47 @@ public final class FormsService { throw new IllegalArgumentException("node " + nodeRef + " is not a form"); } - final Form result = new FormImpl(nodeRef); + final Form result = new FormImpl(nodeRef, this); if (LOGGER.isDebugEnabled()) LOGGER.debug("loaded form " + result + " for noderef " + nodeRef); return result; } + + public FormInstanceData getFormInstanceData(final int version, final String avmPath) + { + return this.getFormInstanceData(AVMNodeConverter.ToNodeRef(version, avmPath)); + } + + public FormInstanceData getFormInstanceData(final NodeRef nodeRef) + { + final String avmPath = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(); + final WebProject webProject = new WebProject(avmPath); + return new FormInstanceDataImpl(nodeRef, this) + { + @Override + public Form getForm() + throws FormNotFoundException + { + final Form f = super.getForm(); + try + { + return webProject.getForm(f.getName()); + } + catch (FormNotFoundException fnfne) + { + throw new FormNotFoundException(f, webProject, this); + } + } + }; + } + + public Rendition getRendition(final int version, final String avmPath) + { + return this.getRendition(AVMNodeConverter.ToNodeRef(version, avmPath)); + } + + public Rendition getRendition(final NodeRef nodeRef) + { + return new RenditionImpl(nodeRef, this); + } } diff --git a/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java b/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java index 23b393fa19..2d27cc740a 100644 --- a/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java +++ b/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java @@ -90,9 +90,11 @@ public class RenderingEngineTemplateImpl private final NodeRef nodeRef; private final NodeRef renditionPropertiesNodeRef; + private final FormsService formsService; protected RenderingEngineTemplateImpl(final NodeRef nodeRef, - final NodeRef renditionPropertiesNodeRef) + final NodeRef renditionPropertiesNodeRef, + final FormsService formsService) { if (nodeRef == null) { @@ -102,8 +104,13 @@ public class RenderingEngineTemplateImpl { throw new NullPointerException(); } + if (formsService == null) + { + throw new NullPointerException(); + } this.nodeRef = nodeRef; this.renditionPropertiesNodeRef = renditionPropertiesNodeRef; + this.formsService = formsService; } public String getName() @@ -162,8 +169,7 @@ public class RenderingEngineTemplateImpl final String renderingEngineName = (String) nodeService.getProperty(this.nodeRef, WCMAppModel.PROP_PARENT_RENDERING_ENGINE_NAME); - final FormsService fs = FormsService.getInstance(); - return fs.getRenderingEngine(renderingEngineName); + return this.formsService.getRenderingEngine(renderingEngineName); } /** @@ -262,17 +268,18 @@ public class RenderingEngineTemplateImpl AVMNodeConverter.SplitBase(renditionAvmPath)[1]); if (LOGGER.isDebugEnabled()) LOGGER.debug("Created file node for file: " + renditionAvmPath); + + avmService.addAspect(renditionAvmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA); + avmService.addAspect(renditionAvmPath, ContentModel.ASPECT_TITLED); + avmService.addAspect(renditionAvmPath, WCMAppModel.ASPECT_RENDITION); } - final Rendition result = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, renditionAvmPath)); + final Rendition result = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, renditionAvmPath), + this.formsService); this.render(formInstanceData, result); if (!isRegenerate) { - avmService.addAspect(renditionAvmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA); - avmService.addAspect(renditionAvmPath, ContentModel.ASPECT_TITLED); - avmService.addAspect(renditionAvmPath, WCMAppModel.ASPECT_RENDITION); - final PropertyValue pv = avmService.getNodeProperty(-1, formInstanceData.getPath(), WCMAppModel.PROP_RENDITIONS); final Collection renditions = (pv == null diff --git a/source/java/org/alfresco/web/forms/RenditionImpl.java b/source/java/org/alfresco/web/forms/RenditionImpl.java index 2fdd8bf727..b12d75ca53 100644 --- a/source/java/org/alfresco/web/forms/RenditionImpl.java +++ b/source/java/org/alfresco/web/forms/RenditionImpl.java @@ -51,27 +51,41 @@ import org.xml.sax.SAXException; * * @author Ariel Backenroth */ -public class RenditionImpl +/* package */ class RenditionImpl implements Rendition { private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class); private final NodeRef nodeRef; + private final FormsService formsService; private transient RenderingEngineTemplate renderingEngineTemplate; - public RenditionImpl(final NodeRef nodeRef) + /* package */ RenditionImpl(final NodeRef nodeRef, final FormsService formsService) { if (nodeRef == null) { throw new NullPointerException(); } + if (formsService == null) + { + throw new NullPointerException(); + } + final NodeService nodeService = this.getServiceRegistry().getNodeService(); + if (!nodeService.hasAspect(nodeRef, WCMAppModel.ASPECT_RENDITION)) + { + throw new IllegalArgumentException("node " + nodeRef + + " does not have aspect " + WCMAppModel.ASPECT_RENDITION); + } this.nodeRef = nodeRef; + this.formsService = formsService; } - public RenditionImpl(final int version, final String avmPath) + /* package */ RenditionImpl(final int version, + final String avmPath, + final FormsService formsService) { - this(AVMNodeConverter.ToNodeRef(version, avmPath)); + this(AVMNodeConverter.ToNodeRef(version, avmPath), formsService); } /** the name of this rendition */ @@ -115,7 +129,7 @@ public class RenditionImpl { throw new FileNotFoundException("unable to find primary form instance data " + path); } - return new FormInstanceDataImpl(-1, path); + return this.formsService.getFormInstanceData(-1, path); } /** the rendering engine template that generated this rendition */ @@ -159,7 +173,7 @@ public class RenditionImpl this.getPath()); return null; } - this.renderingEngineTemplate = new RenderingEngineTemplateImpl(retNodeRef, rpNodeRef); + this.renderingEngineTemplate = new RenderingEngineTemplateImpl(retNodeRef, rpNodeRef, this.formsService); } return this.renderingEngineTemplate; } diff --git a/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java b/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java index a0cfbe0f23..d0df764605 100644 --- a/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java +++ b/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java @@ -87,6 +87,7 @@ public class Schema2XForms private final String action; private final SubmitMethod submitMethod; private final String base; + private final Stack parentStack = new Stack(); /** * generic counter -> replaced by an hashMap with: @@ -1144,6 +1145,8 @@ public class Schema2XForms final ResourceBundle resourceBundle) throws FormBuilderException { + LOGGER.debug("adding element " + elementDecl + " at path " + pathToRoot); + XSTypeDefinition controlType = elementDecl.getTypeDefinition(); if (controlType == null) { @@ -1659,7 +1662,14 @@ public class Schema2XForms final String path = (pathToRoot.length() == 0 ? elementName : pathToRoot + "/" + elementName); - LOGGER.debug("addElement to group " + elementName + " at " + path); + LOGGER.debug("addElement to group " + elementName + " at " + path + " parentStack " + this.parentStack); + + if (this.parentStack.contains(element)) + { + throw new FormBuilderException("recursion detected at element " + elementName); + } + LOGGER.debug("pushing element " + element + " onto parent stack"); + this.parentStack.push(element); final Element newDefaultInstanceElement = xformsDocument.createElement(elementName); if (element.getConstraintType() != XSConstants.VC_NONE) @@ -1677,6 +1687,8 @@ public class Schema2XForms path, occurs, resourceBundle); + LOGGER.debug("popped element " + this.parentStack.pop() + " from parent stack"); + // final SchemaUtil.Occurrence occurs = SchemaUtil.getOccurrence(element); LOGGER.debug("adding " + (occurs.maximum == 1 diff --git a/source/java/org/alfresco/web/forms/xforms/Schema2XFormsTest.java b/source/java/org/alfresco/web/forms/xforms/Schema2XFormsTest.java index 4c6cc220a5..b57729629d 100644 --- a/source/java/org/alfresco/web/forms/xforms/Schema2XFormsTest.java +++ b/source/java/org/alfresco/web/forms/xforms/Schema2XFormsTest.java @@ -160,6 +160,7 @@ public class Schema2XFormsTest } catch (FormBuilderException fbe) { + LOGGER.debug("got expected exception " + fbe.getMessage()); } } @@ -181,6 +182,31 @@ public class Schema2XFormsTest // } } + public void testRecursive() + throws Exception + { + final Document schemaDocument = this.loadTestResourceDocument("xforms/unit-tests/automated/recursive-test.xsd"); + Document xformsDocument = this.buildXForm(null, schemaDocument, "non-recursive-test"); + try + { + xformsDocument = this.buildXForm(null, schemaDocument, "recursive-test"); + fail("expected failure creating xform with recursive element definition root element recursive-test in schema " + XMLUtil.toString(schemaDocument)); + } + catch (FormBuilderException fbe) + { + LOGGER.debug("got expected exception " + fbe.getMessage()); + } + try + { + xformsDocument = this.buildXForm(null, schemaDocument, "nested-recursive-test"); + fail("expected failure creating xform with recursive element definition root element nested-recursive-test in schema " + XMLUtil.toString(schemaDocument)); + } + catch (FormBuilderException fbe) + { + LOGGER.debug("got expected exception " + fbe.getMessage()); + } + } + private void assertRepeatProperties(final Document xformsDocument, final String nodeset, final SchemaUtil.Occurrence o) { final Element[] bindElements = this.resolveBind(xformsDocument, nodeset); diff --git a/source/test-resources/xforms/unit-tests/automated/recursive-test.xsd b/source/test-resources/xforms/unit-tests/automated/recursive-test.xsd new file mode 100644 index 0000000000..5fb3c566eb --- /dev/null +++ b/source/test-resources/xforms/unit-tests/automated/recursive-test.xsd @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 08fd5e8ef0..fe4f0b5b08 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -2492,6 +2492,10 @@ workflowService #{WorkflowService} + + formsService + #{FormsService} + @@ -2537,6 +2541,10 @@ workflowService #{WorkflowService} + + formsService + #{FormsService} + @@ -2582,6 +2590,10 @@ avmSyncService #{AVMSyncService} + + formsService + #{FormsService} + @@ -2619,10 +2631,6 @@ dictionaryService #{DictionaryService} - - workflowService - #{WorkflowService} - avmService #{AVMLockingAwareService} @@ -2643,6 +2651,10 @@ filePickerBean #{FilePickerBean} + + formsService + #{FormsService} + @@ -2680,10 +2692,6 @@ dictionaryService #{DictionaryService} - - workflowService - #{WorkflowService} - avmService #{AVMLockingAwareService} @@ -2704,6 +2712,10 @@ filePickerBean #{FilePickerBean} + + formsService + #{FormsService} + @@ -2745,6 +2757,10 @@ avmLockingService #{AVMLockingService} + + formsService + #{FormsService} + @@ -2786,6 +2802,10 @@ personService #{PersonService} + + formsService + #{FormsService} + @@ -2897,6 +2917,10 @@ workflowService #{WorkflowService} + + formsService + #{FormsService} + @@ -2911,8 +2935,25 @@ #{AVMLockingAwareService} - avmSyncService - #{AVMSyncService} + avmBrowseBean + #{AVMBrowseBean} + + + formsService + #{FormsService} + + + + + + The bean that backs up the AVM file editing screens + + EditAvmFileDialog + org.alfresco.web.bean.wcm.EditAvmFileDialog + session + + avmService + #{AVMLockingAwareService} avmBrowseBean @@ -2920,6 +2961,27 @@ + + + The bean that backs up the dialog for associating form instance data with a form + + PromptForWebFormDialog + org.alfresco.web.bean.wcm.PromptForWebFormDialog + session + + avmService + #{AVMLockingAwareService} + + + avmBrowseBean + #{AVMBrowseBean} + + + formsService + #{FormsService} + + + The bean that backs up the Snapshot Sandbox Dialog @@ -2952,6 +3014,10 @@ avmBrowseBean #{AVMBrowseBean} + + formsService + #{FormsService} + @@ -3383,6 +3449,10 @@ nameMatcher #{globalPathExcluder} + + formsService + #{FormsService} + diff --git a/source/web/WEB-INF/faces-config-navigation.xml b/source/web/WEB-INF/faces-config-navigation.xml index 9781025c48..09bf5d26fb 100644 --- a/source/web/WEB-INF/faces-config-navigation.xml +++ b/source/web/WEB-INF/faces-config-navigation.xml @@ -904,14 +904,17 @@ addAvmContent /jsp/wcm/add-content-dialog.jsp + updateAvmFile /jsp/wcm/update-file.jsp + showFileDetails /jsp/wcm/file-details.jsp diff --git a/source/web/jsp/wcm/edit-file.jsp b/source/web/jsp/wcm/edit-file.jsp index 3573d77abf..168cf7ea16 100644 --- a/source/web/jsp/wcm/edit-file.jsp +++ b/source/web/jsp/wcm/edit-file.jsp @@ -20,7 +20,7 @@ * 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" + * http://www.alfresco.com/legal/licensing --%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> @@ -30,143 +30,24 @@ <%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %> <%@ page isELIgnored="false" %> -<%@ page import="org.alfresco.web.ui.common.PanelGenerator" %> - - - - - <%-- load a bundle of properties with I18N strings --%> - - - <%-- set the form name here --%> - - - <%-- Main outer table --%> - - - <%-- Title bar --%> - - - - - <%-- Main area --%> - - <%-- Shelf --%> - - - <%-- Work Area --%> - - -
- <%@ include file="../parts/titlebar.jsp" %> -
- <%@ include file="../parts/shelf.jsp" %> - - - <%-- Breadcrumb --%> - <%@ include file="../parts/breadcrumb.jsp" %> - - <%-- Status and Actions --%> - - - - - - - <%-- separator row with gradient shadow --%> - - - - - - - <%-- Details --%> - - - - - - - <%-- Error Messages --%> - - - - - - - <%-- separator row with bottom panel graphics --%> - - - - - - -
- - <%-- Status and Actions inner contents table --%> - <%-- Generally this consists of an icon, textual summary and actions for the current object --%> - - - - - -
- -
''
-
-
- -
- - - - - - -
- <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %> - - - - - - - - - - -
- - - -
- <%-- downloadable file link --%> - -
- -
- <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "white"); %> -
- <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "greyround", "#F5F5F5"); %> - - - - -
- -
- <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "greyround"); %> -
-
- <%-- messages tag to show messages not handled by other specific message tags --%> - -
-
- -
- -
- -
\ No newline at end of file + + + + + + + <%-- downloadable file link --%> + + + + + + + diff --git a/source/web/jsp/wcm/edit-xml-inline.jsp b/source/web/jsp/wcm/edit-xml-inline.jsp deleted file mode 100644 index f83110a81f..0000000000 --- a/source/web/jsp/wcm/edit-xml-inline.jsp +++ /dev/null @@ -1,46 +0,0 @@ -<%-- - * 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" ---%> -<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> -<%@ taglib uri="/WEB-INF/wcm.tld" prefix="wcm" %> - - - - - - \ No newline at end of file diff --git a/source/web/jsp/wcm/prompt-for-web-form.jsp b/source/web/jsp/wcm/prompt-for-web-form.jsp new file mode 100644 index 0000000000..a3304943a5 --- /dev/null +++ b/source/web/jsp/wcm/prompt-for-web-form.jsp @@ -0,0 +1,57 @@ +<%-- + * 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 +--%> +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> +<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> + +<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %> +<%@ page isELIgnored="false" %> + + + + + + + + + + + + + + + + + + + +