RM-2120: Add Java backed webscript to set the security clearance for a specified user

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@103827 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Webster
2015-05-07 14:01:56 +00:00
parent 98155a3147
commit 35afc42a8c
4 changed files with 96 additions and 0 deletions

View File

@@ -676,4 +676,11 @@
parent="rmBaseWebscript">
<property name="securityClearanceService" ref="SecurityClearanceService" />
</bean>
<!-- REST impl for PUT user security clearance -->
<bean id="webscript.org.alfresco.rma.classification.usersecurityclearance.put"
class="org.alfresco.module.org_alfresco_module_rm.script.classification.UserSecurityClearancePut"
parent="rmBaseWebscript">
<property name="securityClearanceService" ref="SecurityClearanceService"/>
</bean>
</beans>

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Users security clearance</shortname>
<description>REST API to set users security clearance</description>
<url>/api/classification/clearance?username={username}&amp;clearanceId={clearanceId}</url>
<format default="json">argument</format>
<authentication>admin</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,7 @@
<#import "usersecurityclearance.lib.ftl" as usersecurityclearance />
<#escape x as jsonUtils.encodeJSONString(x)>
{
"data": <@usersecurityclearance.usersecurityclearanceJSON item=item />
}
</#escape>

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2005-2015 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.classification;
import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearance;
import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService;
import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
import java.util.HashMap;
import java.util.Map;
/**
* Implementation for Java backed webscript to set users security clearance.
*
* @author David Webster
* @author Tom Page
* @since 3.0
*/
public class UserSecurityClearancePut extends AbstractRmWebScript
{
/** Constants */
private static final String USERNAME = "username";
private static final String CLEARANCE_ID = "clearanceId";
private static final String ITEM = "item";
/** Security clearance service */
private SecurityClearanceService securityClearanceService;
/**
* @param securityClearanceService the securityClearanceService to set
*/
public void setSecurityClearanceService(SecurityClearanceService securityClearanceService)
{
this.securityClearanceService = securityClearanceService;
}
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
* org.springframework.extensions.webscripts.Status,
* org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
String username = req.getParameter(USERNAME);
String clearanceId = req.getParameter(CLEARANCE_ID);
SecurityClearance securityClearance = securityClearanceService.setUserSecurityClearance(username, clearanceId);
Map<String, Object> model = new HashMap<>();
model.put(ITEM, securityClearance);
return model;
}
}