first pass at summary screen for create web content.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4368 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-11-16 07:28:33 +00:00
parent 67aab090e5
commit 612dd27044
11 changed files with 379 additions and 42 deletions

View File

@@ -50,7 +50,7 @@ import org.apache.commons.logging.LogFactory;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
public class FormImpl
class FormImpl
implements Form
{
private static final Log LOGGER = LogFactory.getLog(FormImpl.class);

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.forms;
import java.io.Serializable;
/**
* Encapsulation of form instance data.
*
* @author Ariel Backenroth
*/
public interface FormInstanceData
extends Serializable
{
/** the form generate this form instance data */
public Form getForm();
/** the name of this instance data */
public String getName();
/** the path relative to the containing webapp */
public String getWebappRelativePath();
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.forms;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TemplateNode;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.AVMConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Encapsulation of a rendition.
*
* @author Ariel Backenroth
*/
public class FormInstanceDataImpl
implements FormInstanceData
{
private final NodeRef nodeRef;
public FormInstanceDataImpl(final NodeRef nodeRef)
{
this.nodeRef = nodeRef;
}
/** the name of this rendition */
public String getName()
{
final NodeService nodeService = this.getServiceRegistry().getNodeService();
return (String)
nodeService.getProperty(this.nodeRef, ContentModel.PROP_NAME);
}
/** the path relative to the containing webapp */
public String getWebappRelativePath()
{
return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
}
public Form getForm()
{
final NodeService nodeService = this.getServiceRegistry().getNodeService();
final NodeRef formNodeRef = (NodeRef)
nodeService.getProperty(this.nodeRef,
WCMModel.PROP_PARENT_FORM);
return new FormImpl(formNodeRef);
}
/** the node ref containing the contents of this rendition */
public NodeRef getNodeRef()
{
return this.nodeRef;
}
private ServiceRegistry getServiceRegistry()
{
final FacesContext fc = FacesContext.getCurrentInstance();
return Repository.getServiceRegistry(fc);
}
}

View File

@@ -275,7 +275,7 @@ public final class FormsService
*
* @param formInstanceDataNodeRef the noderef containing the form instance data
*/
public void generateRenditions(final NodeRef formInstanceDataNodeRef)
public List<Rendition> generateRenditions(final NodeRef formInstanceDataNodeRef)
throws IOException,
SAXException,
RenderingEngine.RenderingException
@@ -291,6 +291,7 @@ public final class FormsService
AVMNodeConverter.ToAVMVersionPath(formInstanceDataNodeRef).getSecond();
LOGGER.debug("generating renditions for " + formInstanceDataAvmPath);
final List<Rendition> result = new LinkedList<Rendition>();
for (RenderingEngineTemplate ret : form.getRenderingEngineTemplates())
{
// get the node ref of the node that will contain the content
@@ -312,17 +313,17 @@ public final class FormsService
final NodeRef renditionNodeRef =
AVMNodeConverter.ToNodeRef(-1, renditionAvmPath);
form.registerFormInstanceData(renditionNodeRef);
ret.registerRendition(renditionNodeRef, formInstanceDataNodeRef);
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f);
props.put(ContentModel.PROP_TITLE, AVMNodeConverter.SplitBase(renditionAvmPath)[1]);
nodeService.addAspect(renditionNodeRef, ContentModel.ASPECT_TITLED, props);
result.add(new RenditionImpl(renditionNodeRef));
if (LOGGER.isDebugEnabled())
LOGGER.debug("generated " + renditionAvmPath + " using " + ret);
}
return result;
}
/**
@@ -330,7 +331,7 @@ public final class FormsService
*
* @param formInstanceDataNodeRef the node ref containing the form instance data.
*/
public void regenerateRenditions(final NodeRef formInstanceDataNodeRef)
public List<Rendition> regenerateRenditions(final NodeRef formInstanceDataNodeRef)
throws IOException,
SAXException,
RenderingEngine.RenderingException
@@ -348,7 +349,7 @@ public final class FormsService
// other parameter values passed to rendering engine
final String formInstanceDataAvmPath = AVMNodeConverter.ToAVMVersionPath(formInstanceDataNodeRef).getSecond();
LOGGER.debug("regenerating renditions for " + formInstanceDataAvmPath);
final List<Rendition> result = new LinkedList<Rendition>();
for (RenderingEngineTemplate ret : form.getRenderingEngineTemplates())
{
final String renditionAvmPath =
@@ -376,9 +377,13 @@ public final class FormsService
ret.getRenderingEngine().render(formInstanceData, ret, parameters, out);
out.close();
final NodeRef renditionNodeRef =
AVMNodeConverter.ToNodeRef(-1, renditionAvmPath);
result.add(new RenditionImpl(renditionNodeRef));
if (LOGGER.isDebugEnabled())
LOGGER.debug("generated " + renditionAvmPath + " using " + ret);
LOGGER.debug("regenerated " + renditionAvmPath + " using " + ret);
}
return result;
}
private static String getOutputAvmPathForRendition(final RenderingEngineTemplate ret,

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.forms;
import org.alfresco.service.cmr.repository.NodeRef;
import java.io.Serializable;
/**
* Encapsulation of a rendition.
*
* @author Ariel Backenroth
*/
public interface Rendition
extends Serializable
{
/** the name of this instance data */
public String getName();
/** the path relative to the containing webapp */
public String getWebappRelativePath();
/** the primary form instance data used to generate this rendition */
public FormInstanceData getPrimaryFormInstanceData();
/** the rendering engine template that generated this rendition */
public RenderingEngineTemplate getRenderingEngineTemplate();
/** the node ref containing the contents of this rendition */
public NodeRef getNodeRef();
}

View File

@@ -0,0 +1,101 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.forms;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TemplateNode;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.AVMConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Encapsulation of a rendition.
*
* @author Ariel Backenroth
*/
public class RenditionImpl
implements Rendition
{
private final NodeRef nodeRef;
public RenditionImpl(final NodeRef nodeRef)
{
this.nodeRef = nodeRef;
}
/** the name of this rendition */
public String getName()
{
final NodeService nodeService = this.getServiceRegistry().getNodeService();
return (String)
nodeService.getProperty(this.nodeRef, ContentModel.PROP_NAME);
}
/** the path relative to the containing webapp */
public String getWebappRelativePath()
{
return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
}
public FormInstanceData getPrimaryFormInstanceData()
{
final NodeService nodeService = this.getServiceRegistry().getNodeService();
final NodeRef fidNodeRef = (NodeRef)
nodeService.getProperty(this.nodeRef,
WCMModel.PROP_PRIMARY_FORM_INSTANCE_DATA);
return new FormInstanceDataImpl(fidNodeRef);
}
/** the rendering engine template that generated this rendition */
public RenderingEngineTemplate getRenderingEngineTemplate()
{
final NodeService nodeService = this.getServiceRegistry().getNodeService();
final NodeRef retNodeRef = (NodeRef)
nodeService.getProperty(this.nodeRef,
WCMModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE);
final NodeRef rpNodeRef = (NodeRef)
nodeService.getProperty(this.nodeRef,
WCMModel.PROP_PARENT_RENDITION_PROPERTIES);
return new RenderingEngineTemplateImpl(retNodeRef, rpNodeRef);
}
/** the node ref containing the contents of this rendition */
public NodeRef getNodeRef()
{
return this.nodeRef;
}
private ServiceRegistry getServiceRegistry()
{
final FacesContext fc = FacesContext.getCurrentInstance();
return Repository.getServiceRegistry(fc);
}
}