mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
RM-3134: Fix community build - delete files not deleted by previous revert
This commit is contained in:
@@ -1,71 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/* package scope */ final class PivotUtil
|
|
||||||
{
|
|
||||||
private PivotUtil()
|
|
||||||
{
|
|
||||||
// Will not be called
|
|
||||||
}
|
|
||||||
|
|
||||||
static Map<String, List<String>> getPivot(Map<String, List<String>> source)
|
|
||||||
{
|
|
||||||
|
|
||||||
Map<String, List<String>> pivot = new HashMap<String, List<String>>();
|
|
||||||
|
|
||||||
for (Map.Entry<String, List<String>> entry : source.entrySet())
|
|
||||||
{
|
|
||||||
List<String>values = entry.getValue();
|
|
||||||
for (String value : values)
|
|
||||||
{
|
|
||||||
String authority = entry.getKey();
|
|
||||||
if (pivot.containsKey(value))
|
|
||||||
{
|
|
||||||
// already exists
|
|
||||||
List<String> list = pivot.get(value);
|
|
||||||
list.add(authority );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// New value
|
|
||||||
List<String> list = new ArrayList<String>();
|
|
||||||
list.add(authority);
|
|
||||||
pivot.put(value, list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pivot;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,121 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
|
|
||||||
public interface RMCaveatConfigComponent
|
|
||||||
{
|
|
||||||
void init();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get allowed values for given caveat list (for current user)
|
|
||||||
*
|
|
||||||
* @param constraintName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<String> getRMAllowedValues(String constraintName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get custom caveat models
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<QName> getRMCaveatModels();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether access to 'record component' node is vetoed for current user due to caveat(s)
|
|
||||||
*
|
|
||||||
* @param nodeRef
|
|
||||||
* @return false, if caveat(s) veto access otherwise return true
|
|
||||||
*/
|
|
||||||
boolean hasAccess(NodeRef nodeRef);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get RM constraint list
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
*/
|
|
||||||
RMConstraintInfo getRMConstraint(String listName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add RM constraint
|
|
||||||
*/
|
|
||||||
void addRMConstraint(String listName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add RM constraint value for given authority
|
|
||||||
*/
|
|
||||||
void addRMConstraintListValue(String listName, String authorityName, String value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update RM constraint values for given authority
|
|
||||||
*/
|
|
||||||
void updateRMConstraintListAuthority(String listName, String authorityName, List<String>values);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update RM constraint authorities for given value
|
|
||||||
*/
|
|
||||||
void updateRMConstraintListValue(String listName, String valueName, List<String>authorities);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove RM constraint value (all authorities)
|
|
||||||
*/
|
|
||||||
void removeRMConstraintListValue(String listName, String valueName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove RM constraint authority (all values)
|
|
||||||
*/
|
|
||||||
void removeRMConstraintListAuthority(String listName, String authorityName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete RM Constraint
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
*/
|
|
||||||
void deleteRMConstraint(String listName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the details of a caveat list
|
|
||||||
* @param listName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Map<String, List<String>> getListDetails(String listName);
|
|
||||||
|
|
||||||
NodeRef updateOrCreateCaveatConfig(File jsonFile);
|
|
||||||
|
|
||||||
NodeRef updateOrCreateCaveatConfig(String jsonString);
|
|
||||||
|
|
||||||
NodeRef updateOrCreateCaveatConfig(InputStream is);
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,161 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
|
|
||||||
public interface RMCaveatConfigService
|
|
||||||
{
|
|
||||||
void init();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get allowed values for given caveat list (for current user)
|
|
||||||
* @param constraintName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<String> getRMAllowedValues(String constraintName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether access to 'record component' node is vetoed for current user due to caveat(s)
|
|
||||||
*
|
|
||||||
* @param nodeRef
|
|
||||||
* @return false, if caveat(s) veto access otherwise return true
|
|
||||||
*/
|
|
||||||
boolean hasAccess(NodeRef nodeRef);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get a single RM constraint
|
|
||||||
*/
|
|
||||||
RMConstraintInfo getRMConstraint(String listName);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the names of all the caveat lists
|
|
||||||
*/
|
|
||||||
Set<RMConstraintInfo> getAllRMConstraints();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the details of a caveat list
|
|
||||||
* @param listName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Map<String, List<String>> getListDetails(String listName);
|
|
||||||
|
|
||||||
NodeRef updateOrCreateCaveatConfig(File jsonFile);
|
|
||||||
|
|
||||||
NodeRef updateOrCreateCaveatConfig(String jsonString);
|
|
||||||
|
|
||||||
NodeRef updateOrCreateCaveatConfig(InputStream is);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add RM constraint list
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
* @param listTitle
|
|
||||||
*/
|
|
||||||
RMConstraintInfo addRMConstraint(String listName, String listTitle, String[] allowedValues);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update RM constraint list allowed values
|
|
||||||
* @param listName the name of the RMConstraintList - can not be changed
|
|
||||||
* @param allowedValues
|
|
||||||
*/
|
|
||||||
RMConstraintInfo updateRMConstraintAllowedValues(String listName, String[] allowedValues);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update RM constraint Title
|
|
||||||
* @param listName the name of the RMConstraintList - can not be changed
|
|
||||||
* @param allowedValues
|
|
||||||
*/
|
|
||||||
RMConstraintInfo updateRMConstraintTitle(String listName, String newTitle);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* delete RM Constraint
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
*/
|
|
||||||
void deleteRMConstraint(String listName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a single value to an authority in a list. The existing values of the list remain.
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
* @param authorityName
|
|
||||||
* @param values
|
|
||||||
* @throws AlfrescoRuntimeException if either the list or the authority do not already exist.
|
|
||||||
*/
|
|
||||||
void addRMConstraintListValue(String listName, String authorityName, String value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace the values for an authority in a list.
|
|
||||||
* The existing values are removed.
|
|
||||||
*
|
|
||||||
* If the authority does not already exist in the list, it will be added
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
* @param authorityName
|
|
||||||
* @param values
|
|
||||||
*/
|
|
||||||
void updateRMConstraintListAuthority(String listName, String authorityName, List<String>values);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove an authority from a list
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
* @param authorityName
|
|
||||||
* @param values
|
|
||||||
*/
|
|
||||||
void removeRMConstraintListAuthority(String listName, String authorityName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace the values for an authority in a list.
|
|
||||||
* The existing values are removed.
|
|
||||||
*
|
|
||||||
* If the authority does not already exist in the list, it will be added
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
* @param value
|
|
||||||
* @param authorities
|
|
||||||
*/
|
|
||||||
void updateRMConstraintListValue(String listName, String value, List<String>authorities);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove an authority from a list
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
* @param authorityName
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
void removeRMConstraintListValue(String listName, String valueName);
|
|
||||||
}
|
|
@@ -1,437 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.securitymarks.RMListOfValuesConstraint.MatchLogic;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
|
||||||
import org.alfresco.service.cmr.dictionary.Constraint;
|
|
||||||
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RM Caveat Config Service impl
|
|
||||||
*
|
|
||||||
* @author janv
|
|
||||||
*/
|
|
||||||
public class RMCaveatConfigServiceImpl implements RMCaveatConfigService
|
|
||||||
{
|
|
||||||
private static Log logger = LogFactory.getLog(RMCaveatConfigServiceImpl.class);
|
|
||||||
|
|
||||||
private NamespaceService namespaceService;
|
|
||||||
private DictionaryService dictionaryService;
|
|
||||||
|
|
||||||
private RMCaveatConfigComponent rmCaveatConfigComponent;
|
|
||||||
private RecordsManagementAdminService recordsManagementAdminService;
|
|
||||||
|
|
||||||
|
|
||||||
public void setNamespaceService(NamespaceService namespaceService)
|
|
||||||
{
|
|
||||||
this.namespaceService = namespaceService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
|
||||||
{
|
|
||||||
this.dictionaryService = dictionaryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCaveatConfigComponent(RMCaveatConfigComponent rmCaveatConfigComponent)
|
|
||||||
{
|
|
||||||
this.rmCaveatConfigComponent = rmCaveatConfigComponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService)
|
|
||||||
{
|
|
||||||
this.recordsManagementAdminService = recordsManagementAdminService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RecordsManagementAdminService getRecordsManagementAdminService()
|
|
||||||
{
|
|
||||||
return recordsManagementAdminService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
rmCaveatConfigComponent.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NodeRef updateOrCreateCaveatConfig(InputStream is)
|
|
||||||
{
|
|
||||||
return rmCaveatConfigComponent.updateOrCreateCaveatConfig(is);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NodeRef updateOrCreateCaveatConfig(File jsonFile)
|
|
||||||
{
|
|
||||||
return rmCaveatConfigComponent.updateOrCreateCaveatConfig(jsonFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NodeRef updateOrCreateCaveatConfig(String jsonString)
|
|
||||||
{
|
|
||||||
return rmCaveatConfigComponent.updateOrCreateCaveatConfig(jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get allowed values for given caveat (for current user)
|
|
||||||
public List<String> getRMAllowedValues(String constraintName)
|
|
||||||
{
|
|
||||||
return rmCaveatConfigComponent.getRMAllowedValues(constraintName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether access to 'record component' node is vetoed for current user due to caveat(s)
|
|
||||||
*
|
|
||||||
* @param nodeRef
|
|
||||||
* @return false, if caveat(s) veto access otherwise return true
|
|
||||||
*/
|
|
||||||
public boolean hasAccess(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
return rmCaveatConfigComponent.hasAccess(nodeRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add RM constraint list
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
*/
|
|
||||||
public RMConstraintInfo addRMConstraint(String listName, String title, String[] values)
|
|
||||||
{
|
|
||||||
return addRMConstraint(listName, title, values, MatchLogic.AND);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RMConstraintInfo addRMConstraint(String listName, String title, String[] values, MatchLogic matchLogic)
|
|
||||||
{
|
|
||||||
if (listName == null)
|
|
||||||
{
|
|
||||||
// Generate a list name
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(RecordsManagementCustomModel.RM_CUSTOM_PREFIX);
|
|
||||||
sb.append(QName.NAMESPACE_PREFIX);
|
|
||||||
sb.append(UUID.randomUUID().toString());
|
|
||||||
listName = sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String>allowedValues = new ArrayList<String>();
|
|
||||||
for(String value : values)
|
|
||||||
{
|
|
||||||
allowedValues.add(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
QName listQName = QName.createQName(listName, namespaceService);
|
|
||||||
|
|
||||||
// TEMP review - if it already exists then change it for now
|
|
||||||
try
|
|
||||||
{
|
|
||||||
recordsManagementAdminService.addCustomConstraintDefinition(listQName, title, true, allowedValues, matchLogic);
|
|
||||||
}
|
|
||||||
catch (AlfrescoRuntimeException e)
|
|
||||||
{
|
|
||||||
if (e.getMessage().contains("Constraint already exists"))
|
|
||||||
{
|
|
||||||
recordsManagementAdminService.changeCustomConstraintValues(listQName, allowedValues);
|
|
||||||
recordsManagementAdminService.changeCustomConstraintTitle(listQName, title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rmCaveatConfigComponent.addRMConstraint(listName);
|
|
||||||
|
|
||||||
RMConstraintInfo info = new RMConstraintInfo();
|
|
||||||
info.setName(listQName.toPrefixString());
|
|
||||||
info.setTitle(title);
|
|
||||||
info.setAllowedValues(values);
|
|
||||||
info.setCaseSensitive(true);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* delete RM Constraint List
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
*/
|
|
||||||
public void deleteRMConstraint(String listName)
|
|
||||||
{
|
|
||||||
rmCaveatConfigComponent.deleteRMConstraint(listName);
|
|
||||||
|
|
||||||
QName listQName = QName.createQName(listName, namespaceService);
|
|
||||||
|
|
||||||
recordsManagementAdminService.removeCustomConstraintDefinition(listQName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a single value to an authority in a list. The existing values of the list remain.
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
* @param authorityName
|
|
||||||
* @param values
|
|
||||||
* @throws AlfrescoRuntimeException if either the list or the authority do not already exist.
|
|
||||||
*/
|
|
||||||
public void addRMConstraintListValue(String listName, String authorityName, String value)
|
|
||||||
{
|
|
||||||
rmCaveatConfigComponent.addRMConstraintListValue(listName, authorityName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the details of the specified list
|
|
||||||
* @param listName
|
|
||||||
* @return the details of the specified list
|
|
||||||
*/
|
|
||||||
public Map<String, List<String>> getListDetails(String listName)
|
|
||||||
{
|
|
||||||
return rmCaveatConfigComponent.getListDetails(listName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace the values for an authority in a list.
|
|
||||||
* The existing values are removed.
|
|
||||||
*
|
|
||||||
* If the authority does not already exist in the list, it will be added
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
* @param authorityName
|
|
||||||
* @param values
|
|
||||||
*/
|
|
||||||
public void updateRMConstraintListAuthority(String listName, String authorityName, List<String>values)
|
|
||||||
{
|
|
||||||
rmCaveatConfigComponent.updateRMConstraintListAuthority(listName, authorityName, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace the authorities for a value in a list
|
|
||||||
*
|
|
||||||
* @param listName
|
|
||||||
* @param valueName
|
|
||||||
* @param authorities
|
|
||||||
*/
|
|
||||||
public void updateRMConstraintListValue(String listName, String valueName, List<String>authorities)
|
|
||||||
{
|
|
||||||
rmCaveatConfigComponent.updateRMConstraintListValue(listName, valueName, authorities);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove an authority from a list
|
|
||||||
*
|
|
||||||
* @param listName the name of the RMConstraintList
|
|
||||||
* @param authorityName
|
|
||||||
* @param values
|
|
||||||
*/
|
|
||||||
public void removeRMConstraintListAuthority(String listName, String authorityName)
|
|
||||||
{
|
|
||||||
rmCaveatConfigComponent.removeRMConstraintListAuthority(listName, authorityName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all Constraint Lists
|
|
||||||
*/
|
|
||||||
public Set<RMConstraintInfo> getAllRMConstraints()
|
|
||||||
{
|
|
||||||
Set<RMConstraintInfo> info = new HashSet<RMConstraintInfo>();
|
|
||||||
|
|
||||||
List<ConstraintDefinition> defs = new ArrayList<ConstraintDefinition>(10);
|
|
||||||
for (QName caveatModelQName : rmCaveatConfigComponent.getRMCaveatModels())
|
|
||||||
{
|
|
||||||
defs.addAll(recordsManagementAdminService.getCustomConstraintDefinitions(caveatModelQName));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(ConstraintDefinition dictionaryDef : defs)
|
|
||||||
{
|
|
||||||
Constraint con = dictionaryDef.getConstraint();
|
|
||||||
if (con instanceof RMListOfValuesConstraint)
|
|
||||||
{
|
|
||||||
final RMListOfValuesConstraint def = (RMListOfValuesConstraint)con;
|
|
||||||
RMConstraintInfo i = new RMConstraintInfo();
|
|
||||||
i.setName(def.getShortName());
|
|
||||||
i.setTitle(def.getTitle());
|
|
||||||
|
|
||||||
// note: assumes only one caveat/LOV against a given property
|
|
||||||
List<String> allowedValues = AuthenticationUtil.runAs(new RunAsWork<List<String>>()
|
|
||||||
{
|
|
||||||
public List<String> doWork()
|
|
||||||
{
|
|
||||||
return def.getAllowedValues();
|
|
||||||
}
|
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
|
||||||
|
|
||||||
i.setAllowedValues(allowedValues.toArray(new String[allowedValues.size()]));
|
|
||||||
i.setCaseSensitive(def.isCaseSensitive());
|
|
||||||
info.add(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an RMConstraintInfo
|
|
||||||
* @param listQName
|
|
||||||
* @return the constraint or null if it does not exist
|
|
||||||
*/
|
|
||||||
public RMConstraintInfo getRMConstraint(QName listQName)
|
|
||||||
{
|
|
||||||
ConstraintDefinition dictionaryDef = dictionaryService.getConstraint(listQName);
|
|
||||||
if(dictionaryDef != null)
|
|
||||||
{
|
|
||||||
Constraint con = dictionaryDef.getConstraint();
|
|
||||||
if (con instanceof RMListOfValuesConstraint)
|
|
||||||
{
|
|
||||||
final RMListOfValuesConstraint def = (RMListOfValuesConstraint)con;
|
|
||||||
|
|
||||||
RMConstraintInfo info = new RMConstraintInfo();
|
|
||||||
info.setName(listQName.toPrefixString());
|
|
||||||
info.setTitle(con.getTitle());
|
|
||||||
List<String> allowedValues = AuthenticationUtil.runAs(new RunAsWork<List<String>>()
|
|
||||||
{
|
|
||||||
public List<String> doWork()
|
|
||||||
{
|
|
||||||
return def.getAllowedValues();
|
|
||||||
}
|
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
|
||||||
|
|
||||||
info.setAllowedValues(allowedValues.toArray(new String[allowedValues.size()]));
|
|
||||||
info.setCaseSensitive(def.isCaseSensitive());
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get RM Constraint detail.
|
|
||||||
*
|
|
||||||
* @return the constraintInfo or null
|
|
||||||
*/
|
|
||||||
public RMConstraintInfo getRMConstraint(String listName)
|
|
||||||
{
|
|
||||||
QName listQName = QName.createQName(listName, namespaceService);
|
|
||||||
return getRMConstraint(listQName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update The allowed values for an RM Constraint.
|
|
||||||
*
|
|
||||||
* @param listName The name of the list.
|
|
||||||
* @param allowedValues the new alowed values
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public RMConstraintInfo updateRMConstraintAllowedValues(String listName, String[] allowedValues)
|
|
||||||
{
|
|
||||||
QName listQName = QName.createQName(listName, namespaceService);
|
|
||||||
|
|
||||||
if(allowedValues != null)
|
|
||||||
{
|
|
||||||
List<String>allowedValueList = new ArrayList<String>();
|
|
||||||
for(String value : allowedValues)
|
|
||||||
{
|
|
||||||
allowedValueList.add(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConstraintDefinition dictionaryDef = dictionaryService.getConstraint(listQName);
|
|
||||||
Constraint con = dictionaryDef.getConstraint();
|
|
||||||
if (con instanceof RMListOfValuesConstraint)
|
|
||||||
{
|
|
||||||
final RMListOfValuesConstraint def = (RMListOfValuesConstraint)con;
|
|
||||||
List<String> oldAllowedValues = AuthenticationUtil.runAs(new RunAsWork<List<String>>()
|
|
||||||
{
|
|
||||||
public List<String> doWork()
|
|
||||||
{
|
|
||||||
return def.getAllowedValues();
|
|
||||||
}
|
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deal with any additions
|
|
||||||
*/
|
|
||||||
for(String newValue : allowedValueList)
|
|
||||||
{
|
|
||||||
if(!oldAllowedValues.contains(newValue) && logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
// This is an addition
|
|
||||||
logger.debug("value added to list:" + listQName + ":" + newValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deal with any deletions
|
|
||||||
*/
|
|
||||||
for(String oldValue : oldAllowedValues)
|
|
||||||
{
|
|
||||||
if(!allowedValueList.contains(oldValue))
|
|
||||||
{
|
|
||||||
// This is a deletion
|
|
||||||
if(logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("value removed from list:" + listQName + ":" + oldValue);
|
|
||||||
}
|
|
||||||
removeRMConstraintListValue(listName, oldValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
recordsManagementAdminService.changeCustomConstraintValues(listQName, allowedValueList);
|
|
||||||
}
|
|
||||||
|
|
||||||
return getRMConstraint(listName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a value from a list and cascade delete.
|
|
||||||
*/
|
|
||||||
public void removeRMConstraintListValue(String listName, String valueName)
|
|
||||||
{
|
|
||||||
//TODO need to update the rm constraint definition
|
|
||||||
// recordsManagementAdminService.
|
|
||||||
|
|
||||||
rmCaveatConfigComponent.removeRMConstraintListValue(listName, valueName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the title of this RM Constraint.
|
|
||||||
*/
|
|
||||||
public RMConstraintInfo updateRMConstraintTitle(String listName, String newTitle)
|
|
||||||
{
|
|
||||||
QName listQName = QName.createQName(listName, namespaceService);
|
|
||||||
|
|
||||||
recordsManagementAdminService.changeCustomConstraintTitle(listQName, newTitle);
|
|
||||||
return getRMConstraint(listName);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,88 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class RMConstraintInfo
|
|
||||||
{
|
|
||||||
private String name;
|
|
||||||
private String title;
|
|
||||||
private boolean caseSensitive;
|
|
||||||
private String[] allowedValues;
|
|
||||||
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setTitle(String title)
|
|
||||||
{
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
public String getTitle()
|
|
||||||
{
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setCaseSensitive(boolean caseSensitive)
|
|
||||||
{
|
|
||||||
this.caseSensitive = caseSensitive;
|
|
||||||
}
|
|
||||||
public boolean isCaseSensitive()
|
|
||||||
{
|
|
||||||
return caseSensitive;
|
|
||||||
}
|
|
||||||
public void setAllowedValues(String[] values)
|
|
||||||
{
|
|
||||||
this.allowedValues = values.clone();
|
|
||||||
}
|
|
||||||
public String[] getAllowedValues()
|
|
||||||
{
|
|
||||||
return allowedValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("RMConstraintInfo [name=");
|
|
||||||
builder.append(this.name);
|
|
||||||
builder.append(", title=");
|
|
||||||
builder.append(this.title);
|
|
||||||
builder.append(", caseSensitive=");
|
|
||||||
builder.append(this.caseSensitive);
|
|
||||||
builder.append(", allowedValues=");
|
|
||||||
builder.append(Arrays.toString(this.allowedValues));
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,39 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class to hold I18N keys for messages related to constraint validation.
|
|
||||||
*
|
|
||||||
* @author tpage
|
|
||||||
*/
|
|
||||||
public class RMConstraintMessageKeys
|
|
||||||
{
|
|
||||||
public static final String ERR_NON_STRING = "d_dictionary.constraint.string_length.non_string";
|
|
||||||
public static final String ERR_INVALID_VALUE = "d_dictionary.constraint.list_of_values.invalid_value";
|
|
||||||
}
|
|
@@ -1,259 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.service.cmr.dictionary.ConstraintException;
|
|
||||||
import org.alfresco.service.cmr.i18n.MessageLookup;
|
|
||||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
|
||||||
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RM Constraint implementation that ensures the value is one of a constrained
|
|
||||||
* <i>list of values</i>. By default, this constraint is case-sensitive.
|
|
||||||
*
|
|
||||||
* @see #setAllowedValues(List)
|
|
||||||
* @see #setCaseSensitive(boolean)
|
|
||||||
*
|
|
||||||
* @author janv
|
|
||||||
*/
|
|
||||||
public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|
||||||
{
|
|
||||||
private static final String LOV_CONSTRAINT_VALUE = "listconstraint";
|
|
||||||
private List<String> allowedValues;
|
|
||||||
private List<String> allowedValuesUpper;
|
|
||||||
// defined match logic used by caveat matching (default = "AND")
|
|
||||||
private MatchLogic matchLogic = MatchLogic.AND;
|
|
||||||
|
|
||||||
public enum MatchLogic
|
|
||||||
{
|
|
||||||
// closed marking - all values must match
|
|
||||||
AND,
|
|
||||||
// open marking - at least one value must match
|
|
||||||
OR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// note: alternative to static init could be to use 'registered' constraint
|
|
||||||
private static RMCaveatConfigService caveatConfigService;
|
|
||||||
|
|
||||||
public void setCaveatConfigService(RMCaveatConfigService caveatConfigService)
|
|
||||||
{
|
|
||||||
RMListOfValuesConstraint.caveatConfigService = caveatConfigService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder(80);
|
|
||||||
sb.append("RMListOfValuesConstraint")
|
|
||||||
.append("[allowedValues=").append(getAllowedValues())
|
|
||||||
.append(", caseSensitive=").append(isCaseSensitive())
|
|
||||||
.append(", sorted=").append(isSorted())
|
|
||||||
.append(", matchLogic=").append(getMatchLogic())
|
|
||||||
.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public RMListOfValuesConstraint()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
|
|
||||||
// Set RM list of value constraints to be sorted by default
|
|
||||||
sorted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the allowed values. Note that these are <tt>String</tt> instances, but may
|
|
||||||
* represent non-<tt>String</tt> values. It is up to the caller to distinguish.
|
|
||||||
*
|
|
||||||
* @return Returns the values allowed
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<String> getRawAllowedValues()
|
|
||||||
{
|
|
||||||
String runAsUser = AuthenticationUtil.getRunAsUser();
|
|
||||||
if ((runAsUser != null) && (! runAsUser.equals(AuthenticationUtil.getSystemUserName())) && (caveatConfigService != null))
|
|
||||||
{
|
|
||||||
// get allowed values for current user
|
|
||||||
List<String> allowedForUser = caveatConfigService.getRMAllowedValues(getShortName());
|
|
||||||
|
|
||||||
List<String> filteredList = new ArrayList<String>(allowedForUser.size());
|
|
||||||
for (String allowed : allowedForUser)
|
|
||||||
{
|
|
||||||
if (this.allowedValues.contains(allowed))
|
|
||||||
{
|
|
||||||
filteredList.add(allowed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filteredList;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return this.allowedValues;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayLabel(String constraintAllowableValue, MessageLookup messageLookup)
|
|
||||||
{
|
|
||||||
if (!this.allowedValues.contains(constraintAllowableValue))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String key = LOV_CONSTRAINT_VALUE;
|
|
||||||
key += "." + this.getShortName();
|
|
||||||
key += "." + constraintAllowableValue;
|
|
||||||
key = StringUtils.replace(key, ":", "_");
|
|
||||||
|
|
||||||
String message = messageLookup.getMessage(key, I18NUtil.getLocale());
|
|
||||||
return message == null ? constraintAllowableValue : message;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> getAllowedValuesUpper()
|
|
||||||
{
|
|
||||||
String runAsUser = AuthenticationUtil.getRunAsUser();
|
|
||||||
if ((runAsUser != null) && (! runAsUser.equals(AuthenticationUtil.getSystemUserName())) && (caveatConfigService != null))
|
|
||||||
{
|
|
||||||
// get allowed values for current user
|
|
||||||
List<String> allowedForUser = caveatConfigService.getRMAllowedValues(getType());
|
|
||||||
|
|
||||||
List<String> filteredList = new ArrayList<String>(allowedForUser.size());
|
|
||||||
for (String allowed : allowedForUser)
|
|
||||||
{
|
|
||||||
if (this.allowedValuesUpper.contains(allowed.toUpperCase()))
|
|
||||||
{
|
|
||||||
filteredList.add(allowed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filteredList;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return this.allowedValuesUpper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the values that are allowed by the constraint.
|
|
||||||
*
|
|
||||||
* @param values a list of allowed values
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
||||||
@Override
|
|
||||||
public void setAllowedValues(List allowedValues)
|
|
||||||
{
|
|
||||||
if (allowedValues == null)
|
|
||||||
{
|
|
||||||
allowedValues = new ArrayList<String>(0);
|
|
||||||
}
|
|
||||||
int valueCount = allowedValues.size();
|
|
||||||
this.allowedValues = Collections.unmodifiableList(allowedValues);
|
|
||||||
|
|
||||||
// make the upper case versions
|
|
||||||
this.allowedValuesUpper = new ArrayList<String>(valueCount);
|
|
||||||
for (String allowedValue : this.allowedValues)
|
|
||||||
{
|
|
||||||
allowedValuesUpper.add(allowedValue.toUpperCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize()
|
|
||||||
{
|
|
||||||
checkPropertyNotNull("allowedValues", allowedValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> getParameters()
|
|
||||||
{
|
|
||||||
Map<String, Object> params = new HashMap<String, Object>(2);
|
|
||||||
|
|
||||||
params.put("caseSensitive", isCaseSensitive());
|
|
||||||
params.put("allowedValues", getAllowedValues());
|
|
||||||
params.put("sorted", isSorted());
|
|
||||||
params.put("matchLogic", getMatchLogic());
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MatchLogic getMatchLogicEnum()
|
|
||||||
{
|
|
||||||
return matchLogic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMatchLogic()
|
|
||||||
{
|
|
||||||
return matchLogic.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMatchLogic(String matchLogicStr)
|
|
||||||
{
|
|
||||||
this.matchLogic = MatchLogic.valueOf(matchLogicStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void evaluateSingleValue(Object value)
|
|
||||||
{
|
|
||||||
// convert the value to a String
|
|
||||||
String valueStr = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
valueStr = DefaultTypeConverter.INSTANCE.convert(String.class, value);
|
|
||||||
}
|
|
||||||
catch (TypeConversionException e)
|
|
||||||
{
|
|
||||||
throw new ConstraintException(RMConstraintMessageKeys.ERR_NON_STRING, value, e);
|
|
||||||
}
|
|
||||||
// check that the value is in the set of allowed values
|
|
||||||
if (isCaseSensitive())
|
|
||||||
{
|
|
||||||
if (!getAllowedValues().contains(valueStr))
|
|
||||||
{
|
|
||||||
throw new ConstraintException(RMConstraintMessageKeys.ERR_INVALID_VALUE, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!getAllowedValuesUpper().contains(valueStr.toUpperCase()))
|
|
||||||
{
|
|
||||||
throw new ConstraintException(RMConstraintMessageKeys.ERR_INVALID_VALUE, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,60 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
|
|
||||||
public class ScriptAuthority implements Serializable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private String authorityTitle;
|
|
||||||
private String authorityName;
|
|
||||||
|
|
||||||
public void setAuthorityName(String authorityName)
|
|
||||||
{
|
|
||||||
this.authorityName = authorityName;
|
|
||||||
}
|
|
||||||
public String getAuthorityName()
|
|
||||||
{
|
|
||||||
return authorityName;
|
|
||||||
}
|
|
||||||
public void setAuthorityTitle(String authorityName)
|
|
||||||
{
|
|
||||||
this.authorityTitle = authorityName;
|
|
||||||
}
|
|
||||||
public String getAuthorityTitle()
|
|
||||||
{
|
|
||||||
return authorityTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@@ -1,270 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
public class ScriptConstraint implements Serializable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private RMConstraintInfo info;
|
|
||||||
|
|
||||||
private RMCaveatConfigService rmCaveatconfigService;
|
|
||||||
|
|
||||||
private AuthorityService authorityService;
|
|
||||||
|
|
||||||
ScriptConstraint(RMConstraintInfo info, RMCaveatConfigService rmCaveatconfigService, AuthorityService authorityService)
|
|
||||||
{
|
|
||||||
this.info = info;
|
|
||||||
this.rmCaveatconfigService = rmCaveatconfigService;
|
|
||||||
this.authorityService = authorityService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title)
|
|
||||||
{
|
|
||||||
info.setTitle(title);
|
|
||||||
}
|
|
||||||
public String getTitle()
|
|
||||||
{
|
|
||||||
return info.getTitle();
|
|
||||||
}
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
info.setName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return info.getName().replace(":", "_");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCaseSensitive()
|
|
||||||
{
|
|
||||||
return info.isCaseSensitive();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getAllowedValues()
|
|
||||||
{
|
|
||||||
return info.getAllowedValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptConstraintAuthority[] getAuthorities()
|
|
||||||
{
|
|
||||||
Map<String, List<String>> values = rmCaveatconfigService.getListDetails(info.getName());
|
|
||||||
|
|
||||||
if (values == null)
|
|
||||||
{
|
|
||||||
return new ScriptConstraintAuthority[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Here with some data to return
|
|
||||||
Set<String> authorities = values.keySet();
|
|
||||||
|
|
||||||
ArrayList<ScriptConstraintAuthority> constraints = new ArrayList<ScriptConstraintAuthority>(values.size());
|
|
||||||
for(String authority : authorities)
|
|
||||||
{
|
|
||||||
ScriptConstraintAuthority constraint = new ScriptConstraintAuthority();
|
|
||||||
constraint.setAuthorityName(authority);
|
|
||||||
constraint.setValues(values.get(authority));
|
|
||||||
constraints.add(constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptConstraintAuthority[] retVal = constraints.toArray(new ScriptConstraintAuthority[constraints.size()]);
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updateTitle
|
|
||||||
*/
|
|
||||||
public void updateTitle(String newTitle)
|
|
||||||
{
|
|
||||||
info.setTitle(newTitle);
|
|
||||||
rmCaveatconfigService.updateRMConstraintTitle(info.getName(), newTitle) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updateAllowedValues
|
|
||||||
*/
|
|
||||||
public void updateAllowedValues(String[] allowedValues)
|
|
||||||
{
|
|
||||||
info.setAllowedValues(allowedValues);
|
|
||||||
rmCaveatconfigService.updateRMConstraintAllowedValues(info.getName(), allowedValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a value
|
|
||||||
* @param values
|
|
||||||
* @param authorities
|
|
||||||
*/
|
|
||||||
public void updateValues(JSONArray bodge) throws Exception
|
|
||||||
{
|
|
||||||
for(int i = 0; i < bodge.length(); i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
JSONObject obj = bodge.getJSONObject(i);
|
|
||||||
String value = obj.getString("value");
|
|
||||||
JSONArray authorities = obj.getJSONArray("authorities");
|
|
||||||
List<String> aList = new ArrayList<String>();
|
|
||||||
for(int j = 0; j < authorities.length();j++)
|
|
||||||
{
|
|
||||||
aList.add(authorities.getString(j));
|
|
||||||
}
|
|
||||||
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, aList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a value
|
|
||||||
* @param values
|
|
||||||
* @param authorities
|
|
||||||
*/
|
|
||||||
public void updateValues(String value, String[] authorities)
|
|
||||||
{
|
|
||||||
List<String> list = Arrays.asList(authorities);
|
|
||||||
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cascade delete an authority
|
|
||||||
* @param authority
|
|
||||||
*/
|
|
||||||
public void deleteAuthority(String authority)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cascade delete a value
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
public void deleteValue(String value)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a single value
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ScriptConstraintValue getValue(String value)
|
|
||||||
{
|
|
||||||
ScriptConstraintValue[] values = getValues();
|
|
||||||
|
|
||||||
for(ScriptConstraintValue val : values)
|
|
||||||
{
|
|
||||||
if(val.getValueName().equalsIgnoreCase(value))
|
|
||||||
{
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptConstraintValue[] getValues()
|
|
||||||
{
|
|
||||||
// authority, values
|
|
||||||
Map<String, List<String>> details = rmCaveatconfigService.getListDetails(info.getName());
|
|
||||||
|
|
||||||
if (details == null)
|
|
||||||
{
|
|
||||||
details = new HashMap<String, List<String>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// values, authorities
|
|
||||||
Map<String, List<String>> pivot = PivotUtil.getPivot(details);
|
|
||||||
|
|
||||||
// Here with some data to return
|
|
||||||
Set<String> values = pivot.keySet();
|
|
||||||
|
|
||||||
ArrayList<ScriptConstraintValue> constraints = new ArrayList<ScriptConstraintValue>(pivot.size());
|
|
||||||
for(String value : values)
|
|
||||||
{
|
|
||||||
ScriptConstraintValue constraint = new ScriptConstraintValue();
|
|
||||||
constraint.setValueName(value);
|
|
||||||
constraint.setValueTitle(value);
|
|
||||||
|
|
||||||
List<String>authorities = pivot.get(value);
|
|
||||||
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
|
||||||
for(String authority : authorities)
|
|
||||||
{
|
|
||||||
ScriptAuthority a = new ScriptAuthority();
|
|
||||||
a.setAuthorityName(authority);
|
|
||||||
|
|
||||||
String displayName = authorityService.getAuthorityDisplayName(authority);
|
|
||||||
if(StringUtils.isNotBlank(displayName))
|
|
||||||
{
|
|
||||||
a.setAuthorityTitle(displayName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
a.setAuthorityTitle(authority);
|
|
||||||
}
|
|
||||||
sauth.add(a);
|
|
||||||
}
|
|
||||||
constraint.setAuthorities(sauth);
|
|
||||||
constraints.add(constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Now go through and add any "empty" values
|
|
||||||
*/
|
|
||||||
for(String value : info.getAllowedValues())
|
|
||||||
{
|
|
||||||
if(!values.contains(value))
|
|
||||||
{
|
|
||||||
ScriptConstraintValue constraint = new ScriptConstraintValue();
|
|
||||||
constraint.setValueName(value);
|
|
||||||
constraint.setValueTitle(value);
|
|
||||||
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
|
||||||
constraint.setAuthorities(sauth);
|
|
||||||
constraints.add(constraint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return constraints.toArray(new ScriptConstraintValue[constraints.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,58 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ScriptConstraintAuthority implements Serializable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -4659454215122271811L;
|
|
||||||
private String authorityName;
|
|
||||||
private List<String>values;
|
|
||||||
|
|
||||||
public void setValues(List<String> values)
|
|
||||||
{
|
|
||||||
this.values = values;
|
|
||||||
}
|
|
||||||
public List<String> getValues()
|
|
||||||
{
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
public void setAuthorityName(String authorityName)
|
|
||||||
{
|
|
||||||
this.authorityName = authorityName;
|
|
||||||
}
|
|
||||||
public String getAuthorityName()
|
|
||||||
{
|
|
||||||
return authorityName;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,66 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ScriptConstraintValue implements Serializable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -4659454215122271811L;
|
|
||||||
private String value;
|
|
||||||
private List<ScriptAuthority>authorities;
|
|
||||||
|
|
||||||
public void setAuthorities(List<ScriptAuthority> values)
|
|
||||||
{
|
|
||||||
this.authorities = values;
|
|
||||||
}
|
|
||||||
public List<ScriptAuthority> getAuthorities()
|
|
||||||
{
|
|
||||||
return authorities;
|
|
||||||
}
|
|
||||||
public void setValueName(String authorityName)
|
|
||||||
{
|
|
||||||
this.value = authorityName;
|
|
||||||
}
|
|
||||||
public String getValueName()
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
public void setValueTitle(String authorityName)
|
|
||||||
{
|
|
||||||
this.value = authorityName;
|
|
||||||
}
|
|
||||||
public String getValueTitle()
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,174 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.securitymarks;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
|
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Script projection of RM Caveat Config Service
|
|
||||||
*
|
|
||||||
* @author Mark Rogers
|
|
||||||
*/
|
|
||||||
public class ScriptRMCaveatConfigService extends BaseScopableProcessorExtension
|
|
||||||
{
|
|
||||||
private RMCaveatConfigService caveatConfigService;
|
|
||||||
private AuthorityService authorityService;
|
|
||||||
|
|
||||||
public void setCaveatConfigService(RMCaveatConfigService rmCaveatConfigService)
|
|
||||||
{
|
|
||||||
this.caveatConfigService = rmCaveatConfigService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RMCaveatConfigService getRmCaveatConfigService()
|
|
||||||
{
|
|
||||||
return caveatConfigService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthorityService(AuthorityService authorityService)
|
|
||||||
{
|
|
||||||
this.authorityService = authorityService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthorityService getAuthorityService()
|
|
||||||
{
|
|
||||||
return authorityService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptConstraint getConstraint(String listName)
|
|
||||||
{
|
|
||||||
//TODO Temporary conversion
|
|
||||||
String xxx = listName.replace("_", ":");
|
|
||||||
|
|
||||||
RMConstraintInfo info = caveatConfigService.getRMConstraint(xxx);
|
|
||||||
|
|
||||||
if(info != null)
|
|
||||||
{
|
|
||||||
return new ScriptConstraint(info, caveatConfigService, getAuthorityService());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptConstraint[] getAllConstraints()
|
|
||||||
{
|
|
||||||
return getConstraints(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptConstraint[] getConstraintsWithoutEmptyList()
|
|
||||||
{
|
|
||||||
return getConstraints(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ScriptConstraint[] getConstraints(boolean includeEmptyList)
|
|
||||||
{
|
|
||||||
Set<RMConstraintInfo> values = caveatConfigService.getAllRMConstraints();
|
|
||||||
|
|
||||||
List<ScriptConstraint> vals = new ArrayList<ScriptConstraint>(values.size());
|
|
||||||
for(RMConstraintInfo value : values)
|
|
||||||
{
|
|
||||||
ScriptConstraint c = new ScriptConstraint(value, caveatConfigService, getAuthorityService());
|
|
||||||
if (includeEmptyList)
|
|
||||||
{
|
|
||||||
vals.add(c);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (c.getValues().length > 0)
|
|
||||||
{
|
|
||||||
vals.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vals.toArray(new ScriptConstraint[vals.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete list
|
|
||||||
* @param listName
|
|
||||||
|
|
||||||
*/
|
|
||||||
public void deleteConstraintList(String listName)
|
|
||||||
{
|
|
||||||
//TODO Temporary conversion
|
|
||||||
String xxx = listName.replace("_", ":");
|
|
||||||
caveatConfigService.deleteRMConstraint(xxx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update value
|
|
||||||
*/
|
|
||||||
public void updateConstraintValues(String listName, String authorityName, String[]values)
|
|
||||||
{
|
|
||||||
List<String> vals = new ArrayList<String>();
|
|
||||||
caveatConfigService.updateRMConstraintListAuthority(listName, authorityName, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the constraint values. i.e remove an authority from a constraint list
|
|
||||||
*/
|
|
||||||
public void deleteRMConstraintListAuthority(String listName, String authorityName)
|
|
||||||
{
|
|
||||||
//TODO Temporary conversion
|
|
||||||
String xxx = listName.replace("_", ":");
|
|
||||||
|
|
||||||
caveatConfigService.removeRMConstraintListAuthority(xxx, authorityName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the constraint values. i.e remove a value from a constraint list
|
|
||||||
*/
|
|
||||||
public void deleteRMConstraintListValue(String listName, String valueName)
|
|
||||||
{
|
|
||||||
//TODO Temporary conversion
|
|
||||||
String xxx = listName.replace("_", ":");
|
|
||||||
|
|
||||||
caveatConfigService.removeRMConstraintListValue(xxx, valueName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptConstraint createConstraint(String listName, String title, String[] allowedValues)
|
|
||||||
{
|
|
||||||
//TODO Temporary conversion
|
|
||||||
if(listName != null)
|
|
||||||
{
|
|
||||||
listName = listName.replace("_", ":");
|
|
||||||
}
|
|
||||||
|
|
||||||
RMConstraintInfo info = caveatConfigService.addRMConstraint(listName, title, allowedValues);
|
|
||||||
return new ScriptConstraint(info, caveatConfigService, getAuthorityService());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user