Search in sources :

Example 26 with InvalidParameterException

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();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Calendar(java.util.Calendar) Paint(android.graphics.Paint)

Example 27 with InvalidParameterException

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();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) File(java.io.File) ActionCascadeService(org.jcryptool.actions.core.registry.ActionCascadeService) URL(java.net.URL) WorkbenchException(org.eclipse.ui.WorkbenchException) ExecutionException(org.eclipse.core.commands.ExecutionException) InvalidParameterException(java.security.InvalidParameterException)

Example 28 with InvalidParameterException

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;
    }
}
Also used : Pattern(java.util.regex.Pattern) InvalidParameterException(java.security.InvalidParameterException) ReplaceOnValueHelper(org.talend.dataprep.transformation.actions.common.ReplaceOnValueHelper)

Example 29 with InvalidParameterException

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;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) ECParameterSpec(java.security.spec.ECParameterSpec) ECKey(java.security.interfaces.ECKey) ECNamedCurveSpec(org.bouncycastle.jce.spec.ECNamedCurveSpec)

Example 30 with InvalidParameterException

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);
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Params(org.alfresco.rest.framework.resource.parameters.Params) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Aggregations

InvalidParameterException (java.security.InvalidParameterException)280 IOException (java.io.IOException)34 ArrayList (java.util.ArrayList)24 ActionEvent (com.cloud.event.ActionEvent)22 SecureRandom (java.security.SecureRandom)19 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)18 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)16 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)16 File (java.io.File)16 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)15 FirewallRule (com.cloud.network.rules.FirewallRule)14 DB (com.cloud.utils.db.DB)14 Map (java.util.Map)14 HashMap (java.util.HashMap)12 MalformedURLException (java.net.MalformedURLException)11 Paint (android.graphics.Paint)9 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)8 CommunicationException (com.globalcollect.gateway.sdk.client.android.sdk.exception.CommunicationException)8 HttpURLConnection (java.net.HttpURLConnection)8 Scanner (java.util.Scanner)8