diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml
index 9cfd1a90ae..fe6cedfd6d 100644
--- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml
+++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml
@@ -86,8 +86,6 @@
-
-
diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml
index 4f91d82304..40c4434610 100644
--- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml
+++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml
@@ -375,10 +375,10 @@
-
+
-
@@ -568,9 +568,9 @@
parent="baseService">
-
-
-
+
+
+
@@ -1062,8 +1062,8 @@
-
-
+
+
@@ -1499,7 +1499,6 @@
-
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java
index 34e1b014c1..5cd600edb7 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java
@@ -44,7 +44,6 @@ import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
-import org.alfresco.module.org_alfresco_module_rm.model.rma.type.HoldType;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
@@ -103,8 +102,6 @@ public class HoldServiceImpl extends ServiceBaseImpl
/** records management audit service */
private RecordsManagementAuditService recordsManagementAuditService;
- private HoldType holdType;
-
/**
* Set the file plan service
*
@@ -163,11 +160,6 @@ public class HoldServiceImpl extends ServiceBaseImpl
this.recordsManagementAuditService = recordsManagementAuditService;
}
- public void setHoldType(HoldType holdType)
- {
- this.holdType = holdType;
- }
-
/**
* Initialise hold service
*/
@@ -602,15 +594,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
}
// Link the record to the hold
- holdType.disable();
- try
- {
- nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS);
- }
- finally
- {
- holdType.enable();
- }
+ nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS);
// audit item being added to the hold
recordsManagementAuditService.auditEvent(nodeRef, AUDIT_ADD_TO_HOLD);
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldType.java
deleted file mode 100644
index f36db06383..0000000000
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldType.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * #%L
- * Alfresco Records Management Module
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * -
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- * -
- * 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 .
- * #L%
- */
-
-package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
-
-import java.security.InvalidParameterException;
-
-import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
-import org.alfresco.repo.node.NodeServicePolicies;
-import org.alfresco.repo.policy.annotation.Behaviour;
-import org.alfresco.repo.policy.annotation.BehaviourBean;
-import org.alfresco.repo.policy.annotation.BehaviourKind;
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
-
-/**
- * rma:transferContainer behaviour bean
- *
- * @author Silviu Dinuta
- * @since 2.6
- */
-@BehaviourBean(defaultType = "rma:hold")
-public class HoldType extends BaseBehaviourBean implements NodeServicePolicies.OnCreateChildAssociationPolicy
-{
- private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForHoldType";
-
- /**
- * Disable the behaviours for this transaction
- *
- */
- public void disable()
- {
- getBehaviour(BEHAVIOUR_NAME).disable();
- }
-
- /**
- * Enable behaviours for this transaction
- *
- */
- public void enable()
- {
- getBehaviour(BEHAVIOUR_NAME).enable();
- }
-
- @Override
- @Behaviour
- (
- kind = BehaviourKind.ASSOCIATION,
- name = BEHAVIOUR_NAME
- )
- public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
- {
- throw new InvalidParameterException("Operation failed. Creation is not allowed in Hold Folders");
- }
-
-}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java
index 0a6c839818..9368c467d6 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java
@@ -28,10 +28,14 @@
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import java.io.Serializable;
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
+import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
@@ -55,6 +59,8 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
import org.alfresco.util.PropertyMap;
+import com.google.common.collect.Sets;
+
/**
* Behaviour associated with the RM Site type
*
@@ -68,10 +74,11 @@ import org.alfresco.util.PropertyMap;
public class RmSiteType extends BaseBehaviourBean
implements NodeServicePolicies.OnCreateNodePolicy,
NodeServicePolicies.OnUpdatePropertiesPolicy,
- NodeServicePolicies.BeforeDeleteNodePolicy
+ NodeServicePolicies.BeforeDeleteNodePolicy,
+ NodeServicePolicies.OnCreateChildAssociationPolicy
{
- /** Constant values */
- public static final String COMPONENT_DOCUMENT_LIBRARY = "documentLibrary";
+ /** Constant values */
+ public static final String COMPONENT_DOCUMENT_LIBRARY = "documentLibrary";
public static final String DEFAULT_SITE_NAME = "rm";
public static final QName DEFAULT_FILE_PLAN_TYPE = TYPE_FILE_PLAN;
@@ -96,8 +103,8 @@ public class RmSiteType extends BaseBehaviourBean
*/
public void setSiteService(SiteService siteService)
{
- this.siteService = siteService;
- }
+ this.siteService = siteService;
+ }
/**
* @param recordsManagementSearchService records management search service
@@ -132,39 +139,39 @@ public class RmSiteType extends BaseBehaviourBean
*/
public void registerFilePlanType(QName siteType, QName filePlanType)
{
- ParameterCheck.mandatory("siteType", siteType);
- ParameterCheck.mandatory("filePlanType", filePlanType);
+ ParameterCheck.mandatory("siteType", siteType);
+ ParameterCheck.mandatory("filePlanType", filePlanType);
- // check that the registered site type is a subtype of rma:rmsite
- if (!dictionaryService.isSubClass(siteType, TYPE_RM_SITE))
- {
- throw new AlfrescoRuntimeException(
- "Can't register site type, because site type is not a sub type of rma:rmsite (siteType=" + siteType.toString() + ")");
- }
+ // check that the registered site type is a subtype of rma:rmsite
+ if (!dictionaryService.isSubClass(siteType, TYPE_RM_SITE))
+ {
+ throw new AlfrescoRuntimeException(
+ "Can't register site type, because site type is not a sub type of rma:rmsite (siteType=" + siteType.toString() + ")");
+ }
- // check that the registered file plan type is a sub type of rma:filePlan
- if (!dictionaryService.isSubClass(filePlanType, TYPE_FILE_PLAN))
- {
- throw new AlfrescoRuntimeException(
- "Can't register file plan type, because site type is not a sub type of rma:filePlan (filePlanType=" + filePlanType.toString() + ")");
- }
+ // check that the registered file plan type is a sub type of rma:filePlan
+ if (!dictionaryService.isSubClass(filePlanType, TYPE_FILE_PLAN))
+ {
+ throw new AlfrescoRuntimeException(
+ "Can't register file plan type, because site type is not a sub type of rma:filePlan (filePlanType=" + filePlanType.toString() + ")");
+ }
- // add site and file plan types to map
- mapFilePlanType.put(siteType, filePlanType);
+ // add site and file plan types to map
+ mapFilePlanType.put(siteType, filePlanType);
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
*/
- @Override
- @Behaviour
- (
- kind = BehaviourKind.CLASS,
- notificationFrequency = NotificationFrequency.FIRST_EVENT
- )
- public void onCreateNode(ChildAssociationRef childAssocRef)
- {
- final NodeRef rmSite = childAssocRef.getChildRef();
+ @Override
+ @Behaviour
+ (
+ kind = BehaviourKind.CLASS,
+ notificationFrequency = NotificationFrequency.FIRST_EVENT
+ )
+ public void onCreateNode(ChildAssociationRef childAssocRef)
+ {
+ final NodeRef rmSite = childAssocRef.getChildRef();
// Do not execute behaviour if this has been created in the archive store
if(rmSite.getStoreRef().equals(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE))
@@ -179,52 +186,52 @@ public class RmSiteType extends BaseBehaviourBean
{
public Object doWork()
{
- SiteInfo siteInfo = siteService.getSite(rmSite);
- if (siteInfo != null)
- {
- // Create the file plan component
- siteService.createContainer(siteInfo.getShortName(), COMPONENT_DOCUMENT_LIBRARY, getFilePlanType(siteInfo), null);
+ SiteInfo siteInfo = siteService.getSite(rmSite);
+ if (siteInfo != null)
+ {
+ // Create the file plan component
+ siteService.createContainer(siteInfo.getShortName(), COMPONENT_DOCUMENT_LIBRARY, getFilePlanType(siteInfo), null);
- // Add the reports
- recordsManagementSearchService.addReports(siteInfo.getShortName());
- }
+ // Add the reports
+ recordsManagementSearchService.addReports(siteInfo.getShortName());
+ }
return null;
}
}, AuthenticationUtil.getAdminUserName());
}
- }
+ }
- /**
- * Get the file plan type for the given site.
- *
- * @param siteInfo site info
- * @return QName file plan type to create as a container
- * @since 2.2
- */
- private QName getFilePlanType(SiteInfo siteInfo)
- {
- ParameterCheck.mandatory("siteInfo", siteInfo);
+ /**
+ * Get the file plan type for the given site.
+ *
+ * @param siteInfo site info
+ * @return QName file plan type to create as a container
+ * @since 2.2
+ */
+ private QName getFilePlanType(SiteInfo siteInfo)
+ {
+ ParameterCheck.mandatory("siteInfo", siteInfo);
- // set default file plan
- QName result = DEFAULT_FILE_PLAN_TYPE;
+ // set default file plan
+ QName result = DEFAULT_FILE_PLAN_TYPE;
- // check to see if there is an 'override' for the file plan type given the site type
- QName siteType = nodeService.getType(siteInfo.getNodeRef());
- if (mapFilePlanType.containsKey(siteType))
- {
- result = mapFilePlanType.get(siteType);
- }
+ // check to see if there is an 'override' for the file plan type given the site type
+ QName siteType = nodeService.getType(siteInfo.getNodeRef());
+ if (mapFilePlanType.containsKey(siteType))
+ {
+ result = mapFilePlanType.get(siteType);
+ }
- return result;
- }
+ return result;
+ }
- /**
- * Ensure that the visibility of a RM site can not be changed to anything but public.
- *
- * TODO support other site visibilities
- *
- * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
- */
+ /**
+ * Ensure that the visibility of a RM site can not be changed to anything but public.
+ *
+ * TODO support other site visibilities
+ *
+ * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
+ */
@Behaviour
(
kind = BehaviourKind.CLASS,
@@ -295,4 +302,44 @@ public class RmSiteType extends BaseBehaviourBean
}
}
}
+
+ /**
+ * @author Silviu Dinuta
+ * @since 2.6
+ */
+ @Override
+ @Behaviour(kind = BehaviourKind.ASSOCIATION)
+ public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, boolean isNewNode)
+ {
+ AuthenticationUtil.runAsSystem(new RunAsWork()
+ {
+ @Override
+ public Void doWork()
+ {
+ final NodeRef child = childAssocRef.getChildRef();
+ final NodeRef parent = childAssocRef.getParentRef();
+ List acceptedUniqueChildTypes = new ArrayList();
+ SiteInfo siteInfo = siteService.getSite(parent);
+ acceptedUniqueChildTypes.add(getFilePlanType(siteInfo));
+ List acceptedNonUniqueChildTypes = new ArrayList();
+ acceptedNonUniqueChildTypes.add(ContentModel.TYPE_FOLDER);
+ // check the created child is of an accepted type
+ validateNewChildAssociation(parent, child, acceptedUniqueChildTypes, acceptedNonUniqueChildTypes);
+ return null;
+ }
+ });
+ }
+
+ @Override
+ protected void validateNewChildAssociation(NodeRef parent, NodeRef child, List acceptedUniqueChildType,
+ List acceptedMultipleChildType) throws InvalidParameterException
+ {
+ super.validateNewChildAssociation(parent, child, acceptedUniqueChildType, acceptedMultipleChildType);
+
+ // check the user is not trying to create more than 2 folders that are created by default
+ if(nodeService.getChildAssocs(parent, Sets.newHashSet(ContentModel.TYPE_FOLDER)).size() > 2)
+ {
+ throw new InvalidParameterException("Operation failed. Children of type " + ContentModel.TYPE_FOLDER + " are not allowed");
+ }
+ }
}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMNodes.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMNodes.java
index c495eb0ebf..983f985e96 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMNodes.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMNodes.java
@@ -45,11 +45,4 @@ public interface RMNodes extends Nodes
public static String PARAM_INCLUDE_HAS_RETENTION_SCHEDULE = "hasRetentionSchedule";
public static String PARAM_INCLUDE_IS_CLOSED = "isClosed";
public static String PARAM_INCLUDE_IS_COMPLETED = "isCompleted";
-
- /**
- * Verifies if the post request is allowed for nodeId received as parameter.
- *
- * @param nodeId
- */
- void checkPostPermission(String nodeId);
}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java
index b2cb97d3a0..b127e2fbe1 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java
@@ -59,8 +59,6 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.site.SiteInfo;
-import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
@@ -86,7 +84,6 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
private Repository repositoryHelper;
private DictionaryService dictionaryService;
private DispositionService dispositionService;
- private SiteService siteService;
/**
* TODO to remove this after isSpecialNode is made protected in core implementation(REPO-1459)
@@ -98,7 +95,6 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
this.nodeService = serviceRegistry.getNodeService();
this.dictionaryService = serviceRegistry.getDictionaryService();
this.dispositionService = serviceRegistry.getDispositionService();
- this.siteService = serviceRegistry.getSiteService();
}
public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry serviceRegistry)
@@ -402,20 +398,4 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
}
super.deleteNode(nodeId, parameters);
}
-
- @Override
- public void checkPostPermission(String nodeId)
- {
- NodeRef parentNodeRef = validateOrLookupNode(nodeId, null);
-
- SiteInfo siteInfo = siteService.getSite(FilePlanService.DEFAULT_RM_SITE_ID);
- if(siteInfo !=null)
- {
- NodeRef rmNodeRef = siteInfo.getNodeRef();
- if(rmNodeRef.equals(parentNodeRef))
- {
- throw new PermissionDeniedException("POST request not allowed in RM site.");
- }
- }
- }
}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelation.java
index 2ff63ba601..9573442927 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelation.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelation.java
@@ -67,7 +67,6 @@ public class FileplanComponentChildrenRelation implements RelationshipResourceAc
@Override
public List create(String parentFolderNodeId, List nodeInfos, Parameters parameters)
{
- nodes.checkPostPermission(parentFolderNodeId);
List result = new ArrayList<>(nodeInfos.size());
for (Node nodeInfo : nodeInfos)
@@ -81,7 +80,6 @@ public class FileplanComponentChildrenRelation implements RelationshipResourceAc
@Override
public Node create(String parentFolderNodeId, FormData formData, Parameters parameters, WithResponse withResponse)
{
- nodes.checkPostPermission(parentFolderNodeId);
return nodes.upload(parentFolderNodeId, formData, parameters);
}
}
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java
index cc4bf8c36c..0a82499e08 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java
@@ -51,7 +51,6 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
-import org.alfresco.module.org_alfresco_module_rm.model.rma.type.HoldType;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldTypeUnitTest.java
deleted file mode 100644
index 339bb290d9..0000000000
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldTypeUnitTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * #%L
- * Alfresco Records Management Module
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * -
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- * -
- * 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 .
- * #L%
- */
-
-package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.security.InvalidParameterException;
-
-import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
-import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.namespace.QName;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-
-/**
- * Unit test for HoldType
- *
- * @author Silviu Dinuta
- * @since 2.6
- *
- */
-public class HoldTypeUnitTest extends BaseUnitTest
-{
- /** test object */
- private @InjectMocks HoldType holdType;
-
- /**
- * Given that we try to add to hold folder,
- * Then InvalidParameterException is thrown.
- */
- @Test(expected = InvalidParameterException.class)
- public void testAddToHoldFolderTest()
- {
- NodeRef holdFolder = generateNodeRef(TYPE_HOLD, true);
-
- QName type = AlfMock.generateQName();
- NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
-
- ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
- when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
- when(mockedChildAssoc.getParentRef()).thenReturn(holdFolder);
- holdType.onCreateChildAssociation(mockedChildAssoc, true);
- }
-}
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java
index 166af4c5bb..3ae63a99c2 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java
@@ -65,7 +65,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
-import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -725,45 +724,6 @@ public class RMNodesImplUnitTest extends BaseUnitTest
verify(mockedFileFolderService, never()).delete(nodeRef);
}
- @Test
- public void testCheckPostPermissionForRMSite() throws Exception
- {
- NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
- SiteInfo mockedSiteInfo = mock(SiteInfo.class);
- when(mockedSiteInfo.getNodeRef()).thenReturn(parentNodeRef);
- when(mockedSiteService.getSite(RM_SITE_ID)).thenReturn(mockedSiteInfo);
-
- try
- {
- rmNodesImpl.checkPostPermission(parentNodeRef.getId());
- fail("Expected ecxeption as post should not be permitted on the RM site");
- }
- catch(PermissionDeniedException ex)
- {
- assertEquals("POST request not allowed in RM site.", ex.getMsgId());
- }
- }
-
- @Test
- public void testCheckPostPermissionForNormalNodeRefWhenRMSiteExists() throws Exception
- {
- NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
- NodeRef rmSiteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
- SiteInfo mockedSiteInfo = mock(SiteInfo.class);
- when(mockedSiteInfo.getNodeRef()).thenReturn(rmSiteNodeRef);
- when(mockedSiteService.getSite(RM_SITE_ID)).thenReturn(mockedSiteInfo);
- rmNodesImpl.checkPostPermission(parentNodeRef.getId());
- }
-
- @Test
- public void testCheckPostPermission() throws Exception
- {
- NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
- QName type = AlfMock.generateQName();
- when(mockedNodeService.getType(parentNodeRef)).thenReturn(type);
- rmNodesImpl.checkPostPermission(parentNodeRef.getId());
- }
-
private void setupCompanyHomeAndPrimaryParent(NodeRef nodeRef)
{
NodeRef companyHomeNodeRef = AlfMock.generateNodeRef(mockedNodeService);
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelationUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelationUnitTest.java
index f16cc01103..7e9c9d75e2 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelationUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelationUnitTest.java
@@ -28,10 +28,7 @@
package org.alfresco.rm.rest.api.nodes;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -41,7 +38,6 @@ import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.rest.api.model.Node;
-import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rest.framework.webscripts.WithResponse;
import org.alfresco.rm.rest.api.impl.RMNodesImpl;
@@ -50,7 +46,6 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.extensions.webscripts.servlet.FormData;
@@ -99,29 +94,6 @@ public class FileplanComponentChildrenRelationUnitTest extends BaseUnitTest
verify(mockedRMNodes, times(1)).createNode(parentNodeRef.getId(), nodeInfos.get(0), mockedParameters);
}
- @Test
- public void testCreateOnRMSite() throws Exception
- {
- Parameters mockedParameters = mock(Parameters.class);
- NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
-
- List nodeInfos = new ArrayList();
- Node mokedNodeInfo = mock(Node.class);
- nodeInfos.add(mokedNodeInfo);
-
- Mockito.doThrow(new PermissionDeniedException("POST request not allowed in RM site.")).when(mockedRMNodes).checkPostPermission(parentNodeRef.getId());
- try
- {
- filePlanComponentChildrenRelation.create(parentNodeRef.getId(), nodeInfos, mockedParameters);
- fail("Expected ecxeption as POST request is not allowed in RM site.");
- }
- catch(PermissionDeniedException ex)
- {
- assertEquals("POST request not allowed in RM site.", ex.getMsgId());
- }
- verify(mockedRMNodes, never()).createNode(parentNodeRef.getId(), nodeInfos.get(0), mockedParameters);
- }
-
@Test
public void testUpload() throws Exception
{
@@ -132,25 +104,4 @@ public class FileplanComponentChildrenRelationUnitTest extends BaseUnitTest
filePlanComponentChildrenRelation.create(parentNodeRef.getId(), mockedFormData, mockedParameters, mockedWithResponse);
verify(mockedRMNodes, times(1)).upload(parentNodeRef.getId(), mockedFormData, mockedParameters);
}
-
- @Test
- public void testUploadOnRMSite() throws Exception
- {
- Parameters mockedParameters = mock(Parameters.class);
- NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
- FormData mockedFormData = mock(FormData.class);
- WithResponse mockedWithResponse = mock(WithResponse.class);
-
- Mockito.doThrow(new PermissionDeniedException("POST request not allowed in RM site.")).when(mockedRMNodes).checkPostPermission(parentNodeRef.getId());
- try
- {
- filePlanComponentChildrenRelation.create(parentNodeRef.getId(), mockedFormData, mockedParameters, mockedWithResponse);
- fail("Expected ecxeption as POST request is not allowed in RM site.");
- }
- catch(PermissionDeniedException ex)
- {
- assertEquals("POST request not allowed in RM site.", ex.getMsgId());
- }
- verify(mockedRMNodes, never()).upload(parentNodeRef.getId(), mockedFormData, mockedParameters);
- }
}