mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1639 (Recordable Version Configuration Rule)
* Refactored code (added recordable version config service) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@89727 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1581,4 +1581,49 @@
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Recordable Verison Config Service -->
|
||||
|
||||
<bean id="recordableVersionConfigService" class="org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigServiceImpl">
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="RecordableVersionConfigService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="recordableVersionConfigService"/>
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref local="RecordableVersionConfigService_transaction"/>
|
||||
<idref bean="exceptionTranslator"/>
|
||||
<idref local="RecordableVersionConfigService_security"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="RecordableVersionConfigService_transaction" class="org.springframework.transaction.interceptor.TransactionInterceptor">
|
||||
<property name="transactionManager">
|
||||
<ref bean="transactionManager"/>
|
||||
</property>
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">${server.transaction.mode.default}</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="RecordableVersionConfigService_security" parent="baseSecurity">
|
||||
<property name="objectDefinitionSource">
|
||||
<value>
|
||||
<![CDATA[
|
||||
org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService.getVersions=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService.setVersion=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService.*=RM_DENY
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
|
@@ -618,11 +618,13 @@
|
||||
<bean id="webscript.org.alfresco.slingshot.documentlibrary.action.recorded-version-config.post"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigPost"
|
||||
parent="rmBaseWebscript">
|
||||
<property name="RecordableVersionConfigService" ref="RecordableVersionConfigService" />
|
||||
</bean>
|
||||
|
||||
<!-- REST impl for GET recorded version config -->
|
||||
<bean id="webscript.org.alfresco.slingshot.documentlibrary.action.recorded-version-config.get"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigGet"
|
||||
parent="rmBaseWebscript">
|
||||
<property name="RecordableVersionConfigService" ref="RecordableVersionConfigService" />
|
||||
</bean>
|
||||
</beans>
|
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.recordableversion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.slingshot.Version;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Recordable version config service interface
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public interface RecordableVersionConfigService
|
||||
{
|
||||
/**
|
||||
* Gets the recordable versions
|
||||
*
|
||||
* @param nodeRef The node reference for which the recordable versions should be retrieved
|
||||
* @return The list of recordable versions
|
||||
*/
|
||||
List<Version> getVersions(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Sets the recordable version for the given node
|
||||
*
|
||||
* @param nodeRef The node reference for which the recorable version should be set
|
||||
* @param version The version to be set
|
||||
*/
|
||||
void setVersion(NodeRef nodeRef, String version);
|
||||
}
|
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.recordableversion;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.NONE;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
import static org.alfresco.util.ParameterCheck.mandatoryString;
|
||||
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.slingshot.Version;
|
||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
||||
/**
|
||||
* Recordable version config service
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class RecordableVersionConfigServiceImpl implements RecordableVersionConfigService, RecordableVersionModel
|
||||
{
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Gets the node service
|
||||
*
|
||||
* @return The node service
|
||||
*/
|
||||
protected NodeService getNodeService()
|
||||
{
|
||||
return this.nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node service
|
||||
*
|
||||
* @param nodeService The node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService#getVersions(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public List<Version> getVersions(NodeRef nodeRef)
|
||||
{
|
||||
mandatory("nodeRef", nodeRef);
|
||||
|
||||
RecordableVersionPolicy[] recordableVersionPolicies = RecordableVersionPolicy.values();
|
||||
List<Version> versions = new ArrayList<Version>(recordableVersionPolicies.length);
|
||||
|
||||
for (RecordableVersionPolicy recordableVersionPolicy : recordableVersionPolicies)
|
||||
{
|
||||
String policy = recordableVersionPolicy.toString();
|
||||
boolean selected = isVersionPolicySelected(recordableVersionPolicy, nodeRef);
|
||||
versions.add(new Version(policy, selected));
|
||||
}
|
||||
|
||||
return versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService#setVersion(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setVersion(NodeRef nodeRef, String version)
|
||||
{
|
||||
mandatory("nodeRef", nodeRef);
|
||||
mandatoryString("recordedVersion", version);
|
||||
|
||||
RecordableVersionPolicy recordableVersionPolicy = RecordableVersionPolicy.valueOf(version);
|
||||
getNodeService().setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, recordableVersionPolicy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified recordable version policy has been selected for the document
|
||||
*
|
||||
* @param recordableVersionPolicy The recordable version policy
|
||||
* @param nodeRef Node reference of the document
|
||||
* @return <code>true</code> if the specified recordable version policy has been selected for the document, <code>false</code> otherwise
|
||||
*/
|
||||
private boolean isVersionPolicySelected(RecordableVersionPolicy recordableVersionPolicy, NodeRef nodeRef)
|
||||
{
|
||||
boolean isVersionPolicySelected = false;
|
||||
String policy = (String) getNodeService().getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY);
|
||||
if (isNotBlank(policy))
|
||||
{
|
||||
if (RecordableVersionPolicy.valueOf(policy).equals(recordableVersionPolicy))
|
||||
{
|
||||
isVersionPolicySelected = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (recordableVersionPolicy.equals(NONE))
|
||||
{
|
||||
isVersionPolicySelected = true;
|
||||
}
|
||||
}
|
||||
return isVersionPolicySelected;
|
||||
}
|
||||
}
|
@@ -18,16 +18,13 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.script.slingshot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript;
|
||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
@@ -38,68 +35,41 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class RecordedVersionConfigGet extends AbstractRmWebScript implements RecordableVersionModel
|
||||
public class RecordedVersionConfigGet extends AbstractRmWebScript
|
||||
{
|
||||
/** Recordable version config service */
|
||||
private RecordableVersionConfigService recordableVersionConfigService;
|
||||
|
||||
/**
|
||||
* Gets the recordable version config service
|
||||
*
|
||||
* @return The recordable version config service
|
||||
*/
|
||||
protected RecordableVersionConfigService getRecordableVersionConfigService()
|
||||
{
|
||||
return this.recordableVersionConfigService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the recordable version config service
|
||||
*
|
||||
* @param recordableVersionConfigService The recordable version config service
|
||||
*/
|
||||
public void setRecordableVersionConfigService(RecordableVersionConfigService recordableVersionConfigService)
|
||||
{
|
||||
this.recordableVersionConfigService = recordableVersionConfigService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
RecordableVersionPolicy[] recordableVersionPolicies = RecordableVersionPolicy.values();
|
||||
List<Map<String, Object>> recordableVersions = new ArrayList<Map<String,Object>>(recordableVersionPolicies.length);
|
||||
NodeRef documentNodeRef = parseRequestForNodeRef(req);
|
||||
|
||||
for (RecordableVersionPolicy recordableVersionPolicy : recordableVersionPolicies)
|
||||
{
|
||||
recordableVersions.add(buildRecordableVersionData(recordableVersionPolicy, documentNodeRef));
|
||||
}
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||
NodeRef nodeRef = parseRequestForNodeRef(req);
|
||||
List<Version> recordableVersions = getRecordableVersionConfigService().getVersions(nodeRef);
|
||||
model.put("recordableVersions", recordableVersions);
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the recordable version data
|
||||
*
|
||||
* @param recordableVersionPolicy The recordable version policy
|
||||
* @param nodeRef Node reference of the document
|
||||
* @return A map containing the information about recordable version policy and if this policy is selected for the document
|
||||
*/
|
||||
private Map<String, Object> buildRecordableVersionData(RecordableVersionPolicy recordableVersionPolicy, NodeRef nodeRef)
|
||||
{
|
||||
Map<String, Object> recordableVersionData = new HashMap<String, Object>(2);
|
||||
recordableVersionData.put("policy", recordableVersionPolicy.toString());
|
||||
recordableVersionData.put("selected", isVersionPolicySelected(recordableVersionPolicy, nodeRef));
|
||||
return recordableVersionData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified recordable version policy has been selected for the document
|
||||
*
|
||||
* @param recordableVersionPolicy The recordable version policy
|
||||
* @param nodeRef Node reference of the document
|
||||
* @return <code>true</code> if the specified recordable version policy has been selected for the document, <code>false</code> otherwise
|
||||
*/
|
||||
private boolean isVersionPolicySelected(RecordableVersionPolicy recordableVersionPolicy, NodeRef nodeRef)
|
||||
{
|
||||
boolean isVersionPolicySelected = false;
|
||||
String policy = (String) getNodeService().getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY);
|
||||
if (StringUtils.isNotBlank(policy))
|
||||
{
|
||||
if (RecordableVersionPolicy.valueOf(policy).equals(recordableVersionPolicy))
|
||||
{
|
||||
isVersionPolicySelected = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (recordableVersionPolicy.equals(RecordableVersionPolicy.NONE))
|
||||
{
|
||||
isVersionPolicySelected = true;
|
||||
}
|
||||
}
|
||||
return isVersionPolicySelected;
|
||||
}
|
||||
}
|
||||
|
@@ -24,9 +24,8 @@ import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript;
|
||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
@@ -39,11 +38,34 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class RecordedVersionConfigPost extends AbstractRmWebScript implements RecordableVersionModel
|
||||
public class RecordedVersionConfigPost extends AbstractRmWebScript
|
||||
{
|
||||
// Constant for recorded version parameter
|
||||
/** Constant for recorded version parameter */
|
||||
public static final String RECORDED_VERSION = "recordedVersion";
|
||||
|
||||
/** Recordable version config service */
|
||||
private RecordableVersionConfigService recordableVersionConfigService;
|
||||
|
||||
/**
|
||||
* Gets the recordable version config service
|
||||
*
|
||||
* @return The recordable version config service
|
||||
*/
|
||||
protected RecordableVersionConfigService getRecordableVersionConfigService()
|
||||
{
|
||||
return this.recordableVersionConfigService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the recordable version config service
|
||||
*
|
||||
* @param recordableVersionConfigService The recordable version config service
|
||||
*/
|
||||
public void setRecordableVersionConfigService(RecordableVersionConfigService recordableVersionConfigService)
|
||||
{
|
||||
this.recordableVersionConfigService = recordableVersionConfigService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||
*/
|
||||
@@ -51,8 +73,8 @@ public class RecordedVersionConfigPost extends AbstractRmWebScript implements Re
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
NodeRef nodeRef = parseRequestForNodeRef(req);
|
||||
RecordableVersionPolicy recordableVersionPolicy = getRecordableVersionPolicy(req);
|
||||
getNodeService().setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, recordableVersionPolicy);
|
||||
String policy = getRecordableVersionPolicy(req);
|
||||
getRecordableVersionConfigService().setVersion(nodeRef, policy);
|
||||
return new HashMap<String, Object>(1);
|
||||
}
|
||||
|
||||
@@ -62,10 +84,9 @@ public class RecordedVersionConfigPost extends AbstractRmWebScript implements Re
|
||||
* @param The webscript request
|
||||
* @return The recordable version policy
|
||||
*/
|
||||
private RecordableVersionPolicy getRecordableVersionPolicy(WebScriptRequest req)
|
||||
private String getRecordableVersionPolicy(WebScriptRequest req)
|
||||
{
|
||||
JSONObject requestContent = getRequestContentAsJsonObject(req);
|
||||
String recordedVersion = getStringValueFromJSONObject(requestContent, RECORDED_VERSION);
|
||||
return RecordableVersionPolicy.valueOf(recordedVersion);
|
||||
return getStringValueFromJSONObject(requestContent, RECORDED_VERSION);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.script.slingshot;
|
||||
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
import static org.alfresco.util.ParameterCheck.mandatoryString;
|
||||
|
||||
/**
|
||||
* Recordable version class
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class Version
|
||||
{
|
||||
/** The version policy */
|
||||
private String policy;
|
||||
|
||||
/** Is the version selected */
|
||||
private boolean selected;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param policy The version policy
|
||||
* @param selected Is the version selected
|
||||
*/
|
||||
public Version(String policy, boolean selected)
|
||||
{
|
||||
mandatoryString("policy", policy);
|
||||
mandatory("selected", selected);
|
||||
|
||||
setPolicy(policy);
|
||||
setSelected(selected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version policy
|
||||
*
|
||||
* @return The version policy
|
||||
*/
|
||||
public String getPolicy()
|
||||
{
|
||||
return this.policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version policy
|
||||
*
|
||||
* @param policy The version policy
|
||||
*/
|
||||
private void setPolicy(String policy)
|
||||
{
|
||||
this.policy = policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the version selected
|
||||
*
|
||||
* @return <code>true</code> if the version is selected, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isSelected()
|
||||
{
|
||||
return this.selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version as selected
|
||||
*
|
||||
* @param selected <code>true</code> if the version should be selected, <code>false</code> otherwise
|
||||
*/
|
||||
private void setSelected(boolean selected)
|
||||
{
|
||||
this.selected = selected;
|
||||
}
|
||||
}
|
@@ -38,7 +38,7 @@ public abstract class BaseRecordedVersionConfigTest extends BaseWebScriptUnitTes
|
||||
/** Node ref for test document */
|
||||
protected NodeRef testdoc;
|
||||
|
||||
/** setup web script parameters */
|
||||
/** Setup web script parameters */
|
||||
protected Map<String, String> buildParameters()
|
||||
{
|
||||
testdoc = generateCmContent("testdoc.txt");
|
||||
|
@@ -18,6 +18,9 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.recorded.version.config;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.ALL;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.MAJOR_ONLY;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.NONE;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
@@ -29,6 +32,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigGet;
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.slingshot.Version;
|
||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
@@ -74,7 +78,16 @@ public class RecordedVersionConfigGetTest extends BaseRecordedVersionConfigTest
|
||||
// Test document should not have any recordable version policy set
|
||||
doReturn(null).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY);
|
||||
|
||||
// execute web script
|
||||
// Setup versions
|
||||
List<Version> versions = Arrays.asList(
|
||||
new Version(NONE.toString(), true),
|
||||
new Version(MAJOR_ONLY.toString(), false),
|
||||
new Version(ALL.toString(), false));
|
||||
|
||||
// Stub getVersions
|
||||
doReturn(versions).when(mockedRecordableVersionConfigService).getVersions(testdoc);
|
||||
|
||||
// Execute web script
|
||||
JSONObject json = executeJSONWebScript(parameters);
|
||||
|
||||
// Do checks
|
||||
|
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.recorded.version.config;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigPost.RECORDED_VERSION;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.ALL;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
@@ -63,10 +65,8 @@ public class RecordedVersionConfigPostTest extends BaseRecordedVersionConfigTest
|
||||
@Test
|
||||
public void setRecordedVersionConfig() throws Exception
|
||||
{
|
||||
RecordableVersionPolicy policy = RecordableVersionPolicy.ALL;
|
||||
|
||||
// Build the content
|
||||
String content = buildContent(policy);
|
||||
String content = buildContent(ALL);
|
||||
|
||||
// Build parameters
|
||||
Map<String, String> parameters = buildParameters();
|
||||
@@ -82,7 +82,7 @@ public class RecordedVersionConfigPostTest extends BaseRecordedVersionConfigTest
|
||||
assertEquals(json.length(), 0);
|
||||
|
||||
// Test document must have recordable version policy "ALL" set
|
||||
doReturn(policy).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY);
|
||||
doReturn(ALL).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +95,7 @@ public class RecordedVersionConfigPostTest extends BaseRecordedVersionConfigTest
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{\"");
|
||||
sb.append(RecordedVersionConfigPost.RECORDED_VERSION);
|
||||
sb.append(RECORDED_VERSION);
|
||||
sb.append("\":\"");
|
||||
sb.append(policy.toString());
|
||||
sb.append("\"}");
|
||||
|
@@ -38,6 +38,7 @@ import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
@@ -119,6 +120,7 @@ public class BaseUnitTest implements RecordsManagementModel, ContentModel
|
||||
@Mock(name="authenticationUtil") protected AuthenticationUtil mockedAuthenticationUtil;
|
||||
@Mock(name="extendedPermissionService") protected ExtendedPermissionService mockedExtendedPermissionService;
|
||||
@Mock(name="extendedSecurityService") protected ExtendedSecurityService mockedExtendedSecurityService;
|
||||
@Mock(name="recordableVersionConfigService") protected RecordableVersionConfigService mockedRecordableVersionConfigService;
|
||||
|
||||
/** application context mock */
|
||||
@Mock(name="applicationContext") protected ApplicationContext mockedApplicationContext;
|
||||
|
Reference in New Issue
Block a user