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.base.models.Transaction.java

/**
 * Define a list of operations that should be send with this transaction.
 * /*from  w  ww . j av a  2s.  c  o  m*/
 * @param operations
 *            A list of operations.
 * @throws InvalidParameterException
 *             If the given object does not contain at least one Operation.
 */
public void setOperations(List<Operation> operations) {
    if (operations == null || operations.isEmpty()) {
        throw new InvalidParameterException("At least one Operation is required.");
    }

    this.operations = operations;
}

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

static AnnotationInfo getAnnotationInfo(final UpdateAssignCache annotation,
        final String targetMethodName, final int jitterDefault) {
    final AnnotationInfo result = new AnnotationInfo();

    if (annotation == null) {
        throw new InvalidParameterException(
                String.format("No annotation of type [%s] found.", UpdateAssignCache.class.getName()));
    }/* ww  w .j a va 2  s  . 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]",
                        UpdateAssignCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Namespace(namespace));

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

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

    final int expiration = annotation.expiration();
    if (expiration < 0) {
        throw new InvalidParameterException(
                String.format("Expiration for annotation [%s] must be 0 or greater on [%s]",
                        UpdateAssignCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Expiration(expiration));

    final int jitter = annotation.jitter();
    if (jitter < -1 || jitter > 99) {
        throw new InvalidParameterException(
                String.format("Jitter for annotation [%s] must be -1 <= jitter <= 99 on [%s]",
                        UpdateAssignCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Jitter(jitter == -1 ? jitterDefault : jitter));

    return result;
}

From source file:com.predic8.membrane.annot.bean.MCUtil.java

private static void addXML(Object object, String id, XMLStreamWriter xew, SerializationContext sc)
        throws XMLStreamException {
    if (object == null)
        throw new InvalidParameterException("'object' must not be null.");

    Class<? extends Object> clazz = object.getClass();

    MCElement e = clazz.getAnnotation(MCElement.class);
    if (e == null)
        throw new IllegalArgumentException("'object' must be @MCElement-annotated.");

    BeanWrapperImpl src = new BeanWrapperImpl(object);

    xew.writeStartElement(e.name());//w ww.j  a  va 2 s  .c  o m

    if (id != null)
        xew.writeAttribute("id", id);

    HashSet<String> attributes = new HashSet<String>();
    for (Method m : clazz.getMethods()) {
        if (!m.getName().startsWith("set"))
            continue;
        String propertyName = AnnotUtils.dejavaify(m.getName().substring(3));
        MCAttribute a = m.getAnnotation(MCAttribute.class);
        if (a != null) {
            Object value = src.getPropertyValue(propertyName);
            String str;
            if (value == null)
                continue;
            else if (value instanceof String)
                str = (String) value;
            else if (value instanceof Boolean)
                str = ((Boolean) value).toString();
            else if (value instanceof Integer)
                str = ((Integer) value).toString();
            else if (value instanceof Long)
                str = ((Long) value).toString();
            else if (value instanceof Enum<?>)
                str = value.toString();
            else {
                MCElement el = value.getClass().getAnnotation(MCElement.class);
                if (el != null) {
                    str = defineBean(sc, value, null, true);
                } else {
                    str = "?";
                    sc.incomplete = true;
                }
            }

            if (a.attributeName().length() > 0)
                propertyName = a.attributeName();

            attributes.add(propertyName);
            xew.writeAttribute(propertyName, str);
        }
    }
    for (Method m : clazz.getMethods()) {
        if (!m.getName().startsWith("set"))
            continue;
        String propertyName = AnnotUtils.dejavaify(m.getName().substring(3));
        MCOtherAttributes o = m.getAnnotation(MCOtherAttributes.class);
        if (o != null) {
            Object value = src.getPropertyValue(propertyName);
            if (value instanceof Map<?, ?>) {
                Map<?, ?> map = (Map<?, ?>) value;
                for (Map.Entry<?, ?> entry : map.entrySet()) {
                    Object key = entry.getKey();
                    Object val = entry.getValue();
                    if (!(key instanceof String) || !(val instanceof String)) {
                        sc.incomplete = true;
                        key = "incompleteAttributes";
                        val = "?";
                    }
                    if (attributes.contains(key))
                        continue;
                    attributes.add((String) key);
                    xew.writeAttribute((String) key, (String) val);
                }
            } else {
                xew.writeAttribute("incompleteAttributes", "?");
                sc.incomplete = true;
            }
        }
    }

    List<Method> childElements = new ArrayList<Method>();
    for (Method m : clazz.getMethods()) {
        if (!m.getName().startsWith("set"))
            continue;
        String propertyName = AnnotUtils.dejavaify(m.getName().substring(3));

        MCChildElement c = m.getAnnotation(MCChildElement.class);
        if (c != null) {
            childElements.add(m);
        }
        MCTextContent t = m.getAnnotation(MCTextContent.class);
        if (t != null) {
            Object value = src.getPropertyValue(propertyName);
            if (value == null) {
                continue;
            } else if (value instanceof String) {
                xew.writeCharacters((String) value);
            } else {
                xew.writeCharacters("?");
                sc.incomplete = true;
            }
        }
    }

    Collections.sort(childElements, new Comparator<Method>() {

        @Override
        public int compare(Method o1, Method o2) {
            MCChildElement c1 = o1.getAnnotation(MCChildElement.class);
            MCChildElement c2 = o2.getAnnotation(MCChildElement.class);
            return c1.order() - c2.order();
        }
    });

    for (Method m : childElements) {
        String propertyName = AnnotUtils.dejavaify(m.getName().substring(3));

        Object value = src.getPropertyValue(propertyName);
        if (value != null) {
            if (value instanceof Collection<?>) {
                for (Object item : (Collection<?>) value)
                    addXML(item, null, xew, sc);
            } else {
                addXML(value, null, xew, sc);
            }
        }
    }

    xew.writeEndElement();
}

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

/** Use setIsRecursive(boolean) instead of this method! */
public void setRecursiveInt(final Integer isRecursiveInt) {
    if (isRecursiveInt == null) {
        throw new InvalidParameterException("Illegal to create an access rule with isRecursiveInt == null");
    }/*ww  w  .java 2s  . c o m*/
    this.recursiveInt = isRecursiveInt;
}

From source file:com.bellman.bible.service.format.osistohtml.osishandlers.OsisToHtmlSaxHandler.java

private void registerHandler(OsisTagHandler handler) {
    if (osisTagHandlers.put(handler.getTagName(), handler) != null) {
        throw new InvalidParameterException("Duplicate handlers for tag " + handler.getTagName());
    }/*from   ww  w.j av  a  2 s  .  c  o  m*/
}

From source file:sh.isaac.api.component.semantic.version.dynamic.DynamicValidatorType.java

/**
 * Parses the./*from  w ww .j  ava  2  s . c o m*/
 *
 * @param nameOrEnumId the name or enum id
 * @param exceptionOnParseFail the exception on parse fail
 * @return the dynamic validator type
 */
public static DynamicValidatorType parse(String nameOrEnumId, boolean exceptionOnParseFail) {
    if (nameOrEnumId == null) {
        return null;
    }

    final String clean = nameOrEnumId.toLowerCase(Locale.ENGLISH).trim();

    if (StringUtils.isBlank(clean)) {
        return null;
    }

    try {
        final int i = Integer.parseInt(clean);

        // enumId
        return DynamicValidatorType.values()[i];
    } catch (final NumberFormatException e) {
        for (final DynamicValidatorType x : DynamicValidatorType.values()) {
            if (x.displayName.equalsIgnoreCase(clean) || x.name().toLowerCase().equals(clean)) {
                return x;
            }
        }
    }

    if (exceptionOnParseFail) {
        throw new InvalidParameterException(
                "The value " + nameOrEnumId + " could not be parsed as a DynamicSememeValidatorType");
    } else {
        return UNKNOWN;
    }
}

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

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (weight > 10000) {
            throw new InvalidParameterException(
                    "The voting weight can't be higher than 10000 which is equivalent to 100%.");
        } else if (weight < -10000) {
            throw new InvalidParameterException(
                    "The voting weight can't be lower than -10000 which is equivalent to -100%.");
        }//from   w w  w . ja  va  2 s . c  o m
    }
}

