Merge branch 'develop' into stable

This commit is contained in:
2023-11-16 09:26:45 -05:00
12 changed files with 171 additions and 81 deletions

View File

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

View File

@@ -22,8 +22,10 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Parameter;
import com.inteligr8.activiti.model.Datum;
import com.inteligr8.activiti.model.ResultList;
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
import com.inteligr8.alfresco.activiti.api.ModelsApi.ModelType;
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
import com.inteligr8.alfresco.activiti.model.ResultListDataRepresentation;
import com.inteligr8.alfresco.activiti.model.Tenant;
@@ -58,24 +60,23 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal {
/**
* This method makes the appropriate service calls to find all the APS
* Apps, returning them as a map of names to IDs.
* Apps, returning them as a map of names to models.
*
* This method does not cache the result.
*
* @return A map of APS App names to their respective IDs; may be empty; never null.
* @return A map of APS App names to their model; may be empty; never null.
*/
protected Map<String, Long> findAppNameIds() {
protected Map<String, ModelRepresentation> buildAppNameMap() {
ApsPublicRestApiJerseyImpl api = this.getApsApi();
Map<String, Long> apps = new HashMap<>(16);
Map<String, ModelRepresentation> apps = new HashMap<>(16);
this.getLog().debug("Searching for all APS Apps");
ResultListDataRepresentation<Datum> results = api.getModelsApi().get("everyone", null, ModelType.App.getId(), null);
ResultList<ModelRepresentation> results = api.getModelsApi().get("everyone", null, ModelType.App.getId(), null);
this.getLog().debug("Found " + results.getTotal() + " APS Apps");
for (Datum datum : results.getData()) {
String name = (String)datum.getAdditionalProperties().get("name");
Number id = (Number)datum.getAdditionalProperties().get("id");
apps.put(name, id.longValue());
for (ModelRepresentation model : results.getData()) {
String name = model.getName();
apps.put(name, model);
}
return apps;
@@ -88,11 +89,11 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal {
* This method does not cache the result.
*
* @param failOnNotFound true to fail if not found; false to return null.
* @return An APS App ID; null if not found.
* @return An APS App model; null if not found.
* @throws MojoExecutionException The APS App could not be found.
*/
protected Long findAppId(boolean failOnNotFound) throws MojoExecutionException {
return this.findAppIdByName(this.apsAppName, failOnNotFound);
protected ModelRepresentation findAppModel(boolean failOnNotFound) throws MojoExecutionException {
return this.findAppModelByName(this.apsAppName, failOnNotFound);
}
/**
@@ -103,15 +104,15 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal {
*
* @param apsName An APS App name.
* @param failOnNotFound true to fail if not found; false to return null.
* @return An APS App ID; null if not found.
* @return An APS App model; null if not found.
* @throws MojoExecutionException The APS App could not be found.
*/
protected Long findAppIdByName(String appName, boolean failOnNotFound) throws MojoExecutionException {
Map<String, Long> apps = this.findAppNameIds();
Long appId = apps.get(this.apsAppName);
if (failOnNotFound && appId == null)
protected ModelRepresentation findAppModelByName(String appName, boolean failOnNotFound) throws MojoExecutionException {
Map<String, ModelRepresentation> apps = this.buildAppNameMap();
ModelRepresentation appModel = apps.get(this.apsAppName);
if (failOnNotFound && appModel == null)
throw new MojoExecutionException("The APS App '" + this.apsAppName + "' could not be found; valid apps: " + apps.keySet());
return appId;
return appModel;
}
}

View File

@@ -30,6 +30,7 @@ import com.inteligr8.activiti.model.Datum;
import com.inteligr8.activiti.model.ResultList;
import com.inteligr8.alfresco.activiti.api.ModelsApi;
import com.inteligr8.alfresco.activiti.model.GroupLight;
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
import com.inteligr8.alfresco.activiti.model.PermissionLevel;
import com.inteligr8.alfresco.activiti.model.PermissionLight;
import com.inteligr8.alfresco.activiti.model.ResultListDataRepresentation;
@@ -108,14 +109,12 @@ public class ApsShareGoal extends ApsAddressibleGoal {
}
private void shareModels(ModelsApi.ModelType modelType, Set<String> readers, Set<String> editors) {
ResultListDataRepresentation<Datum> models = this.getApsApi().getModelsApi().get(null, null, modelType.getId(), null);
ResultList<ModelRepresentation> models = this.getApsApi().getModelsApi().get(null, null, modelType.getId(), null);
if (models.getData() == null)
return;
for (Datum datum : models.getData()) {
Number modelId = (Number)datum.getAdditionalProperties().get("id");
String modelName = (String)datum.getAdditionalProperties().get("name");
if (this.modelName != null && !this.modelName.equals(modelName))
for (ModelRepresentation model : models.getData()) {
if (this.modelName != null && !this.modelName.equals(model.getName()))
continue;
Set<String> groupsAddressed = new HashSet<>();
@@ -123,7 +122,7 @@ public class ApsShareGoal extends ApsAddressibleGoal {
Set<String> editorsUnaddressed = new HashSet<>(editors);
ShareInfoRequest changeRequest = new ShareInfoRequest();
ResultList<SharePermission> shares = this.getApsApi().getShareApi().getShareInfo(modelId.toString());
ResultList<SharePermission> shares = this.getApsApi().getShareApi().getShareInfo(model.getId().toString());
if (shares.getData() != null) {
for (SharePermission share : shares.getData()) {
if (share.getGroup() != null) {
@@ -145,7 +144,7 @@ public class ApsShareGoal extends ApsAddressibleGoal {
if (!changeRequest.getAdded().isEmpty() || !changeRequest.getUpdated().isEmpty() || !changeRequest.getRemoved().isEmpty()) {
this.getLog().info("Sharing model: " + modelType + " => '" + modelName + "'");
this.getApsApi().getShareApi().setShareInfo(modelId.toString(), changeRequest);
this.getApsApi().getShareApi().setShareInfo(model.getId().toString(), changeRequest);
}
}
}

View File

@@ -102,7 +102,7 @@ public abstract class ApsTemplateAddressibleGoal extends ApsAddressibleGoal {
int pageSize = 50;
int page = 1;
ResultList<EmailTemplateLight> templates = this.getApsApi().getTemplatesApi().getCustomEmailTemplates(null, (page-1) * pageSize, pageSize, null, tenantId);
ResultList<EmailTemplateLight> templates = this.getApsApi().getTemplatesApi().getCustomEmailTemplates(null, (page-1) * pageSize, pageSize, "sort_by_name_asc", tenantId);
while (!templates.getData().isEmpty()) {
for (EmailTemplateLight template : templates.getData()) {
for (Pattern pattern : matchingPatterns) {
@@ -112,7 +112,7 @@ public abstract class ApsTemplateAddressibleGoal extends ApsAddressibleGoal {
}
page++;
templates = this.getApsApi().getTemplatesApi().getCustomEmailTemplates(null, (page-1) * pageSize, pageSize, null, tenantId);
templates = this.getApsApi().getTemplatesApi().getCustomEmailTemplates(null, (page-1) * pageSize, pageSize, "sort_by_name_asc", tenantId);
}
this.getLog().debug("Found APS Custom Email Templates: " + map.size());
@@ -126,7 +126,7 @@ public abstract class ApsTemplateAddressibleGoal extends ApsAddressibleGoal {
int pageSize = 50;
int page = 1;
ResultList<DocumentTemplateLight> templates = this.getApsApi().getTemplatesApi().getDocumentTemplates(null, (page-1) * pageSize, pageSize, null, tenantId);
ResultList<DocumentTemplateLight> templates = this.getApsApi().getTemplatesApi().getDocumentTemplates(null, (page-1) * pageSize, pageSize, "sort_by_name_asc", tenantId);
while (!templates.getData().isEmpty()) {
for (DocumentTemplateLight template : templates.getData()) {
for (Pattern pattern : matchingPatterns) {
@@ -136,7 +136,7 @@ public abstract class ApsTemplateAddressibleGoal extends ApsAddressibleGoal {
}
page++;
templates = this.getApsApi().getTemplatesApi().getDocumentTemplates(null, (page-1) * pageSize, pageSize, null, tenantId);
templates = this.getApsApi().getTemplatesApi().getDocumentTemplates(null, (page-1) * pageSize, pageSize, "sort_by_name_asc", tenantId);
}
this.getLog().debug("Found APS Document Templates: " + map.size());

View File

@@ -46,7 +46,7 @@ public class DownloadAppGoal extends ApsAppAddressibleGoal {
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
this.validateTargetDirectory();
Long appId = this.findAppId(true);
Long appId = this.findAppModel(true).getId();
File appZip = this.downloadApp(appId);
File toAppZip = new File(this.zipDirectory, this.apsAppName + ".zip");

View File

@@ -66,30 +66,38 @@ public class DownloadTemplateGoal extends ApsTemplateAddressibleGoal {
try {
Map<TemplateType, Map<String, ? extends BaseTemplateLight>> templates = this.findTemplates(tenantId);
for (TemplateType ttype : templates.keySet()) {
this.getLog().debug("Downloading templates: " + ttype);
this.getLog().info("Downloading " + templates.get(ttype).size() + " " + ttype + " templates");
for (Entry<String, ? extends BaseTemplateLight> template : templates.get(ttype).entrySet()) {
switch (ttype) {
case Document:
File dfilebin = new File(this.templateDirectory, template.getValue().getId() + ".doc-template.docx");
Response response = this.getApsApi().getTemplatesApi().getDocumentTemplate(
template.getValue().getId(),
System.currentTimeMillis());
try {
if (response.getStatus() / 100 == 2) {
InputStream istream = (InputStream) response.getEntity();
try {
FileUtils.copyInputStreamToFile(istream, dfilebin);
} finally {
istream.close();
}
} else {
this.getLog().warn("The document template could not be downloaded; skipping: " + template.getValue().getName());
continue;
}
} finally {
response.close();
}
ObjectNode djson = ModelUtil.getInstance().readPojo(template.getValue());
File dfile = new File(this.templateDirectory, template.getValue().getId() + ".doc-template.json");
ModelUtil.getInstance().writeJson(djson, dfile, this.diffFriendly);
if (this.normalize)
new ApsTemplateJsonNormalizer(this.diffFriendly).normalizeFile(dfile, null);
File dfilebin = new File(this.templateDirectory, template.getValue().getId() + ".doc-template.docx");
Response response = this.getApsApi().getTemplatesApi().getDocumentTemplate((DocumentTemplateLight) template.getValue());
try {
InputStream istream = (InputStream) response.getEntity();
try {
FileUtils.copyInputStreamToFile(istream, dfilebin);
} finally {
istream.close();
}
} finally {
response.close();
}
break;
case CustomEmail:
EmailTemplate etemplate = this.getApsApi().getTemplatesApi().getCustomEmailTemplate(template.getValue().getId(), tenantId);

View File

@@ -39,10 +39,13 @@ public class PublishAppGoal extends ApsAppAddressibleGoal {
@Parameter( property = "aps-model.publish.comment", required = true, defaultValue = "Automated by 'aps-model-maven-plugin'" )
protected String comment;
@Parameter( property = "aps-model.dryRun", required = true, defaultValue = "false" )
protected boolean dryRun;
@Override
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
Long appId = this.findAppId(false);
Long appId = this.findAppModel(false).getId();
try {
this.publishApp(appId);
@@ -56,7 +59,12 @@ public class PublishAppGoal extends ApsAppAddressibleGoal {
AppDefinitionPublishRepresentation appDefPublish = new AppDefinitionPublishRepresentation();
appDefPublish.setComment(this.comment);
api.getAppDefinitionsApi().publish(appId, appDefPublish);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Publishing app: " + appId);
} else {
this.getLog().info("Publishing app: " + appId);
api.getAppDefinitionsApi().publish(appId, appDefPublish);
}
}
}

View File

@@ -29,6 +29,7 @@ import org.codehaus.plexus.component.annotations.Component;
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation;
import com.inteligr8.alfresco.activiti.model.FileMultipartJersey;
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
/**
* A class that implements an APS service upload goal.
@@ -49,6 +50,9 @@ public class UploadAppGoal extends ApsAppAddressibleGoal {
@Parameter( property = "publish", required = true, defaultValue = "false" )
protected boolean publish = false;
@Parameter( property = "aps-model.dryRun", required = true, defaultValue = "false" )
protected boolean dryRun;
protected final int bufferSize = 128 * 1024;
@@ -56,10 +60,10 @@ public class UploadAppGoal extends ApsAppAddressibleGoal {
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
File sourceFile = this.validateSourceDirectory();
Long appId = this.findAppId(false);
ModelRepresentation appModel = this.findAppModel(false);
try {
this.uploadApp(appId, sourceFile);
this.uploadApp(appModel, sourceFile);
} catch (IOException ie) {
throw new MojoExecutionException("The APS App could not be uploaded", ie);
}
@@ -83,7 +87,7 @@ public class UploadAppGoal extends ApsAppAddressibleGoal {
return sourceFile;
}
private void uploadApp(Long appId, File appZip) throws IOException, MojoExecutionException {
private void uploadApp(ModelRepresentation appModel, File appZip) throws IOException, MojoExecutionException {
ApsPublicRestApiJerseyImpl api = this.getApsApi();
FileInputStream fistream = new FileInputStream(appZip);
@@ -91,25 +95,41 @@ public class UploadAppGoal extends ApsAppAddressibleGoal {
try {
FileMultipartJersey multipart = FileMultipartJersey.from(appZip.getName(), bistream);
if (appId == null) {
if (appModel == null) {
if (this.publish) {
this.getLog().info("Uploading & publishing new APS App: " + this.apsAppName);
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(multipart);
if (Boolean.TRUE.equals(appDefUpdate.getError()))
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Uploading & publishing new APS App: " + this.apsAppName);
} else {
this.getLog().info("Uploading & publishing new APS App: " + this.apsAppName);
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(multipart);
if (Boolean.TRUE.equals(appDefUpdate.getError()))
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
}
} else {
this.getLog().info("Uploading new APS App: " + this.apsAppName);
api.getAppDefinitionsJerseyApi().importApp(multipart, true);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Uploading new APS App: " + this.apsAppName);
} else {
this.getLog().info("Uploading new APS App: " + this.apsAppName);
api.getAppDefinitionsJerseyApi().importApp(multipart, true);
}
}
} else {
if (this.publish) {
this.getLog().info("Uploading, versioning, & publishing APS App: " + this.apsAppName + " (" + appId + ")");
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(appId, multipart);
if (Boolean.TRUE.equals(appDefUpdate.getError()))
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Uploading, versioning, & publishing APS App: " + this.apsAppName + " (" + appModel.getId() + ")");
} else {
this.getLog().info("Uploading, versioning, & publishing APS App: " + this.apsAppName + " (" + appModel.getId() + ")");
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(appModel.getId(), multipart);
if (Boolean.TRUE.equals(appDefUpdate.getError()))
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
}
} else {
this.getLog().info("Uploading & versioning APS App: " + this.apsAppName + " (" + appId + ")");
api.getAppDefinitionsJerseyApi().importApp(appId, multipart, true);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Uploading & versioning APS App: " + this.apsAppName + " (" + appModel.getId() + ")");
} else {
this.getLog().info("Uploading & versioning APS App: " + this.apsAppName + " (" + appModel.getId() + ")");
api.getAppDefinitionsJerseyApi().importApp(appModel.getId(), multipart, true);
}
}
}
} catch (ParseException pe) {

View File

@@ -30,6 +30,7 @@ import org.codehaus.plexus.component.annotations.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.inteligr8.alfresco.activiti.model.DocumentTemplateLight;
import com.inteligr8.alfresco.activiti.model.EmailTemplate;
import com.inteligr8.alfresco.activiti.model.EmailTemplateLight;
import com.inteligr8.alfresco.activiti.model.FileMultipartJersey;
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
@@ -50,6 +51,12 @@ public class UploadTemplateGoal extends ApsAddressibleGoal {
@Parameter( property = "aps-model.upload.directory", required = true, defaultValue = "${project.build.directory}/aps" )
protected File templateDirectory;
@Parameter( required = true, defaultValue = "false" )
protected boolean alwaysOverwrite;
@Parameter( property = "aps-model.dryRun", required = true, defaultValue = "false" )
protected boolean dryRun;
protected final int bufferSize = 128 * 1024;
@@ -68,6 +75,13 @@ public class UploadTemplateGoal extends ApsAddressibleGoal {
try {
if (file.getName().endsWith(".doc-template.json")) {
DocumentTemplateLight template = ModelUtil.getInstance().writePojo(ModelUtil.getInstance().readJsonAsMap(file), DocumentTemplateLight.class);
if (!this.alwaysOverwrite && template.getId() != null && template.getCreated() != null) {
DocumentTemplateLight serverSideTemplate = this.getApsApi().getTemplatesApi().getDocumentTemplate(template.getId());
if (serverSideTemplate != null && !serverSideTemplate.getCreated().isBefore(template.getCreated())) {
this.getLog().debug("Document template unchanged; not updating: " + template.getId());
continue;
}
}
File docxfile = new File(file.getParent(), file.getName().substring(0, file.getName().length() - ".json".length()) + ".docx");
if (!docxfile.exists())
@@ -78,9 +92,19 @@ public class UploadTemplateGoal extends ApsAddressibleGoal {
try {
FileMultipartJersey multipart = FileMultipartJersey.from(docxfile.getName(), bistream);
if (template.getId() == null) {
this.getApsApi().getTemplatesJerseyApi().createDocumentTemplate(tenantId, multipart);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Creating document template: " + template.getName());
} else {
this.getLog().info("Creating document template: " + template.getName());
this.getApsApi().getTemplatesJerseyApi().createDocumentTemplate(tenantId, multipart);
}
} else {
this.getApsApi().getTemplatesJerseyApi().updateDocumentTemplate(template.getId(), tenantId, multipart);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Updating document template: " + template.getName());
} else {
this.getLog().info("Updating document template: " + template.getName());
this.getApsApi().getTemplatesJerseyApi().updateDocumentTemplate(template.getId(), tenantId, multipart);
}
}
} finally {
bistream.close();
@@ -88,14 +112,45 @@ public class UploadTemplateGoal extends ApsAddressibleGoal {
}
} else if (file.getName().endsWith(".custom-email-template.json")) {
EmailTemplate template = ModelUtil.getInstance().writePojo(ModelUtil.getInstance().readJsonAsMap(file), EmailTemplate.class);
if (!this.alwaysOverwrite && template.getId() != null && template.getCreated() != null) {
EmailTemplate serverSideTemplate = this.getApsApi().getTemplatesApi().getCustomEmailTemplate(template.getId(), tenantId);
if (serverSideTemplate != null && !serverSideTemplate.getCreated().isBefore(template.getCreated())) {
this.getLog().debug("Custom email template unchanged; not updating: " + template.getId());
continue;
}
}
if (template.getId() == null) {
this.getApsApi().getTemplatesJerseyApi().createCustomEmailTemplate(template);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Creating custom email template: " + template.getName());
} else {
this.getLog().info("Creating custom email template: " + template.getName());
this.getApsApi().getTemplatesJerseyApi().createCustomEmailTemplate(template);
}
} else {
this.getApsApi().getTemplatesJerseyApi().updateCustomEmailTemplate(template.getId(), template);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Updating custom email template: " + template.getName());
} else {
this.getLog().info("Updating custom email template: " + template.getName());
this.getApsApi().getTemplatesJerseyApi().updateCustomEmailTemplate(template.getId(), template);
}
}
} else if (file.getName().endsWith(".system-email-template.json")) {
EmailTemplate template = ModelUtil.getInstance().writePojo(ModelUtil.getInstance().readJsonAsMap(file), EmailTemplate.class);
this.getApsApi().getTemplatesJerseyApi().updateSystemEmailTemplate(template.getName(), template);
if (!this.alwaysOverwrite) {
EmailTemplate serverSideTemplate = this.getApsApi().getTemplatesApi().getSystemEmailTemplate(template.getName(), tenantId);
if (serverSideTemplate != null && template.getTemplate().equals(serverSideTemplate.getTemplate())) {
this.getLog().debug("System email template unchanged; not updating: " + template.getName());
continue;
}
}
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Updating system email template: " + template.getName());
} else {
this.getLog().info("Updating system email template: " + template.getName());
this.getApsApi().getTemplatesJerseyApi().updateSystemEmailTemplate(template.getName(), template);
}
}
} catch (JsonProcessingException jpe) {
throw new MojoExecutionException("The APS templates JSON files could not be parsed", jpe);

View File

@@ -27,7 +27,7 @@ import com.inteligr8.maven.aps.modeling.util.ModelUtil;
/**
* This class implements an APS template JSON configuration file normalizer.
*
* This will remove the 'created' date of each defined template.
* This will remove the 'createdBy' of each defined template.
*
* @author brian@inteligr8.com
*/
@@ -66,7 +66,7 @@ public class ApsTemplateJsonNormalizer implements ApsFileNormalizer {
this.logger.trace("Removing excess template meta-data: {}", jsonModel.get("name"));
int fields = jsonModel.size();
jsonModel.remove(Arrays.asList("created", "createdBy"));
jsonModel.remove(Arrays.asList("createdBy"));
return jsonModel.size() < fields;
}

View File

@@ -27,9 +27,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.inteligr8.activiti.model.Datum;
import com.inteligr8.activiti.model.ResultList;
import com.inteligr8.alfresco.activiti.ApsPublicRestApi;
import com.inteligr8.alfresco.activiti.api.ModelsApi.ModelType;
import com.inteligr8.alfresco.activiti.model.GroupLight;
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
import com.inteligr8.alfresco.activiti.model.ResultListDataRepresentation;
import com.inteligr8.alfresco.activiti.model.Tenant;
import com.inteligr8.maven.aps.modeling.crawler.ApsAppCrawlable;
@@ -196,18 +198,15 @@ public class ApsAppTranslator implements ApsAppCrawlable {
return map;
}
@SuppressWarnings("unchecked")
protected Index<Long, String> buildApsModelIndex(ModelType modelType) {
ResultListDataRepresentation<Datum> results = this.api.getModelsApi().get("everyone", null, modelType.getId(), null);
ResultList<ModelRepresentation> results = this.api.getModelsApi().get("everyone", null, modelType.getId(), null);
this.logger.debug("APS {} models found: {} out of {}", modelType, results.getSize(), results.getTotal());
Index<Long, String> map = new Index<>(results.getSize().intValue(), false);
try {
for (Datum datum : results.getData()) {
Number defId = (Number)datum.getAdditionalProperties().get("id");
String defName = (String)datum.getAdditionalProperties().get("name");
map.put(defId.longValue(), defName);
for (ModelRepresentation model : results.getData()) {
map.put(model.getId(), model.getName());
// FIXME add paging support
}

View File

@@ -110,7 +110,7 @@ public class ApsTemplateTranslator implements ApsTemplateCrawlable {
int perPage = 50;
int page = 1;
ResultList<? extends BaseTemplateLight> templates = this.api.getTemplatesApi().getDocumentTemplates(null, (page-1)*perPage, perPage, null, tenantId);
ResultList<? extends BaseTemplateLight> templates = this.api.getTemplatesApi().getDocumentTemplates(null, (page-1)*perPage, perPage, "sort_by_name_asc", tenantId);
Index<Long, String> index = new Index<>(templates.getTotal() / 2, false);
while (!templates.getData().isEmpty()) {
@@ -120,7 +120,7 @@ public class ApsTemplateTranslator implements ApsTemplateCrawlable {
index.put(template.getId(), template.getName());
page++;
templates = this.api.getTemplatesApi().getDocumentTemplates(null, (page-1)*perPage, perPage, null, tenantId);
templates = this.api.getTemplatesApi().getDocumentTemplates(null, (page-1)*perPage, perPage, "sort_by_name_asc", tenantId);
}
return index;
@@ -130,7 +130,7 @@ public class ApsTemplateTranslator implements ApsTemplateCrawlable {
int perPage = 50;
int page = 1;
ResultList<? extends BaseTemplateLight> templates = this.api.getTemplatesApi().getCustomEmailTemplates(null, (page-1)*perPage, perPage, null, tenantId);
ResultList<? extends BaseTemplateLight> templates = this.api.getTemplatesApi().getCustomEmailTemplates(null, (page-1)*perPage, perPage, "sort_by_name_asc", tenantId);
Index<Long, String> index = new Index<>(templates.getTotal() / 2, false);
while (!templates.getData().isEmpty()) {
@@ -140,7 +140,7 @@ public class ApsTemplateTranslator implements ApsTemplateCrawlable {
index.put(template.getId(), template.getName());
page++;
templates = this.api.getTemplatesApi().getCustomEmailTemplates(null, (page-1)*perPage, perPage, null, tenantId);
templates = this.api.getTemplatesApi().getCustomEmailTemplates(null, (page-1)*perPage, perPage, "sort_by_name_asc", tenantId);
}
return index;