mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-489: The user should be informed if the data set cannot be imported
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@43044 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
{
|
||||||
"success": ${success?string}
|
"success": ${success?string},
|
||||||
|
"message": "${message}"
|
||||||
}
|
}
|
||||||
</#escape>
|
</#escape>
|
@@ -268,7 +268,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Unexpected exception thrown", ex);
|
throw new RuntimeException("Unexpected exception thrown. Please refer to the log files for details.", ex);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@@ -9,6 +9,9 @@ import org.alfresco.module.org_alfresco_module_rm.model.RmSiteType;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
@@ -23,6 +26,9 @@ public class DataSetPost extends DeclarativeWebScript implements RecordsManageme
|
|||||||
/** Constant for the data set id parameter */
|
/** Constant for the data set id parameter */
|
||||||
private static final String ARG_DATA_SET_ID = "dataSetId";
|
private static final String ARG_DATA_SET_ID = "dataSetId";
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
private static Log logger = LogFactory.getLog(DataSetPost.class);
|
||||||
|
|
||||||
/** Site service */
|
/** Site service */
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
|
|
||||||
@@ -57,45 +63,55 @@ public class DataSetPost extends DeclarativeWebScript implements RecordsManageme
|
|||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
// Resolve data set id
|
|
||||||
String dataSetId = req.getServiceMatch().getTemplateVars().get(ARG_DATA_SET_ID);
|
|
||||||
if (StringUtils.isBlank(dataSetId))
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "A data set id was not provided.");
|
|
||||||
}
|
|
||||||
if (!dataSetService.existsDataSet(dataSetId))
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "A data set with the id '" + dataSetId + "'"
|
|
||||||
+ " does not exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve RM site
|
|
||||||
String siteName = req.getParameter(ARG_SITE_NAME);
|
|
||||||
if (StringUtils.isBlank(siteName))
|
|
||||||
{
|
|
||||||
siteName = RmSiteType.DEFAULT_SITE_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the site if it exists
|
|
||||||
if (siteService.getSite(siteName) == null)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "A Records Management site with the name '"
|
|
||||||
+ siteName + "' does not exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve documentLibrary (filePlan) container
|
|
||||||
NodeRef filePlan = siteService.getContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY);
|
|
||||||
if (filePlan == null)
|
|
||||||
{
|
|
||||||
filePlan = siteService.createContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY,
|
|
||||||
TYPE_FILE_PLAN, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load data set in to the file plan
|
|
||||||
dataSetService.loadDataSet(filePlan, dataSetId);
|
|
||||||
|
|
||||||
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
|
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
|
||||||
model.put("success", true);
|
try
|
||||||
|
{
|
||||||
|
// Resolve data set id
|
||||||
|
String dataSetId = req.getServiceMatch().getTemplateVars().get(ARG_DATA_SET_ID);
|
||||||
|
if (StringUtils.isBlank(dataSetId))
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "A data set id was not provided.");
|
||||||
|
}
|
||||||
|
if (!dataSetService.existsDataSet(dataSetId))
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "A data set with the id '" + dataSetId + "'"
|
||||||
|
+ " does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve RM site
|
||||||
|
String siteName = req.getParameter(ARG_SITE_NAME);
|
||||||
|
if (StringUtils.isBlank(siteName))
|
||||||
|
{
|
||||||
|
siteName = RmSiteType.DEFAULT_SITE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the site if it exists
|
||||||
|
if (siteService.getSite(siteName) == null)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "A Records Management site with the name '"
|
||||||
|
+ siteName + "' does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve documentLibrary (filePlan) container
|
||||||
|
NodeRef filePlan = siteService.getContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY);
|
||||||
|
if (filePlan == null)
|
||||||
|
{
|
||||||
|
filePlan = siteService.createContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY,
|
||||||
|
TYPE_FILE_PLAN, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load data set in to the file plan
|
||||||
|
dataSetService.loadDataSet(filePlan, dataSetId);
|
||||||
|
|
||||||
|
model.put("success", true);
|
||||||
|
model.put("message", "Successfully imported data set.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
model.put("success", false);
|
||||||
|
model.put("message", ex.getMessage());
|
||||||
|
logger.error(ExceptionUtils.getFullStackTrace(ex));
|
||||||
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user