Example usage for java.security InvalidParameterException InvalidParameterException

List of usage examples for java.security InvalidParameterException InvalidParameterException

Introduction

In this page you can find the example usage for java.security InvalidParameterException InvalidParameterException.

Prototype

public InvalidParameterException(String msg) 

Source Link

Document

Constructs an InvalidParameterException with the specified detail message.

Usage

From source file:eu.bittrade.libs.steemj.protocol.operations.TransferOperation.java

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        super.validate(validationType);

        if (!ValidationType.SKIP_ASSET_VALIDATION.equals(validationType)) {
            if (amount.getSymbol().equals(SteemJConfig.getInstance().getVestsSymbol())) {
                throw new InvalidParameterException("Transfering Steem Power (VESTS) is not allowed.");
            } else if (amount.getAmount() <= 0) {
                throw new InvalidParameterException("Must transfer a nonzero amount.");
            }//from  w  ww .  ja v  a  2 s . c o  m
        }

        if (memo.length() > 2048) {
            throw new InvalidParameterException("The memo is too long. Only 2048 characters are allowed.");
        }
    }
}

From source file:org.etudes.jforum.util.preferences.SystemGlobals.java

private void buildSystem(String appPath, String defaultConfig) throws IOException {
    if (defaultConfig == null) {
        throw new InvalidParameterException("defaultConfig could not be null");
    }// ww  w  .j av a2  s  . co  m

    this.defaultConfig = defaultConfig;
    this.defaults = new Properties();

    this.defaults.put(ConfigKeys.APPLICATION_PATH, appPath);
    this.defaults.put(ConfigKeys.DEFAULT_CONFIG, defaultConfig);

    SystemGlobals.loadDefaults();

    this.installation = new Properties();
    // this.installationConfig = getVariableValue(ConfigKeys.INSTALLATION_CONFIG);

    for (Iterator iter = additionalDefaultsList.iterator(); iter.hasNext();) {
        loadAdditionalDefaults((String) iter.next());
    }

    /*if (new File(this.installationConfig).exists()) {
       loadAdditionalDefaults(this.installationConfig);
    }*/
}

From source file:org.openflexo.foundation.fml.action.CreateModelSlot.java

@Override
protected void doAction(Object context) throws NotImplementedException, InvalidParameterException {
    logger.info("Add model slot, technologyAdapter=" + technologyAdapter);

    if (technologyAdapter == null) {
        throw new InvalidParameterException("No technology adapter supplied");
    }/*w ww  .j  a  va2 s  . com*/

    /*if (technologyAdapter instanceof FMLTechnologyAdapter) {
       FMLTechnologyAdapter virtualModelTechnologyAdapter = (FMLTechnologyAdapter) technologyAdapter;
       newModelSlot = virtualModelTechnologyAdapter.makeModelSlot(FMLRTModelSlot.class, getFocusedObject());
       newModelSlot.setName(modelSlotName);
       ((FMLRTModelSlot) newModelSlot).setVirtualModelResource(vmRes);
       newModelSlot.setIsRequired(required);
       newModelSlot.setIsReadOnly(readOnly);
       newModelSlot.setDescription(description);
       getFocusedObject().addToModelSlots(newModelSlot);
    }*/

    if (technologyAdapter != null && getModelSlotClass() != null) {
        // if (getFocusedObject() instanceof VirtualModel) {
        newModelSlot = technologyAdapter.makeModelSlot(getModelSlotClass(), getFocusedObject());
        /*} else if (getFocusedObject() instanceof ViewPoint) {
           newModelSlot = technologyAdapter.createNewModelSlot((ViewPoint) getFocusedObject());
        }*/
        newModelSlot.setName(modelSlotName);
        if (newModelSlot instanceof FMLRTModelSlot) {
            ((FMLRTModelSlot) newModelSlot).setVirtualModelResource(vmRes);

        } else if (newModelSlot instanceof TypeAwareModelSlot) {
            ((TypeAwareModelSlot) newModelSlot).setMetaModelResource(mmRes);
        }
        newModelSlot.setIsRequired(required);
        newModelSlot.setIsReadOnly(readOnly);
        newModelSlot.setDescription(description);
        // if (getFocusedObject() instanceof VirtualModel) {
        getFocusedObject().addToModelSlots(newModelSlot);
        /*} else if (getFocusedObject() instanceof ViewPoint) {
           ((ViewPoint) getFocusedObject()).addToModelSlots(newModelSlot);
        }*/
    }

}

