mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
adding a check in create form to ensure that rendering engine template output path patterns don't clobber each other.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4560 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -155,6 +155,9 @@ public class CreateFormWizard
|
||||
|
||||
public static final String FILE_SCHEMA = "schema";
|
||||
|
||||
private final static String DEFAULT_EXTENSION_PATTERN = "${extension}";
|
||||
private final static String DEFAULT_NAME_PATTERN = "${name}";
|
||||
|
||||
private final static Log LOGGER = LogFactory.getLog(CreateFormWizard.class);
|
||||
|
||||
private String schemaRootElementName = null;
|
||||
@@ -360,7 +363,7 @@ public class CreateFormWizard
|
||||
public String getOutputPathPatternForRendition()
|
||||
{
|
||||
return (this.outputPathPatternForRendition == null
|
||||
? "${name}.${extension}"
|
||||
? DEFAULT_NAME_PATTERN + '.' + DEFAULT_EXTENSION_PATTERN
|
||||
: this.outputPathPatternForRendition);
|
||||
}
|
||||
|
||||
@@ -377,12 +380,24 @@ public class CreateFormWizard
|
||||
*/
|
||||
public String getMimetypeForRendition()
|
||||
{
|
||||
if (this.mimetypeForRendition == null && this.outputPathPatternForRendition != null)
|
||||
String result = null;
|
||||
if (this.mimetypeForRendition != null)
|
||||
{
|
||||
this.mimetypeForRendition =
|
||||
this.mimetypeService.guessMimetype(this.outputPathPatternForRendition);
|
||||
result = this.mimetypeForRendition;
|
||||
}
|
||||
return this.mimetypeForRendition;
|
||||
else
|
||||
{
|
||||
if (this.outputPathPatternForRendition != null &&
|
||||
!this.outputPathPatternForRendition.endsWith(DEFAULT_EXTENSION_PATTERN))
|
||||
{
|
||||
result = this.mimetypeService.guessMimetype(this.outputPathPatternForRendition);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = MimetypeMap.MIMETYPE_HTML;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,13 +413,26 @@ public class CreateFormWizard
|
||||
*/
|
||||
public void addSelectedRenderingEngineTemplate(final ActionEvent event)
|
||||
{
|
||||
final String opp = this.getOutputPathPatternForRendition();
|
||||
final String mimetype = this.getMimetypeForRendition();
|
||||
for (RenderingEngineTemplateData retd : this.renderingEngineTemplates)
|
||||
{
|
||||
if (opp.equals(retd.getOutputPathPatternForRendition()) &&
|
||||
opp.indexOf(DEFAULT_EXTENSION_PATTERN) >= 0 &&
|
||||
mimetype.equals(retd.getMimetypeForRendition()))
|
||||
{
|
||||
Utils.addErrorMessage("A rendering engine template with the output path pattern " + opp +
|
||||
" and mimetype " + mimetype + " already exists");
|
||||
return;
|
||||
}
|
||||
}
|
||||
final RenderingEngineTemplateData data =
|
||||
this.new RenderingEngineTemplateData(this.getRenderingEngineTemplateFileName(),
|
||||
this.getRenderingEngineTemplateFile(),
|
||||
this.getRenderingEngineTemplateTitle(),
|
||||
this.getRenderingEngineTemplateDescription(),
|
||||
this.getOutputPathPatternForRendition(),
|
||||
this.getMimetypeForRendition(),
|
||||
opp,
|
||||
mimetype,
|
||||
this.renderingEngine);
|
||||
this.renderingEngineTemplates.add(data);
|
||||
this.removeUploadedRenderingEngineTemplateFile();
|
||||
@@ -695,7 +723,7 @@ public class CreateFormWizard
|
||||
{
|
||||
if (this.outputPathPatternForFormInstanceData == null)
|
||||
{
|
||||
this.outputPathPatternForFormInstanceData = "${name}.xml";
|
||||
this.outputPathPatternForFormInstanceData = DEFAULT_NAME_PATTERN + ".xml";
|
||||
}
|
||||
return this.outputPathPatternForFormInstanceData;
|
||||
}
|
||||
|
Reference in New Issue
Block a user