implementing the regenerate renditions wizard

- refactoring to centralize regenerate code
- adding onchange event to UISelectList to trigger reload of page
- reorganizing some webproject code for better reuse
- fix for submit from create web content (a webproject property was added to submitdialog but not createwebcontent)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5889 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2007-06-08 01:09:56 +00:00
parent aa13da35dc
commit fbc1e891c8
27 changed files with 1451 additions and 340 deletions

View File

@@ -292,6 +292,7 @@ add_content=Add Content
create_content=Create Content create_content=Create Content
create_form=Create Web Form create_form=Create Web Form
edit_form=Edit Web Form edit_form=Edit Web Form
regenerate_renditions=Regenerate Renditions
add_multiple_files=Add Multiple Files add_multiple_files=Add Multiple Files
import_directory=Import Directory import_directory=Import Directory
advanced_space_wizard=Advanced Space Wizard advanced_space_wizard=Advanced Space Wizard
@@ -707,6 +708,22 @@ content=Content
text_content=Plain Text Content text_content=Plain Text Content
html_content=HTML Content html_content=HTML Content
xml_content=XML Content xml_content=XML Content
regenerate_renditions_title=Regenerate Renditions Wizard
regenerate_renditions_desc=This wizard helps you regenerate renditions.
regenerate_renditions_select_renditions_title=Select Renditions
regenerate_renditions_select_renditions_step_title=Select Renditions
regenerate_renditions_select_renditions_desc=Select which renditions you want to regenerate.
regenerate_renditions_select_renditions_select_item_desc={0} related renditions in {1}.
regenerate_renditions_select_renditions_select_web_project=Select the web project in which you want to regenerate renditions.
regenerate_renditions_select_renditions_select_regenerate_scope=Select which renditions you want to regenerate within the selected web project.
regenerate_renditions_select_renditions_scope_all=Choose this option to regenerate all renditions of all form generated content within the selected web project.
regenerate_renditions_select_renditions_scope_form=Choose this option to regenerate all renditions of content generated by a particular set of forms configured for the selected web project.
regenerate_renditions_select_renditions_scope_rendering_engine_templates=Choose this option to regenerate particular renditions generated by a particular set of rendering engine templates.
regenerate_renditions_select_renditions_instruction=To regenerate renditions based on your selection, click next.
regenerate_renditions_summary_desc={0} renditions have been regenerated in web project {1}.
regenerate_renditions_summary_instruction=To commit these changes to the web project, click Finish.
create_form_title=Create Web Form Wizard create_form_title=Create Web Form Wizard
edit_form_title=Edit Web Form Wizard edit_form_title=Edit Web Form Wizard
create_form_desc=This wizard helps you create a new form. create_form_desc=This wizard helps you create a new form.
@@ -740,6 +757,7 @@ create_web_content_summary_submit_message=Submit {0,choice,0#__SHOULD NOT BE ZER
default_rendition_description=Rendered by {0} into {1} default_rendition_description=Rendered by {0} into {1}
rendering_engine_type=Rendering Engine rendering_engine_type=Rendering Engine
apply_default_workflow=Apply default workflow apply_default_workflow=Apply default workflow
rendering_engine_template=Rendering Engine Template
rendering_engine_templates=Rendering Engine Templates rendering_engine_templates=Rendering Engine Templates
selected_rendering_engine_templates=Selected Rendering Engines selected_rendering_engine_templates=Selected Rendering Engines
rendering_engine_template_file=Rendering Engine Template File rendering_engine_template_file=Rendering Engine Template File
@@ -748,7 +766,8 @@ output_path_pattern=Output path pattern
mimetype_for_renditions=Rendition mimetype mimetype_for_renditions=Rendition mimetype
schema=Schema schema=Schema
schema_root_element_name=Root element schema_root_element_name=Root element
form=Form form=Web Form
web_project=Web Project
# Rule and Action Wizard messages # Rule and Action Wizard messages
run_action_title=Run Action Wizard run_action_title=Run Action Wizard
@@ -986,6 +1005,7 @@ website_browse_files=Browse Files
creator=Creator creator=Creator
modified_items=Modified Items modified_items=Modified Items
content_forms=Web Forms content_forms=Web Forms
store_created_on=Created On store_created_on=Created On
store_created_by=Created By store_created_by=Created By
store_working_users=There {0,choice,0#are no users|1#is one user|1<are {0,number} users} working on this web project. store_working_users=There {0,choice,0#are no users|1#is one user|1<are {0,number} users} working on this web project.

View File

@@ -372,6 +372,18 @@
</params> </params>
</action> </action>
<!-- Create XML content type -->
<action id="regenerate_renditions">
<evaluator>org.alfresco.web.action.evaluator.RegenerateRenditionsEvaluator</evaluator>
<label-id>regenerate_renditions</label-id>
<image>/images/icons/regenerate_renditions.gif</image>
<action>wizard:regenerateRenditions</action>
<action-listener>#{BrowseBean.setupSpaceAction}</action-listener>
<params>
<param name="id">#{actionContext.id}</param>
</params>
</action>
<!-- Create space --> <!-- Create space -->
<action id="create_space"> <action id="create_space">
<permissions> <permissions>
@@ -700,7 +712,7 @@
<action idref="create_form" /> <action idref="create_form" />
<action idref="create_website_wizard" /> <action idref="create_website_wizard" />
<action idref="create_space" /> <action idref="create_space" />
<action idref= "create_multilingual_space" /> <action idref="create_multilingual_space" />
<action idref="create_space_wizard" /> <action idref="create_space_wizard" />
</action-group> </action-group>

View File

@@ -409,6 +409,7 @@
<show-link>false</show-link> <show-link>false</show-link>
<!-- add the edit form action --> <!-- add the edit form action -->
<action idref="edit_form"/> <action idref="edit_form"/>
<action idref="regenerate_renditions"/>
<!-- hide the cut and copy operations for web form --> <!-- hide the cut and copy operations for web form -->
<action idref="cut_node" hide="true" /> <action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" /> <action idref="copy_node" hide="true" />
@@ -418,6 +419,7 @@
<action-group id="browse_actions_menu"> <action-group id="browse_actions_menu">
<!-- add the edit form action --> <!-- add the edit form action -->
<action idref="edit_form" /> <action idref="edit_form" />
<action idref="regenerate_renditions" />
<!-- hide the cut and copy operations for web form --> <!-- hide the cut and copy operations for web form -->
<action idref="cut_node" hide="true" /> <action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" /> <action idref="copy_node" hide="true" />
@@ -427,11 +429,11 @@
<action-group id="space_details_actions"> <action-group id="space_details_actions">
<!-- add the edit form action --> <!-- add the edit form action -->
<action idref="edit_form" /> <action idref="edit_form" />
<action idref="regenerate_renditions" />
<!-- hide the cut and copy operations for web form --> <!-- hide the cut and copy operations for web form -->
<action idref="cut_node" hide="true" /> <action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" /> <action idref="copy_node" hide="true" />
</action-group> </action-group>
</actions> </actions>
</config> </config>

View File

@@ -419,7 +419,27 @@
instruction-id="content_finish_instruction" /> instruction-id="content_finish_instruction" />
</step> </step>
</wizard> </wizard>
<!-- Definition of the create form wizard -->
<wizard name="regenerateRenditions" managed-bean="RegenerateRenditionsWizard"
title-id="regenerate_renditions_title" description-id="regenerate_renditions_desc"
icon="/images/icons/regenerate_renditions_large.gif">
<step name="select_renditions"
title-id="regenerate_renditions_select_renditions_title"
description-id="regenerate_renditions_select_renditions_desc">
<page path="/jsp/wcm/regenerate-renditions-wizard/select_renditions.jsp"
title-id="regenerate_renditions_select_renditions_step_title"
description-id="regenerate_renditions_select_renditions_desc"
instruction-id="regenerate_renditions_select_renditions_instruction" />
</step>
<step name="summary" title-id="summary" description-id="summary_step_description">
<page path="/jsp/wcm/regenerate-renditions-wizard/summary.jsp"
title-id="summary"
description-id="regenerate_renditions_summary_desc"
instruction-id="regenerate_renditions_summary_instruction" />
</step>
</wizard>
<!-- Definition of the Dashboard Layout wizard --> <!-- Definition of the Dashboard Layout wizard -->
<wizard name="configureDashboard" managed-bean="DashboardWizard" <wizard name="configureDashboard" managed-bean="DashboardWizard"
title-id="configure_dashboard_title" description-id="configure_dashboard_desc" title-id="configure_dashboard_title" description-id="configure_dashboard_desc"
@@ -472,4 +492,4 @@
</wizards> </wizards>
</config> </config>
</alfresco-config> </alfresco-config>

View File

@@ -0,0 +1,63 @@
/*
* 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.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.WCMAppModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.action.ActionEvaluator;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator for Regenerate Renditions in the Forms DataDictionary folder
*
* @author Ariel Backenroth
*/
public class RegenerateRenditionsEvaluator implements ActionEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(final Node node)
{
final FacesContext fc = FacesContext.getCurrentInstance();
final ServiceRegistry services = Repository.getServiceRegistry(fc);
final NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME);
// get the path to the current name - compare last element with the Website folder assoc name
final Path path = navigator.getCurrentNode().getNodePath();
final Path.Element element = path.get(path.size() - 1);
final String endPath = element.getPrefixedString(services.getNamespaceService());
return (node.hasAspect(WCMAppModel.ASPECT_FORM) ||
node.hasAspect(WCMAppModel.ASPECT_RENDERING_ENGINE_TEMPLATE) ||
Application.getContentFormsFolderName(fc).equals(endPath));
}
}

View File

