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
|
||||
* <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
|
||||
@@ -50,23 +50,23 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
private static final String LOV_CONSTRAINT_VALUE = "listconstraint";
|
||||
private List<String> allowedValues;
|
||||
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
|
||||
{
|
||||
AND, // closed marking - all values must match
|
||||
OR; // open marking - at least one value must match
|
||||
}
|
||||
|
||||
|
||||
// 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()
|
||||
{
|
||||
@@ -79,19 +79,19 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public RMListOfValuesConstraint()
|
||||
|
||||
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
|
||||
* 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
|
||||
@@ -101,7 +101,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
if ((runAsUser != null) && (! runAsUser.equals(AuthenticationUtil.getSystemUserName())) && (caveatConfigService != null))
|
||||
{
|
||||
List<String> allowedForUser = caveatConfigService.getRMAllowedValues(getShortName()); // get allowed values for current user
|
||||
|
||||
|
||||
List<String> filteredList = new ArrayList<String>(allowedForUser.size());
|
||||
for (String allowed : allowedForUser)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
filteredList.add(allowed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return filteredList;
|
||||
}
|
||||
else
|
||||
@@ -118,7 +118,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
return this.allowedValues;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getDisplayLabel(String constraintAllowableValue, MessageLookup messageLookup)
|
||||
{
|
||||
if (!this.allowedValues.contains(constraintAllowableValue))
|
||||
@@ -134,14 +134,14 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
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))
|
||||
{
|
||||
List<String> allowedForUser = caveatConfigService.getRMAllowedValues(getType()); // get allowed values for current user
|
||||
|
||||
|
||||
List<String> filteredList = new ArrayList<String>(allowedForUser.size());
|
||||
for (String allowed : allowedForUser)
|
||||
{
|
||||
@@ -150,7 +150,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
filteredList.add(allowed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return filteredList;
|
||||
}
|
||||
else
|
||||
@@ -160,7 +160,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
}
|
||||
/**
|
||||
* Set the values that are allowed by the constraint.
|
||||
*
|
||||
*
|
||||
* @param values a list of allowed values
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@@ -173,7 +173,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
}
|
||||
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)
|
||||
@@ -181,41 +181,41 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
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)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ public class RMListOfValuesConstraint extends ListOfValuesConstraint
|
||||
}
|
||||
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
|
||||
if (isCaseSensitive())
|
||||
|
@@ -197,7 +197,7 @@ public class BootstrapTestDataGet extends DeclarativeWebScript
|
||||
}
|
||||
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);
|
||||
importerService.importView(viewReader, location, null, null);
|
||||
|
@@ -83,7 +83,7 @@ public class EmailMapPost extends DeclarativeWebScript
|
||||
catch (AlfrescoRuntimeException are)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,
|
||||
are.getMessage());
|
||||
are.getMessage(), are);
|
||||
}
|
||||
|
||||
return model;
|
||||
|
@@ -45,7 +45,7 @@ import org.json.JSONTokener;
|
||||
|
||||
/**
|
||||
* This class provides the implementation for the rmaction webscript.
|
||||
*
|
||||
*
|
||||
* @author Neil McErlean
|
||||
*/
|
||||
public class RmActionPost extends DeclarativeWebScript
|
||||
@@ -78,7 +78,7 @@ public class RmActionPost extends DeclarativeWebScript
|
||||
try
|
||||
{
|
||||
reqContentAsString = req.getContent().getContent();
|
||||
}
|
||||
}
|
||||
catch (IOException iox)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
||||
@@ -136,7 +136,7 @@ public class RmActionPost extends DeclarativeWebScript
|
||||
String dateStringValue = ((JSONObject)nextValue).getString("iso8601");
|
||||
nextValue = ISO8601DateFormat.parse(dateStringValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actionParams.put(nextKeyString, (Serializable)nextValue);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class RmActionPost extends DeclarativeWebScript
|
||||
}
|
||||
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.
|
||||
|
@@ -43,7 +43,7 @@ public class RmEventPut extends RMEventBase
|
||||
{
|
||||
/** Parameter names */
|
||||
public static final String PARAM_EVENTNAME = "eventname";
|
||||
|
||||
|
||||
/** Records management event service */
|
||||
private RecordsManagementEventService rmEventService;
|
||||
|
||||
@@ -77,8 +77,8 @@ public class RmEventPut extends RMEventBase
|
||||
// Check the event name
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
String eventName = templateVars.get(PARAM_EVENTNAME);
|
||||
if (eventName == null ||
|
||||
eventName.isEmpty() ||
|
||||
if (eventName == null ||
|
||||
eventName.isEmpty() ||
|
||||
rmEventService.existsEvent(eventName) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided.");
|
||||
@@ -140,7 +140,7 @@ public class RmEventPut extends RMEventBase
|
||||
}
|
||||
catch (AlfrescoRuntimeException are)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, are.getLocalizedMessage());
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, are.getLocalizedMessage(), are);
|
||||
}
|
||||
|
||||
return canEditEvent;
|
||||
|
Reference in New Issue
Block a user