mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. WCM UI
- Create Web Content action (HTML and plain text) now creates content in the current AVM store - TODO: create in the correct sub-folder - Refactoring of the modified Create Content Wizard into a new wizard Create Web Content Wizard - Integrated XML form templating into the current website AVM path (still needs some testing/fixing up…) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3867 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -334,7 +334,16 @@ public abstract class BaseContentWizard extends BaseWizardBean
|
||||
protected void saveContent(File fileContent, String strContent) throws Exception
|
||||
{
|
||||
// get the node ref of the node that will contain the content
|
||||
NodeRef containerNodeRef = getContainerNodeRef();
|
||||
NodeRef containerNodeRef;
|
||||
String nodeId = this.navigator.getCurrentNodeId();
|
||||
if (nodeId == null)
|
||||
{
|
||||
containerNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
containerNodeRef = new NodeRef(Repository.getStoreRef(), nodeId);
|
||||
}
|
||||
|
||||
FileInfo fileInfo = this.fileFolderService.create(
|
||||
containerNodeRef,
|
||||
|
@@ -57,87 +57,94 @@ import org.xml.sax.SAXException;
|
||||
*/
|
||||
public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
{
|
||||
private final static Log LOGGER =
|
||||
LogFactory.getLog(CreateXmlContentTypeWizard.class);
|
||||
|
||||
private final static Log LOGGER =
|
||||
LogFactory.getLog(CreateXmlContentTypeWizard.class);
|
||||
|
||||
private String presentationTemplateType;
|
||||
protected ContentService contentService;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// get the node ref of the node that will contain the content
|
||||
NodeRef containerNodeRef = this.getContainerNodeRef();
|
||||
|
||||
FileInfo fileInfo =
|
||||
this.fileFolderService.create(containerNodeRef,
|
||||
this.getSchemaFileName(),
|
||||
ContentModel.TYPE_CONTENT);
|
||||
final NodeRef schemaFileNodeRef = fileInfo.getNodeRef();
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("Created file node for file: " +
|
||||
this.getSchemaFileName());
|
||||
|
||||
// get a writer for the content and put the file
|
||||
ContentWriter writer = contentService.getWriter(schemaFileNodeRef,
|
||||
ContentModel.PROP_CONTENT, true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype("text/xml");
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(this.getSchemaFile());
|
||||
|
||||
fileInfo = this.fileFolderService.create(containerNodeRef,
|
||||
this.getPresentationTemplateFileName(),
|
||||
ContentModel.TYPE_CONTENT);
|
||||
final NodeRef presentationTemplateFileNodeRef = fileInfo.getNodeRef();
|
||||
private String presentationTemplateType;
|
||||
protected ContentService contentService;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// get the node ref of the node that will contain the content
|
||||
NodeRef containerNodeRef;
|
||||
String nodeId = this.navigator.getCurrentNodeId();
|
||||
if (nodeId == null)
|
||||
{
|
||||
containerNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
containerNodeRef = new NodeRef(Repository.getStoreRef(), nodeId);
|
||||
}
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("Created file node for file: " +
|
||||
this.getPresentationTemplateFileName());
|
||||
|
||||
// get a writer for the content and put the file
|
||||
writer = contentService.getWriter(presentationTemplateFileNodeRef,
|
||||
ContentModel.PROP_CONTENT, true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype("text/xml");
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(this.getPresentationTemplateFile());
|
||||
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final String rootTagName =
|
||||
this.getSchemaFileName().replaceAll("([^\\.])\\..+", "$1");
|
||||
final TemplateType tt = ts.newTemplateType(rootTagName, schemaFileNodeRef);
|
||||
if (this.getPresentationTemplateFile() != null)
|
||||
{
|
||||
tt.addOutputMethod(new XSLTOutputMethod(presentationTemplateFileNodeRef));
|
||||
}
|
||||
ts.registerTemplateType(tt);
|
||||
|
||||
// return the default outcome
|
||||
return outcome;
|
||||
}
|
||||
FileInfo fileInfo = this.fileFolderService.create(containerNodeRef,
|
||||
this.getSchemaFileName(),
|
||||
ContentModel.TYPE_CONTENT);
|
||||
final NodeRef schemaFileNodeRef = fileInfo.getNodeRef();
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("Created file node for file: " +
|
||||
this.getSchemaFileName());
|
||||
|
||||
// get a writer for the content and put the file
|
||||
ContentWriter writer = contentService.getWriter(schemaFileNodeRef,
|
||||
ContentModel.PROP_CONTENT, true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype("text/xml");
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(this.getSchemaFile());
|
||||
|
||||
fileInfo = this.fileFolderService.create(containerNodeRef,
|
||||
this.getPresentationTemplateFileName(),
|
||||
ContentModel.TYPE_CONTENT);
|
||||
final NodeRef presentationTemplateFileNodeRef = fileInfo.getNodeRef();
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("Created file node for file: " +
|
||||
this.getPresentationTemplateFileName());
|
||||
|
||||
// get a writer for the content and put the file
|
||||
writer = contentService.getWriter(presentationTemplateFileNodeRef,
|
||||
ContentModel.PROP_CONTENT, true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype("text/xml");
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(this.getPresentationTemplateFile());
|
||||
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final String rootTagName =
|
||||
this.getSchemaFileName().replaceAll("([^\\.])\\..+", "$1");
|
||||
final TemplateType tt = ts.newTemplateType(rootTagName, schemaFileNodeRef);
|
||||
if (this.getPresentationTemplateFile() != null)
|
||||
{
|
||||
tt.addOutputMethod(new XSLTOutputMethod(presentationTemplateFileNodeRef));
|
||||
}
|
||||
ts.registerTemplateType(tt);
|
||||
|
||||
// return the default outcome
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
|
||||
this.removeUploadedSchemaFile();
|
||||
this.removeUploadedPresentationTemplateFile();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
this.removeUploadedSchemaFile();
|
||||
this.removeUploadedPresentationTemplateFile();
|
||||
return super.cancel();
|
||||
this.removeUploadedSchemaFile();
|
||||
this.removeUploadedPresentationTemplateFile();
|
||||
return super.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,8 +160,8 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
disabled = (this.getSchemaFileName() == null ||
|
||||
this.getSchemaFileName().length() == 0);
|
||||
disabled = (this.getSchemaFileName() == null ||
|
||||
this.getSchemaFileName().length() == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -162,26 +169,26 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
return disabled;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
// {
|
||||
// // as we were successful, go to the set properties dialog if asked
|
||||
// // to otherwise just return
|
||||
// if (this.showOtherProperties)
|
||||
// {
|
||||
// // we are going to immediately edit the properties so we need
|
||||
// // to setup the BrowseBean context appropriately
|
||||
// this.browseBean.setDocument(new Node(this.createdNode));
|
||||
//
|
||||
// return getDefaultFinishOutcome() + AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
// "dialog:setContentProperties";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return outcome;
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
// {
|
||||
// // as we were successful, go to the set properties dialog if asked
|
||||
// // to otherwise just return
|
||||
// if (this.showOtherProperties)
|
||||
// {
|
||||
// // we are going to immediately edit the properties so we need
|
||||
// // to setup the BrowseBean context appropriately
|
||||
// this.browseBean.setDocument(new Node(this.createdNode));
|
||||
//
|
||||
// return getDefaultFinishOutcome() + AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
// "dialog:setContentProperties";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return outcome;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Action handler called when the user wishes to remove an uploaded file
|
||||
*/
|
||||
@@ -192,7 +199,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
// refresh the current page
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action handler called when the user wishes to remove an uploaded file
|
||||
*/
|
||||
@@ -204,105 +211,106 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the mime type currenty selected
|
||||
*/
|
||||
public String getPresentationTemplateType()
|
||||
{
|
||||
if (this.getPresentationTemplateFileName() != null)
|
||||
{
|
||||
// String s = this.getPresentationTemplateFileName();
|
||||
// String extension =
|
||||
this.presentationTemplateType = "XSL";
|
||||
}
|
||||
return this.presentationTemplateType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param presentationTemplateType Sets the currently selected mime type
|
||||
*/
|
||||
public void setPresentationTemplateType(String presentationTemplateType)
|
||||
{
|
||||
this.presentationTemplateType = presentationTemplateType;
|
||||
}
|
||||
public String getPresentationTemplateType()
|
||||
{
|
||||
if (this.getPresentationTemplateFileName() != null)
|
||||
{
|
||||
// String s = this.getPresentationTemplateFileName();
|
||||
// String extension =
|
||||
this.presentationTemplateType = "XSL";
|
||||
}
|
||||
return this.presentationTemplateType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param presentationTemplateType Sets the currently selected mime type
|
||||
*/
|
||||
public void setPresentationTemplateType(String presentationTemplateType)
|
||||
{
|
||||
this.presentationTemplateType = presentationTemplateType;
|
||||
}
|
||||
|
||||
private FileUploadBean getFileUploadBean(final String id)
|
||||
{
|
||||
final FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
final Map sessionMap = ctx.getExternalContext().getSessionMap();
|
||||
return (FileUploadBean)sessionMap.get(FileUploadBean.getKey(id));
|
||||
}
|
||||
|
||||
private FileUploadBean getFileUploadBean(final String id)
|
||||
{
|
||||
final FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
final Map sessionMap = ctx.getExternalContext().getSessionMap();
|
||||
return (FileUploadBean)sessionMap.get(FileUploadBean.getKey(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the name of the file
|
||||
*/
|
||||
private String getFileName(final String id)
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
final FileUploadBean fileBean = this.getFileUploadBean(id);
|
||||
return fileBean == null ? null : fileBean.getFileName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
private File getFile(final String id)
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
final FileUploadBean fileBean = this.getFileUploadBean(id);
|
||||
return fileBean != null ? fileBean.getFile() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
public File getSchemaFile()
|
||||
{
|
||||
return this.getFile("schema");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
public String getSchemaFileName()
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
return this.getFileName("schema");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
public String getPresentationTemplateFileName()
|
||||
{
|
||||
return this.getFileName("pt");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the presentationTemplate file or <tt>null</tt>
|
||||
*/
|
||||
public File getPresentationTemplateFile()
|
||||
{
|
||||
return this.getFile("pt");
|
||||
}
|
||||
private String getFileName(final String id)
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
final FileUploadBean fileBean = this.getFileUploadBean(id);
|
||||
return fileBean == null ? null : fileBean.getFileName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
private File getFile(final String id)
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
final FileUploadBean fileBean = this.getFileUploadBean(id);
|
||||
return fileBean != null ? fileBean.getFile() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
public File getSchemaFile()
|
||||
{
|
||||
return this.getFile("schema");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
public String getSchemaFileName()
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
return this.getFileName("schema");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
public String getPresentationTemplateFileName()
|
||||
{
|
||||
return this.getFileName("pt");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the presentationTemplate file or <tt>null</tt>
|
||||
*/
|
||||
public File getPresentationTemplateFile()
|
||||
{
|
||||
return this.getFile("pt");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a list of mime types to allow the user to select from
|
||||
*/
|
||||
public List<SelectItem> getCreatePresentationTemplateTypes()
|
||||
{
|
||||
return (List<SelectItem>)Arrays.asList(new SelectItem[] {
|
||||
new SelectItem("freemarker", "FreeMarker"),
|
||||
new SelectItem("xslt", "XSLT")
|
||||
});
|
||||
return (List<SelectItem>)Arrays.asList(new SelectItem[] {
|
||||
new SelectItem("freemarker", "FreeMarker"),
|
||||
new SelectItem("xslt", "XSLT")
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
@@ -312,15 +320,15 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
|
||||
// TODO: show first few lines of content here?
|
||||
return buildSummary(new String[] {
|
||||
"Schema File",
|
||||
"Presentation Template Type",
|
||||
"Presentation Template"
|
||||
},
|
||||
new String[] {
|
||||
this.getSchemaFileName(),
|
||||
this.getPresentationTemplateType(),
|
||||
this.getPresentationTemplateFileName()
|
||||
});
|
||||
"Schema File",
|
||||
"Presentation Template Type",
|
||||
"Presentation Template"
|
||||
},
|
||||
new String[] {
|
||||
this.getSchemaFileName(),
|
||||
this.getPresentationTemplateType(),
|
||||
this.getPresentationTemplateFileName()
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
@@ -328,7 +336,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Service Injection
|
||||
|
||||
|
||||
/**
|
||||
* @param contentService The contentService to set.
|
||||
*/
|
||||
@@ -336,21 +344,21 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper Methods
|
||||
|
||||
/**
|
||||
*/
|
||||
protected void clearUpload(final String id)
|
||||
{
|
||||
protected void clearUpload(final String id)
|
||||
{
|
||||
// remove the file upload bean from the session
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
FileUploadBean fileBean = (FileUploadBean)
|
||||
ctx.getExternalContext().getSessionMap().
|
||||
get(FileUploadBean.getKey(id));
|
||||
if (fileBean != null)
|
||||
fileBean.setFile(null);
|
||||
}
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
FileUploadBean fileBean = (FileUploadBean)
|
||||
ctx.getExternalContext().getSessionMap().
|
||||
get(FileUploadBean.getKey(id));
|
||||
if (fileBean != null)
|
||||
fileBean.setFile(null);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user