RM-2053 Added classification capability restriction to classify action. Code review changes.

This commit is contained in:
Roxana Lucanu-Ghetu
2018-03-27 01:25:49 +03:00
parent ce623e7f9f
commit a431b6bfcf
2 changed files with 66 additions and 42 deletions

View File

@@ -45,6 +45,7 @@ import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
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.util.FileUtils;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authority.RMAuthority;
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
@@ -273,7 +274,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
{
throw new AlfrescoRuntimeException("Could not load default bootstrap roles configuration");
}
array = new JSONArray(convertStreamToString(is));
array = new JSONArray(FileUtils.convertStreamToString(is));
}
catch (IOException ioe)
{
@@ -370,47 +371,6 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
}, AuthenticationUtil.getSystemUserName());
}
/**
* Helper method to convert a stream to a string.
*
* @param is input stream
* @return {@link String} string
* @throws IOException
*/
public String convertStreamToString(InputStream is) throws IOException
{
/*
* To convert the InputStream to String we use the BufferedReader.readLine()
* method. We iterate until the BufferedReader return null which means
* there's no more data to read. Each line will appended to a StringBuilder
* and returned as String.
*/
BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
StringBuilder sb = new StringBuilder();
String line = null;
try
{
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
}
finally
{
try
{
is.close();
}
catch (IOException e)
{
LOGGER.debug("Ignoring failed attempt to close stream.", e);
}
}
return sb.toString();
}
/**
* Helper method to check whether the current authority is a system role or not
*

View File

@@ -0,0 +1,64 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2018 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.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
/**
* Utility class for working with files.
*
* @author Roxana Lucanu
* @since 2.7
*/
public class FileUtils
{
/**
* Helper method to convert a stream to a string.
*
* @param is input stream
* @return {@link String} string
* @throws IOException
*/
public static String convertStreamToString(InputStream is) throws IOException
{
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))))
{
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
return sb.toString();
}
}
}