@@ -21,6 +21,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
@@ -542,53 +543,14 @@ public class AVMEditBean
@Override @Override
public Form getForm() { return AVMEditBean.this.getForm(); } public Form getForm() { return AVMEditBean.this.getForm(); }
}; };
final List<FormInstanceData.RegenerateResult> result = fid.regenerateRenditions();
if (LOGGER.isDebugEnabled()) for (FormInstanceData.RegenerateResult rr : result)
LOGGER.debug("regenerating renditions of " + fid);
String originalParentAvmPath = (String)
this.nodeService.getProperty(((FormInstanceDataImpl)fid).getNodeRef(),
WCMAppModel.PROP_ORIGINAL_PARENT_PATH);
if (originalParentAvmPath == null)
{ {
originalParentAvmPath = AVMNodeConverter.SplitBase(avmPath)[0]; if (rr.getException() != null)
}
final HashSet<RenderingEngineTemplate> allRets =
new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
// regenerate existing renditions
for (final Rendition r : fid.getRenditions())
{
final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
if (!allRets.contains(ret))
{ {
continue; Utils.addErrorMessage("error regenerating rendition using " + rr.getRenderingEngineTemplate().getName() +
} ": " + rr.getException().getMessage(),
try rr.getException());
{
ret.render(fid, r);
allRets.remove(ret);
}
catch (Exception e)
{
Utils.addErrorMessage("error regenerating rendition using " + ret.getName() +
": " + e.getMessage(),
e);
}
}
// render all renditions for newly added templates
for (final RenderingEngineTemplate ret : allRets)
{
try
{
final String path = ret.getOutputPathForRendition(fid, originalParentAvmPath);
ret.render(fid, path);
}
catch (Exception e)
{
Utils.addErrorMessage("error regenerating rendition using " + ret.getName() +
": " + e.getMessage(),
e);
} }
} }
} }

View File

