Merge branch 'feature-2.3/RM-5878_SavedSearchMNT' into 'release/V2.3'

Feature 2.3/rm 5878 saved search mnt

See merge request !705
This commit is contained in:
Ross Gale
2017-12-04 12:11:41 +00:00
12 changed files with 220 additions and 31 deletions

View File

@@ -74,6 +74,11 @@
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -150,7 +150,6 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.htmlelements</groupId>

View File

@@ -699,6 +699,10 @@
</mandatory-aspects>
</aspect>
<aspect name="rma:savedSearch">
<title>Saved search</title>
</aspect>
<aspect name="rma:vitalRecordDefinition">
<title>Vital Record Definition</title>
<properties>

View File

@@ -9,7 +9,7 @@
<property name="description" value="RM patch executer"/>
<property name="sinceVersion" value="2.2"/>
<property name="executeOnceOnly" value="false"/>
<property name="moduleSchema" value="1012"/>
<property name="moduleSchema" value="1013"/>
<property name="attributeService" ref="AttributeService" />
<property name="dependsOn">
<list>

View File

@@ -34,4 +34,14 @@
<property name="authorityService" ref="authorityService"/>
</bean>
<bean id="rm.savedSearchPatch"
parent="rm.parentModulePatch"
class="org.alfresco.module.org_alfresco_module_rm.patch.v23.RMv23SavedSearchesPatch">
<property name="description" value="Add aspect to saved searches."/>
<property name="fixesToSchema" value="1012"/>
<property name="targetSchema" value="1013"/>
<property name="recordsManagementSearchService" ref="RecordsManagementSearchService"/>
<property name="nodeService" ref="NodeService"/>
</bean>
</beans>

View File

@@ -327,6 +327,7 @@
]]>
</value>
</property>
<property name="nodeService" ref="NodeService"/>
</bean>
<bean id="RecordsManagementSearchService" class="org.springframework.aop.framework.ProxyFactoryBean">

View File

@@ -79,16 +79,6 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
<suiteXmlFiles>
<suiteXmlFile>${project.build.testOutputDirectory}/testng.xml</suiteXmlFile>
</suiteXmlFiles>
@@ -253,6 +243,12 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<!-- Database drivers -->
<dependency>
<groupId>postgresql</groupId>
@@ -267,12 +263,6 @@
<scope>test</scope>
</dependency>
<!-- Dependencies for the test result reports -->
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>

View File

@@ -16,6 +16,7 @@
* 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.model;
import org.alfresco.service.namespace.QName;
@@ -149,7 +150,9 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
QName PROP_DISPOSITION_ACTION_ID = QName.createQName(RM_URI, "dispositionActionId");
QName PROP_DISPOSITION_ACTION = QName.createQName(RM_URI, "dispositionAction");
QName PROP_DISPOSITION_AS_OF = QName.createQName(RM_URI, "dispositionAsOf");
/** A flag indicating that the "disposition as of" date has been manually set and shouldn't be changed. */
/**
* A flag indicating that the "disposition as of" date has been manually set and shouldn't be changed.
*/
QName PROP_MANUALLY_SET_AS_OF = QName.createQName(RM_URI, "manuallySetAsOf");
QName PROP_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "dispositionEventsEligible");
QName PROP_DISPOSITION_ACTION_STARTED_AT = QName.createQName(RM_URI, "dispositionActionStartedAt");
@@ -229,13 +232,16 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
QName PROP_RS_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "recordSearchDispositionEventsEligible");
QName PROP_RS_DISPOSITION_EVENTS = QName.createQName(RM_URI, "recordSearchDispositionEvents");
QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriod");
QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriodExpression");
QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION = QName.createQName(RM_URI,
"recordSearchVitalRecordReviewPeriodExpression");
QName PROP_RS_DISPOSITION_PERIOD = QName.createQName(RM_URI, "recordSearchDispositionPeriod");
QName PROP_RS_DISPOSITION_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchDispositionPeriodExpression");
QName PROP_RS_HAS_DISPOITION_SCHEDULE = QName.createQName(RM_URI, "recordSearchHasDispositionSchedule");
QName PROP_RS_DISPOITION_INSTRUCTIONS = QName.createQName(RM_URI, "recordSearchDispositionInstructions");
QName PROP_RS_DISPOITION_AUTHORITY = QName.createQName(RM_URI, "recordSearchDispositionAuthority");
/** @depreacted as of 2.2, because disposable items can now be in multiple holds */
/**
* @depreacted as of 2.2, because disposable items can now be in multiple holds
*/
@Deprecated
QName PROP_RS_HOLD_REASON = QName.createQName(RM_URI, "recordSearchHoldReason");
@@ -245,9 +251,12 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
// Extended security aspect
// @deprecated as of 2.5, because of performance issues
@Deprecated QName ASPECT_EXTENDED_SECURITY = QName.createQName(RM_URI, "extendedSecurity");
@Deprecated QName PROP_READERS = QName.createQName(RM_URI, "readers");
@Deprecated QName PROP_WRITERS = QName.createQName(RM_URI, "writers");
@Deprecated
QName ASPECT_EXTENDED_SECURITY = QName.createQName(RM_URI, "extendedSecurity");
@Deprecated
QName PROP_READERS = QName.createQName(RM_URI, "readers");
@Deprecated
QName PROP_WRITERS = QName.createQName(RM_URI, "writers");
// Originating details of a record
QName ASPECT_RECORD_ORIGINATING_DETAILS = QName.createQName(RM_URI, "recordOriginatingDetails");
@@ -269,4 +278,6 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
// Countable aspect
QName ASPECT_COUNTABLE = QName.createQName(RM_URI, "countable");
QName PROP_COUNT = QName.createQName(RM_URI, "count");
QName ASPECT_SAVED_SEARCH = QName.createQName(RM_URI, "savedSearch");
}

