changed template naming

This commit is contained in:
Brian Long 2023-11-16 13:39:58 -05:00
parent 0b9473465e
commit a856f9580b
3 changed files with 13 additions and 13 deletions

View File

@ -51,7 +51,7 @@
<dependency> <dependency>
<groupId>com.inteligr8.alfresco</groupId> <groupId>com.inteligr8.alfresco</groupId>
<artifactId>aps-public-rest-api</artifactId> <artifactId>aps-public-rest-api</artifactId>
<version>2.0.16</version> <version>2.0.17</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.inteligr8.alfresco</groupId> <groupId>com.inteligr8.alfresco</groupId>

View File

@ -71,7 +71,7 @@ public class DownloadTemplateGoal extends ApsTemplateAddressibleGoal {
for (Entry<String, ? extends BaseTemplateLight> template : templates.get(ttype).entrySet()) { for (Entry<String, ? extends BaseTemplateLight> template : templates.get(ttype).entrySet()) {
switch (ttype) { switch (ttype) {
case Document: case Document:
File dfilebin = new File(this.templateDirectory, template.getValue().getId() + ".doc-template.docx"); File dfilebin = new File(this.templateDirectory, template.getValue().getName());
Response response = this.getApsApi().getTemplatesApi().getDocumentTemplate( Response response = this.getApsApi().getTemplatesApi().getDocumentTemplate(
template.getValue().getId(), template.getValue().getId(),
@ -93,7 +93,7 @@ public class DownloadTemplateGoal extends ApsTemplateAddressibleGoal {
} }
ObjectNode djson = ModelUtil.getInstance().readPojo(template.getValue()); ObjectNode djson = ModelUtil.getInstance().readPojo(template.getValue());
File dfile = new File(this.templateDirectory, template.getValue().getId() + ".doc-template.json"); File dfile = new File(this.templateDirectory, template.getValue().getName() + ".dt.json");
ModelUtil.getInstance().writeJson(djson, dfile, this.diffFriendly); ModelUtil.getInstance().writeJson(djson, dfile, this.diffFriendly);
if (this.normalize) if (this.normalize)
new ApsTemplateJsonNormalizer(this.diffFriendly).normalizeFile(dfile, null); new ApsTemplateJsonNormalizer(this.diffFriendly).normalizeFile(dfile, null);
@ -102,7 +102,7 @@ public class DownloadTemplateGoal extends ApsTemplateAddressibleGoal {
case CustomEmail: case CustomEmail:
EmailTemplate etemplate = this.getApsApi().getTemplatesApi().getCustomEmailTemplate(template.getValue().getId(), tenantId); EmailTemplate etemplate = this.getApsApi().getTemplatesApi().getCustomEmailTemplate(template.getValue().getId(), tenantId);
ObjectNode ejson = ModelUtil.getInstance().readPojo(etemplate); ObjectNode ejson = ModelUtil.getInstance().readPojo(etemplate);
File efile = new File(this.templateDirectory, template.getValue().getId() + ".custom-email-template.json"); File efile = new File(this.templateDirectory, template.getValue().getName() + ".cet.json");
ModelUtil.getInstance().writeJson(ejson, efile, this.diffFriendly); ModelUtil.getInstance().writeJson(ejson, efile, this.diffFriendly);
if (this.normalize) if (this.normalize)
new ApsTemplateJsonNormalizer(this.diffFriendly).normalizeFile(efile, null); new ApsTemplateJsonNormalizer(this.diffFriendly).normalizeFile(efile, null);
@ -111,7 +111,7 @@ public class DownloadTemplateGoal extends ApsTemplateAddressibleGoal {
case SystemEmail: case SystemEmail:
EmailTemplate stemplate = this.getApsApi().getTemplatesApi().getSystemEmailTemplate(template.getValue().getName(), tenantId); EmailTemplate stemplate = this.getApsApi().getTemplatesApi().getSystemEmailTemplate(template.getValue().getName(), tenantId);
ObjectNode sjson = ModelUtil.getInstance().readPojo(stemplate); ObjectNode sjson = ModelUtil.getInstance().readPojo(stemplate);
File sfile = new File(this.templateDirectory, template.getValue().getName() + ".system-email-template.json"); File sfile = new File(this.templateDirectory, template.getValue().getName() + ".set.json");
ModelUtil.getInstance().writeJson(sjson, sfile, this.diffFriendly); ModelUtil.getInstance().writeJson(sjson, sfile, this.diffFriendly);
if (this.normalize) if (this.normalize)
new ApsTemplateJsonNormalizer(this.diffFriendly).normalizeFile(sfile, null); new ApsTemplateJsonNormalizer(this.diffFriendly).normalizeFile(sfile, null);

View File

@ -73,7 +73,7 @@ public class UploadTemplateGoal extends ApsAddressibleGoal {
} }
try { try {
if (file.getName().endsWith(".doc-template.json")) { if (file.getName().endsWith(".dt.json")) {
DocumentTemplateLight template = ModelUtil.getInstance().writePojo(ModelUtil.getInstance().readJsonAsMap(file), DocumentTemplateLight.class); DocumentTemplateLight template = ModelUtil.getInstance().writePojo(ModelUtil.getInstance().readJsonAsMap(file), DocumentTemplateLight.class);
if (!this.alwaysOverwrite && template.getId() != null && template.getCreated() != null) { if (!this.alwaysOverwrite && template.getId() != null && template.getCreated() != null) {
DocumentTemplateLight serverSideTemplate = this.getApsApi().getTemplatesApi().getDocumentTemplate(template.getId()); DocumentTemplateLight serverSideTemplate = this.getApsApi().getTemplatesApi().getDocumentTemplate(template.getId());
@ -83,14 +83,14 @@ public class UploadTemplateGoal extends ApsAddressibleGoal {
} }
} }
File docxfile = new File(file.getParent(), file.getName().substring(0, file.getName().length() - ".json".length()) + ".docx"); File dfile = new File(file.getParent(), file.getName().substring(0, file.getName().length() - ".dt.json".length()));
if (!docxfile.exists()) if (!dfile.exists())
throw new FileNotFoundException("The file, '" + docxfile.getName() + "' was expected and not found"); throw new FileNotFoundException("The file, '" + dfile.getName() + "' was expected and not found");
FileInputStream fistream = new FileInputStream(docxfile); FileInputStream fistream = new FileInputStream(dfile);
BufferedInputStream bistream = new BufferedInputStream(fistream, this.bufferSize); BufferedInputStream bistream = new BufferedInputStream(fistream, this.bufferSize);
try { try {
FileMultipartJersey multipart = FileMultipartJersey.from(docxfile.getName(), bistream); FileMultipartJersey multipart = FileMultipartJersey.from(dfile.getName(), bistream);
if (template.getId() == null) { if (template.getId() == null) {
if (this.dryRun) { if (this.dryRun) {
this.getLog().info("[DRYRUN]: Creating document template: " + template.getName()); this.getLog().info("[DRYRUN]: Creating document template: " + template.getName());
@ -110,7 +110,7 @@ public class UploadTemplateGoal extends ApsAddressibleGoal {
bistream.close(); bistream.close();
fistream.close(); fistream.close();
} }
} else if (file.getName().endsWith(".custom-email-template.json")) { } else if (file.getName().endsWith(".cet.json")) {
EmailTemplate template = ModelUtil.getInstance().writePojo(ModelUtil.getInstance().readJsonAsMap(file), EmailTemplate.class); EmailTemplate template = ModelUtil.getInstance().writePojo(ModelUtil.getInstance().readJsonAsMap(file), EmailTemplate.class);
if (!this.alwaysOverwrite && template.getId() != null && template.getCreated() != null) { if (!this.alwaysOverwrite && template.getId() != null && template.getCreated() != null) {
EmailTemplate serverSideTemplate = this.getApsApi().getTemplatesApi().getCustomEmailTemplate(template.getId(), tenantId); EmailTemplate serverSideTemplate = this.getApsApi().getTemplatesApi().getCustomEmailTemplate(template.getId(), tenantId);
@ -135,7 +135,7 @@ public class UploadTemplateGoal extends ApsAddressibleGoal {
this.getApsApi().getTemplatesJerseyApi().updateCustomEmailTemplate(template.getId(), template); this.getApsApi().getTemplatesJerseyApi().updateCustomEmailTemplate(template.getId(), template);
} }
} }
} else if (file.getName().endsWith(".system-email-template.json")) { } else if (file.getName().endsWith(".set.json")) {
EmailTemplate template = ModelUtil.getInstance().writePojo(ModelUtil.getInstance().readJsonAsMap(file), EmailTemplate.class); EmailTemplate template = ModelUtil.getInstance().writePojo(ModelUtil.getInstance().readJsonAsMap(file), EmailTemplate.class);
if (!this.alwaysOverwrite) { if (!this.alwaysOverwrite) {
EmailTemplate serverSideTemplate = this.getApsApi().getTemplatesApi().getSystemEmailTemplate(template.getName(), tenantId); EmailTemplate serverSideTemplate = this.getApsApi().getTemplatesApi().getSystemEmailTemplate(template.getName(), tenantId);