@@ -1044,8 +1044,7 @@ public class CreateFormWizard
{ {
// get list of workflows from config definitions // get list of workflows from config definitions
final List<WorkflowDefinition> workflowDefs = AVMWorkflowUtil.getConfiguredWorkflows(); final List<WorkflowDefinition> workflowDefs = AVMWorkflowUtil.getConfiguredWorkflows();
this.defaultWorkflowChoices = new ArrayList<UIListItem>(workflowDefs.size() + 1); this.defaultWorkflowChoices = new ArrayList<UIListItem>(workflowDefs.size());
for (WorkflowDefinition workflowDef : workflowDefs) for (WorkflowDefinition workflowDef : workflowDefs)
{ {
final UIListItem item = new UIListItem(); final UIListItem item = new UIListItem();

View File

@@ -405,6 +405,8 @@ public class CreateWebContentWizard extends BaseContentWizard
this.nodeService); this.nodeService);
parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef); parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef);
parameters.put(WCMWorkflowModel.ASSOC_WEBPROJECT,
this.avmBrowseBean.getWebsite().getNodeRef());
// TODO: capture label and comment? // TODO: capture label and comment?
parameters.put(WCMWorkflowModel.PROP_LABEL, parameters.put(WCMWorkflowModel.PROP_LABEL,
MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null

View File

@@ -38,7 +38,6 @@ import javax.faces.event.ActionEvent;
import javax.faces.model.DataModel; import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel; import javax.faces.model.ListDataModel;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
@@ -97,8 +96,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
protected String webapp = WEBAPP_DEFAULT; protected String webapp = WEBAPP_DEFAULT;
protected List<String> deployTo; protected List<String> deployTo;
protected String websitesFolderId = null;
protected AVMService avmService; protected AVMService avmService;
protected WorkflowService workflowService; protected WorkflowService workflowService;
protected PersonService personService; protected PersonService personService;
@@ -163,10 +160,10 @@ public class CreateWebsiteWizard extends BaseWizardBean
protected String finishImpl(FacesContext context, String outcome) throws Exception protected String finishImpl(FacesContext context, String outcome) throws Exception
{ {
// create the website space in the correct parent folder // create the website space in the correct parent folder
String websiteParentId = getWebsitesFolderId(); final NodeRef websiteParent = WebProject.getWebsitesFolder();
FileInfo fileInfo = this.fileFolderService.create( FileInfo fileInfo = this.fileFolderService.create(
new NodeRef(Repository.getStoreRef(), websiteParentId), websiteParent,
this.name, this.name,
WCMAppModel.TYPE_AVMWEBFOLDER); WCMAppModel.TYPE_AVMWEBFOLDER);
NodeRef nodeRef = fileInfo.getNodeRef(); NodeRef nodeRef = fileInfo.getNodeRef();
@@ -218,7 +215,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
saveWebProjectModel(nodeRef); saveWebProjectModel(nodeRef);
// navigate to the Websites folder so we can see the newly created folder // navigate to the Websites folder so we can see the newly created folder
this.navigator.setCurrentNodeId(websiteParentId); this.navigator.setCurrentNodeId(websiteParent.getId());
outcome = AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME; outcome = AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME;
} }
@@ -803,37 +800,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Helper methods // Helper methods
/**
* Helper to get the ID of the 'Websites' system folder
*
* @return ID of the 'Websites' system folder
*
* @throws AlfrescoRuntimeException if unable to find the required folder
*/
private String getWebsitesFolderId()
{
if (this.websitesFolderId == null)
{
// get the template from the special Content Templates folder
FacesContext fc = FacesContext.getCurrentInstance();
String xpath = Application.getRootPath(fc) + "/" + Application.getWebsitesFolderName(fc);
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService();
List<NodeRef> results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
if (results.size() == 1)
{
this.websitesFolderId = results.get(0).getId();
}
else
{
throw new AlfrescoRuntimeException("Unable to find 'Websites' system folder at: " + xpath);
}
}
return this.websitesFolderId;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Inner classes // Inner classes

View File

@@ -0,0 +1,548 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.web.bean.wcm;
import java.io.File;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.model.SelectItem;
import org.alfresco.web.ui.common.component.UIListItems;
import org.alfresco.web.ui.common.component.data.UIRichList;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.*;
import org.alfresco.service.cmr.search.*;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.BaseWizardBean;
import org.alfresco.web.data.IDataContainer;
import org.alfresco.web.data.QuickSort;
import org.alfresco.web.forms.*;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.wcm.WebResources;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
/**
* @author arielb
*/
public class RegenerateRenditionsWizard
extends BaseWizardBean
{
public final String REGENERATE_SCOPE_ALL = "all";
public final String REGENERATE_SCOPE_FORM = "form";
public final String REGENERATE_SCOPE_RENDERING_ENGINE_TEMPLATE = "rendering_engine_template";
private final static Log LOGGER = LogFactory.getLog(RegenerateRenditionsWizard.class);
private AVMService avmService;
private AVMSyncService avmSyncService;
private ContentService contentService;
private SearchService searchService;
private WebProject selectedWebProject;
private String[] selectedForms;
private String[] selectedRenderingEngineTemplates;
private UIRichList renditionChoicesRichList;
private List<Rendition> regeneratedRenditions;
private String regenerateScope;
// ------------------------------------------------------------------------------
// Wizard implementation
@Override
protected String finishImpl(final FacesContext context, final String outcome)
throws Exception
{
if (this.regeneratedRenditions != null)
{
final List<AVMDifference> diffList = new ArrayList<AVMDifference>(this.regeneratedRenditions.size());
for (final Rendition r : this.regeneratedRenditions)
{
diffList.add(new AVMDifference(-1, r.getPath(),
-1, AVMUtil.getCorrespondingPathInMainStore(r.getPath()),
AVMDifference.NEWER));
}
LOGGER.debug("updating " + diffList.size() + " renditions in staging");
this.avmSyncService.update(diffList, null, true, true, true, true, null, null);
}
return outcome;
}
@Override
public void init(final Map<String, String> parameters)
{
super.init(parameters);
this.selectedWebProject = null;
this.selectedForms = null;
this.selectedRenderingEngineTemplates = null;
this.renditionChoicesRichList = null;
this.regeneratedRenditions = null;
this.regenerateScope = REGENERATE_SCOPE_ALL;
if (this.browseBean.getDocument() != null)
{
if (this.browseBean.getDocument().hasAspect(WCMAppModel.ASPECT_FORM))
{
this.selectedForms = new String[] { this.browseBean.getDocument().getName() };
}
else if (this.browseBean.getDocument().hasAspect(WCMAppModel.ASPECT_RENDERING_ENGINE_TEMPLATE))
{
// System.err.println("how to handle ? " + this.browseBean.getDocument());
// this.selectedRenderingEngineTemplates = new String[] { "*:
}
}
else if (this.browseBean.getActionSpace() != null)
{
this.selectedForms = new String[] { this.browseBean.getActionSpace().getName() };
}
}
@Override
public String next()
{
final int step = Application.getWizardManager().getCurrentStep();
if (step == 2)
{
try
{
this.regeneratedRenditions = this.regenerateRenditions();
}
catch (Exception e)
{
Application.getWizardManager().getState().setCurrentStep(step - 1);
Utils.addErrorMessage(e.getMessage(), e);
}
}
return super.next();
}
@Override
public String cancel()
{
if (this.selectedWebProject != null)
{
final String stagingStoreName = this.selectedWebProject.getStoreId();
final String previewStoreName = AVMUtil.getCorrespondingPreviewStoreName(stagingStoreName);
this.avmSyncService.resetLayer(AVMUtil.buildStoreRootPath(previewStoreName));
}
return super.cancel();
}
@Override
public boolean getNextButtonDisabled()
{
return false;
}
@Override
public String getStepDescription()
{
final ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
final String stepName = Application.getWizardManager().getCurrentStepName();
if ("summary".equals(stepName))
{
final String s = this.selectedWebProject.getTitle();
return MessageFormat.format(bundle.getString("regenerate_renditions_summary_desc"),
this.regeneratedRenditions.size(),
s != null && s.length() != 0 ? s : this.selectedWebProject.getName());
}
else
{
return super.getContainerDescription();
}
}
// ------------------------------------------------------------------------------
// Bean Getters and Setters
public String getRegenerateScope()
{
return this.regenerateScope;
}
public void setRegenerateScope(final String regenerateScope)
{
this.regenerateScope = regenerateScope;
}
public List<SelectItem> getWebProjectChoices()
{
final List<WebProject> webProjects = WebProject.getWebProjects();
final List<SelectItem> result = new ArrayList<SelectItem>(webProjects.size());
for (final WebProject wp : webProjects)
{
final String s = wp.getTitle();
if (this.selectedWebProject == null)
{
this.selectedWebProject = wp;
}
result.add(new SelectItem(wp.getNodeRef().toString(), s != null && s.length() != 0 ? s : wp.getName()));
}
return result;
}
public String getSelectedWebProject()
{
return this.selectedWebProject == null ? null : this.selectedWebProject.getNodeRef().toString();
}
public void setSelectedWebProject(final String webProject)
{
this.selectedWebProject = (webProject == null || webProject.length() == 0
? null
: new WebProject(new NodeRef(webProject)));
final UIViewRoot c = FacesContext.getCurrentInstance().getViewRoot();
((UIListItems)c.findComponent("wizard:wizard-body:select_list_form_choices:list_items_form_choices")).setValue(null);
((UIListItems)c.findComponent("wizard:wizard-body:select_list_rendering_engine_template_choices:list_items_rendering_engine_template_choices")).setValue(null);
this.renditionChoicesRichList = null;
}
public List<UIListItem> getFormChoices()
{
final List<UIListItem> result = new LinkedList<UIListItem>();
final ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
if (this.selectedWebProject != null)
{
for (final Form f : this.selectedWebProject.getForms())
{
final UIListItem item = new UIListItem();
item.setValue(f.getName());
item.setLabel(f.getTitle());
final List<FormInstanceData> fids = this.getRelatedFormInstanceData(this.selectedWebProject, f);
item.setDescription(MessageFormat.format(bundle.getString("regenerate_renditions_select_renditions_select_item_desc"),
fids.size() * f.getRenderingEngineTemplates().size(),
this.selectedWebProject.getName()));
item.setImage("/images/icons/webform_large.gif");
result.add(item);
}
}
return result;
}
public String[] getSelectedForms()
{
return this.selectedForms;
}
public void setSelectedForms(final String[] forms)
{
this.selectedForms = forms == null || forms.length == 0 ? null : forms;
}
public String getSelectedForm()
{
return this.selectedForms != null && this.selectedForms.length != 0 ? this.selectedForms[0] : null;
}
public void setSelectedForm(final String form)
{
this.selectedForms = form == null || form.length() == 0 ? null : new String[] { form };
this.renditionChoicesRichList = null;
}
public List<UIListItem> getRenderingEngineTemplateChoices()
{
final List<UIListItem> result = new LinkedList<UIListItem>();
final ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
for (final Form f : this.selectedWebProject.getForms())
{
for (final RenderingEngineTemplate ret : f.getRenderingEngineTemplates())
{
final UIListItem item = new UIListItem();
item.setValue(f.getName() + ":" + ret.getName());
item.setLabel(ret.getTitle() + "(" + ret.getMimetypeForRendition() + ")");
final List<Rendition> rs = this.getRelatedRenditions(this.selectedWebProject, ret);
item.setDescription(MessageFormat.format(bundle.getString("regenerate_renditions_select_renditions_select_item_desc"),
rs.size(),
this.selectedWebProject.getName()));
item.setImage(Utils.getFileTypeImage(ret.getName(), false));
result.add(item);
}
}
return result;
}
public String[] getSelectedRenderingEngineTemplates()
{
return this.selectedRenderingEngineTemplates;
}
public void setSelectedRenderingEngineTemplates(final String[] renderingEngineTemplates)
{
this.selectedRenderingEngineTemplates = renderingEngineTemplates;
this.renditionChoicesRichList = null;
}
public List<Rendition> getRegeneratedRenditions()
{
return this.regeneratedRenditions;
}
public void setRegeneratedRenditionsRichList(UIRichList richList)
{
this.renditionChoicesRichList = richList;
}
public UIRichList getRegeneratedRenditionsRichList()
{
return this.renditionChoicesRichList;
}
// ------------------------------------------------------------------------------
// Service Injection
/**
* @param contentService The contentService to set.
*/
public void setContentService(final ContentService contentService)
{
this.contentService = contentService;
}
/**
* @param avmService The AVMService to set.
*/
public void setAvmService(final AVMService avmService)
{
this.avmService = avmService;
}
/**
* @param avmSyncService The AVMSyncService to set.
*/
public void setAvmSyncService(final AVMSyncService avmSyncService)
{
this.avmSyncService = avmSyncService;
}
/**
* @param searchService The SearchService to set.
*/
public void setSearchService(final SearchService searchService)
{
this.searchService = searchService;
}
// ------------------------------------------------------------------------------
// Helper Methods
private List<FormInstanceData> getRelatedFormInstanceData(final WebProject webProject, final Form f)
{
final SearchParameters sp = new SearchParameters();
final StoreRef storeRef = AVMNodeConverter.ToStoreRef(webProject.getStagingStore());
sp.addStore(storeRef);
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
StringBuilder query = new StringBuilder();
query.append("+ASPECT:\"" + WCMAppModel.ASPECT_FORM_INSTANCE_DATA + "\"");
query.append("-ASPECT:\"" + WCMAppModel.ASPECT_RENDITION + "\"");
query.append(" +@" + Repository.escapeQName(WCMAppModel.PROP_PARENT_FORM_NAME) +
":\"" + f.getName() + "\"");
LOGGER.debug("running query " + query);
sp.setQuery(query.toString());
final ResultSet rs = this.searchService.query(sp);
final List<FormInstanceData> result = new ArrayList<FormInstanceData>(rs.length());
for (final ResultSetRow row : rs)
{
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()
{
return RegenerateRenditionsWizard.this.selectedWebProject.getForm(super.getForm().getName());
}
};
result.add(fid);
}
return result;
}
private List<Rendition> getRelatedRenditions(final WebProject webProject, final RenderingEngineTemplate ret)
{
final SearchParameters sp = new SearchParameters();
final StoreRef storeRef = AVMNodeConverter.ToStoreRef(webProject.getStagingStore());
sp.addStore(storeRef);
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
StringBuilder query = new StringBuilder();
query.append("+ASPECT:\"" + WCMAppModel.ASPECT_RENDITION + "\"");
query.append("+@" + Repository.escapeQName(WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE) +
":\"" + ((RenderingEngineTemplateImpl)ret).getNodeRef() + "\"");
LOGGER.debug("running query " + query);
sp.setQuery(query.toString());
final ResultSet rs = this.searchService.query(sp);
final List<Rendition> result = new ArrayList<Rendition>(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);
}
return result;
}
private List<Rendition> regenerateRenditions()
{
final String stagingStoreName = this.selectedWebProject.getStoreId();
final String previewStoreName = AVMUtil.getCorrespondingPreviewStoreName(stagingStoreName);
this.avmSyncService.resetLayer(AVMUtil.buildStoreRootPath(previewStoreName));
final SearchParameters sp = new SearchParameters();
final StoreRef storeRef = AVMNodeConverter.ToStoreRef(this.selectedWebProject.getStagingStore());
sp.addStore(storeRef);
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
StringBuilder query = new StringBuilder();
if (this.regenerateScope.equals(REGENERATE_SCOPE_ALL) ||
this.regenerateScope.equals(REGENERATE_SCOPE_FORM))
{
query.append("+ASPECT:\"" + WCMAppModel.ASPECT_FORM_INSTANCE_DATA + "\"");
query.append("-ASPECT:\"" + WCMAppModel.ASPECT_RENDITION + "\"");
}
else
{
query.append("+ASPECT:\"" + WCMAppModel.ASPECT_RENDITION + "\"");
}
if (this.regenerateScope.equals(REGENERATE_SCOPE_FORM))
{
query.append(" +(");
for (int i = 0; i < this.selectedForms.length; i++)
{
query.append("@" + Repository.escapeQName(WCMAppModel.PROP_PARENT_FORM_NAME) +
":\"" + this.selectedForms[i] + "\"");
if (i != this.selectedForms.length - 1)
{
query.append(" OR ");
}
}
query.append(") ");
}
if (this.regenerateScope.equals(REGENERATE_SCOPE_RENDERING_ENGINE_TEMPLATE))
{
query.append(" +(");
for (int i = 0; i < this.selectedRenderingEngineTemplates.length; i++)
{
final Form f = this.selectedWebProject.getForm(this.selectedRenderingEngineTemplates[i].split(":")[0]);
final RenderingEngineTemplate ret = f.getRenderingEngineTemplate((String)this.selectedRenderingEngineTemplates[i].split(":")[1]);
query.append("@" + Repository.escapeQName(WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE) +
":\"" + ((RenderingEngineTemplateImpl)ret).getNodeRef() + "\"");
if (i != this.selectedRenderingEngineTemplates.length - 1)
{
query.append(" OR ");
}
}
query.append(") ");
}
LOGGER.debug("running query " + query);
sp.setQuery(query.toString());
final ResultSet rs = this.searchService.query(sp);
if (LOGGER.isDebugEnabled())
LOGGER.debug("received " + rs.length() + " results");
final List<Rendition> result = new ArrayList<Rendition>(rs.length());
for (final ResultSetRow row : rs)
{
final String avmPath = AVMNodeConverter.ToAVMVersionPath(row.getNodeRef()).getSecond();
final String previewAvmPath = AVMUtil.getCorrespondingPathInPreviewStore(avmPath);
if (this.regenerateScope.equals(REGENERATE_SCOPE_ALL) ||
this.regenerateScope.equals(REGENERATE_SCOPE_FORM))
{
final FormInstanceDataImpl fid = new FormInstanceDataImpl(-1, previewAvmPath)
{
@Override
public Form getForm()
{
return RegenerateRenditionsWizard.this.selectedWebProject.getForm(super.getForm().getName());
}
};
final List<FormInstanceData.RegenerateResult> regenResults = fid.regenerateRenditions();
for (final FormInstanceData.RegenerateResult rr : regenResults)
{
if (rr.getException() != null)
{
Utils.addErrorMessage("error regenerating rendition using " + rr.getRenderingEngineTemplate().getName() +
": " + rr.getException().getMessage(),
rr.getException());
}
else
{
result.add(rr.getRendition());
}
}
}
else
{
final Rendition r = new RenditionImpl(-1, previewAvmPath);
try
{
r.regenerate();
result.add(r);
}
catch (Exception e)
{
Utils.addErrorMessage("error regenerating rendition using " + r.getRenderingEngineTemplate().getName() +
": " + e.getMessage(),
e);
}
}
}
return result;
}
}

View File

@@ -33,6 +33,7 @@ import java.util.Map;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.sandbox.SandboxConstants; import org.alfresco.sandbox.SandboxConstants;
@@ -42,7 +43,14 @@ import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User; import org.alfresco.web.bean.repository.User;
import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.IDataContainer;
@@ -52,6 +60,8 @@ import org.alfresco.web.forms.FormImpl;
import org.alfresco.web.forms.FormsService; import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.RenderingEngineTemplate; import org.alfresco.web.forms.RenderingEngineTemplate;
import org.alfresco.web.forms.RenderingEngineTemplateImpl; import org.alfresco.web.forms.RenderingEngineTemplateImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** /**
* Provides configured data for a web project. * Provides configured data for a web project.
@@ -165,6 +175,9 @@ public class WebProject
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
private final static Log LOGGER = LogFactory.getLog(WebProject.class);
private static String websitesFolderId;
private final NodeRef nodeRef; private final NodeRef nodeRef;
public WebProject(final NodeRef nodeRef) public WebProject(final NodeRef nodeRef)
@@ -180,6 +193,16 @@ public class WebProject
SandboxConstants.PROP_WEB_PROJECT_NODE_REF).getValue(DataTypeDefinition.NODE_REF); SandboxConstants.PROP_WEB_PROJECT_NODE_REF).getValue(DataTypeDefinition.NODE_REF);
} }
/**
* Returns the noderef for the webproject
*
* @return the noderef for the webproject.
*/
public NodeRef getNodeRef()
{
return this.nodeRef;
}
/** /**
* Returns the name of the web project. * Returns the name of the web project.
* *
@@ -192,6 +215,30 @@ public class WebProject
return (String)nodeService.getProperty(this.nodeRef, ContentModel.PROP_NAME); return (String)nodeService.getProperty(this.nodeRef, ContentModel.PROP_NAME);
} }
/**
* Returns the title of the web project.
*
* @return the title of the web project.
*/
public String getTitle()
{
final ServiceRegistry serviceRegistry = this.getServiceRegistry();
final NodeService nodeService = serviceRegistry.getNodeService();
return (String)nodeService.getProperty(this.nodeRef, ContentModel.PROP_TITLE);
}
/**
* Returns the description of the web project.
*
* @return the description of the web project.
*/
public String getDescription()
{
final ServiceRegistry serviceRegistry = this.getServiceRegistry();
final NodeService nodeService = serviceRegistry.getNodeService();
return (String)nodeService.getProperty(this.nodeRef, ContentModel.PROP_DESCRIPTION);
}
/** /**
* Returns the store id for this web project. * Returns the store id for this web project.
* *
@@ -221,8 +268,8 @@ public class WebProject
*/ */
public List<Form> getForms() public List<Form> getForms()
{ {
List forms = new ArrayList(this.getFormsImpl().values()); final List forms = new ArrayList(this.getFormsImpl().values());
QuickSort sorter = new QuickSort(forms, "name", true, IDataContainer.SORT_CASEINSENSITIVE); final QuickSort sorter = new QuickSort(forms, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort(); sorter.sort();
return Collections.unmodifiableList(forms); return Collections.unmodifiableList(forms);
} }
@@ -290,6 +337,60 @@ public class WebProject
nodeService.getProperty(this.nodeRef, WCMAppModel.PROP_DEFAULTWEBAPP); nodeService.getProperty(this.nodeRef, WCMAppModel.PROP_DEFAULTWEBAPP);
} }
/**
* Helper to get the ID of the 'Websites' system folder
*
* @return ID of the 'Websites' system folder
*
* @throws AlfrescoRuntimeException if unable to find the required folder
*/
public static NodeRef getWebsitesFolder()
{
if (WebProject.websitesFolderId == null)
{
// get the template from the special Content Templates folder
final FacesContext fc = FacesContext.getCurrentInstance();
final String xpath = Application.getRootPath(fc) + "/" + Application.getWebsitesFolderName(fc);
final NodeRef rootNodeRef = WebProject.getServiceRegistry().getNodeService().getRootNode(Repository.getStoreRef());
final NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService();
final List<NodeRef> results = WebProject.getServiceRegistry().getSearchService().selectNodes(rootNodeRef, xpath, null, resolver, false);
if (results.size() == 1)
{
WebProject.websitesFolderId = results.get(0).getId();
}
else
{
throw new AlfrescoRuntimeException("Unable to find 'Websites' system folder at: " + xpath);
}
}
return new NodeRef(Repository.getStoreRef(), WebProject.websitesFolderId);
}
public static List<WebProject> getWebProjects()
{
final ServiceRegistry serviceRegistry = WebProject.getServiceRegistry();
final SearchParameters sp = new SearchParameters();
sp.addStore(Repository.getStoreRef());
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery("+TYPE:\"" + WCMAppModel.TYPE_AVMWEBFOLDER +
"\" +PARENT:\"" + WebProject.getWebsitesFolder() + "\"");
if (LOGGER.isDebugEnabled())
LOGGER.debug("running query [" + sp.getQuery() + "]");
final ResultSet rs = serviceRegistry.getSearchService().query(sp);
if (LOGGER.isDebugEnabled())
LOGGER.debug("received " + rs.length() + " results");
final List<WebProject> result = new ArrayList<WebProject>(rs.length());
for (ResultSetRow row : rs)
{
result.add(new WebProject(row.getNodeRef()));
}
QuickSort sorter = new QuickSort((List)result, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
return result;
}
private Map<String, Form> getFormsImpl() private Map<String, Form> getFormsImpl()
{ {
final ServiceRegistry serviceRegistry = this.getServiceRegistry(); final ServiceRegistry serviceRegistry = this.getServiceRegistry();
@@ -309,9 +410,21 @@ public class WebProject
return result; return result;
} }
private ServiceRegistry getServiceRegistry() private static ServiceRegistry getServiceRegistry()
{ {
final FacesContext fc = FacesContext.getCurrentInstance(); final FacesContext fc = FacesContext.getCurrentInstance();
return Repository.getServiceRegistry(fc); return Repository.getServiceRegistry(fc);
} }
}
public boolean equals(final Object other)
{
return (other != null &&
other instanceof WebProject &&
this.getNodeRef().equals(((WebProject)other).getNodeRef()));
}
public int hashCode()
{
return this.nodeRef.hashCode();
}
}

