mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-736 (DOD Recert: Bugs on the "List of Values" page)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@50975 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,29 +28,30 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class ScriptConstraint implements Serializable
|
public class ScriptConstraint implements Serializable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private RMConstraintInfo info;
|
private RMConstraintInfo info;
|
||||||
|
|
||||||
private RMCaveatConfigService rmCaveatconfigService;
|
private RMCaveatConfigService rmCaveatconfigService;
|
||||||
|
|
||||||
private AuthorityService authorityService;
|
private AuthorityService authorityService;
|
||||||
|
|
||||||
ScriptConstraint(RMConstraintInfo info, RMCaveatConfigService rmCaveatconfigService, AuthorityService authorityService)
|
ScriptConstraint(RMConstraintInfo info, RMCaveatConfigService rmCaveatconfigService, AuthorityService authorityService)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.rmCaveatconfigService = rmCaveatconfigService;
|
this.rmCaveatconfigService = rmCaveatconfigService;
|
||||||
this.authorityService = authorityService;
|
this.authorityService = authorityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title)
|
public void setTitle(String title)
|
||||||
{
|
{
|
||||||
info.setTitle(title);
|
info.setTitle(title);
|
||||||
@@ -63,49 +64,49 @@ public class ScriptConstraint implements Serializable
|
|||||||
{
|
{
|
||||||
info.setName(name);
|
info.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
String xxx = info.getName().replace(":", "_");
|
String xxx = info.getName().replace(":", "_");
|
||||||
return xxx;
|
return xxx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCaseSensitive()
|
public boolean isCaseSensitive()
|
||||||
{
|
{
|
||||||
return info.isCaseSensitive();
|
return info.isCaseSensitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getAllowedValues()
|
public String[] getAllowedValues()
|
||||||
{
|
{
|
||||||
return info.getAllowedValues();
|
return info.getAllowedValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptConstraintAuthority[] getAuthorities()
|
public ScriptConstraintAuthority[] getAuthorities()
|
||||||
{
|
{
|
||||||
Map<String, List<String>> values = rmCaveatconfigService.getListDetails(info.getName());
|
Map<String, List<String>> values = rmCaveatconfigService.getListDetails(info.getName());
|
||||||
|
|
||||||
if (values == null)
|
if (values == null)
|
||||||
{
|
{
|
||||||
return new ScriptConstraintAuthority[0];
|
return new ScriptConstraintAuthority[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here with some data to return
|
// Here with some data to return
|
||||||
Set<String> authorities = values.keySet();
|
Set<String> authorities = values.keySet();
|
||||||
|
|
||||||
ArrayList<ScriptConstraintAuthority> constraints = new ArrayList<ScriptConstraintAuthority>(values.size());
|
ArrayList<ScriptConstraintAuthority> constraints = new ArrayList<ScriptConstraintAuthority>(values.size());
|
||||||
for(String authority : authorities)
|
for(String authority : authorities)
|
||||||
{
|
{
|
||||||
ScriptConstraintAuthority constraint = new ScriptConstraintAuthority();
|
ScriptConstraintAuthority constraint = new ScriptConstraintAuthority();
|
||||||
constraint.setAuthorityName(authority);
|
constraint.setAuthorityName(authority);
|
||||||
constraint.setValues(values.get(authority));
|
constraint.setValues(values.get(authority));
|
||||||
constraints.add(constraint);
|
constraints.add(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptConstraintAuthority[] retVal = constraints.toArray(new ScriptConstraintAuthority[constraints.size()]);
|
ScriptConstraintAuthority[] retVal = constraints.toArray(new ScriptConstraintAuthority[constraints.size()]);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updateTitle
|
* updateTitle
|
||||||
*/
|
*/
|
||||||
@@ -114,7 +115,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
info.setTitle(newTitle);
|
info.setTitle(newTitle);
|
||||||
rmCaveatconfigService.updateRMConstraintTitle(info.getName(), newTitle) ;
|
rmCaveatconfigService.updateRMConstraintTitle(info.getName(), newTitle) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updateAllowedValues
|
* updateAllowedValues
|
||||||
*/
|
*/
|
||||||
@@ -123,7 +124,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
info.setAllowedValues(allowedValues);
|
info.setAllowedValues(allowedValues);
|
||||||
rmCaveatconfigService.updateRMConstraintAllowedValues(info.getName(), allowedValues);
|
rmCaveatconfigService.updateRMConstraintAllowedValues(info.getName(), allowedValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a value
|
* Update a value
|
||||||
* @param values
|
* @param values
|
||||||
@@ -133,7 +134,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
{
|
{
|
||||||
for(int i = 0; i < bodge.length(); i++)
|
for(int i = 0; i < bodge.length(); i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
JSONObject obj = bodge.getJSONObject(i);
|
JSONObject obj = bodge.getJSONObject(i);
|
||||||
String value = obj.getString("value");
|
String value = obj.getString("value");
|
||||||
JSONArray authorities = obj.getJSONArray("authorities");
|
JSONArray authorities = obj.getJSONArray("authorities");
|
||||||
@@ -142,10 +143,10 @@ public class ScriptConstraint implements Serializable
|
|||||||
{
|
{
|
||||||
aList.add(authorities.getString(j));
|
aList.add(authorities.getString(j));
|
||||||
}
|
}
|
||||||
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, aList);
|
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, aList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a value
|
* Update a value
|
||||||
* @param values
|
* @param values
|
||||||
@@ -154,27 +155,27 @@ public class ScriptConstraint implements Serializable
|
|||||||
public void updateValues(String value, String[] authorities)
|
public void updateValues(String value, String[] authorities)
|
||||||
{
|
{
|
||||||
List<String> list = Arrays.asList(authorities);
|
List<String> list = Arrays.asList(authorities);
|
||||||
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, list);
|
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cascade delete an authority
|
* Cascade delete an authority
|
||||||
* @param authority
|
* @param authority
|
||||||
*/
|
*/
|
||||||
public void deleteAuthority(String authority)
|
public void deleteAuthority(String authority)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cascade delete a value
|
* Cascade delete a value
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
public void deleteValue(String value)
|
public void deleteValue(String value)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a single value
|
* Get a single value
|
||||||
@@ -184,7 +185,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
public ScriptConstraintValue getValue(String value)
|
public ScriptConstraintValue getValue(String value)
|
||||||
{
|
{
|
||||||
ScriptConstraintValue[] values = getValues();
|
ScriptConstraintValue[] values = getValues();
|
||||||
|
|
||||||
for(ScriptConstraintValue val : values)
|
for(ScriptConstraintValue val : values)
|
||||||
{
|
{
|
||||||
if(val.getValueName().equalsIgnoreCase(value))
|
if(val.getValueName().equalsIgnoreCase(value))
|
||||||
@@ -194,39 +195,39 @@ public class ScriptConstraint implements Serializable
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptConstraintValue[] getValues()
|
public ScriptConstraintValue[] getValues()
|
||||||
{
|
{
|
||||||
// authority, values
|
// authority, values
|
||||||
Map<String, List<String>> details = rmCaveatconfigService.getListDetails(info.getName());
|
Map<String, List<String>> details = rmCaveatconfigService.getListDetails(info.getName());
|
||||||
|
|
||||||
if (details == null)
|
if (details == null)
|
||||||
{
|
{
|
||||||
details = new HashMap<String, List<String>>();
|
details = new HashMap<String, List<String>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// values, authorities
|
// values, authorities
|
||||||
Map<String, List<String>> pivot = PivotUtil.getPivot(details);
|
Map<String, List<String>> pivot = PivotUtil.getPivot(details);
|
||||||
|
|
||||||
// Here with some data to return
|
// Here with some data to return
|
||||||
Set<String> values = pivot.keySet();
|
Set<String> values = pivot.keySet();
|
||||||
|
|
||||||
ArrayList<ScriptConstraintValue> constraints = new ArrayList<ScriptConstraintValue>(pivot.size());
|
ArrayList<ScriptConstraintValue> constraints = new ArrayList<ScriptConstraintValue>(pivot.size());
|
||||||
for(String value : values)
|
for(String value : values)
|
||||||
{
|
{
|
||||||
ScriptConstraintValue constraint = new ScriptConstraintValue();
|
ScriptConstraintValue constraint = new ScriptConstraintValue();
|
||||||
constraint.setValueName(value);
|
constraint.setValueName(value);
|
||||||
constraint.setValueTitle(value);
|
constraint.setValueTitle(value);
|
||||||
|
|
||||||
List<String>authorities = pivot.get(value);
|
List<String>authorities = pivot.get(value);
|
||||||
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
||||||
for(String authority : authorities)
|
for(String authority : authorities)
|
||||||
{
|
{
|
||||||
ScriptAuthority a = new ScriptAuthority();
|
ScriptAuthority a = new ScriptAuthority();
|
||||||
a.setAuthorityName(authority);
|
a.setAuthorityName(authority);
|
||||||
|
|
||||||
String displayName = authorityService.getAuthorityDisplayName(authority);
|
String displayName = authorityService.getAuthorityDisplayName(authority);
|
||||||
if(displayName != null)
|
if(StringUtils.isNotBlank(displayName))
|
||||||
{
|
{
|
||||||
a.setAuthorityTitle(displayName);
|
a.setAuthorityTitle(displayName);
|
||||||
}
|
}
|
||||||
@@ -236,10 +237,10 @@ public class ScriptConstraint implements Serializable
|
|||||||
}
|
}
|
||||||
sauth.add(a);
|
sauth.add(a);
|
||||||
}
|
}
|
||||||
constraint.setAuthorities(sauth);
|
constraint.setAuthorities(sauth);
|
||||||
constraints.add(constraint);
|
constraints.add(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Now go through and add any "empty" values
|
* Now go through and add any "empty" values
|
||||||
*/
|
*/
|
||||||
@@ -251,14 +252,14 @@ public class ScriptConstraint implements Serializable
|
|||||||
constraint.setValueName(value);
|
constraint.setValueName(value);
|
||||||
constraint.setValueTitle(value);
|
constraint.setValueTitle(value);
|
||||||
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
||||||
constraint.setAuthorities(sauth);
|
constraint.setAuthorities(sauth);
|
||||||
constraints.add(constraint);
|
constraints.add(constraint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScriptConstraintValue[] retVal = constraints.toArray(new ScriptConstraintValue[constraints.size()]);
|
ScriptConstraintValue[] retVal = constraints.toArray(new ScriptConstraintValue[constraints.size()]);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user