diff --git a/CHANGELOG.md b/CHANGELOG.md index ea3c655986..d358042603 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com) ## Unreleased ([details][unreleased changes details]) +## Fixed + +- #3140 - Fixed issue where malformed MCP process nodes can cause a NPE that breaks the entire MPC reporting UI. Now displays more friendly values in UI to help remove the invalid nodes. - #3150 - Support for case-insensitive redirect rules ( [NC] flag equivalent of apache) - #3138 - Re-arrange action removes data from redirect node diff --git a/bundle/src/main/java/com/adobe/acs/commons/mcp/model/impl/ArchivedProcessInstance.java b/bundle/src/main/java/com/adobe/acs/commons/mcp/model/impl/ArchivedProcessInstance.java index d57bc9a38d..120dcb14bd 100644 --- a/bundle/src/main/java/com/adobe/acs/commons/mcp/model/impl/ArchivedProcessInstance.java +++ b/bundle/src/main/java/com/adobe/acs/commons/mcp/model/impl/ArchivedProcessInstance.java @@ -23,13 +23,7 @@ import com.adobe.acs.commons.mcp.ProcessInstance; import com.adobe.acs.commons.mcp.model.ManagedProcess; import com.adobe.acs.commons.mcp.util.DeserializeException; -import java.io.Serializable; -import java.util.Map; -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Named; -import javax.jcr.RepositoryException; -import javax.management.openmbean.CompositeData; +import org.apache.commons.lang3.StringUtils; import org.apache.sling.api.resource.LoginException; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceResolver; @@ -37,6 +31,14 @@ import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.Via; +import javax.annotation.PostConstruct; +import javax.inject.Inject; +import javax.inject.Named; +import javax.jcr.RepositoryException; +import javax.management.openmbean.CompositeData; +import java.io.Serializable; +import java.util.Map; + /** * */ @@ -60,24 +62,42 @@ public class ArchivedProcessInstance implements ProcessInstance, Serializable { @Named("jcr:content") public ManagedProcess infoBean; + @Override public String getName() { - return getInfo().getName(); + return StringUtils.defaultIfBlank(getInfo().getName(), getId()); } @Override public ManagedProcess getInfo() { + // Handle cases where archived processes are invalid/null such that they display in the UI and do not break its rendering. + if (infoBean.getName() == null) { + infoBean.setName("Invalid (" + getId() + ")"); + } + + if (infoBean.getDescription() == null) { + infoBean.setDescription("Archived process at " + getPath() + " is null"); + } + + if (infoBean.getStartTime() == null) { + infoBean.setStartTime(-1L); + } + + if (infoBean.getStopTime() == null) { + infoBean.setStopTime(-1L); + } + return infoBean; } @Override public String getId() { - return id; + return StringUtils.defaultString(id, resource.getName()); } @Override public String getPath() { - return path; + return StringUtils.defaultString(path, resource.getPath()); } @PostConstruct @@ -87,7 +107,7 @@ protected void markNotRunning() { getInfo().setStatus("Halted abnormally"); } } - + @PostConstruct protected void setValues() { id = resource.getName();