- adding in a getRenditions call to forminstancedata

- some further cleanup and fixes for summary screens
- adding new repeat icons from linton
- fix for filename expanding endlessly when pressing the back button at the summary page for create web content.
- making the primaryfominstancedata property of rendition a sandbox relative path so as to make it easier to retrieve the corresponding xml in the same sandbox

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4557 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-12-07 21:03:58 +00:00
parent c513c17e70
commit 406f9b4f4e
14 changed files with 95 additions and 32 deletions

View File

@@ -43,6 +43,8 @@ import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.FormProcessor;
import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.Rendition;
import org.alfresco.web.forms.RenditionImpl;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -269,7 +271,7 @@ public class AVMEditBean
{
if (LOGGER.isDebugEnabled())
LOGGER.debug(avmRef + " is a rendition, editing primary rendition instead");
avmRef = (NodeRef)this.nodeService.getProperty(avmRef, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA);
avmRef = new RenditionImpl(avmRef).getPrimaryFormInstanceData().getNodeRef();
final Pair<Integer, String> p = AVMNodeConverter.ToAVMVersionPath(avmRef);
if (LOGGER.isDebugEnabled())

View File

@@ -233,6 +233,12 @@ public class CreateWebContentWizard extends BaseContentWizard
}
this.avmSyncService.update(diffList, null, true, true, true, true, null, null);
// reset all paths and structures to the main store
this.createdPath = this.createdPath.replaceFirst(AVMConstants.STORE_PREVIEW,
AVMConstants.STORE_MAIN);
this.formInstanceData = new FormInstanceDataImpl(AVMNodeConverter.ToNodeRef(-1, this.createdPath));
this.renditions = this.formInstanceData.getRenditions();
if (this.startWorkflow)
{
WorkflowDefinition wd = null;
@@ -317,6 +323,7 @@ public class CreateWebContentWizard extends BaseContentWizard
this.nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true);
parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef);
// TODO: capture label and comment?
// ariel to kev: this.fileName may be inaccurate. use formInstanceData.getName() instead
parameters.put(AVMWorkflowUtil.PROP_LABEL, this.fileName);
parameters.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMConstants.buildAVMStoreRootPath(
this.avmBrowseBean.getSandbox()));
@@ -371,20 +378,21 @@ public class CreateWebContentWizard extends BaseContentWizard
throws Exception
{
final FormsService fs = FormsService.getInstance();
if (LOGGER.isDebugEnabled())
LOGGER.debug("saving file content to " + this.fileName);
// get the parent path of the location to save the content
String fileName = this.fileName;
if (LOGGER.isDebugEnabled())
LOGGER.debug("saving file content to " + fileName);
String path = this.avmBrowseBean.getCurrentPath();
path = path.replaceFirst(AVMConstants.STORE_MAIN, AVMConstants.STORE_PREVIEW);
if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null)
{
final Document formInstanceData = fs.parseXML(this.content);
path = this.getForm().getOutputPathForFormInstanceData(path, this.fileName, formInstanceData);
path = this.getForm().getOutputPathForFormInstanceData(path, fileName, formInstanceData);
final String[] sb = AVMNodeConverter.SplitBase(path);
path = sb[0];
this.fileName = sb[1];
fileName = sb[1];
}
if (LOGGER.isDebugEnabled())
@@ -399,20 +407,20 @@ public class CreateWebContentWizard extends BaseContentWizard
fs.makeAllDirectories(path);
if (LOGGER.isDebugEnabled())
LOGGER.debug("creating file " + this.fileName + " in " + path);
LOGGER.debug("creating file " + fileName + " in " + path);
// put the content of the file into the AVM store
avmService.createFile(path,
this.fileName,
fileName,
new ByteArrayInputStream((this.content == null ? "" : this.content).getBytes()));
// remember the created path
this.createdPath = path + '/' + this.fileName;
this.createdPath = path + '/' + fileName;
// add titled aspect for the read/edit properties screens
final NodeRef formInstanceDataNodeRef = AVMNodeConverter.ToNodeRef(-1, this.createdPath);
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(1, 1.0f);
titledProps.put(ContentModel.PROP_TITLE, this.fileName);
titledProps.put(ContentModel.PROP_TITLE, fileName);
this.nodeService.addAspect(formInstanceDataNodeRef, ContentModel.ASPECT_TITLED, titledProps);
if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null)