View File

@@ -19,7 +19,8 @@
* and Open Source Software ("FLOSS") applications as described in Alfresco's * and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing * FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here: * 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; package org.alfresco.web.forms;
import freemarker.ext.dom.NodeModel; import freemarker.ext.dom.NodeModel;

View File

@@ -38,6 +38,49 @@ public interface FormInstanceData
extends Serializable extends Serializable
{ {
/////////////////////////////////////////////////////////////////////////////
public static class RegenerateResult
{
private final RenderingEngineTemplate ret;
private final Rendition r;
private final Exception e;
public RegenerateResult(final RenderingEngineTemplate ret,
final Rendition r)
{
this.ret = ret;
this.r = r;
this.e = null;
}
public RegenerateResult(final RenderingEngineTemplate ret,
final Exception e)
{
this.ret = ret;
this.e = e;
this.r = null;
}
public RenderingEngineTemplate getRenderingEngineTemplate()
{
return this.ret;
}
public Rendition getRendition()
{
return this.r;
}
public Exception getException()
{
return this.e;
}
}
/////////////////////////////////////////////////////////////////////////////
/** the form generate this form instance data */ /** the form generate this form instance data */
public Form getForm(); public Form getForm();
@@ -60,6 +103,9 @@ public interface FormInstanceData
public Document getDocument() public Document getDocument()
throws IOException, SAXException; throws IOException, SAXException;
/** Regenerates all renditions of this form instance data */
public List<RegenerateResult> regenerateRenditions();
/** returns all renditions of this form instance data */ /** returns all renditions of this form instance data */
public List<Rendition> getRenditions(); public List<Rendition> getRenditions();
} }

View File