From source file:net.blogracy.controller.MediaController.java

/**
 * Get the images from recordDb given the userId and the associated albumId
 * //from w  w w .ja v a2 s  .  com
 * @param userId
 * @param albumId
 * @return
 */
public List<MediaItem> getMediaItems(String userId, String albumId) {
    if (userId == null)
        throw new InvalidParameterException("userId cannot be null");

    if (albumId == null)
        throw new InvalidParameterException("albumId cannot be null");

    List<MediaItem> mediaItems = new ArrayList<MediaItem>();

    try {
        JSONObject recordDb = DistributedHashTable.getSingleton().getRecord(userId);

        if (recordDb == null)
            return mediaItems;

        JSONArray mediaItemsArray = recordDb.optJSONArray("mediaItems");

        if (mediaItemsArray != null) {
            for (int i = 0; i < mediaItemsArray.length(); ++i) {
                JSONObject singleAlbumObject = mediaItemsArray.getJSONObject(i);
                MediaItem entry = (MediaItem) CONVERTER.convertToObject(singleAlbumObject, MediaItem.class);

                if (entry.getAlbumId().equals(albumId))
                    mediaItems.add(entry);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return mediaItems;
}

From source file:com.mobdb.android.MobDB.java

/**
 * Send's Push notification related request
 * @param appKey String value Application key
 * @param push Push object//from w w  w.  ja  v a 2 s  .  c o  m
 * @param bargraph String value for Analytics tag name
 * @param secure boolean value to set for SSL communication
 * @param listener MobDBResponseListener object
 * @throws InvalidParameterException
 */
public synchronized void execute(String appKey, Push push, String bargraph, boolean secure,
        MobDBResponseListener listener) throws InvalidParameterException {

    try {

        JSONObject req = new JSONObject();

        if (appKey == null) {
            throw new InvalidParameterException("Application key required.");
        }

        req.put(SDKConstants.KEY, appKey);

        if (push == null) {
            throw new InvalidParameterException("Push object required.");
        }

        if (bargraph != null) {
            req.put(SDKConstants.BAR_GRAPH, bargraph);
        }

        req.put(SDKConstants.PUSH, push.getQueryString());

        MobDBRequest request = new MobDBRequest(secure, listener);
        request.setParams(req.toString());
        requestQueue.add(request);
        executeRequest();

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:org.flite.cach3.config.Cach3State.java

public <L extends CacheListener> List<L> getListeners(final Class<L> type) {
    if (type == null) {
        throw new InvalidParameterException("Type must be defined.");
    }//from   w  w w . j  av a 2  s .c o m

    final List<L> listenerList = (List<L>) listeners.get(type);
    if (listenerList == null) {
        throw new InvalidParameterException(String.format("No listeners found of type [%s]", type.getName()));
    }

    return listenerList;
}