use of java.security.InvalidParameterException in project android_packages_apps_OmniClock by omnirom.
the class MonthView method setMonthParams.
/**
* Sets all the parameters for displaying this week. The only required
* parameter is the week number. Other parameters have a default value and
* will only update if a new value is included, except for focus month,
* which will always default to no focus month if no value is passed in. See
* {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
*
* @param params A map of the new parameters, see
* {@link #VIEW_PARAMS_HEIGHT}
*/
public void setMonthParams(HashMap<String, Integer> params) {
if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
throw new InvalidParameterException("You must specify month and year for this view");
}
setTag(params);
// We keep the current value for any params not present
if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
if (mRowHeight < MIN_HEIGHT) {
mRowHeight = MIN_HEIGHT;
}
}
if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
}
// Allocate space for caching the day numbers and focus values
mMonth = params.get(VIEW_PARAMS_MONTH);
mYear = params.get(VIEW_PARAMS_YEAR);
// Figure out what day today is
// final Time today = new Time(Time.getCurrentTimezone());
// today.setToNow();
final Calendar today = Calendar.getInstance();
mHasToday = false;
mToday = -1;
mCalendar.set(Calendar.MONTH, mMonth);
mCalendar.set(Calendar.YEAR, mYear);
mCalendar.set(Calendar.DAY_OF_MONTH, 1);
mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
} else {
mWeekStart = mCalendar.getFirstDayOfWeek();
}
mNumCells = mCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
for (int i = 0; i < mNumCells; i++) {
final int day = i + 1;
if (sameDay(day, today)) {
mHasToday = true;
mToday = day;
}
}
mNumRows = calculateNumRows();
// Invalidate cached accessibility information.
mTouchHelper.invalidateRoot();
}
use of java.security.InvalidParameterException in project core by jcryptool.
the class ImportSampleHandler method getCascadeFilename.
private String getCascadeFilename(ExecutionEvent event) {
// $NON-NLS-1$
String cascadeFilename = event.getParameter("cascadeFilename");
if (cascadeFilename == null) {
// $NON-NLS-1$
throw new InvalidParameterException("command parameter cascadeFilename is required");
}
URL bundleUrl = null;
File cascadeFile = null;
try {
bundleUrl = // $NON-NLS-1$
FileLocator.toFileURL((ActionsUIPlugin.getDefault().getBundle().getEntry("/")));
cascadeFile = new File(bundleUrl.getFile() + "templates" + // $NON-NLS-1$
File.separatorChar + // $NON-NLS-1$
cascadeFilename);
} catch (Exception ex) {
// $NON-NLS-1$ //$NON-NLS-2$
LogUtil.logError("Error loading sample file " + cascadeFilename + " from plugin.", ex);
}
ActionCascadeService service = ActionCascadeService.getInstance();
if (service.getCurrentActionCascade() != null && service.getCurrentActionCascade().getSize() > 0) {
boolean confirmImport = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), Messages.ImportHandler_0, Messages.ImportHandler_1);
if (!confirmImport) {
return null;
}
}
return cascadeFile.getAbsolutePath();
}
use of java.security.InvalidParameterException in project data-prep by Talend.
the class ReplaceOnValue method computeNewValue.
/**
* Compute the new action based on the current action context.
*
* @param context the action context.
* @param originalValue the original value.
* @return the new value to set based on the parameters within the action context.
*/
protected String computeNewValue(ActionContext context, String originalValue) {
if (originalValue == null) {
return null;
}
// There are direct calls to this method from unit tests, normally such checks are done during transformation.
if (context.getActionStatus() != ActionContext.ActionStatus.OK) {
return originalValue;
}
final Map<String, String> parameters = context.getParameters();
String replacement = parameters.get(REPLACE_VALUE_PARAMETER);
boolean replaceEntireCell = Boolean.valueOf(parameters.get(REPLACE_ENTIRE_CELL_PARAMETER));
try {
final ReplaceOnValueHelper replaceOnValueParameter = context.get(REGEX_HELPER_KEY);
boolean matches = replaceOnValueParameter.matches(originalValue);
if (matches) {
if (replaceOnValueParameter.getOperator().equals(ReplaceOnValueHelper.REGEX_MODE)) {
final Pattern pattern = replaceEntireCell ? replaceOnValueParameter.getPattern() : Pattern.compile(replaceOnValueParameter.getToken());
try {
return pattern.matcher(originalValue).replaceAll(replacement);
} catch (IndexOutOfBoundsException e) {
// catch to fix TDP_1227 PB#1
return originalValue;
}
} else if (replaceEntireCell) {
return replacement;
} else {
return originalValue.replace(replaceOnValueParameter.getToken(), replacement);
}
} else {
return originalValue;
}
} catch (InvalidParameterException e) {
return originalValue;
}
}
use of java.security.InvalidParameterException in project keystore-explorer by kaikramer.
the class EccUtil method getNamedCurve.
/**
* Determines the name of the domain parameters that were used for generating the key.
*
* @param key An EC key
* @return The name of the domain parameters that were used for the EC key,
* or an empty string if curve is unknown.
*/
public static String getNamedCurve(Key key) {
if (!(key instanceof ECKey)) {
throw new InvalidParameterException("Not a EC private key.");
}
ECKey ecKey = (ECKey) key;
ECParameterSpec params = ecKey.getParams();
if (!(params instanceof ECNamedCurveSpec)) {
return "";
}
ECNamedCurveSpec ecPrivateKeySpec = (ECNamedCurveSpec) params;
String namedCurve = ecPrivateKeySpec.getName();
return namedCurve;
}
use of java.security.InvalidParameterException in project records-management by Alfresco.
the class RMSiteEntityResourceUnitTest method deleteNonRMSite.
@Test
public void deleteNonRMSite() throws Exception {
String siteId = NON_RM_SITE_ID;
Params parameters = mock(Params.class);
when(parameters.getParameter(PERMANENT_PARAMETER)).thenReturn(null);
try {
rmSiteEntityResource.delete(siteId, parameters);
fail("Expected ecxeption as siteId was different than rm");
} catch (InvalidParameterException ex) {
assertEquals("The Deletion is supported only for siteId = rm.", ex.getMessage());
}
verify(mockedRMSites, never()).deleteRMSite(siteId, parameters);
}
Aggregations