View File

@@ -32,6 +32,8 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteService;
import org.springframework.beans.factory.BeanNameAware;
import static org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType.DEFAULT_SITE_NAME;
/**
* RM v2.0 Saved Search Patch
*
@@ -42,9 +44,6 @@ import org.springframework.beans.factory.BeanNameAware;
public class RMv2SavedSearchPatch extends ModulePatchComponent
implements BeanNameAware, RecordsManagementModel, DOD5015Model
{
/** RM site id */
private static final String RM_SITE_ID = "rm";
/** Records management search service */
private RecordsManagementSearchService recordsManagementSearchService;
@@ -84,10 +83,10 @@ public class RMv2SavedSearchPatch extends ModulePatchComponent
@Override
protected void executePatch()
{
if (siteService.getSite(RM_SITE_ID) != null)
if (siteService.getSite(DEFAULT_SITE_NAME) != null)
{
// get the saved searches
List<SavedSearchDetails> savedSearches = recordsManagementSearchService.getSavedSearches(RM_SITE_ID);
List<SavedSearchDetails> savedSearches = recordsManagementSearchService.getSavedSearches(DEFAULT_SITE_NAME);
if (LOGGER.isDebugEnabled())
{

View File

@@ -0,0 +1,71 @@
/*
* 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.patch.v23;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_SAVED_SEARCH;
import static org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType.DEFAULT_SITE_NAME;
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails;
import org.alfresco.service.cmr.repository.NodeService;
/**
* RM v2.3 patch that adds the saved search aspect.
*
* @author Ross Gale
* @since 2.3
*/
public class RMv23SavedSearchesPatch extends AbstractModulePatch
{
/** records management search service */
private RecordsManagementSearchService recordsManagementSearchService;
/** node service */
private NodeService nodeService;
/**
* @param recordsManagementSearchService records management search service
*/
public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService)
{
this.recordsManagementSearchService = recordsManagementSearchService;
}
/**
* @param nodeService node service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* Retrieves all saved searches for the records management site and adds ASPECT_SAVED_SEARCH
*/
@Override
public void applyInternal()
{
for(SavedSearchDetails savedSearchDetails : recordsManagementSearchService.getSavedSearches(DEFAULT_SITE_NAME))
{
nodeService.addAspect(savedSearchDetails.getNodeRef(), ASPECT_SAVED_SEARCH,null);
}
}
}

View File

@@ -18,6 +18,8 @@
*/
package org.alfresco.module.org_alfresco_module_rm.search;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_SAVED_SEARCH;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
@@ -34,6 +36,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters;
@@ -49,6 +52,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Records management search service implementation
*
@@ -73,6 +77,9 @@ public class RecordsManagementSearchServiceImpl implements RecordsManagementSear
/** Namespace service */
private NamespaceService namespaceService;
/** Node service */
private NodeService nodeService;
/** List of report details */
private List<ReportDetails> reports = new ArrayList<ReportDetails>(13);
@@ -108,7 +115,15 @@ public class RecordsManagementSearchServiceImpl implements RecordsManagementSear
this.namespaceService = namespaceService;
}
/**
/**
* @param nodeService Node service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param reportsJSON
*/
public void setReportsJSON(String reportsJSON)
@@ -520,7 +535,7 @@ public class RecordsManagementSearchServiceImpl implements RecordsManagementSear
}
}, AuthenticationUtil.getSystemUserName());
}
nodeService.addAspect(searchNode, ASPECT_SAVED_SEARCH, null);
// Write the JSON content to search node
final NodeRef writableSearchNode = searchNode;
AuthenticationUtil.runAs(new RunAsWork<Void>()

View File

@@ -0,0 +1,84 @@
/*
* 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.patch.v23;
import static java.util.Arrays.asList;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_SAVED_SEARCH;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchServiceImpl;
import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
/**
* patch.v23 unit test
*
* @author Ross Gale
* @since 2.3
*/
public class RMv23SavedSearchesPatchUnitTest
{
@Mock
private NodeService nodeService;
@Mock
private RecordsManagementSearchServiceImpl recordsManagementSearchService;
@Mock
private SavedSearchDetails mockSavedSearchDetails1, mockSavedSearchDetails2;
@InjectMocks
private RMv23SavedSearchesPatch patch;
/**
* Given that I am upgrading an existing repository to v2.3
* When I execute the patch
* Then any existing rm saved searches will have the saved search aspect applied
*/
@Test
public void executePatch()
{
MockitoAnnotations.initMocks(this);
NodeRef noderef1 = new NodeRef("foo://123/456");
NodeRef noderef2 = new NodeRef("bar://123/456");
List<SavedSearchDetails> searches = asList(mockSavedSearchDetails1, mockSavedSearchDetails2);
when(mockSavedSearchDetails1.getNodeRef()).thenReturn(noderef1);
when(mockSavedSearchDetails2.getNodeRef()).thenReturn(noderef2);
when(recordsManagementSearchService.getSavedSearches("rm")).thenReturn(searches);
// execute patch
patch.applyInternal();
verify(nodeService, times(1)).addAspect(noderef1, ASPECT_SAVED_SEARCH, null);
verify(nodeService, times(1)).addAspect(noderef2, ASPECT_SAVED_SEARCH, null);
}
}