@@ -119,6 +119,61 @@ public class FormInstanceDataImpl
return AVMUtil.buildAssetUrl(this.getPath()); return AVMUtil.buildAssetUrl(this.getPath());
} }
public List<FormInstanceData.RegenerateResult> regenerateRenditions()
{
if (LOGGER.isDebugEnabled())
LOGGER.debug("regenerating renditions of " + this);
String originalParentAvmPath = (String)
this.getServiceRegistry().getNodeService().getProperty(this.getNodeRef(),
WCMAppModel.PROP_ORIGINAL_PARENT_PATH);
if (originalParentAvmPath == null)
{
originalParentAvmPath = AVMNodeConverter.SplitBase(this.getPath())[0];
}
final HashSet<RenderingEngineTemplate> allRets =
new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
final List<RegenerateResult> result = new LinkedList<RegenerateResult>();
// regenerate existing renditions
for (final Rendition r : this.getRenditions())
{
final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
if (ret == null || !allRets.contains(ret))
{
continue;
}
try
{
LOGGER.debug("regenerating rendition " + r + " using template " + ret);
ret.render(this, r);
allRets.remove(ret);
result.add(new RegenerateResult(ret, r));
}
catch (Exception e)
{
result.add(new RegenerateResult(ret, e));
}
}
// render all renditions for newly added templates
for (final RenderingEngineTemplate ret : allRets)
{
try
{
final String path = ret.getOutputPathForRendition(this, originalParentAvmPath);
LOGGER.debug("regenerating rendition of " + this.getPath() +
" at " + path + " using template " + ret);
result.add(new RegenerateResult(ret, ret.render(this, path)));
}
catch (Exception e)
{
result.add(new RegenerateResult(ret, e));
}
}
return result;
}
public List<Rendition> getRenditions() public List<Rendition> getRenditions()
{ {
final AVMService avmService = this.getServiceRegistry().getAVMService(); final AVMService avmService = this.getServiceRegistry().getAVMService();
@@ -131,8 +186,18 @@ public class FormInstanceDataImpl
final List<Rendition> result = new ArrayList<Rendition>(renditionPaths.size()); final List<Rendition> result = new ArrayList<Rendition>(renditionPaths.size());
for (Serializable path : renditionPaths) for (Serializable path : renditionPaths)
{ {
result.add(new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, storeName + ':' + (String)path))); if (avmService.lookup(-1, storeName + ':' + (String)path) != null)
{
final Rendition r = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, storeName + ':' + (String)path));
if (r.getRenderingEngineTemplate() != null)
{
result.add(r);
}
}
else
{
LOGGER.debug("ignoring dangling rendition at " + storeName + ':' + (String)path);
}
} }
return result; return result;
} }
@@ -142,4 +207,15 @@ public class FormInstanceDataImpl
final FacesContext fc = FacesContext.getCurrentInstance(); final FacesContext fc = FacesContext.getCurrentInstance();
return Repository.getServiceRegistry(fc); return Repository.getServiceRegistry(fc);
} }
public int hashCode()
{
return this.getPath().hashCode() ^ this.getForm().hashCode();
}
public String toString()
{
return (this.getClass().getName() + "{path : " + this.getPath() +
", form : " + this.getForm().getName() + "}");
}
} }

View File

@@ -186,7 +186,8 @@ public final class FormsService
final SearchParameters sp = new SearchParameters(); final SearchParameters sp = new SearchParameters();
sp.addStore(Repository.getStoreRef()); sp.addStore(Repository.getStoreRef());
sp.setLanguage(SearchService.LANGUAGE_LUCENE); sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery("ASPECT:\"" + WCMAppModel.ASPECT_FORM + "\""); sp.setQuery("+ASPECT:\"" + WCMAppModel.ASPECT_FORM +
"\" +PARENT:\"" + this.getContentFormsNodeRef() + "\"");
if (LOGGER.isDebugEnabled()) if (LOGGER.isDebugEnabled())
LOGGER.debug("running query [" + sp.getQuery() + "]"); LOGGER.debug("running query [" + sp.getQuery() + "]");
final ResultSet rs = this.searchService.query(sp); final ResultSet rs = this.searchService.query(sp);

View File

@@ -19,7 +19,8 @@
* and Open Source Software ("FLOSS") applications as described in Alfresco's * and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing * FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here: * 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; package org.alfresco.web.forms;
import freemarker.ext.dom.NodeModel; import freemarker.ext.dom.NodeModel;
@@ -564,5 +565,10 @@ public class RenderingEngineTemplateImpl
{ {
return this.getName().hashCode(); return this.getName().hashCode();
} }
public String toString()
{
return this.getClass().getName() + "{name : " + this.getName() + "}";
}
} }

View File

@@ -19,7 +19,8 @@
* and Open Source Software ("FLOSS") applications as described in Alfresco's * and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing * FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here: * 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; package org.alfresco.web.forms;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@@ -35,6 +36,7 @@ import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.util.Pair;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.AVMUtil;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
@@ -65,6 +67,11 @@ public class RenditionImpl
this.nodeRef = nodeRef; this.nodeRef = nodeRef;
} }
public RenditionImpl(final int version, final String avmPath)
{
this(AVMNodeConverter.ToNodeRef(version, avmPath));
}
/** the name of this rendition */ /** the name of this rendition */
public String getName() public String getName()
{ {
@@ -118,9 +125,22 @@ public class RenditionImpl
final NodeRef retNodeRef = (NodeRef) final NodeRef retNodeRef = (NodeRef)
nodeService.getProperty(this.nodeRef, nodeService.getProperty(this.nodeRef,
WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE); WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE);
if (retNodeRef == null)
{
LOGGER.debug("unable to locate parent rendering engine template of rendition " +
this.getPath());
return null;
}
final NodeRef rpNodeRef = (NodeRef) final NodeRef rpNodeRef = (NodeRef)
nodeService.getProperty(this.nodeRef, nodeService.getProperty(this.nodeRef,
WCMAppModel.PROP_PARENT_RENDITION_PROPERTIES); WCMAppModel.PROP_PARENT_RENDITION_PROPERTIES);
if (rpNodeRef == null)
{
LOGGER.debug("unable to locate parent rendering engine template properties of rendition " +
this.getPath());
return null;
}
this.renderingEngineTemplate = new RenderingEngineTemplateImpl(retNodeRef, rpNodeRef); this.renderingEngineTemplate = new RenderingEngineTemplateImpl(retNodeRef, rpNodeRef);
} }
return this.renderingEngineTemplate; return this.renderingEngineTemplate;
@@ -149,7 +169,12 @@ public class RenditionImpl
public OutputStream getOutputStream() public OutputStream getOutputStream()
{ {
return this.getServiceRegistry().getAVMService().getFileOutputStream(this.getPath()); final AVMService avmService = this.getServiceRegistry().getAVMService();
final Pair<Integer, String> p = AVMNodeConverter.ToAVMVersionPath(this.nodeRef);
return (avmService.lookup(p.getFirst(), p.getSecond()) == null
? avmService.createFile(AVMNodeConverter.SplitBase(p.getSecond())[0],
AVMNodeConverter.SplitBase(p.getSecond())[1])
: avmService.getFileOutputStream(this.getPath()));
} }
public void regenerate() public void regenerate()
@@ -174,4 +199,17 @@ public class RenditionImpl
final FacesContext fc = FacesContext.getCurrentInstance(); final FacesContext fc = FacesContext.getCurrentInstance();
return Repository.getServiceRegistry(fc); return Repository.getServiceRegistry(fc);
} }
public int hashCode()
{
return this.getPath().hashCode() ^ this.getRenderingEngineTemplate().hashCode();
}
public String toString()
{
return (this.getClass().getName() +
"{path : " + this.getPath() +
", rendering_engine_template : " + this.getRenderingEngineTemplate() +
"}");
}
} }

View File

@@ -57,7 +57,6 @@ public class UIListItems extends SelfRenderingComponent
this.value = vb.getValue(getFacesContext()); this.value = vb.getValue(getFacesContext());
} }
} }
return this.value; return this.value;
} }
@@ -85,11 +84,8 @@ public class UIListItems extends SelfRenderingComponent
*/ */
public Object saveState(FacesContext context) public Object saveState(FacesContext context)
{ {
Object values[] = new Object[2];
// standard component attributes are saved by the super class // standard component attributes are saved by the super class
values[0] = super.saveState(context); return new Object[] { super.saveState(context), this.value };
values[1] = this.value;
return (values);
} }
} }

View File

