Skip to content

Commit

Permalink
Fix/3140 - Null MCP process instance records breaking MCP UI (#3154)
Browse files Browse the repository at this point in the history
* fix/3140
  • Loading branch information
davidjgonzalez authored Aug 8, 2023
1 parent 4faab41 commit 87a1216
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,22 @@
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;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
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;

/**
*
*/
Expand All @@ -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
Expand All @@ -87,7 +107,7 @@ protected void markNotRunning() {
getInfo().setStatus("Halted abnormally");
}
}

@PostConstruct
protected void setValues() {
id = resource.getName();
Expand Down

0 comments on commit 87a1216

Please sign in to comment.