Source:
public static DurationBean getCurrentLifecycleStateDuration(String registryPathToResource, String lifecycleName, Registry registry) throws GovernanceException { if (StringUtils.isEmpty(registryPathToResource) || StringUtils.isEmpty(lifecycleName) || registry == null) { throw new IllegalArgumentException("Invalid arguments supplied as registryPathToResource: '" + registryPathToResource + "', lifecycleName: " + lifecycleName + " and registry."); } DurationBean durationBean = null; String historyResourcePath = LifecycleConstants.LOG_DEFAULT_PATH + registryPathToResource .replaceAll("/", "_"); UserRegistry userRegistry = (UserRegistry) registry; try { if(log.isDebugEnabled()){ log.debug("Resource history file accessed in: " + historyResourcePath); } if (userRegistry.resourceExists(historyResourcePath)) { String textContent = RegistryUtils.decodeBytes((byte[]) userRegistry.get(historyResourcePath) .getContent()); boolean historyFileEmpty = StringUtils.isEmpty(textContent); if(log.isDebugEnabled()){ log.debug("Resource history file empty = " + historyFileEmpty); } if (!historyFileEmpty) { OMElement omElement = getHistoryElement(textContent, lifecycleName, historyResourcePath); String lastStateChangedTime = omElement.getAttribute(new QName(LifecycleConstants .HISTORY_ITEM_TIME_STAMP)).getAttributeValue(); durationBean = getCheckpointByDuration(lifecycleName, calculateTimeDifference(getCurrentTime(), lastStateChangedTime), registryPathToResource, registry); } } } catch (RegistryException e) { throw new GovernanceException( "Error while checking resource exists for: '" + registryPathToResource + "'"); } return durationBean; }

Target:
public static DurationBean getCurrentLifecycleStateDuration(String registryPathToResource, String lifecycleName, Registry registry) throws GovernanceException { if (StringUtils.isEmpty(registryPathToResource) || StringUtils.isEmpty(lifecycleName) || registry == null) { throw new IllegalArgumentException("Invalid arguments supplied as registryPathToResource: '" + registryPathToResource + "', lifecycleName: " + lifecycleName + " and registry."); } DurationBean durationBean = null; String historyResourcePath = LifecycleConstants.LOG_DEFAULT_PATH + registryPathToResource .replaceAll("/", "_"); UserRegistry userRegistry = (UserRegistry) registry; try { if(log.isDebugEnabled()){ log.debug("Resource history file accessed in: " + historyResourcePath); } if (userRegistry.resourceExists(historyResourcePath)) { String textContent = RegistryUtils.decodeBytes((byte[]) userRegistry.get(historyResourcePath) .getContent()); boolean historyFileEmpty = StringUtils.isEmpty(textContent); if(log.isDebugEnabled()){ log.debug("Resource history file empty = " + historyFileEmpty); } if (!historyFileEmpty) { OMElement omElement = getHistoryElement(textContent, lifecycleName, historyResourcePath); String lastStateChangedTime = omElement.getAttribute(new QName(LifecycleConstants .HISTORY_ITEM_TIME_STAMP)).getAttributeValue(); durationBean = getCheckpointByDuration(lifecycleName, calculateTimeDifference(getCurrentTime(), lastStateChangedTime), registryPathToResource, registry); } } } catch (RegistryException e) { throw new GovernanceException( "Error while checking resource exists for: '" + registryPathToResource + "'", e); } return durationBean; }