From source file:org.flite.cach3.aop.L2InvalidateMultiCacheAdvice.java

static AnnotationInfo getAnnotationInfo(final L2InvalidateMultiCache annotation,
        final String targetMethodName) {
    final AnnotationInfo result = new AnnotationInfo();

    if (annotation == null) {
        throw new InvalidParameterException(
                String.format("No annotation of type [%s] found.", L2InvalidateMultiCache.class.getName()));
    }//from   ww w . j av  a2s.  co  m

    final String namespace = annotation.namespace();
    if (AnnotationConstants.DEFAULT_STRING.equals(namespace) || namespace == null || namespace.length() < 1) {
        throw new InvalidParameterException(
                String.format("Namespace for annotation [%s] must be defined on [%s]",
                        L2InvalidateMultiCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Namespace(namespace));

    final String keyPrefix = annotation.keyPrefix();
    if (!AnnotationConstants.DEFAULT_STRING.equals(keyPrefix)) {
        if (StringUtils.isBlank(keyPrefix)) {
            throw new InvalidParameterException(String.format(
                    "KeyPrefix for annotation [%s] must not be defined as an empty string on [%s]",
                    L2InvalidateMultiCache.class.getName(), targetMethodName));
        }
        result.add(new AType.KeyPrefix(keyPrefix));
    }

    final Integer keyIndex = annotation.keyIndex();
    if (keyIndex < -1) {
        throw new InvalidParameterException(
                String.format("KeyIndex for annotation [%s] must be -1 or greater on [%s]",
                        L2InvalidateMultiCache.class.getName(), targetMethodName));
    }
    result.add(new AType.KeyIndex(keyIndex));

    final String keyTemplate = annotation.keyTemplate();
    if (!AnnotationConstants.DEFAULT_STRING.equals(keyTemplate)) {
        if (StringUtils.isBlank(keyTemplate)) {
            throw new InvalidParameterException(String.format(
                    "KeyTemplate for annotation [%s] must not be defined as an empty string on [%s]",
                    L2InvalidateMultiCache.class.getName(), targetMethodName));
        }
        result.add(new AType.KeyTemplate(keyTemplate));
    }

    return result;
}

From source file:org.flite.cach3.aop.L2ReadThroughSingleCacheAdvice.java

static AnnotationInfo getAnnotationInfo(final L2ReadThroughSingleCache annotation,
        final String targetMethodName) {
    final AnnotationInfo result = new AnnotationInfo();

    if (annotation == null) {
        throw new InvalidParameterException(
                String.format("No annotation of type [%s] found.", L2ReadThroughSingleCache.class.getName()));
    }// w  w  w.java  2s.c o m

    final String namespace = annotation.namespace();
    if (AnnotationConstants.DEFAULT_STRING.equals(namespace) || namespace == null || namespace.length() < 1) {
        throw new InvalidParameterException(
                String.format("Namespace for annotation [%s] must be defined on [%s]",
                        L2ReadThroughSingleCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Namespace(namespace));

    final String keyPrefix = annotation.keyPrefix();
    if (!AnnotationConstants.DEFAULT_STRING.equals(keyPrefix)) {
        if (StringUtils.isBlank(keyPrefix)) {
            throw new InvalidParameterException(String.format(
                    "KeyPrefix for annotation [%s] must not be defined as an empty string on [%s]",
                    L2ReadThroughSingleCache.class.getName(), targetMethodName));
        }
        result.add(new AType.KeyPrefix(keyPrefix));
    }

    final Integer keyIndex = annotation.keyIndex();
    if (keyIndex != AnnotationConstants.DEFAULT_KEY_INDEX && keyIndex < -1) {
        throw new InvalidParameterException(
                String.format("KeyIndex for annotation [%s] must be -1 or greater on [%s]",
                        L2ReadThroughSingleCache.class.getName(), targetMethodName));
    }
    final boolean keyIndexDefined = keyIndex >= -1;

    final String keyTemplate = annotation.keyTemplate();
    if (StringUtils.isBlank(keyTemplate)) {
        throw new InvalidParameterException(
                String.format("KeyTemplate for annotation [%s] must not be defined as an empty string on [%s]",
                        L2ReadThroughSingleCache.class.getName(), targetMethodName));
    }
    final boolean keyTemplateDefined = !AnnotationConstants.DEFAULT_STRING.equals(keyTemplate);

    if (keyIndexDefined == keyTemplateDefined) {
        throw new InvalidParameterException(String.format(
                "Exactly one of [keyIndex,keyTemplate] must be defined for annotation [%s] on [%s]",
                L2ReadThroughSingleCache.class.getName(), targetMethodName));
    }

    if (keyIndexDefined) {
        result.add(new AType.KeyIndex(keyIndex));
    }

    if (keyTemplateDefined) {
        result.add(new AType.KeyTemplate(keyTemplate));
    }

    final Duration window = annotation.window();
    if (window == Duration.UNDEFINED) {
        throw new InvalidParameterException(
                String.format("Window for annotation [%s] must be a defined value on [%s]",
                        L2ReadThroughSingleCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Window(window));

    return result;
}

From source file:net.sf.zekr.engine.addonmgr.AddOnManagerUtils.java

@SuppressWarnings("rawtypes")
public static String getValidInstallationFileExtensions(Class resourceType) {
    if (AudioData.class.equals(resourceType))
        return "*-online.properties;*.recit.zip";
    else if (TranslationData.class.equals(resourceType))
        return "*.trans.zip";
    else/*from  w ww .j  a  va  2 s .  c  o m*/
        throw new InvalidParameterException("ResourceType not handled");
}

From source file:org.cesecore.authorization.user.AccessUserAspectData.java

@Override
public void setMatchTypeAsValue(AccessMatchType matchType) {
    if (matchType == null) {
        throw new InvalidParameterException("Invalid to set matchType == null");
    }/*from   w  w w .  j  a v a 2 s .  com*/
    this.matchType = matchType;
}

From source file:org.cesecore.authorization.rules.AccessRuleData.java

public void setInternalState(final AccessRuleState state) {
    if (state == null) {
        throw new InvalidParameterException("Illegal to create an access rule with state == null");
    }//www  .  ja  v a 2s.  c om
    this.internalState = state;
    if (!internalState.equals(AccessRuleState.RULE_ACCEPT) && getRecursive()) {
        setRecursive(false);
    }
}

From source file:eu.bittrade.libs.steemj.plugins.apis.follow.models.operations.FollowOperation.java

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (this.getFollower() == null) {
            throw new InvalidParameterException("The follower account cannot be null.");
        } else if (this.getFollowing() == null) {
            throw new InvalidParameterException("The following account cannot be null.");
        } else if (this.getFollower().equals(this.getFollowing())) {
            throw new InvalidParameterException("You cannot follow yourself.");
        }//w  ww .  j a v a2  s .  co  m
    }
}

From source file:com.door43.translationstudio.ui.dialogs.BackupDialog.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    v = inflater.inflate(R.layout.dialog_backup, container, false);

    // get target translation to backup
    Bundle args = getArguments();/*from  w ww . j  av a2s  . c o m*/
    if (args != null && args.containsKey(ARG_TARGET_TRANSLATION_ID)) {
        String targetTranslationId = args.getString(ARG_TARGET_TRANSLATION_ID, null);
        targetTranslation = App.getTranslator().getTargetTranslation(targetTranslationId);
        if (targetTranslation == null) {
            throw new InvalidParameterException(
                    "The target translation '" + targetTranslationId + "' is invalid");
        }
    } else {
        throw new InvalidParameterException("The target translation id was not specified");
    }

    targetTranslation.setDefaultContributor(App.getProfile().getNativeSpeaker());

    mBackupToCloudButton = (LinearLayout) v.findViewById(R.id.backup_to_cloud);
    LinearLayout exportProjectButton = (LinearLayout) v.findViewById(R.id.backup_to_sd);
    Button backupToAppButton = (Button) v.findViewById(R.id.backup_to_app);
    Button backupToDeviceButton = (Button) v.findViewById(R.id.backup_to_device);
    LinearLayout exportToPDFButton = (LinearLayout) v.findViewById(R.id.export_to_pdf);
    LinearLayout exportToUsfmButton = (LinearLayout) v.findViewById(R.id.export_to_usfm);

    Button logout = (Button) v.findViewById(R.id.logout_button);
    logout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            App.setProfile(null);
            Intent logoutIntent = new Intent(getActivity(), ProfileActivity.class);
            startActivity(logoutIntent);
        }
    });

    final String filename = targetTranslation.getId() + "." + Translator.ARCHIVE_EXTENSION;

    initProgressWatcher(R.string.backup);

    if (savedInstanceState != null) {
        // check if returning from device alias dialog
        settingDeviceAlias = savedInstanceState.getBoolean(STATE_SETTING_DEVICE_ALIAS, false);
        mDialogShown = eDialogShown
                .fromInt(savedInstanceState.getInt(STATE_DIALOG_SHOWN, eDialogShown.NONE.getValue()));
        mAccessFile = savedInstanceState.getString(STATE_ACCESS_FILE, null);
        mDialogMessage = savedInstanceState.getString(STATE_DIALOG_MESSAGE, null);
        isOutputToDocumentFile = savedInstanceState.getBoolean(STATE_OUTPUT_TO_DOCUMENT_FILE, false);
        mDestinationFolderUri = Uri.parse(savedInstanceState.getString(STATE_OUTPUT_FOLDER_URI, ""));
        restoreDialogs();
    }

    Button dismissButton = (Button) v.findViewById(R.id.dismiss_button);
    dismissButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    backupToDeviceButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO: 11/18/2015 eventually we need to support bluetooth as well as an adhoc network
            showDeviceNetworkAliasDialog();
        }
    });

    // backup buttons
    mBackupToCloudButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (App.isNetworkAvailable()) {
                // make sure we have a gogs user
                if (App.getProfile().gogsUser == null) {
                    showDoor43LoginDialog();
                    return;
                }

                doPullTargetTranslationTask(targetTranslation, MergeStrategy.RECURSIVE);
            } else {
                showNoInternetDialog(); // replaced snack popup which could be hidden behind dialog
            }
        }
    });

    exportToPDFButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PrintDialog printDialog = new PrintDialog();
            Bundle printArgs = new Bundle();
            printArgs.putString(PrintDialog.ARG_TARGET_TRANSLATION_ID, targetTranslation.getId());
            printDialog.setArguments(printArgs);
            showDialogFragment(printDialog, PrintDialog.TAG);
        }
    });

    exportProjectButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            doSelectDestinationFolder(false);
        }
    });

    exportToUsfmButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            doSelectDestinationFolder(true);
        }
    });

    if (targetTranslation.isObsProject()) {
        LinearLayout exportToUsfmSeparator = (LinearLayout) v.findViewById(R.id.export_to_usfm_separator);
        exportToUsfmSeparator.setVisibility(View.GONE);
        exportToUsfmButton.setVisibility(View.GONE);
    }

    backupToAppButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            File exportFile = new File(App.getSharingDir(), filename);
            try {
                App.getTranslator().exportArchive(targetTranslation, exportFile);
            } catch (Exception e) {
                Logger.e(TAG, "Failed to export the target translation " + targetTranslation.getId(), e);
            }
            if (exportFile.exists()) {
                Uri u = FileProvider.getUriForFile(getActivity(), "com.door43.translationstudio.fileprovider",
                        exportFile);
                Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("application/zip");
                i.putExtra(Intent.EXTRA_STREAM, u);
                startActivity(Intent.createChooser(i, "Email:"));
            } else {
                Snackbar snack = Snackbar.make(getActivity().findViewById(android.R.id.content),
                        R.string.translation_export_failed, Snackbar.LENGTH_LONG);
                ViewUtil.setSnackBarTextColor(snack, getResources().getColor(R.color.light_primary_text));
                snack.show();
            }
        }
    });

    // connect to existing tasks
    PullTargetTranslationTask pullTask = (PullTargetTranslationTask) TaskManager
            .getTask(PullTargetTranslationTask.TASK_ID);
    RegisterSSHKeysTask keysTask = (RegisterSSHKeysTask) TaskManager.getTask(RegisterSSHKeysTask.TASK_ID);
    CreateRepositoryTask repoTask = (CreateRepositoryTask) TaskManager.getTask(CreateRepositoryTask.TASK_ID);
    PushTargetTranslationTask pushTask = (PushTargetTranslationTask) TaskManager
            .getTask(PushTargetTranslationTask.TASK_ID);
    ExportProjectTask projectExportTask = (ExportProjectTask) TaskManager.getTask(ExportProjectTask.TASK_ID);
    ExportToUsfmTask usfmExportTask = (ExportToUsfmTask) TaskManager.getTask(ExportToUsfmTask.TASK_ID);

    if (pullTask != null) {
        taskWatcher.watch(pullTask);
    } else if (keysTask != null) {
        taskWatcher.watch(keysTask);
    } else if (repoTask != null) {
        taskWatcher.watch(repoTask);
    } else if (pushTask != null) {
        taskWatcher.watch(pushTask);
    } else if (projectExportTask != null) {
        taskWatcher.watch(projectExportTask);
    } else if (usfmExportTask != null) {
        taskWatcher.watch(usfmExportTask);
    }

    return v;
}