Examples of CommandType


Examples of org.apache.cloudstack.api.BaseCmd.CommandType

            }

            //check access on the resource this field points to
            try {
                ACL checkAccess = field.getAnnotation(ACL.class);
                CommandType fieldType = parameterAnnotation.type();

                if (checkAccess != null) {
                    // Verify that caller can perform actions in behalf of vm owner
                    //acumulate all Controlled Entities together.

                    //parse the array of resource types and in case of map check access on key or value or both as specified in @acl
                    //implement external dao for classes that need findByName
                    //for maps, specify access to be checkd on key or value.

                    // find the controlled entity DBid by uuid
                    if (parameterAnnotation.entityType() != null) {
                        Class<?>[] entityList = parameterAnnotation.entityType()[0].getAnnotation(EntityReference.class).value();

                        for (Class entity : entityList) {
                            // Check if the parameter type is a single
                            // Id or list of id's/name's
                            switch (fieldType) {
                            case LIST:
                                CommandType listType = parameterAnnotation.collectionType();
                                switch (listType) {
                                case LONG:
                                case UUID:
                                    List<Long> listParam = (List<Long>)field.get(cmd);
                                    for (Long entityId : listParam) {
View Full Code Here

Examples of org.apache.cloudstack.api.BaseCmd.CommandType

    @SuppressWarnings({"unchecked", "rawtypes"})
    private static void setFieldValue(Field field, BaseCmd cmdObj, Object paramObj, Parameter annotation) throws IllegalArgumentException, ParseException {
        try {
            field.setAccessible(true);
            CommandType fieldType = annotation.type();
            switch (fieldType) {
            case BOOLEAN:
                field.set(cmdObj, Boolean.valueOf(paramObj.toString()));
                break;
            case DATE:
                // This piece of code is for maintaining backward compatibility
                // and support both the date formats(Bug 9724)
                // Do the date messaging for ListEventsCmd only
                if (cmdObj instanceof ListEventsCmd || cmdObj instanceof DeleteEventsCmd
                        || cmdObj instanceof ArchiveEventsCmd
                        || cmdObj instanceof ArchiveAlertsCmd
                        || cmdObj instanceof DeleteAlertsCmd) {
                    boolean isObjInNewDateFormat = isObjInNewDateFormat(paramObj.toString());
                    if (isObjInNewDateFormat) {
                        DateFormat newFormat = BaseCmd.NEW_INPUT_FORMAT;
                        synchronized (newFormat) {
                            field.set(cmdObj, newFormat.parse(paramObj.toString()));
                        }
                    } else {
                        DateFormat format = BaseCmd.INPUT_FORMAT;
                        synchronized (format) {
                            Date date = format.parse(paramObj.toString());
                            if (field.getName().equals("startDate")) {
                                date = messageDate(date, 0, 0, 0);
                            } else if (field.getName().equals("endDate")) {
                                date = messageDate(date, 23, 59, 59);
                            }
                            field.set(cmdObj, date);
                        }
                    }
                } else {
                    final DateFormat format = BaseCmd.INPUT_FORMAT;
                    synchronized (format) {
                        format.setLenient(false);
                        field.set(cmdObj, format.parse(paramObj.toString()));
                    }
                }
                break;
            case FLOAT:
                // Assuming that the parameters have been checked for required before now,
                // we ignore blank or null values and defer to the command to set a default
                // value for optional parameters ...
                if (paramObj != null && isNotBlank(paramObj.toString())) {
                    field.set(cmdObj, Float.valueOf(paramObj.toString()));
                }
                break;
            case INTEGER:
                // Assuming that the parameters have been checked for required before now,
                // we ignore blank or null values and defer to the command to set a default
                // value for optional parameters ...
                if (paramObj != null && isNotBlank(paramObj.toString())) {
                    field.set(cmdObj, Integer.valueOf(paramObj.toString()));
                }
                break;
            case LIST:
                List listParam = new ArrayList();
                StringTokenizer st = new StringTokenizer(paramObj.toString(), ",");
                while (st.hasMoreTokens()) {
                    String token = st.nextToken();
                    CommandType listType = annotation.collectionType();
                    switch (listType) {
                    case INTEGER:
                        listParam.add(Integer.valueOf(token));
                        break;
                    case UUID:
View Full Code Here

Examples of org.apache.qpid.disttest.message.CommandType

        }

        @Override
        public boolean supports(Command command)
        {
            CommandType type = command.getType();
            if (type == CommandType.RESPONSE)
            {
                Response response = (Response)command;
                return _setOfResponsesToExpect.contains(response.getInReplyToCommandType());
            }
View Full Code Here

Examples of org.apache.qpid.disttest.message.CommandType

        }

        @Override
        public boolean supports(Command command)
        {
            CommandType type = command.getType();
            if (type == CommandType.RESPONSE)
            {
                Response response = (Response)command;
                return _setOfResponsesToExpect.contains(response.getInReplyToCommandType());
            }
View Full Code Here

Examples of org.apache.qpid.disttest.message.CommandType

    public static Command messageToCommand(final Message jmsMessage)
    {
        Command command = null;
        try
        {
            final CommandType commandType = CommandType.valueOf(jmsMessage
                            .getStringProperty(DistributedTestConstants.MSG_COMMAND_PROPERTY));
            final JsonHandler jsonHandler = new JsonHandler();
            command = jsonHandler.unmarshall(jmsMessage.getStringProperty(DistributedTestConstants.MSG_JSON_PROPERTY),
                            getCommandClassFromType(commandType));
        }
View Full Code Here

Examples of org.apache.qpid.disttest.message.CommandType

        }

        @Override
        public boolean supports(Command command)
        {
            CommandType type = command.getType();
            if (type == CommandType.RESPONSE)
            {
                Response response = (Response)command;
                return _setOfResponsesToExpect.contains(response.getInReplyToCommandType());
            }
View Full Code Here

Examples of org.rhq.enterprise.communications.command.CommandType

     *
     * @see    CommandExecutor#execute(Command, InputStream, OutputStream)
     */
    public CommandResponse execute(Command command, InputStream in, OutputStream out) {
        // find what executor should be responsible for executing the command
        CommandType commandTypeToExecute = command.getCommandType();
        CommandTypeExecutor typeExecutor = getExecutors().get(commandTypeToExecute);

        if (typeExecutor == null) {
            // this should never really happen; I can't think of a case where it would under normal circumstances
            throw new IllegalArgumentException(getLog()
View Full Code Here

Examples of org.rhq.enterprise.communications.command.CommandType

            // cross your fingers and hope that the command type defined by the user is processable on the server-side
            LOG.debug(CommI18NResourceKeys.CMDLINE_CLIENT_USING_GENERIC_CLIENT, cnfe.getMessage());

            try {
                GenericCommandClient customClient = new GenericCommandClient();
                customClient.setCommandType(new CommandType(m_commandName, m_commandVersion));
                commandClient = customClient;
            } catch (Exception e) {
                // any exception that occurred while trying to build a generic client should throw a ClassNotFound
                // to alert the caller that the original client class was not found and our workaround didn't work
                throw new ClassNotFoundException(cnfe.toString(), e);
View Full Code Here

Examples of org.rhq.enterprise.communications.command.CommandType

     * Tests the ability to dynamically define metadata for a command.
     *
     * @throws Exception
     */
    public void testDynamicDefinition() throws Exception {
        GenericCommand gc = new GenericCommand(new CommandType("foo", 123), new ParameterDefinition[] {
            new ParameterDefinition("string", "java.lang.String", true, false, false, ""),
            new ParameterDefinition("int", "java.lang.Integer", true, true, false, "") });

        assertEquals(new CommandType("foo", 123), gc.getCommandType());
        assertEquals(2, gc.getParameterDefinitions().length);
        try {
            gc.checkParameterValidity(true);
            fail("should have failed - the parameters are required");
        } catch (InvalidParameterValueException e) {
View Full Code Here

Examples of org.rhq.enterprise.communications.command.CommandType

    /**
     * testSetCommandType
     */
    public void testSetCommandType() {
        CommandType oldType = m_cmd.getCommandType();
        CommandType newType = new CommandType("newtesttype", 123);

        m_cmd.setCommandType(newType);

        assertFalse(oldType.equals(m_cmd.getCommandType()));
        assertEquals("newtesttype", m_cmd.getCommandType().getName());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.