@@ -27,6 +27,7 @@ package org.alfresco.web.ui.common.component;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.faces.component.NamingContainer; import javax.faces.component.NamingContainer;
@@ -65,7 +66,7 @@ public class UISelectList extends UIInput implements NamingContainer
private Boolean activeSelect; private Boolean activeSelect;
private int rowIndex = -1; private int rowIndex = -1;
private int itemCount; private int itemCount;
private String onchange = null;
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Component Impl // Component Impl
@@ -97,6 +98,7 @@ public class UISelectList extends UIInput implements NamingContainer
this.multiSelect = (Boolean)values[1]; this.multiSelect = (Boolean)values[1];
this.activeSelect = (Boolean)values[2]; this.activeSelect = (Boolean)values[2];
this.itemCount = (Integer)values[3]; this.itemCount = (Integer)values[3];
this.onchange = (String)values[4];
} }
/** /**
@@ -104,13 +106,14 @@ public class UISelectList extends UIInput implements NamingContainer
*/ */
public Object saveState(FacesContext context) public Object saveState(FacesContext context)
{ {
Object values[] = new Object[4]; return new Object[]
// standard component attributes are saved by the super class {
values[0] = super.saveState(context); super.saveState(context),
values[1] = this.multiSelect; this.multiSelect,
values[2] = this.activeSelect; this.activeSelect,
values[3] = this.itemCount; this.itemCount,
return (values); this.onchange
};
} }
/** /**
@@ -124,11 +127,7 @@ public class UISelectList extends UIInput implements NamingContainer
{ {
String clientId = super.getClientId(context); String clientId = super.getClientId(context);
int rowIndex = getRowIndex(); int rowIndex = getRowIndex();
if (rowIndex == -1) return (rowIndex == -1 ? clientId : clientId + "_" + rowIndex);
{
return clientId;
}
return clientId + "_" + rowIndex;
} }
/** /**
@@ -144,9 +143,8 @@ public class UISelectList extends UIInput implements NamingContainer
} }
setRowIndex(-1); setRowIndex(-1);
for (Iterator itr=getChildren().iterator(); itr.hasNext(); /**/) for (UIComponent child : (List<UIComponent>)this.getChildren())
{ {
UIComponent child = (UIComponent)itr.next();
if (child instanceof UIListItem == false && child instanceof UIListItems == false) if (child instanceof UIListItem == false && child instanceof UIListItems == false)
{ {
for (int i=0; i<this.itemCount; i++) for (int i=0; i<this.itemCount; i++)
@@ -238,7 +236,7 @@ public class UISelectList extends UIInput implements NamingContainer
*/ */
public void encodeBegin(FacesContext context) throws IOException public void encodeBegin(FacesContext context) throws IOException
{ {
if (isRendered() == false) if (!isRendered())
{ {
return; return;
} }
@@ -269,18 +267,16 @@ public class UISelectList extends UIInput implements NamingContainer
// get the child components and look for compatible ListItem objects // get the child components and look for compatible ListItem objects
this.itemCount = 0; this.itemCount = 0;
setRowIndex(-1); setRowIndex(-1);
for (Iterator i = getChildren().iterator(); i.hasNext(); /**/) for (final UIComponent child : (List<UIComponent>)this.getChildren())
{ {
UIComponent child = (UIComponent)i.next();
if (child instanceof UIListItems) if (child instanceof UIListItems)
{ {
// get the value of the list items component and iterate through it's collection // get the value of the list items component and iterate through it's collection
Object listItems = ((UIListItems)child).getValue(); Object listItems = ((UIListItems)child).getValue();
if (listItems instanceof Collection) if (listItems instanceof Collection)
{ {
for (Iterator iter = ((Collection)listItems).iterator(); iter.hasNext(); /**/) for (final UIListItem item : (Collection<UIListItem>)listItems)
{ {
UIListItem item = (UIListItem)iter.next();
if (item.isRendered()) if (item.isRendered())
{ {
if (var != null) if (var != null)
@@ -355,7 +351,11 @@ public class UISelectList extends UIInput implements NamingContainer
out.write(id); out.write(id);
out.write("' value='"); out.write("' value='");
out.write(itemValue); out.write(itemValue);
out.write('\''); out.write("'");
if (this.onchange != null)
{
out.write(" onchange='" + this.onchange + "'");
}
String[] value = (String[])getValue(); String[] value = (String[])getValue();
if (multiSelect) if (multiSelect)
{ {
@@ -454,9 +454,8 @@ public class UISelectList extends UIInput implements NamingContainer
if (isActiveSelect()) if (isActiveSelect())
{ {
this.rowIndex = rowIndex; this.rowIndex = rowIndex;
for (Iterator itr=getChildren().iterator(); itr.hasNext(); /**/) for (UIComponent child : (List<UIComponent>)this.getChildren())
{ {
UIComponent child = (UIComponent)itr.next();
if (child instanceof UIListItem == false && child instanceof UIListItems == false) if (child instanceof UIListItem == false && child instanceof UIListItems == false)
{ {
// forces a reset of the clientId for the component // forces a reset of the clientId for the component
@@ -482,15 +481,7 @@ public class UISelectList extends UIInput implements NamingContainer
this.multiSelect = (Boolean)vb.getValue(getFacesContext()); this.multiSelect = (Boolean)vb.getValue(getFacesContext());
} }
if (this.multiSelect != null) return this.multiSelect != null ? this.multiSelect.booleanValue() : false;
{
return this.multiSelect.booleanValue();
}
else
{
// return the default
return false;
}
} }
/** /**
@@ -516,15 +507,7 @@ public class UISelectList extends UIInput implements NamingContainer
this.activeSelect = (Boolean)vb.getValue(getFacesContext()); this.activeSelect = (Boolean)vb.getValue(getFacesContext());
} }
if (this.activeSelect != null) return (this.activeSelect != null ? this.activeSelect.booleanValue() : false;
{
return this.activeSelect.booleanValue();
}
else
{
// return the default
return false;
}
} }
/** /**

View File

@@ -59,6 +59,7 @@ public class SelectListTag extends HtmlComponentTag
setStringProperty(component, "itemStyle", this.itemStyle); setStringProperty(component, "itemStyle", this.itemStyle);
setStringProperty(component, "itemStyleClass", this.itemStyleClass); setStringProperty(component, "itemStyleClass", this.itemStyleClass);
setStringProperty(component, "value", this.value); setStringProperty(component, "value", this.value);
setStringProperty(component, "onchange", this.onchange);
} }
/** /**
@@ -73,6 +74,7 @@ public class SelectListTag extends HtmlComponentTag
this.itemStyle = null; this.itemStyle = null;
this.itemStyleClass = null; this.itemStyleClass = null;
this.value = null; this.value = null;
this.onchange = null;
} }
/** /**
@@ -135,6 +137,16 @@ public class SelectListTag extends HtmlComponentTag
this.value = value; this.value = value;
} }
/**
* Set the onchange handler
*
* @param value the onchange handler.
*/
public void setOnchange(final String onchange)
{
this.onchange = onchange;
}
/** the selected value */ /** the selected value */
private String value; private String value;
@@ -152,4 +164,7 @@ public class SelectListTag extends HtmlComponentTag
/** the variable name for row item context */ /** the variable name for row item context */
private String var; private String var;
/** the event handler for a change in selection */
private String onchange;
} }

View File

@@ -1959,6 +1959,12 @@
<rtexprvalue>true</rtexprvalue> <rtexprvalue>true</rtexprvalue>
</attribute> </attribute>
<attribute>
<name>onchange</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute> <attribute>
<name>value</name> <name>value</name>
<required>false</required> <required>false</required>

View File

@@ -2482,6 +2482,51 @@
<value>#{WorkflowService}</value> <value>#{WorkflowService}</value>
</managed-property> </managed-property>
</managed-bean> </managed-bean>
<managed-bean>
<description>
The bean that backs up the Regenerate Renditions Wizard
</description>
<managed-bean-name>RegenerateRenditionsWizard</managed-bean-name>
<managed-bean-class>org.alfresco.web.bean.wcm.RegenerateRenditionsWizard</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>nodeService</property-name>
<value>#{NodeService}</value>
</managed-property>
<managed-property>
<property-name>fileFolderService</property-name>
<value>#{FileFolderService}</value>
</managed-property>
<managed-property>
<property-name>searchService</property-name>
<value>#{SearchService}</value>
</managed-property>
<managed-property>
<property-name>namespaceService</property-name>
<value>#{NamespaceService}</value>
</managed-property>
<managed-property>
<property-name>navigator</property-name>
<value>#{NavigationBean}</value>
</managed-property>
<managed-property>
<property-name>browseBean</property-name>
<value>#{BrowseBean}</value>
</managed-property>
<managed-property>
<property-name>contentService</property-name>
<value>#{ContentService}</value>
</managed-property>
<managed-property>
<property-name>avmService</property-name>
<value>#{AVMService}</value>
</managed-property>
<managed-property>
<property-name>avmSyncService</property-name>
<value>#{AVMSyncService}</value>
</managed-property>
</managed-bean>
<managed-bean> <managed-bean>
<description> <description>

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,4 +1,4 @@
<%-- <!--
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2007 Alfresco Software Limited.
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@@ -19,206 +19,218 @@
* FLOSS exception. You should have recieved a copy of the text describing * FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here: * 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" %> <jsp:root version="1.2"
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> xmlns:jsp="http://java.sun.com/JSP/Page"
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> xmlns:c="http://java.sun.com/jsp/jstl/core"
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
<%@ page import="org.alfresco.web.bean.wcm.CreateFormWizard" %> xmlns:a="urn:jsptld:/WEB-INF/alfresco.tld"
<%@ page import="org.alfresco.web.ui.common.PanelGenerator" %> xmlns:f="http://java.sun.com/jsf/core"
<f:verbatim> xmlns:h="http://java.sun.com/jsf/html">
<script type="text/javascript"
src="<%=request.getContextPath()%>/scripts/validation.js">
</script>
<script type="text/javascript"
src="<%=request.getContextPath()%>/scripts/upload_helper.js">
</script>
<script type="text/javascript"> <jsp:output doctype-root-element="html"
var finishButtonPressed = false; doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
window.onload = pageLoaded; doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
function pageLoaded()
{
if (document.getElementById("wizard:wizard-body:file-input"))
document.getElementById("wizard:wizard-body:file-input").focus()
else
document.getElementById("wizard:wizard-body:form-name").focus();
document.getElementById("wizard").onsubmit = validate;
document.getElementById("wizard:next-button").onclick = function() {finishButtonPressed = true; clear_wizard();}
document.getElementById("wizard:finish-button").onclick = function() {finishButtonPressed = true; clear_wizard();}
}
function validate()
{
if (!finishButtonPressed)
return true;
finishButtonPressed = false;
var formName = document.getElementById("wizard:wizard-body:form-name");
return validateMandatory(formName) &&
validateName(formName,
'</f:verbatim><a:outputText value="#{msg.validation_invalid_character}" /><f:verbatim>',
true)
}
function handle_upload(target)
{
handle_upload_helper(target,
"<%= CreateFormWizard.FILE_SCHEMA %>",
upload_complete,
"<%= request.getContextPath() %>")
}
function upload_complete(id, path, filename) <jsp:directive.page import="org.alfresco.web.ui.common.PanelGenerator"/>
{ <jsp:directive.page import="org.alfresco.web.bean.wcm.CreateFormWizard"/>
var schema_file_input = <jsp:directive.page language="java" buffer="32kb" contentType="text/html; charset=UTF-8"/>
document.getElementById("wizard:wizard-body:schema-file"); <jsp:directive.page isELIgnored="false"/>
schema_file_input.value = filename;
schema_file_input.form.submit();
}
</script>
</f:verbatim>
<h:inputText id="schema-file" <f:verbatim>
value="#{WizardManager.bean.schemaFileName}" <script type="text/javascript"
immediate="true" src="${pageContext.request.contextPath}/scripts/validation.js">&#160;
style="display:none;" </script>
valueChangeListener="#{WizardManager.bean.schemaFileValueChanged}"/> <script type="text/javascript"
src="${pageContext.request.contextPath}/scripts/upload_helper.js">&#160;
<h:panelGrid id="panel_grid_1" </script>
columns="1" cellpadding="2"
style="padding-top: 4px; padding-bottom: 4px;"
width="100%" rowClasses="wizardSectionHeading">
<h:outputText id="panel_grid_1_out_1"
value="&nbsp;#{msg.general_properties}" escape="false" />
</h:panelGrid>
<h:panelGrid id="panel_grid_2"
columns="1" cellpadding="3" cellspacing="3" border="0" width="100%">
<h:outputText id="step-1-text"
value="1. #{msg.create_form_form_details_step1_desc}"
escape="false" />
<h:panelGrid id="schema_panel_grid"
columns="4"
cellpadding="3"
cellspacing="3"
border="0"
width="100%"
columnClasses="panelGridRequiredImageColumn,panelGridLabelColumn,panelGridValueColumn,panelGridRequiredImageColumn">
<h:graphicImage id="img_schema"
value="/images/icons/required_field.gif" alt="#{msg.required_field}" />
<h:outputText id="out_schema"
value="#{msg.schema}:"/>
<h:column id="column_schema_empty"
rendered="#{empty WizardManager.bean.schemaFileName}">
<f:verbatim><input id="wizard:wizard-body:file-input"
type="file"
size="35"
name="alfFileInput"
onchange="javascript:handle_upload(this)"/></f:verbatim>
</h:column>
<h:column id="column_schema_not_empty"
rendered="#{!empty WizardManager.bean.schemaFileName}">
<h:outputText id="out_schema_name"
value="#{WizardManager.bean.schemaFileName}"/>
<h:outputText id="out_schema_space"
value="&nbsp;"
escape="false"/>
<a:actionLink id="action_link_remove_schema"
image="/images/icons/delete.gif"
value="#{msg.remove}"
action="#{WizardManager.bean.removeUploadedSchemaFile}"
showLink="false"
target="top"/>
</h:column>
<h:column id="no_img_schema_help"/>
<h:column id="no_img_root_element_name"/> <script type="text/javascript">
<h:outputText id="out_root_element_name" value="#{msg.schema_root_element_name}:"/> var finishButtonPressed = false;
<h:selectOneMenu id="schema-root-element-name" window.onload = pageLoaded;
disabled="#{WizardManager.bean.schemaFileName == null}"
style="width:100%;" function pageLoaded()
value="#{WizardManager.bean.schemaRootElementName}" {
rendered="#{!empty WizardManager.bean.schemaRootElementNameChoices}"> if (document.getElementById("wizard:wizard-body:file-input"))
<f:selectItems id="schema-root-element-name-choices" document.getElementById("wizard:wizard-body:file-input").focus()
value="#{WizardManager.bean.schemaRootElementNameChoices}"/> else
</h:selectOneMenu> document.getElementById("wizard:wizard-body:form-name").focus();
<h:outputText id="schema-root-element-name-no-schema" document.getElementById("wizard").onsubmit = validate;
rendered="#{empty WizardManager.bean.schemaRootElementNameChoices && empty WizardManager.bean.schemaFileName}" document.getElementById("wizard:next-button").onclick = function() {finishButtonPressed = true; clear_wizard();}
value="#{msg.create_form_form_details_no_schema_selected}"/> document.getElementById("wizard:finish-button").onclick = function() {finishButtonPressed = true; clear_wizard();}
<h:panelGroup id="schema-root-element-name-no-choices" }
rendered="#{empty WizardManager.bean.schemaRootElementNameChoices && !empty WizardManager.bean.schemaFileName}">
<f:verbatim><% PanelGenerator.generatePanelStart(out, request.getContextPath(), "yellowInner", "#ffffcc"); %></f:verbatim> function validate()
<h:panelGrid columns="2" cellpadding="0" cellpadding="0"> {
<h:graphicImage url="/images/icons/warning.gif" style="padding-top:2px;padding-right:4px" width="16" height="16"/> if (!finishButtonPressed)
<h:outputText styleClass="mainSubText" value="#{msg.create_form_form_details_no_elements_in_schema}"/> return true;
</h:panelGrid> finishButtonPressed = false;
<f:verbatim><% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "yellowInner"); %></f:verbatim> var formName = document.getElementById("wizard:wizard-body:form-name");
</h:panelGroup> return validateMandatory(formName) <![CDATA[&&]]>
<%-- we need to include this invisible image in order to get the column to size correctly --%> validateName(formName,
<h:graphicImage id="invisible_img_schema_root_element_name_choices_help" "${msg.validation_invalid_character}",
value="/images/icons/Help_icon.gif" style="cursor:help; visibility: hidden;"/> true)
}
function handle_upload(target)
{
handle_upload_helper(target,
"<jsp:expression>CreateFormWizard.FILE_SCHEMA</jsp:expression>",
upload_complete,
"${pageContext.request.contextPath}")
}
function upload_complete(id, path, filename)
{
var schema_file_input =
document.getElementById("wizard:wizard-body:schema-file");
schema_file_input.value = filename;
schema_file_input.form.submit();
}
</script>
</f:verbatim>
<h:inputText id="schema-file"
value="#{WizardManager.bean.schemaFileName}"
immediate="true"
style="display:none;"
valueChangeListener="#{WizardManager.bean.schemaFileValueChanged}"/>
<h:panelGrid id="panel_grid_1"
columns="1" cellpadding="2"
style="padding-top: 4px; padding-bottom: 4px;"
width="100%" rowClasses="wizardSectionHeading">
<h:outputText id="panel_grid_1_out_1"
value="&#160;#{msg.general_properties}" escape="false" />
</h:panelGrid> </h:panelGrid>
<h:outputText id="step-2-text" value="2. #{msg.create_form_form_details_step2_desc}" escape="false" /> <h:panelGrid id="panel_grid_2"
columns="1" cellpadding="3" cellspacing="3" border="0" width="100%">
<h:panelGrid id="details_panel_grid" <h:outputText id="step-1-text"
columns="4" value="1. #{msg.create_form_form_details_step1_desc}"
cellpadding="3" escape="false" />
cellspacing="3"
border="0"
columnClasses="panelGridRequiredImageColumn,panelGridLabelColumn,panelGridValueColumn,panelGridRequiredImageColumn">
width="100%">
<h:graphicImage id="img_name"
value="/images/icons/required_field.gif"
alt="#{msg.required_field}" />
<h:outputText id="out_name" value="#{msg.name}:"/>
<h:inputText id="form-name"
disabled="#{WizardManager.bean.schemaFileName == null}"
value="#{WizardManager.bean.formName}"
maxlength="1024"
size="35"/>
<h:column id="no_img_name_help"/>
<h:column id="no_img_title"/> <h:panelGrid id="schema_panel_grid"
<h:outputText id="out_title" value="#{msg.title}:"/> columns="4"
<h:inputText id="form-title" cellpadding="3"
disabled="#{WizardManager.bean.schemaFileName == null}" cellspacing="3"
value="#{WizardManager.bean.formTitle}" border="0"
maxlength="1024" width="100%"
size="35"/> columnClasses="panelGridRequiredImageColumn,panelGridLabelColumn,panelGridValueColumn,panelGridRequiredImageColumn">
<h:column id="no_img_title_help"/> <h:graphicImage id="img_schema"
value="/images/icons/required_field.gif" alt="#{msg.required_field}" />
<h:column id="no_img_description"/> <h:outputText id="out_schema"
<h:outputText id="out_description" value="#{msg.description}:"/> value="#{msg.schema}:"/>
<h:inputText id="form-description" <h:column id="column_schema_empty"
disabled="#{WizardManager.bean.schemaFileName == null}" rendered="#{empty WizardManager.bean.schemaFileName}">
value="#{WizardManager.bean.formDescription}" <f:verbatim><input id="wizard:wizard-body:file-input"
maxlength="1024" type="file"
style="width:100%"/> size="35"
<h:outputText id="no_img_description_help" value=""/> name="alfFileInput"
onchange="javascript:handle_upload(this)"/></f:verbatim>
<h:graphicImage id="img_form_instance_data_output_path_pattern" </h:column>
value="/images/icons/required_field.gif" <h:column id="column_schema_not_empty"
alt="#{msg.required_field}" /> rendered="#{!empty WizardManager.bean.schemaFileName}">
<h:outputText id="out_form_instance_data_output_path_pattern" <h:outputText id="out_schema_name"
value="#{msg.output_path_pattern}:"/> value="#{WizardManager.bean.schemaFileName}"/>
<h:inputText id="form_instance_data_output_path_pattern" <h:outputText id="out_schema_space"
disabled="#{WizardManager.bean.schemaFileName == null}" value="&#160;"
value="#{WizardManager.bean.outputPathPatternForFormInstanceData}" escape="false"/>
style="width:100%"/> <a:actionLink id="action_link_remove_schema"
<h:graphicImage id="img_form_instance_data_output_path_pattern_help" image="/images/icons/delete.gif"
value="/images/icons/Help_icon.gif" style="cursor:help" value="#{msg.remove}"
onclick="javascript:toggleOutputPathPatternHelp()" /> action="#{WizardManager.bean.removeUploadedSchemaFile}"
showLink="false"
target="top"/>
</h:column>
<h:column id="no_img_schema_help"/>
<h:column id="no_img_root_element_name"/>
<h:outputText id="out_root_element_name" value="#{msg.schema_root_element_name}:"/>
<h:selectOneMenu id="schema-root-element-name"
disabled="#{WizardManager.bean.schemaFileName == null}"
style="width:100%;"
value="#{WizardManager.bean.schemaRootElementName}"
rendered="#{!empty WizardManager.bean.schemaRootElementNameChoices}">
<f:selectItems id="schema-root-element-name-choices"
value="#{WizardManager.bean.schemaRootElementNameChoices}"/>
</h:selectOneMenu>
<h:outputText id="schema-root-element-name-no-schema"
rendered="#{empty WizardManager.bean.schemaRootElementNameChoices and empty WizardManager.bean.schemaFileName}"
value="#{msg.create_form_form_details_no_schema_selected}"/>
<h:panelGroup id="schema-root-element-name-no-choices"
rendered="#{empty WizardManager.bean.schemaRootElementNameChoices and !empty WizardManager.bean.schemaFileName}">
<f:verbatim><jsp:scriptlet>PanelGenerator.generatePanelStart(out, request.getContextPath(), "yellowInner", "#ffffcc");</jsp:scriptlet></f:verbatim>
<h:panelGrid columns="2" cellspacing="0" cellpadding="0">
<h:graphicImage url="/images/icons/warning.gif" style="padding-top:2px;padding-right:4px" width="16" height="16"/>
<h:outputText styleClass="mainSubText" value="#{msg.create_form_form_details_no_elements_in_schema}"/>
</h:panelGrid>
<f:verbatim><jsp:scriptlet>PanelGenerator.generatePanelEnd(out, request.getContextPath(), "yellowInner");</jsp:scriptlet></f:verbatim>
</h:panelGroup>
<!-- we need to include this invisible image in order to get the column to size correctly -->
<h:graphicImage id="invisible_img_schema_root_element_name_choices_help"
value="/images/icons/Help_icon.gif" style="cursor:help; visibility: hidden;"/>
</h:panelGrid>
<h:column id="output_path_pattern_help_empty_col_1"/> <h:outputText id="step-2-text" value="2. #{msg.create_form_form_details_step2_desc}" escape="false" />
<h:column id="output_path_pattern_help_empty_col_2"/>
<f:verbatim> <h:panelGrid id="details_panel_grid"
<jsp:directive.include file="/jsp/wcm/output-path-pattern-help.jsp"/> columns="4"
</f:verbatim> cellpadding="3"
<h:column id="output_path_pattern_help_empty_col_3"/> cellspacing="3"
border="0"
columnClasses="panelGridRequiredImageColumn,panelGridLabelColumn,panelGridValueColumn,panelGridRequiredImageColumn"
width="100%">
<h:graphicImage id="img_name"
value="/images/icons/required_field.gif"
alt="#{msg.required_field}" />
<h:outputText id="out_name" value="#{msg.name}:"/>
<h:inputText id="form-name"
disabled="#{WizardManager.bean.schemaFileName == null}"
value="#{WizardManager.bean.formName}"
maxlength="1024"
size="35"/>
<h:column id="no_img_name_help"/>
<h:column id="no_img_title"/>
<h:outputText id="out_title" value="#{msg.title}:"/>
<h:inputText id="form-title"
disabled="#{WizardManager.bean.schemaFileName == null}"
value="#{WizardManager.bean.formTitle}"
maxlength="1024"
size="35"/>
<h:column id="no_img_title_help"/>
<h:column id="no_img_description"/>
<h:outputText id="out_description" value="#{msg.description}:"/>
<h:inputText id="form-description"
disabled="#{WizardManager.bean.schemaFileName == null}"
value="#{WizardManager.bean.formDescription}"
maxlength="1024"
style="width:100%"/>
<h:outputText id="no_img_description_help" value=""/>
<h:graphicImage id="img_form_instance_data_output_path_pattern"
value="/images/icons/required_field.gif"
alt="#{msg.required_field}" />
<h:outputText id="out_form_instance_data_output_path_pattern"
value="#{msg.output_path_pattern}:"/>
<h:inputText id="form_instance_data_output_path_pattern"
disabled="#{WizardManager.bean.schemaFileName == null}"
value="#{WizardManager.bean.outputPathPatternForFormInstanceData}"
style="width:100%"/>
<h:graphicImage id="img_form_instance_data_output_path_pattern_help"
value="/images/icons/Help_icon.gif" style="cursor:help"
onclick="javascript:toggleOutputPathPatternHelp()" />
<h:column id="output_path_pattern_help_empty_col_1"/>
<h:column id="output_path_pattern_help_empty_col_2"/>
<f:verbatim>
<jsp:directive.include file="/jsp/wcm/output-path-pattern-help.jsp"/>
</f:verbatim>
<h:column id="output_path_pattern_help_empty_col_3"/>
</h:panelGrid>
</h:panelGrid> </h:panelGrid>
</h:panelGrid> </jsp:root>

View File

@@ -0,0 +1,108 @@
<!--
* 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
* 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
-->
<jsp:root version="1.2"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
xmlns:a="urn:jsptld:/WEB-INF/alfresco.tld"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<jsp:output doctype-root-element="html"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<jsp:directive.page language="java" buffer="32kb" contentType="text/html; charset=UTF-8"/>
<jsp:directive.page isELIgnored="false"/>
<h:panelGrid columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;"
width="100%">
<h:outputText id="step-1-text"
value="1. #{msg.regenerate_renditions_select_renditions_select_web_project}"
escape="false" />
<h:panelGrid id="panel_grid_3"
columns="3" cellpadding="3" cellspacing="3" border="0" width="100%"
columnClasses="panelGridRequiredImageColumn,panelGridLabelColumn,panelGridValueColumn">
<h:graphicImage id="img_web_project"
value="/images/icons/required_field.gif"
alt="#{msg.required_field}" />
<h:outputText id="output_text_web_project"
value="#{msg.web_project}:"/>
<h:selectOneMenu id="selectone-webproject"
style="width:100%;"
onchange="this.form.submit()"
value="#{WizardManager.bean.selectedWebProject}">
<f:selectItems id="selectitems-webproject"
value="#{WizardManager.bean.webProjectChoices}"/>
</h:selectOneMenu>
</h:panelGrid>
<h:outputText id="step-2-text"
value="2. #{msg.regenerate_renditions_select_renditions_select_regenerate_scope}"
escape="false" />
<h:selectOneRadio id="selectone-regenerate-mode"
onchange="this.form.submit()"
disabled="#{empty WizardManager.bean.selectedWebProject}"
layout="pageDirection"
value="#{WizardManager.bean.regenerateScope}">
<f:selectItem itemLabel="#{msg.regenerate_renditions_select_renditions_scope_all}"
itemValue="all"/>
<f:selectItem itemLabel="#{msg.regenerate_renditions_select_renditions_scope_form}"
itemValue="form"/>
<f:selectItem itemLabel="#{msg.regenerate_renditions_select_renditions_scope_rendering_engine_templates}"
itemValue="rendering_engine_template"/>
</h:selectOneRadio>
<h:panelGrid rendered="#{WizardManager.bean.regenerateScope eq 'form'}"
columns="3" cellpadding="3" cellspacing="3" border="0" width="100%"
columnClasses="panelGridRequiredImageColumn,panelGridLabelColumn,panelGridValueColumn">
<h:graphicImage value="/images/icons/required_field.gif"
alt="#{msg.required_field}" />
<h:outputText value="#{msg.form}:"/>
<a:selectList id="select_list_form_choices"
style="width:100%;"
onchange="this.form.submit()"
multiSelect="true"
value="#{WizardManager.bean.selectedForms}">
<a:listItems id="list_items_form_choices"
value="#{WizardManager.bean.formChoices}"/>
</a:selectList>
</h:panelGrid>
<h:panelGrid rendered="#{WizardManager.bean.regenerateScope eq 'rendering_engine_template'}"
columns="3" cellpadding="3" cellspacing="3" border="0" width="100%"
columnClasses="panelGridRequiredImageColumn,panelGridLabelColumn,panelGridValueColumn">
<h:graphicImage value="/images/icons/required_field.gif"
alt="#{msg.required_field}" />
<h:outputText value="#{msg.rendering_engine_template}:"/>
<a:selectList id="select_list_rendering_engine_template_choices"
style="width:100%;"
multiSelect="true"
value="#{WizardManager.bean.selectedRenderingEngineTemplates}">
<a:listItems id="list_items_rendering_engine_template_choices"
value="#{WizardManager.bean.renderingEngineTemplateChoices}"/>
</a:selectList>
</h:panelGrid>
</h:panelGrid>
</jsp:root>

View File

@@ -0,0 +1,71 @@
<!--
* 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
* 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
-->
<jsp:root version="1.2"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
xmlns:a="urn:jsptld:/WEB-INF/alfresco.tld"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<jsp:output doctype-root-element="html"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<jsp:directive.page language="java" buffer="32kb" contentType="text/html; charset=UTF-8"/>
<jsp:directive.page isELIgnored="false"/>
<h:panelGrid columns="1" cellpadding="3" cellspacing="3" border="0" width="100%">
<a:richList id="renditions-list" viewMode="details" value="#{WizardManager.bean.regeneratedRenditions}" var="r"
binding="#{WizardManager.bean.regeneratedRenditionsRichList}"
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow"
altRowStyleClass="recordSetRowAlt" width="100%" pageSize="10"
initialSortColumn="name" initialSortDescending="true"
rendered="#{not empty WizardManager.bean.regeneratedRenditions}">
<a:column id="col1" primary="true" width="200" style="padding: 2px; text-align:left">
<f:facet name="header">
<a:sortLink id="col1-sort" label="#{msg.name}" value="name" mode="case-insensitive" styleClass="header"/>
</f:facet>
<f:facet name="small-icon">
<a:actionLink id="col1-act1" value="#{r.name}" href="#{r.url}" target="new" image="#{r.fileTypeImage}"
showLink="false" styleClass="inlineAction" />
</f:facet>
<a:actionLink id="col1-act2" value="#{r.name}" href="#{r.url}" target="new" />
</a:column>
<a:column id="col2" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col2-sort" label="#{msg.description}" value="description" styleClass="header"/>
</f:facet>
<h:outputText id="col2-txt" value="#{r.description}" />
</a:column>
<a:column id="col6" actions="true" style="padding:2px;text-align:left">
<f:facet name="header">
<h:outputText id="col6-txt" value="#{msg.actions}"/>
</f:facet>
<a:actionLink href="#{r.url}" showLink="true" image="/images/icons/preview_website.gif" value="#{msg.file_preview}"/>
</a:column>
<a:dataPager styleClass="pager" />
</a:richList>
</h:panelGrid>
</jsp:root>