mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Fixed major issues reported by sonar (Preserve Stack Trace)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63502 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -36,10 +36,10 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
|||||||
/**
|
/**
|
||||||
* RM Constraint implementation that ensures the value is one of a constrained
|
* RM Constraint implementation that ensures the value is one of a constrained
|
||||||
* <i>list of values</i>. By default, this constraint is case-sensitive.
|
* <i>list of values</i>. By default, this constraint is case-sensitive.
|
||||||
*
|
*
|
||||||
* @see #setAllowedValues(List)
|
* @see #setAllowedValues(List)
|
||||||
* @see #setCaseSensitive(boolean)
|
* @see #setCaseSensitive(boolean)
|
||||||
*
|
*
|
||||||
* @author janv
|
* @author janv
|
||||||
*/
|
*/
|
||||||
public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||||
@@ -50,23 +50,23 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
private static final String LOV_CONSTRAINT_VALUE = "listconstraint";
|
private static final String LOV_CONSTRAINT_VALUE = "listconstraint";
|
||||||
private List<String> allowedValues;
|
private List<String> allowedValues;
|
||||||
private List<String> allowedValuesUpper;
|
private List<String> allowedValuesUpper;
|
||||||
private MatchLogic matchLogic = MatchLogic.AND; // defined match logic used by caveat matching (default = "AND")
|
private MatchLogic matchLogic = MatchLogic.AND; // defined match logic used by caveat matching (default = "AND")
|
||||||
|
|
||||||
public enum MatchLogic
|
public enum MatchLogic
|
||||||
{
|
{
|
||||||
AND, // closed marking - all values must match
|
AND, // closed marking - all values must match
|
||||||
OR; // open marking - at least one value must match
|
OR; // open marking - at least one value must match
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: alternative to static init could be to use 'registered' constraint
|
// note: alternative to static init could be to use 'registered' constraint
|
||||||
private static RMCaveatConfigService caveatConfigService;
|
private static RMCaveatConfigService caveatConfigService;
|
||||||
|
|
||||||
public void setCaveatConfigService(RMCaveatConfigService caveatConfigService)
|
public void setCaveatConfigService(RMCaveatConfigService caveatConfigService)
|
||||||
{
|
{
|
||||||
RMListOfValuesConstraint.caveatConfigService = caveatConfigService;
|
RMListOfValuesConstraint.caveatConfigService = caveatConfigService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
@@ -79,19 +79,19 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
.append("]");
|
.append("]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RMListOfValuesConstraint()
|
public RMListOfValuesConstraint()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// Set RM list of value constraints to be sorted by default
|
// Set RM list of value constraints to be sorted by default
|
||||||
sorted = true;
|
sorted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the allowed values. Note that these are <tt>String</tt> instances, but may
|
* 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.
|
* represent non-<tt>String</tt> values. It is up to the caller to distinguish.
|
||||||
*
|
*
|
||||||
* @return Returns the values allowed
|
* @return Returns the values allowed
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -101,7 +101,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
if ((runAsUser != null) && (! runAsUser.equals(AuthenticationUtil.getSystemUserName())) && (caveatConfigService != null))
|
if ((runAsUser != null) && (! runAsUser.equals(AuthenticationUtil.getSystemUserName())) && (caveatConfigService != null))
|
||||||
{
|
{
|
||||||
List<String> allowedForUser = caveatConfigService.getRMAllowedValues(getShortName()); // get allowed values for current user
|
List<String> allowedForUser = caveatConfigService.getRMAllowedValues(getShortName()); // get allowed values for current user
|
||||||
|
|
||||||
List<String> filteredList = new ArrayList<String>(allowedForUser.size());
|
List<String> filteredList = new ArrayList<String>(allowedForUser.size());
|
||||||
for (String allowed : allowedForUser)
|
for (String allowed : allowedForUser)
|
||||||
{
|
{
|
||||||
@@ -110,7 +110,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
filteredList.add(allowed);
|
filteredList.add(allowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filteredList;
|
return filteredList;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -118,7 +118,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
return this.allowedValues;
|
return this.allowedValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayLabel(String constraintAllowableValue, MessageLookup messageLookup)
|
public String getDisplayLabel(String constraintAllowableValue, MessageLookup messageLookup)
|
||||||
{
|
{
|
||||||
if (!this.allowedValues.contains(constraintAllowableValue))
|
if (!this.allowedValues.contains(constraintAllowableValue))
|
||||||
@@ -134,14 +134,14 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
String message = messageLookup.getMessage(key, I18NUtil.getLocale());
|
String message = messageLookup.getMessage(key, I18NUtil.getLocale());
|
||||||
return message == null ? constraintAllowableValue : message;
|
return message == null ? constraintAllowableValue : message;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getAllowedValuesUpper()
|
private List<String> getAllowedValuesUpper()
|
||||||
{
|
{
|
||||||
String runAsUser = AuthenticationUtil.getRunAsUser();
|
String runAsUser = AuthenticationUtil.getRunAsUser();
|
||||||
if ((runAsUser != null) && (! runAsUser.equals(AuthenticationUtil.getSystemUserName())) && (caveatConfigService != null))
|
if ((runAsUser != null) && (! runAsUser.equals(AuthenticationUtil.getSystemUserName())) && (caveatConfigService != null))
|
||||||
{
|
{
|
||||||
List<String> allowedForUser = caveatConfigService.getRMAllowedValues(getType()); // get allowed values for current user
|
List<String> allowedForUser = caveatConfigService.getRMAllowedValues(getType()); // get allowed values for current user
|
||||||
|
|
||||||
List<String> filteredList = new ArrayList<String>(allowedForUser.size());
|
List<String> filteredList = new ArrayList<String>(allowedForUser.size());
|
||||||
for (String allowed : allowedForUser)
|
for (String allowed : allowedForUser)
|
||||||
{
|
{
|
||||||
@@ -150,7 +150,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
filteredList.add(allowed);
|
filteredList.add(allowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filteredList;
|
return filteredList;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -160,7 +160,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set the values that are allowed by the constraint.
|
* Set the values that are allowed by the constraint.
|
||||||
*
|
*
|
||||||
* @param values a list of allowed values
|
* @param values a list of allowed values
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@@ -173,7 +173,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
}
|
}
|
||||||
int valueCount = allowedValues.size();
|
int valueCount = allowedValues.size();
|
||||||
this.allowedValues = Collections.unmodifiableList(allowedValues);
|
this.allowedValues = Collections.unmodifiableList(allowedValues);
|
||||||
|
|
||||||
// make the upper case versions
|
// make the upper case versions
|
||||||
this.allowedValuesUpper = new ArrayList<String>(valueCount);
|
this.allowedValuesUpper = new ArrayList<String>(valueCount);
|
||||||
for (String allowedValue : this.allowedValues)
|
for (String allowedValue : this.allowedValues)
|
||||||
@@ -181,41 +181,41 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
allowedValuesUpper.add(allowedValue.toUpperCase());
|
allowedValuesUpper.add(allowedValue.toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
checkPropertyNotNull("allowedValues", allowedValues);
|
checkPropertyNotNull("allowedValues", allowedValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getParameters()
|
public Map<String, Object> getParameters()
|
||||||
{
|
{
|
||||||
Map<String, Object> params = new HashMap<String, Object>(2);
|
Map<String, Object> params = new HashMap<String, Object>(2);
|
||||||
|
|
||||||
params.put("caseSensitive", isCaseSensitive());
|
params.put("caseSensitive", isCaseSensitive());
|
||||||
params.put("allowedValues", getAllowedValues());
|
params.put("allowedValues", getAllowedValues());
|
||||||
params.put("sorted", isSorted());
|
params.put("sorted", isSorted());
|
||||||
params.put("matchLogic", getMatchLogic());
|
params.put("matchLogic", getMatchLogic());
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MatchLogic getMatchLogicEnum()
|
public MatchLogic getMatchLogicEnum()
|
||||||
{
|
{
|
||||||
return matchLogic;
|
return matchLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMatchLogic()
|
public String getMatchLogic()
|
||||||
{
|
{
|
||||||
return matchLogic.toString();
|
return matchLogic.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMatchLogic(String matchLogicStr)
|
public void setMatchLogic(String matchLogicStr)
|
||||||
{
|
{
|
||||||
this.matchLogic = MatchLogic.valueOf(matchLogicStr);
|
this.matchLogic = MatchLogic.valueOf(matchLogicStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void evaluateSingleValue(Object value)
|
protected void evaluateSingleValue(Object value)
|
||||||
{
|
{
|
||||||
@@ -227,7 +227,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
|||||||
}
|
}
|
||||||
catch (TypeConversionException e)
|
catch (TypeConversionException e)
|
||||||
{
|
{
|
||||||
throw new ConstraintException(ERR_NON_STRING, value);
|
throw new ConstraintException(ERR_NON_STRING, value, e);
|
||||||
}
|
}
|
||||||
// check that the value is in the set of allowed values
|
// check that the value is in the set of allowed values
|
||||||
if (isCaseSensitive())
|
if (isCaseSensitive())
|
||||||
|
@@ -197,7 +197,7 @@ public class BootstrapTestDataGet extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException error)
|
catch (UnsupportedEncodingException error)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("The Character Encoding '" + charsetName + "' is not supported.");
|
throw new AlfrescoRuntimeException("The Character Encoding '" + charsetName + "' is not supported.", error);
|
||||||
}
|
}
|
||||||
Location location = new Location(filePlan);
|
Location location = new Location(filePlan);
|
||||||
importerService.importView(viewReader, location, null, null);
|
importerService.importView(viewReader, location, null, null);
|
||||||
|
@@ -83,7 +83,7 @@ public class EmailMapPost extends DeclarativeWebScript
|
|||||||
catch (AlfrescoRuntimeException are)
|
catch (AlfrescoRuntimeException are)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,
|
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,
|
||||||
are.getMessage());
|
are.getMessage(), are);
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
|
@@ -45,7 +45,7 @@ import org.json.JSONTokener;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides the implementation for the rmaction webscript.
|
* This class provides the implementation for the rmaction webscript.
|
||||||
*
|
*
|
||||||
* @author Neil McErlean
|
* @author Neil McErlean
|
||||||
*/
|
*/
|
||||||
public class RmActionPost extends DeclarativeWebScript
|
public class RmActionPost extends DeclarativeWebScript
|
||||||
@@ -78,7 +78,7 @@ public class RmActionPost extends DeclarativeWebScript
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
reqContentAsString = req.getContent().getContent();
|
reqContentAsString = req.getContent().getContent();
|
||||||
}
|
}
|
||||||
catch (IOException iox)
|
catch (IOException iox)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
||||||
@@ -136,7 +136,7 @@ public class RmActionPost extends DeclarativeWebScript
|
|||||||
String dateStringValue = ((JSONObject)nextValue).getString("iso8601");
|
String dateStringValue = ((JSONObject)nextValue).getString("iso8601");
|
||||||
nextValue = ISO8601DateFormat.parse(dateStringValue);
|
nextValue = ISO8601DateFormat.parse(dateStringValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actionParams.put(nextKeyString, (Serializable)nextValue);
|
actionParams.put(nextKeyString, (Serializable)nextValue);
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ public class RmActionPost extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
catch (JSONException exception)
|
catch (JSONException exception)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unable to parse request JSON.");
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unable to parse request JSON.", exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate input: check for mandatory params.
|
// validate input: check for mandatory params.
|
||||||
|
@@ -43,7 +43,7 @@ public class RmEventPut extends RMEventBase
|
|||||||
{
|
{
|
||||||
/** Parameter names */
|
/** Parameter names */
|
||||||
public static final String PARAM_EVENTNAME = "eventname";
|
public static final String PARAM_EVENTNAME = "eventname";
|
||||||
|
|
||||||
/** Records management event service */
|
/** Records management event service */
|
||||||
private RecordsManagementEventService rmEventService;
|
private RecordsManagementEventService rmEventService;
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@ public class RmEventPut extends RMEventBase
|
|||||||
// Check the event name
|
// Check the event name
|
||||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||||
String eventName = templateVars.get(PARAM_EVENTNAME);
|
String eventName = templateVars.get(PARAM_EVENTNAME);
|
||||||
if (eventName == null ||
|
if (eventName == null ||
|
||||||
eventName.isEmpty() ||
|
eventName.isEmpty() ||
|
||||||
rmEventService.existsEvent(eventName) == false)
|
rmEventService.existsEvent(eventName) == false)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided.");
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided.");
|
||||||
@@ -140,7 +140,7 @@ public class RmEventPut extends RMEventBase
|
|||||||
}
|
}
|
||||||
catch (AlfrescoRuntimeException are)
|
catch (AlfrescoRuntimeException are)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, are.getLocalizedMessage());
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST, are.getLocalizedMessage(), are);
|
||||||
}
|
}
|
||||||
|
|
||||||
return canEditEvent;
|
return canEditEvent;
|
||||||
|
Reference in New Issue
Block a user