View File

@@ -17,6 +17,7 @@
package org.alfresco.web.forms;
import java.io.Serializable;
import java.util.List;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -42,4 +43,7 @@ public interface FormInstanceData
/** the noderef containing the form instance data */
public NodeRef getNodeRef();
/** returns all renditions of this form instance data */
public List<Rendition> getRenditions();
}

View File

@@ -16,11 +16,14 @@
*/
package org.alfresco.web.forms;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.ServiceRegistry;
@@ -46,6 +49,8 @@ public class FormInstanceDataImpl
implements FormInstanceData
{
private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class);
private final NodeRef nodeRef;
public FormInstanceDataImpl(final NodeRef nodeRef)
@@ -92,6 +97,29 @@ public class FormInstanceDataImpl
return AVMConstants.buildAVMAssetUrl(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond());
}
public List<Rendition> getRenditions()
{
final AVMService avmService = this.getServiceRegistry().getAVMService();
final List<Rendition> result = new LinkedList<Rendition>();
for (RenderingEngineTemplate ret : this.getForm().getRenderingEngineTemplates())
{
final String renditionAvmPath =
FormsService.getOutputAvmPathForRendition(ret, this.getNodeRef());
if (avmService.lookup(-1, renditionAvmPath) == null)
{
LOGGER.warn("unable to locate rendition " + renditionAvmPath +
" for form instance data " + this.getName());
}
else
{
final NodeRef renditionNodeRef =
AVMNodeConverter.ToNodeRef(-1, renditionAvmPath);
result.add(new RenditionImpl(renditionNodeRef));
}
}
return result;
}
private ServiceRegistry getServiceRegistry()
{
final FacesContext fc = FacesContext.getCurrentInstance();

View File

@@ -389,15 +389,15 @@ public final class FormsService
public static String getOutputAvmPathForRendition(final RenderingEngineTemplate ret,
final NodeRef formInstanceDataNodeRef)
{
final String formInstanceDataAvmPath =
AVMNodeConverter.ToAVMVersionPath(formInstanceDataNodeRef).getSecond();
String formInstanceDataFileName = AVMNodeConverter.SplitBase(formInstanceDataAvmPath)[1];
formInstanceDataFileName = FormsService.stripExtension(formInstanceDataFileName);
// final String formInstanceDataAvmPath =
// AVMNodeConverter.ToAVMVersionPath(formInstanceDataNodeRef).getSecond();
// String formInstanceDataFileName = AVMNodeConverter.SplitBase(formInstanceDataAvmPath)[1];
// formInstanceDataFileName = FormsService.stripExtension(formInstanceDataFileName);
String result = ret.getOutputPathForRendition(formInstanceDataNodeRef);
if (result != null && result.charAt(0) == '/')
{
}
// if (result != null && result.charAt(0) == '/')
// {
//
// }
return result;
}

View File

@@ -55,7 +55,6 @@ public interface RenderingEngineTemplate
* Provides the noderef for this template.
*
* @return the noderef for this template.
* @deprecated i'd rather not expose this
*/
public NodeRef getNodeRef();

View File

@@ -192,7 +192,12 @@ public class RenderingEngineTemplateImpl
final NodeService nodeService = this.getServiceRegistry().getNodeService();
final Map<QName, Serializable> props = new HashMap<QName, Serializable>(2, 1.0f);
props.put(WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE, this.nodeRef);
props.put(WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA, primaryFormInstanceDataNodeRef);
// extract a store relative path for the primary form instance data
String path = AVMNodeConverter.ToAVMVersionPath(primaryFormInstanceDataNodeRef).getSecond();
path = path.substring(path.indexOf(':') + 1);
props.put(WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA, path);
nodeService.addAspect(renditionNodeRef, WCMAppModel.ASPECT_RENDITION, props);
}

