mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Refactored links management UI following link validation service API changes
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6024 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -136,4 +136,5 @@ copy-to-web-project.description=This will copy the matched item to a folder in a
|
|||||||
avm-link-validation.title=Performs a link validation check.
|
avm-link-validation.title=Performs a link validation check.
|
||||||
avm-link-validation.description=Performs a link validation check.
|
avm-link-validation.description=Performs a link validation check.
|
||||||
avm-link-validation.monitor.display-label=The status object used to determine progress
|
avm-link-validation.monitor.display-label=The status object used to determine progress
|
||||||
|
avm-link-validation.compare-to-staging.display-label=Determines whether the link check should use the corresponding staging area for comparison
|
||||||
|
|
||||||
|
@@ -59,6 +59,8 @@ wcmwf_workflowmodel.property.wcmwf_launchDate.title=Launch Date
|
|||||||
wcmwf_workflowmodel.property.wcmwf_launchDate.description=Date the content in the submission should be committed
|
wcmwf_workflowmodel.property.wcmwf_launchDate.description=Date the content in the submission should be committed
|
||||||
wcmwf_workflowmodel.property.wcmwf_validateLinks.title=Validate Links
|
wcmwf_workflowmodel.property.wcmwf_validateLinks.title=Validate Links
|
||||||
wcmwf_workflowmodel.property.wcmwf_validateLinks.description=Whether links should be verified before entering the review cycle
|
wcmwf_workflowmodel.property.wcmwf_validateLinks.description=Whether links should be verified before entering the review cycle
|
||||||
|
wcmwf_workflowmodel.property.wcmwf_webapp.title=Webapp
|
||||||
|
wcmwf_workflowmodel.property.wcmwf_webapp.description=The webapp within the workflow store to check links for
|
||||||
wcmwf_workflowmodel.property.wcmwf_reviewerCnt.title=Total Reviewed
|
wcmwf_workflowmodel.property.wcmwf_reviewerCnt.title=Total Reviewed
|
||||||
wcmwf_workflowmodel.property.wcmwf_reviewerCnt.description=Count of people who reviewed
|
wcmwf_workflowmodel.property.wcmwf_reviewerCnt.description=Count of people who reviewed
|
||||||
wcmwf_workflowmodel.property.wcmwf_approveCnt.title=Total Approved
|
wcmwf_workflowmodel.property.wcmwf_approveCnt.title=Total Approved
|
||||||
|
@@ -228,6 +228,11 @@
|
|||||||
<description>Determines whether links should be verified before entering the review cycle</description>
|
<description>Determines whether links should be verified before entering the review cycle</description>
|
||||||
<type>d:boolean</type>
|
<type>d:boolean</type>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="wcmwf:webapp">
|
||||||
|
<title>Webapp</title>
|
||||||
|
<description>The webapp within the workflow store to check links for</description>
|
||||||
|
<type>d:text</type>
|
||||||
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
</aspect>
|
</aspect>
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@ package org.alfresco.linkvalidation;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.config.JNDIConstants;
|
||||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
@@ -51,6 +52,7 @@ public class LinkValidationAction extends ActionExecuterAbstractBase
|
|||||||
{
|
{
|
||||||
public static final String NAME = "avm-link-validation";
|
public static final String NAME = "avm-link-validation";
|
||||||
|
|
||||||
|
public static final String PARAM_COMPARE_TO_STAGING = "compare-to-staging";
|
||||||
public static final String PARAM_MONITOR = "monitor";
|
public static final String PARAM_MONITOR = "monitor";
|
||||||
|
|
||||||
private LinkValidationService linkValidationService;
|
private LinkValidationService linkValidationService;
|
||||||
@@ -81,6 +83,8 @@ public class LinkValidationAction extends ActionExecuterAbstractBase
|
|||||||
@Override
|
@Override
|
||||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||||
{
|
{
|
||||||
|
paramList.add(new ParameterDefinitionImpl(PARAM_COMPARE_TO_STAGING, DataTypeDefinition.BOOLEAN,
|
||||||
|
false, getParamDisplayLabel(PARAM_COMPARE_TO_STAGING)));
|
||||||
paramList.add(new ParameterDefinitionImpl(PARAM_MONITOR, DataTypeDefinition.ANY, false,
|
paramList.add(new ParameterDefinitionImpl(PARAM_MONITOR, DataTypeDefinition.ANY, false,
|
||||||
getParamDisplayLabel(PARAM_MONITOR)));
|
getParamDisplayLabel(PARAM_MONITOR)));
|
||||||
}
|
}
|
||||||
@@ -88,38 +92,86 @@ public class LinkValidationAction extends ActionExecuterAbstractBase
|
|||||||
@Override
|
@Override
|
||||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||||
{
|
{
|
||||||
// get the store to check the links for (is represented by the actioned upon node)
|
// get the webapp path to check the links for (is represented by the actioned upon node)
|
||||||
Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
|
Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
|
||||||
String path = avmVersionPath.getSecond();
|
String webappPath = avmVersionPath.getSecond();
|
||||||
|
|
||||||
// get store name and path parts.
|
// get store name and path parts.
|
||||||
String [] storePath = path.split(":");
|
String [] webappParts = webappPath.split(":");
|
||||||
if (storePath.length != 2)
|
if (webappParts.length != 2)
|
||||||
{
|
{
|
||||||
throw new AVMSyncException("Malformed source path: " + path);
|
throw new AVMSyncException("Malformed source path: " + webappPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract the store name
|
||||||
|
String storeName = actionedUponNodeRef.getStoreRef().getIdentifier();
|
||||||
|
|
||||||
|
// extract the webapp name
|
||||||
|
String webappName = webappPath.substring(webappPath.lastIndexOf("/")+1);
|
||||||
|
|
||||||
|
// get the compare to staging flag
|
||||||
|
String destWebappPath = null;
|
||||||
|
Boolean compareToStaging = (Boolean)action.getParameterValue(PARAM_COMPARE_TO_STAGING);
|
||||||
|
if (compareToStaging != null)
|
||||||
|
{
|
||||||
|
if (compareToStaging.booleanValue())
|
||||||
|
{
|
||||||
|
// get the corresponding path in the staging area for the given source
|
||||||
|
PropertyValue val = this.avmService.getStoreProperty(storeName, SandboxConstants.PROP_WEBSITE_NAME);
|
||||||
|
if (val != null)
|
||||||
|
{
|
||||||
|
String stagingStoreName = val.getStringValue();
|
||||||
|
destWebappPath = stagingStoreName + ":/" + JNDIConstants.DIR_DEFAULT_WWW + "/" +
|
||||||
|
JNDIConstants.DIR_DEFAULT_APPBASE + "/" + webappName;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract the store name
|
|
||||||
String store = storePath[0];
|
|
||||||
|
|
||||||
// get the monitor object
|
// get the monitor object
|
||||||
HrefValidationProgress monitor = (HrefValidationProgress)action.getParameterValue(PARAM_MONITOR);
|
HrefValidationProgress monitor = (HrefValidationProgress)action.getParameterValue(PARAM_MONITOR);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Performing link validation check for store '" + store + "'");
|
{
|
||||||
|
if (destWebappPath == null)
|
||||||
|
{
|
||||||
|
logger.debug("Performing link validation check for webapp '" + webappPath + "'");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.debug("Performing link validation check for webapp '" + webappPath + "', comparing against '" +
|
||||||
|
destWebappPath + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LinkValidationReport report = null;
|
LinkValidationReport report = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// firstly call updateHrefInfo to scan the whole store for broken links
|
// determine which API to call depending on whether there is a destination webapp present
|
||||||
// NOTE: currently this is NOT done incrementally
|
if (destWebappPath != null)
|
||||||
this.linkValidationService.updateHrefInfo(store, false, 10000, 30000, 5, monitor);
|
{
|
||||||
|
// get the object to represent the broken files
|
||||||
|
HrefDifference hdiff = this.linkValidationService.getHrefDifference(webappPath, destWebappPath,
|
||||||
|
10000, 30000, 5, monitor);
|
||||||
|
|
||||||
|
// get the broken files created due to deletions and new/modified files
|
||||||
|
HrefManifest brokenByDelete = this.linkValidationService.getHrefManifestBrokenByDelete(hdiff);
|
||||||
|
HrefManifest brokenByNewOrMod = this.linkValidationService.getHrefManifestBrokenByNewOrMod(hdiff);
|
||||||
|
|
||||||
|
// create the report object using the 2 sets of results
|
||||||
|
report = new LinkValidationReport(storeName, webappName, monitor, brokenByDelete, brokenByNewOrMod);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// firstly call updateHrefInfo to scan the whole store for broken links
|
||||||
|
// NOTE: currently this is NOT done incrementally
|
||||||
|
this.linkValidationService.updateHrefInfo(webappPath, false, 10000, 30000, 5, monitor);
|
||||||
|
|
||||||
// retrieve the manifest of all the broken links and files
|
// retrieve the manifest of all the broken links and files for the webapp
|
||||||
List<HrefManifestEntry> manifests = this.linkValidationService.getBrokenHrefManifestEntries(store);
|
List<HrefManifestEntry> manifests = this.linkValidationService.getBrokenHrefManifestEntries(webappPath);
|
||||||
|
|
||||||
// create the report object using the link check results
|
// create the report object using the link check results
|
||||||
report = new LinkValidationReport(monitor, manifests);
|
report = new LinkValidationReport(storeName, webappName, monitor, manifests);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
@@ -129,15 +181,15 @@ public class LinkValidationAction extends ActionExecuterAbstractBase
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
report = new LinkValidationReport(err);
|
report = new LinkValidationReport(storeName, webappName, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.error("Link Validation Error: ", err);
|
logger.error("Link Validation Error: ", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the report as a store property on the store we ran the link check on
|
// store the report as a store property on the store we ran the link check on
|
||||||
this.avmService.deleteStoreProperty(store, SandboxConstants.PROP_LINK_VALIDATION_REPORT);
|
this.avmService.deleteStoreProperty(storeName, SandboxConstants.PROP_LINK_VALIDATION_REPORT);
|
||||||
this.avmService.setStoreProperty(store, SandboxConstants.PROP_LINK_VALIDATION_REPORT,
|
this.avmService.setStoreProperty(storeName, SandboxConstants.PROP_LINK_VALIDATION_REPORT,
|
||||||
new PropertyValue(DataTypeDefinition.ANY, report));
|
new PropertyValue(DataTypeDefinition.ANY, report));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,10 +27,13 @@ package org.alfresco.linkvalidation;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object representing the result of a link validation action being executed.
|
* Object representing the result of a link validation action being executed.
|
||||||
* This object combines the results of the multiple service calls required to
|
* This object combines the results of the multiple service calls required to
|
||||||
@@ -44,10 +47,13 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class LinkValidationReport implements Serializable
|
public class LinkValidationReport implements Serializable
|
||||||
{
|
{
|
||||||
|
private String store;
|
||||||
|
private String webapp;
|
||||||
private int numberFilesChecked = -1;
|
private int numberFilesChecked = -1;
|
||||||
private int numberLinksChecked = -1;
|
private int numberLinksChecked = -1;
|
||||||
private int numberBrokenLinks = -1;
|
private int numberBrokenLinks = -1;
|
||||||
private boolean successful = true;
|
private boolean successful = true;
|
||||||
|
private Date completedAt;
|
||||||
|
|
||||||
private Throwable error;
|
private Throwable error;
|
||||||
private List<String> brokenFiles;
|
private List<String> brokenFiles;
|
||||||
@@ -56,46 +62,101 @@ public class LinkValidationReport implements Serializable
|
|||||||
private static final long serialVersionUID = 7562964706845609991L;
|
private static final long serialVersionUID = 7562964706845609991L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a link validation report from the results of a check
|
* Constructs a link validation report from the results of a check of the
|
||||||
|
* staging area.
|
||||||
*
|
*
|
||||||
|
* @param store The store the link check was run against
|
||||||
|
* @param webapp The webapp within the store the check was run against
|
||||||
* @param status The object containing status i.e. file, link counts and the list
|
* @param status The object containing status i.e. file, link counts and the list
|
||||||
* of files containing broken links
|
* of files containing broken links
|
||||||
* @param manifests The manifest of broken links and files
|
* @param manifests The manifest of broken links and files
|
||||||
*/
|
*/
|
||||||
public LinkValidationReport(HrefValidationProgress status, List<HrefManifestEntry> manifests)
|
public LinkValidationReport(String store, String webapp, HrefValidationProgress status,
|
||||||
|
List<HrefManifestEntry> manifests)
|
||||||
{
|
{
|
||||||
|
this.store = store;
|
||||||
|
this.webapp = webapp;
|
||||||
|
this.completedAt = new Date();
|
||||||
this.numberFilesChecked = status.getFileUpdateCount();
|
this.numberFilesChecked = status.getFileUpdateCount();
|
||||||
this.numberLinksChecked = status.getUrlUpdateCount();
|
this.numberLinksChecked = status.getUrlUpdateCount();
|
||||||
|
|
||||||
// create a list of broken files
|
// create list and map
|
||||||
this.brokenFiles = new ArrayList<String>(manifests.size());
|
this.brokenFiles = new ArrayList<String>(manifests.size());
|
||||||
|
|
||||||
// create a map of broken links by file.
|
|
||||||
this.brokenLinksByFile = new HashMap<String, HrefManifestEntry>(manifests.size());
|
this.brokenLinksByFile = new HashMap<String, HrefManifestEntry>(manifests.size());
|
||||||
|
|
||||||
// build the required list and maps
|
// build the required list and map
|
||||||
for (HrefManifestEntry manifest : manifests)
|
storeBrokenFiles(manifests);
|
||||||
{
|
}
|
||||||
String fileName = manifest.getFileName();
|
|
||||||
this.brokenFiles.add(fileName);
|
/**
|
||||||
this.brokenLinksByFile.put(fileName, manifest);
|
* Constructs a link validation report from the results of a comparison check
|
||||||
this.numberBrokenLinks = this.numberBrokenLinks + manifest.getHrefs().size();
|
* between the staging area and another sandbox i.e. an authors sandbox or a
|
||||||
}
|
* workflow sandbox.
|
||||||
|
*
|
||||||
|
* @param store The store the link check was run against
|
||||||
|
* @param webapp The webapp within the store the check was run against
|
||||||
|
* @param status The object containing status i.e. file, link counts and the list
|
||||||
|
* of files containing broken links
|
||||||
|
* @param brokenByDelete Object representing the broken links caused by deleted assets
|
||||||
|
* @param brokenByNewOrMod Object representing the broken links caused by new or
|
||||||
|
* modified assets
|
||||||
|
*/
|
||||||
|
public LinkValidationReport(String store, String webapp, HrefValidationProgress status,
|
||||||
|
HrefManifest brokenByDelete, HrefManifest brokenByNewOrMod)
|
||||||
|
{
|
||||||
|
this.store = store;
|
||||||
|
this.webapp = webapp;
|
||||||
|
this.completedAt = new Date();
|
||||||
|
this.numberFilesChecked = status.getFileUpdateCount();
|
||||||
|
this.numberLinksChecked = status.getUrlUpdateCount();
|
||||||
|
|
||||||
|
// get the lists of broken files
|
||||||
|
List<HrefManifestEntry> byDelete = brokenByDelete.getManifestEntries();
|
||||||
|
List<HrefManifestEntry> byNewOrMod = brokenByNewOrMod.getManifestEntries();
|
||||||
|
|
||||||
|
// create list and map
|
||||||
|
this.brokenFiles = new ArrayList<String>(byDelete.size() + byNewOrMod.size());
|
||||||
|
this.brokenLinksByFile = new HashMap<String, HrefManifestEntry>(
|
||||||
|
byDelete.size() + byNewOrMod.size());
|
||||||
|
|
||||||
|
// build the required list and map
|
||||||
|
storeBrokenFiles(byDelete);
|
||||||
|
storeBrokenFiles(byNewOrMod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a link validation report from an error that occurred
|
* Constructs a link validation report from an error that occurred
|
||||||
*
|
*
|
||||||
|
* @param store The store the link check was run against
|
||||||
|
* @param webapp The webapp within the store the check was run against
|
||||||
* @param error The error that caused the link check to fail
|
* @param error The error that caused the link check to fail
|
||||||
*/
|
*/
|
||||||
public LinkValidationReport(Throwable error)
|
public LinkValidationReport(String store, String webapp, Throwable error)
|
||||||
{
|
{
|
||||||
|
this.store = store;
|
||||||
|
this.webapp = webapp;
|
||||||
|
this.completedAt = new Date();
|
||||||
this.setError(error);
|
this.setError(error);
|
||||||
|
|
||||||
this.brokenFiles = Collections.emptyList();
|
this.brokenFiles = Collections.emptyList();
|
||||||
this.brokenLinksByFile = Collections.emptyMap();
|
this.brokenLinksByFile = Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStore()
|
||||||
|
{
|
||||||
|
return this.store;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWebapp()
|
||||||
|
{
|
||||||
|
return this.webapp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCheckCompletedAt()
|
||||||
|
{
|
||||||
|
return this.completedAt;
|
||||||
|
}
|
||||||
|
|
||||||
public int getNumberFilesChecked()
|
public int getNumberFilesChecked()
|
||||||
{
|
{
|
||||||
return this.numberFilesChecked;
|
return this.numberFilesChecked;
|
||||||
@@ -149,6 +210,34 @@ public class LinkValidationReport implements Serializable
|
|||||||
{
|
{
|
||||||
return this.error;
|
return this.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuilder buffer = new StringBuilder(super.toString());
|
||||||
|
buffer.append(" (store=").append(this.store);
|
||||||
|
buffer.append(" webapp=").append(this.webapp);
|
||||||
|
buffer.append(" error=").append(this.error).append(")");
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the given list of manifest entries in the internal lists and maps
|
||||||
|
*
|
||||||
|
* @param manifests Manifest entries to store
|
||||||
|
*/
|
||||||
|
protected void storeBrokenFiles(List<HrefManifestEntry> manifests)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("manifests", manifests);
|
||||||
|
|
||||||
|
for (HrefManifestEntry manifest : manifests)
|
||||||
|
{
|
||||||
|
String fileName = manifest.getFileName();
|
||||||
|
this.brokenFiles.add(fileName);
|
||||||
|
this.brokenLinksByFile.put(fileName, manifest);
|
||||||
|
this.numberBrokenLinks = this.numberBrokenLinks + manifest.getHrefs().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -37,5 +37,6 @@ public interface WCMWorkflowModel
|
|||||||
static final QName PROP_LABEL = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "label");
|
static final QName PROP_LABEL = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "label");
|
||||||
static final QName PROP_LAUNCH_DATE = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "launchDate");
|
static final QName PROP_LAUNCH_DATE = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "launchDate");
|
||||||
static final QName PROP_VALIDATE_LINKS = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "validateLinks");
|
static final QName PROP_VALIDATE_LINKS = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "validateLinks");
|
||||||
|
static final QName PROP_WEBAPP = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "webapp");
|
||||||
static final QName ASSOC_WEBPROJECT = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "webproject");
|
static final QName ASSOC_WEBPROJECT = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "webproject");
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,6 @@ import org.alfresco.config.JNDIConstants;
|
|||||||
import org.alfresco.linkvalidation.HrefValidationProgress;
|
import org.alfresco.linkvalidation.HrefValidationProgress;
|
||||||
import org.alfresco.linkvalidation.LinkValidationAction;
|
import org.alfresco.linkvalidation.LinkValidationAction;
|
||||||
import org.alfresco.linkvalidation.LinkValidationReport;
|
import org.alfresco.linkvalidation.LinkValidationReport;
|
||||||
import org.alfresco.linkvalidation.LinkValidationService;
|
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
import org.alfresco.repo.workflow.jbpm.JBPMNode;
|
import org.alfresco.repo.workflow.jbpm.JBPMNode;
|
||||||
@@ -41,8 +40,6 @@ import org.alfresco.service.cmr.action.Action;
|
|||||||
import org.alfresco.service.cmr.action.ActionService;
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
|
||||||
import org.alfresco.util.Pair;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jbpm.graph.exe.ExecutionContext;
|
import org.jbpm.graph.exe.ExecutionContext;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
@@ -89,21 +86,20 @@ public class AVMSubmitLinkChecker extends JBPMSpringActionHandler
|
|||||||
{
|
{
|
||||||
// retrieve the workflow sandbox (the workflow package)
|
// retrieve the workflow sandbox (the workflow package)
|
||||||
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
|
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
|
||||||
Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
|
|
||||||
|
|
||||||
// remove the trailing www from the path
|
|
||||||
String path = pkgPath.getSecond();
|
|
||||||
path = path.substring(0, (path.length()-JNDIConstants.DIR_DEFAULT_WWW.length()));
|
|
||||||
NodeRef storePath = AVMNodeConverter.ToNodeRef(-1, path);
|
|
||||||
|
|
||||||
// get the store name
|
// get the store name
|
||||||
String storeName = pkg.getStoreRef().getIdentifier();
|
String storeName = pkg.getStoreRef().getIdentifier();
|
||||||
|
|
||||||
|
// retrieve the webapp name from the workflow execution context
|
||||||
|
String webappName = (String)executionContext.getContextInstance().getVariable("wcmwf_webapp");
|
||||||
|
String webappPath = storeName + ":/" + JNDIConstants.DIR_DEFAULT_WWW + "/" +
|
||||||
|
JNDIConstants.DIR_DEFAULT_APPBASE + "/" + webappName;
|
||||||
|
NodeRef webappPathRef = AVMNodeConverter.ToNodeRef(-1, webappPath);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.info("Found workflow store to check links for: " + path);
|
logger.debug("Checking links in workflow webapp: " + webappPath);
|
||||||
|
|
||||||
// create and execute the action in the background
|
// create and execute the action
|
||||||
Throwable cause = null;
|
|
||||||
int brokenLinks = -1;
|
int brokenLinks = -1;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -111,8 +107,15 @@ public class AVMSubmitLinkChecker extends JBPMSpringActionHandler
|
|||||||
HrefValidationProgress monitor = new HrefValidationProgress();
|
HrefValidationProgress monitor = new HrefValidationProgress();
|
||||||
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
|
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
|
||||||
args.put(LinkValidationAction.PARAM_MONITOR, monitor);
|
args.put(LinkValidationAction.PARAM_MONITOR, monitor);
|
||||||
|
|
||||||
|
// TODO: determine what should happen here, comparing against staging
|
||||||
|
// does not work as the webapp is not virtualised yet so workflow
|
||||||
|
// always goes straight to 'review'. Temporarily removed the flag
|
||||||
|
// so just the workflow store gets checked.
|
||||||
|
|
||||||
|
// args.put(LinkValidationAction.PARAM_COMPARE_TO_STAGING, Boolean.TRUE);
|
||||||
Action action = this.fActionService.createAction(LinkValidationAction.NAME, args);
|
Action action = this.fActionService.createAction(LinkValidationAction.NAME, args);
|
||||||
this.fActionService.executeAction(action, storePath, false, false);
|
this.fActionService.executeAction(action, webappPathRef, false, false);
|
||||||
|
|
||||||
// retrieve the deployment report from the store property
|
// retrieve the deployment report from the store property
|
||||||
PropertyValue val = this.fAVMService.getStoreProperty(storeName,
|
PropertyValue val = this.fAVMService.getStoreProperty(storeName,
|
||||||
@@ -124,10 +127,6 @@ public class AVMSubmitLinkChecker extends JBPMSpringActionHandler
|
|||||||
{
|
{
|
||||||
brokenLinks = report.getNumberBrokenLinks();
|
brokenLinks = report.getNumberBrokenLinks();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
cause = report.getError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
@@ -135,16 +134,10 @@ public class AVMSubmitLinkChecker extends JBPMSpringActionHandler
|
|||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
cause = err;
|
logger.error(err);
|
||||||
}
|
|
||||||
|
|
||||||
// set the number of broken links in a variable
|
|
||||||
if (brokenLinks == -1)
|
|
||||||
{
|
|
||||||
// TODO: Decide how to handle errors,
|
|
||||||
// for now just return -1 and the workflow can decide
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the number of broken links in a variable, -1 indicates an error occured
|
||||||
executionContext.setVariable("wcmwf_brokenLinks", brokenLinks);
|
executionContext.setVariable("wcmwf_brokenLinks", brokenLinks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user