RM-5878 mnt changes added to a 2.4 branch

This commit is contained in:
Ross Gale
2017-12-05 16:21:07 +00:00
parent 928235c72e
commit c8932192f9
8 changed files with 216 additions and 8 deletions

View File

@@ -696,6 +696,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

@@ -34,4 +34,15 @@
<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

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

View File

@@ -277,4 +277,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

@@ -27,6 +27,8 @@
package org.alfresco.module.org_alfresco_module_rm.patch.v20;
import static org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType.DEFAULT_SITE_NAME;
import java.util.List;
import org.alfresco.model.ContentModel;
@@ -51,9 +53,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;
@@ -93,10 +92,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,84 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2017 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 <http://www.gnu.org/licenses/>.
* #L%
*/
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

@@ -43,6 +43,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;
@@ -58,6 +59,8 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.extensions.surf.util.I18NUtil;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_SAVED_SEARCH;
/**
* Records management search service implementation
*
@@ -82,7 +85,12 @@ public class RecordsManagementSearchServiceImpl implements RecordsManagementSear
/** Namespace service */
private NamespaceService namespaceService;
/** List of report details */
/**
* Node service
*/
private NodeService nodeService;
/** List of report details */
private List<ReportDetails> reports = new ArrayList<ReportDetails>(13);
/**
@@ -117,7 +125,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)
@@ -526,7 +542,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,91 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2017 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 <http://www.gnu.org/licenses/>.
* #L%
*/
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.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);
}
}