View File

@@ -47,6 +47,8 @@ public class RenditionImpl
implements Rendition
{
private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class);
private final NodeRef nodeRef;
public RenditionImpl(final NodeRef nodeRef)
@@ -76,9 +78,14 @@ public class RenditionImpl
public FormInstanceData getPrimaryFormInstanceData()
{
final NodeService nodeService = this.getServiceRegistry().getNodeService();
final NodeRef fidNodeRef = (NodeRef)
final String fidAVMStoreRelativePath = (String)
nodeService.getProperty(this.nodeRef,
WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA);
String avmStore = AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
avmStore = avmStore.substring(0, avmStore.indexOf(':'));
final NodeRef fidNodeRef =
AVMNodeConverter.ToNodeRef(-1, avmStore + ':' + fidAVMStoreRelativePath);
return new FormInstanceDataImpl(fidNodeRef);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 791 B

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 791 B

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1006 B

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1010 B

After

Width:  |  Height:  |  Size: 253 B

View File

@@ -40,9 +40,9 @@
value="${WizardManager.bean.formName}"
image="/images/icons/webform_large.gif">
<jsp:attribute name="description">
<div>${WizardManager.bean.formDescription}</div>
<div>${msg.description}: ${WizardManager.bean.formDescription}</div>
<div>${msg.schema_root_element_name}: ${WizardManager.bean.schemaRootElementName}</div>
<div>${msg.schema_root_element_name}: ${WizardManager.bean.outputPathPatternForFormInstanceData}</div>
<div>${msg.output_path_pattern}: ${WizardManager.bean.outputPathPatternForFormInstanceData}</div>
</jsp:attribute>
</a:listItem>
</a:selectList>

View File

@@ -31,12 +31,20 @@
</h:panelGrid>
<h:panelGrid columns="2" cellpadding="3" cellspacing="3" border="0">
<h:outputText value="#{msg.name}:"/>
<h:outputText value="#{WizardManager.bean.formInstanceData.name}"/>
<h:outputText value="#{msg.location}:"/>
<h:outputText value="#{WizardManager.bean.formInstanceData.webappRelativePath}"/>
<h:outputText value="#{msg.form}:"/>
<h:outputText value="#{WizardManager.bean.formInstanceData.form.name}"/>
<a:selectList id="form-instance-data-list"
multiSelect="false"
activeSelect="true"
style="width:100%"
itemStyleClass="selectListItem">
<a:listItem label="${WizardManager.bean.formInstanceData.name}"
value="${WizardManager.bean.formInstanceData.name}"
image="/images/filetypes32/xml.gif">
<jsp:attribute name="description">
<div>${msg.form}: ${WizardManager.bean.formInstanceData.form.name}</div>
<div>${msg.location}: ${WizardManager.bean.formInstanceData.webappRelativePath}</div>
</jsp:attribute>
</a:listItem>
</a:selectList>
</h:panelGrid>
<h:panelGrid columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;"
@@ -50,13 +58,15 @@
activeSelect="true"
style="width:100%"
itemStyleClass="selectListItem">
<c:forEach items="${WizardManager.bean.renditions}" var="rendition">
<a:listItem label="${rendition.name}"
<c:forEach items="${WizardManager.bean.renditions}" var="rendition" varStatus="status">
<a:listItem id="listItem${status.index}"
label="${rendition.name}"
value="${rendition.name}"
image="${rendition.fileTypeImage}">
<jsp:attribute name="description">
<span style="float:right">
<a:actionLink value="${rendition.name}"
<a:actionLink id="preview${status.index}"
value="${rendition.name}"
image="/images/icons/preview_website.gif"
showLink="false"
href="${rendition.url}"