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:org.cloudifysource.rest.AttributesContollerTest.java

/**
 * This method finds the handler for a given request URI. It will also
 * ensure that the URI Parameters i.e. /context/test/{name} are added to the
 * request/*from  w w w .  java2s  . c  o  m*/
 *
 * @param request
 *            The request object to be used
 * @return The correct handler for the request
 * @throws Exception
 *             Indicates a matching handler could not be found
 */
private Object getHandlerToRequest(final MockHttpServletRequest request) throws Exception {
    HandlerExecutionChain chain = null;

    final Map<String, HandlerMapping> map = applicationContext.getBeansOfType(HandlerMapping.class);

    for (HandlerMapping mapping : map.values()) {
        chain = mapping.getHandler(request);

        if (chain != null) {
            break;
        }
    }

    if (chain == null) {
        throw new InvalidParameterException(
                "Unable to find handler for request URI: " + request.getRequestURI());
    }

    return chain.getHandler();
}

From source file:com.xpn.xwiki.plugin.charts.params.ChartParams.java

protected void set(String name, Object obj) throws ParamException {
    ChartParam param = (ChartParam) paramMap.get(name);
    if (obj == null || param.getType().isInstance(obj)) {
        valueMap.put(name, obj);//w w  w.java2  s  .c  o  m
    } else {
        throw new InvalidParameterException(
                "Invalid value type for parameter " + param.getName() + " ; expected type: " + param.getType());
    }
}

From source file:org.openanzo.jdbc.opgen.RdbStatement.java

private Parameter getFirstOutput() {
    Iterator<Parameter> iter = outputs.iterator();
    if (!iter.hasNext())
        throw new InvalidParameterException("No outputs specified");
    return iter.next();
}

From source file:org.apache.hawq.pxf.plugins.json.PxfUnit.java

/**
 * Gets an instance of ReadAccessor via reflection.
 * //from  w w  w .  j  ava 2s  . com
 * Searches for a constructor that has a single parameter of some InputData type
 * 
 * @return An ReadAccessor instance
 * @throws Exception
 *             If something bad happens
 */
protected ReadAccessor getReadAccessor(InputData data) throws Exception {

    ReadAccessor accessor = null;

    for (Constructor<?> c : getReadAccessorClass().getConstructors()) {
        if (c.getParameterTypes().length == 1) {
            for (Class<?> clazz : c.getParameterTypes()) {
                if (InputData.class.isAssignableFrom(clazz)) {
                    accessor = (ReadAccessor) c.newInstance(data);
                }
            }
        }
    }

    if (accessor == null) {
        throw new InvalidParameterException(
                "Unable to find Accessor constructor with a BaseMetaData parameter");
    }

    return accessor;

}

From source file:org.zaproxy.zap.extension.customFire.PolicyAllCategoryPanel.java

public void setScanPolicy(CustomScanPolicy scanPolicy) {
    if (!switchable) {
        throw new InvalidParameterException(
                "Cannot change policy if the panel has not been defined as switchable");
    }//from  w ww .j a v a 2 s  .  c o m
    this.policy = scanPolicy;
    this.getPolicySelector().setSelectedItem(scanPolicy.getName());
    this.setThreshold(scanPolicy.getDefaultThreshold());
    this.setStrength(scanPolicy.getDefaultStrength());
    this.getAllCategoryTableModel().setPluginFactory(scanPolicy.getPluginFactory());
}

From source file:com.yunguchang.data.ApplicationRepository.java

@TransactionAttribute(REQUIRES_NEW)
public TBusApplyinfoEntity retreatApply(String applyId, String applyNo, Boolean bySync,
        PrincipalExt principalExt) {// ww  w . j  a  v a  2  s . c  om
    if (applyId == null && applyNo == null) {
        throw new InvalidParameterException("Approve info can not be null!");
    }
    TBusApplyinfoEntity applyinfoEntity;
    if (applyId != null) {
        applyinfoEntity = em.find(TBusApplyinfoEntity.class, applyId);
    } else {
        applyinfoEntity = getApplicationByNo(applyNo, principalExt);
    }
    if (applyinfoEntity == null) {
        throw logger.entityNotFound(TBusApplyinfoEntity.class, applyId);
    }
    if (bySync != null && bySync) {
        applyinfoEntity.setUpdateBySync(true);
    } else {
        applyinfoEntity.setUpdateBySync(false);
    }

    return updateApplicationStatus(applyinfoEntity.getUuid(), ApplyStatus.DISPATCH_REJECT.toStringValue(),
            bySync, principalExt);
}

From source file:org.apache.hawq.pxf.plugins.json.PxfUnit.java

/**
 * Gets an instance of IFieldsResolver via reflection.
 * //from  ww  w  .  j a  v a2  s  .co  m
 * Searches for a constructor that has a single parameter of some BaseMetaData type
 * 
 * @return A IFieldsResolver instance
 * @throws Exception
 *             If something bad happens
 */
protected ReadResolver getReadResolver(InputData data) throws Exception {

    ReadResolver resolver = null;

    // search for a constructor that has a single parameter of a type of
    // BaseMetaData to create the accessor instance
    for (Constructor<?> c : getReadResolverClass().getConstructors()) {
        if (c.getParameterTypes().length == 1) {
            for (Class<?> clazz : c.getParameterTypes()) {
                if (InputData.class.isAssignableFrom(clazz)) {
                    resolver = (ReadResolver) c.newInstance(data);
                }
            }
        }
    }

    if (resolver == null) {
        throw new InvalidParameterException(
                "Unable to find Resolver constructor with a BaseMetaData parameter");
    }

    return resolver;
}

From source file:eu.europa.ec.fisheries.uvms.reporting.service.util.ReportDeserializer.java

private void addVmsFilters(JsonNode vms, List<FilterDTO> filterDTOList, Long reportId) {
    if (vms != null) {
        Iterator<JsonNode> elements = vms.elements();
        while (elements.hasNext()) {
            JsonNode next = elements.next();
            FilterType type = FilterType.valueOf(next.get("type").textValue());
            switch (type) {
            case vmspos:
                addPositionFilter(filterDTOList, reportId, next);
                break;
            case vmstrack:
                addTrackFilterDTO(filterDTOList, reportId, next);
                break;
            case vmsseg:
                addVmsSegmentFilterDTO(filterDTOList, reportId, next);
                break;
            default:
                throw new InvalidParameterException("Unsupported parameter");

            }/*from  w  w w .ja  v a2s  .co  m*/
        }
    }
}

From source file:org.apache.giraph.bsp.BspService.java

/**
 * Get the checkpoint from a finalized checkpoint path
 *
 * @param finalizedPath Path of the finalized checkpoint
 * @return Superstep referring to a checkpoint of the finalized path
 *//*from ww  w  .  j a v a 2s  .co  m*/
public static long getCheckpoint(Path finalizedPath) {
    if (!finalizedPath.getName().endsWith(CHECKPOINT_FINALIZED_POSTFIX)) {
        throw new InvalidParameterException(
                "getCheckpoint: " + finalizedPath + "Doesn't end in " + CHECKPOINT_FINALIZED_POSTFIX);
    }
    String checkpointString = finalizedPath.getName().replace(CHECKPOINT_FINALIZED_POSTFIX, "");
    return Long.parseLong(checkpointString);
}

From source file:com.baasbox.service.user.UserService.java

public static ODocument updateProfile(String username, String role, JsonNode nonAppUserAttributes,
        JsonNode privateAttributes, JsonNode friendsAttributes, JsonNode appUsersAttributes, String id)
        throws InvalidJsonException, AdminCannotChangeRoleException, Exception {
    try {//from   ww  w . ja v a 2s  .  c o m
        if (username.equalsIgnoreCase("admin"))
            throw new AdminCannotChangeRoleException("User 'admin' cannot change role");
        DbHelper.requestTransaction();
        UserDao udao = UserDao.getInstance();
        ODocument profile = udao.getByUserName(username);
        if (profile == null)
            throw new InvalidParameterException(username + " is not a user");
        profile = updateProfile(profile, nonAppUserAttributes, privateAttributes, friendsAttributes,
                appUsersAttributes);

        Set<OIdentifiable> roles = (Set<OIdentifiable>) ((ODocument) profile.field("user")).field("roles");
        //extracts the role skipping the friends ones
        String oldRole = null;
        for (OIdentifiable r : roles) {
            oldRole = ((String) ((ODocument) r.getRecord()).field("name"));
            if (!oldRole.startsWith(RoleDao.FRIENDS_OF_ROLE)) {
                break;
            }
        }

        if (role != null) {
            ORole newORole = RoleDao.getRole(role);
            if (newORole == null)
                throw new InvalidParameterException(role + " is not a role");
            if (!RoleService.isAssignable(newORole))
                throw new RoleIsNotAssignableException("Role " + role + " is not assignable");
            ORID newRole = newORole.getDocument().getIdentity();
            ORole oldORole = RoleDao.getRole(oldRole);
            OUser ouser = udao.getOUserByUsername(username);
            ouser.getRoles().remove(oldORole);
            ouser.addRole(newORole);
            ouser.save();
        }
        if (id != null)
            profile.field(BaasBoxPrivateFields.ID.toString(), id);
        profile.save();
        profile.reload();
        DbHelper.commitTransaction();
        return profile;
    } catch (OSerializationException e) {
        DbHelper.rollbackTransaction();
        throw new InvalidJsonException(e);
    } catch (Exception e) {
        DbHelper.rollbackTransaction();
        throw e;
    }
}