Search in sources :

Example 6 with ObjStoreAttrs

use of com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs in project openmq by eclipse-ee4j.

the class CmdRunner method promptForAuthentication.

/*
     * Prompts for authentication and stores the missing security info. Individual store knows what to ask, so all this has
     * to do is to go through the Vector of missing security attributes and and ask for the missing values, given the name
     * of the attribute.
     */
private ObjStore promptForAuthentication(ObjStore os) {
    /*
         * Retrieve the original ObjStoreAttrs that the user input. This DOES NOT read any jndi property files processed by jndi
         * since this is done PRIOR to creating the initialContext.
         */
    ObjStoreAttrs osa = os.getObjStoreAttrs();
    Vector missingAuthInfo = os.checkAuthentication(osa);
    int missingAuthInfoSize = missingAuthInfo.size();
    boolean carriageReturnNeeded = false;
    for (int i = 0; i < missingAuthInfoSize; i++) {
        carriageReturnNeeded = true;
        String name = (String) missingAuthInfo.elementAt(i);
        String value = null;
        // If prompting for "credentials", use the one that doesn't echo.
        if (name.equals(Context.SECURITY_CREDENTIALS)) {
            value = getPassword(ar.getString(ar.Q_ENTER_VALUE, name));
        } else {
            value = getUserInput(ar.getString(ar.Q_ENTER_VALUE, name));
        }
        os.addObjStoreAttr(name, value);
    }
    if (carriageReturnNeeded)
        Globals.stdOutPrintln("");
    return os;
}
Also used : ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) Vector(java.util.Vector)

Example 7 with ObjStoreAttrs

use of com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs in project openmq by eclipse-ee4j.

the class CmdRunner method runAddCommand.

private int runAddCommand(ObjMgrProperties objMgrProps) {
    ObjStore os;
    int exitcode = 0;
    String input = null;
    Object object = null;
    String yes, yesShort, no, noShort;
    yes = ar.getString(ar.Q_RESPONSE_YES);
    yesShort = ar.getString(ar.Q_RESPONSE_YES_SHORT);
    no = ar.getString(ar.Q_RESPONSE_NO);
    noShort = ar.getString(ar.Q_RESPONSE_NO_SHORT);
    /*
         * Get object type, props object, and lookup name
         */
    String type = objMgrProps.getObjType();
    Properties objProps = objMgrProps.getObjProperties();
    String lookupName = objMgrProps.getLookupName();
    ObjStoreAttrs osa = objMgrProps.getObjStoreAttrs();
    /*
         * Check for any mandatory bind attrs and display warning, if necessary.
         */
    checkObjStoreAttrs(osa);
    Attributes bindAttrs = objMgrProps.getBindAttrs();
    /*
         * Check if -f (force) was specified on cmd line.
         */
    boolean force = objMgrProps.forceModeSet();
    /*
         * Create JMS Object with the specified properties.
         */
    Object newObj = null;
    try {
        if (type.equals(OBJMGR_TYPE_QUEUE)) {
            newObj = JMSObjFactory.createQueue(objProps);
        } else if (type.equals(OBJMGR_TYPE_TOPIC)) {
            newObj = JMSObjFactory.createTopic(objProps);
        } else if (type.equals(OBJMGR_TYPE_QCF)) {
            newObj = JMSObjFactory.createQueueConnectionFactory(objProps);
        } else if (type.equals(OBJMGR_TYPE_TCF)) {
            newObj = JMSObjFactory.createTopicConnectionFactory(objProps);
        } else if (type.equals(OBJMGR_TYPE_CF)) {
            newObj = JMSObjFactory.createConnectionFactory(objProps);
        } else if (type.equals(OBJMGR_TYPE_XTCF)) {
            newObj = JMSObjFactory.createXATopicConnectionFactory(objProps);
        } else if (type.equals(OBJMGR_TYPE_XQCF)) {
            newObj = JMSObjFactory.createXAQueueConnectionFactory(objProps);
        } else if (type.equals(OBJMGR_TYPE_XCF)) {
            newObj = JMSObjFactory.createXAConnectionFactory(objProps);
        }
    } catch (Exception e) {
        handleRunCommandExceptions(e, lookupName);
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_ADD_FAILED));
        return (1);
    }
    /*
         * Set this newly created obj to read-only if specified.
         */
    JMSObjFactory.doReadOnlyForAdd(newObj, objMgrProps.readOnlyValue());
    printAddCmdDescription(newObj, type, lookupName, osa, objMgrProps.readOnlyValue());
    os = createStore(osa);
    if (os == null) {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_ADD_FAILED));
        return (1);
    }
    /*
         * Prompt for missing authentication info BEFORE opening the store.
         */
    if (!force) {
        // Update ObjStoreAttrs in ths ObjStore if some security
        // info was missing.
        os = promptForAuthentication(os);
    }
    /*
         * Open/Initialize the object store
         */
    try {
        openStore(os);
    } catch (Exception e) {
        handleRunCommandExceptions(e, lookupName);
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_ADD_FAILED));
        return (1);
    }
    /*
         * If no -f option, check if the object already exists so we can confirm with user to overwrite.
         */
    if (!force) {
        try {
            object = os.retrieve(lookupName);
        } catch (NameNotFoundException nnfe) {
        // Make sure that this exception is NOT treated as an error for add
        } catch (Exception e) {
            handleRunCommandExceptions(e, lookupName);
            Globals.stdOutPrintln("");
            Globals.stdOutPrintln(ar.getString(ar.I_OBJ_ADD_FAILED));
            return (1);
        }
        // Object already exists so confirm with user.
        if (object != null) {
            Globals.stdOutPrintln(ar.getCString(ar.I_WARNING_MESG), ar.getString(ar.W_OBJ_ALREADY_EXISTS, lookupName));
            Globals.stdOutPrintln(ar.getCString(ar.I_WARNING_MESG), ar.getString(ar.W_ADD_OBJ_BE_OVERWRITTEN));
            input = getUserInput(ar.getString(ar.Q_OVERWRITE_OK), noShort);
        }
    }
    if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_ADDED));
    /*
             * Case where user typed 'y' or 'yes' to overwrite OR case where object doesn't exist yet so no confirmation needed OR
             * case where user used -f.
             */
    } else if ((yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input)) || (object == null) || (force)) {
        /*
             * Update the object in object store.
             */
        try {
            if (bindAttrs.size() > 0)
                os.add(lookupName, newObj, bindAttrs, true);
            else
                os.add(lookupName, newObj, true);
        } catch (NameAlreadyExistsException naee) {
        // Should never happen, since we pass true to add
        } catch (NameNotFoundException nnfe) {
            Globals.stdErrPrintln(ar.getString(ar.I_ERROR_MESG), ar.getKString(ar.E_CANNOT_LOC_TREE));
            exitcode = 1;
        } catch (Exception e) {
            handleRunCommandExceptions(e, lookupName);
            exitcode = 1;
        }
        if (exitcode == 0) {
            Globals.stdOutPrintln(ar.getString(ar.I_OBJ_ADDED));
        } else {
            Globals.stdOutPrintln("");
            Globals.stdOutPrintln(ar.getString(ar.I_OBJ_ADD_FAILED));
        }
    } else {
        Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_ADDED));
        exitcode = 1;
    }
    return (exitcode);
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) Attributes(javax.naming.directory.Attributes) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) AdministeredObject(com.sun.messaging.AdministeredObject) Properties(java.util.Properties) GeneralNamingException(com.sun.messaging.jmq.admin.objstore.GeneralNamingException) AuthenticationNotSupportedException(com.sun.messaging.jmq.admin.objstore.AuthenticationNotSupportedException) MissingVersionNumberException(com.sun.messaging.naming.MissingVersionNumberException) ReadOnlyPropertyException(com.sun.messaging.ReadOnlyPropertyException) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) InitializationException(com.sun.messaging.jmq.admin.objstore.InitializationException) AuthenticationException(com.sun.messaging.jmq.admin.objstore.AuthenticationException) SchemaViolationException(com.sun.messaging.jmq.admin.objstore.SchemaViolationException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException) UnsupportedVersionNumberException(com.sun.messaging.naming.UnsupportedVersionNumberException) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) NoPermissionException(com.sun.messaging.jmq.admin.objstore.NoPermissionException) CommunicationException(com.sun.messaging.jmq.admin.objstore.CommunicationException) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)

Example 8 with ObjStoreAttrs

use of com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs in project openmq by eclipse-ee4j.

the class CmdRunner method runDeleteCommand.

private int runDeleteCommand(ObjMgrProperties objMgrProps) {
    int exitcode = 0;
    /*
         * Get lookup Name.
         */
    String lookupName = objMgrProps.getLookupName();
    Object object = null;
    String input = null;
    ObjStore os;
    String yes, yesShort, no, noShort;
    yes = ar.getString(ar.Q_RESPONSE_YES);
    yesShort = ar.getString(ar.Q_RESPONSE_YES_SHORT);
    no = ar.getString(ar.Q_RESPONSE_NO);
    noShort = ar.getString(ar.Q_RESPONSE_NO_SHORT);
    /*
         * Check if -f (force) was specified on cmd line.
         */
    boolean force = objMgrProps.forceModeSet();
    ObjStoreAttrs osa = objMgrProps.getObjStoreAttrs();
    /*
         * Check for any mandatory bind attrs and display warning, if necessary.
         */
    checkObjStoreAttrs(osa);
    printDeleteCmdDescription(lookupName, osa);
    os = createStore(osa);
    if (os == null) {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_DELETE_FAILED));
        return (1);
    }
    /*
         * Prompt for missing authentication info BEFORE opening the store.
         */
    if (!force) {
        // Update ObjStoreAttrs in ths ObjStore if some security
        // info was missing.
        os = promptForAuthentication(os);
    }
    /*
         * Open/Initialize the object store.
         */
    try {
        openStore(os);
    } catch (Exception e) {
        handleRunCommandExceptions(e, lookupName);
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_DELETE_FAILED));
        return (1);
    }
    /*
         * Retrieve the object by its lookup name.
         */
    try {
        object = os.retrieve(lookupName);
    } catch (NameNotFoundException nnfe) {
        Globals.stdErrPrintln(ar.getKString(ar.E_CANNOT_LOC_OBJ, lookupName));
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_DELETE_FAILED));
        return (1);
    } catch (Exception e) {
        handleRunCommandExceptions(e, lookupName);
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_DELETE_FAILED));
        return (1);
    }
    /*
         * Delete the object if it exists.
         */
    if (object != null) {
        if (!force) {
            input = getUserInput(ar.getString(ar.Q_DELETE_OK), noShort);
        }
        if (yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input) || force) {
            try {
                os.delete(lookupName);
            } catch (Exception e) {
                handleRunCommandExceptions(e, lookupName);
                exitcode = 1;
            }
            if (exitcode == 0) {
                Globals.stdOutPrintln("");
                Globals.stdOutPrintln(ar.getString(ar.I_OBJ_DELETED));
            } else {
                Globals.stdOutPrintln("");
                Globals.stdOutPrintln(ar.getString(ar.I_OBJ_DELETE_FAILED));
            }
        } else if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
            Globals.stdOutPrintln("");
            Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_DELETED));
        } else {
            Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
            Globals.stdOutPrintln("");
            Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_DELETED));
            exitcode = 1;
        }
    } else {
        // object == null
        // Should not happen, since if the object cannot be retrieved,
        // it should throw NameNotFoundException
        Globals.stdErrPrintln(ar.getKString(ar.E_CANNOT_LOC_OBJ), lookupName);
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_DELETE_FAILED));
        exitcode = 1;
    }
    return (exitcode);
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) AdministeredObject(com.sun.messaging.AdministeredObject) GeneralNamingException(com.sun.messaging.jmq.admin.objstore.GeneralNamingException) AuthenticationNotSupportedException(com.sun.messaging.jmq.admin.objstore.AuthenticationNotSupportedException) MissingVersionNumberException(com.sun.messaging.naming.MissingVersionNumberException) ReadOnlyPropertyException(com.sun.messaging.ReadOnlyPropertyException) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) InitializationException(com.sun.messaging.jmq.admin.objstore.InitializationException) AuthenticationException(com.sun.messaging.jmq.admin.objstore.AuthenticationException) SchemaViolationException(com.sun.messaging.jmq.admin.objstore.SchemaViolationException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException) UnsupportedVersionNumberException(com.sun.messaging.naming.UnsupportedVersionNumberException) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) NoPermissionException(com.sun.messaging.jmq.admin.objstore.NoPermissionException) CommunicationException(com.sun.messaging.jmq.admin.objstore.CommunicationException) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)

Example 9 with ObjStoreAttrs

use of com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs in project openmq by eclipse-ee4j.

the class CmdRunner method runQueryCommand.

private int runQueryCommand(ObjMgrProperties objMgrProps) {
    int exitcode = 0;
    /*
         * Get Properties object containing obj attrs
         */
    String lookupName = objMgrProps.getLookupName();
    Object object = null;
    ObjStore os;
    /*
         * Check if -f (force) was specified on cmd line.
         */
    boolean force = objMgrProps.forceModeSet();
    ObjStoreAttrs osa = objMgrProps.getObjStoreAttrs();
    /*
         * Check for any mandatory bind attrs and display warning, if necessary.
         */
    checkObjStoreAttrs(osa);
    printQueryCmdDescription(lookupName, osa);
    os = createStore(osa);
    if (os == null) {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_QUERY_FAILED));
        return (1);
    }
    /*
         * Prompt for missing authentication info BEFORE opening the store.
         */
    if (!force) {
        // Update ObjStoreAttrs in ths ObjStore if some security
        // info was missing.
        os = promptForAuthentication(os);
    }
    /*
         * Open/Initialize the object store.
         */
    try {
        openStore(os);
    } catch (Exception e) {
        handleRunCommandExceptions(e, lookupName);
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_QUERY_FAILED));
        return (1);
    }
    /*
         * Retrieve the object by its lookup name.
         */
    try {
        object = os.retrieve(lookupName);
    } catch (NameNotFoundException nnfe) {
        Globals.stdErrPrintln(ar.getKString(ar.E_CANNOT_LOC_OBJ, lookupName));
        Globals.stdOutPrintln("");
        Globals.stdErrPrintln(ar.getString(ar.I_OBJ_QUERY_FAILED));
        return (1);
    } catch (Exception e) {
        handleRunCommandExceptions(e, lookupName);
        Globals.stdOutPrintln("");
        Globals.stdErrPrintln(ar.getString(ar.I_OBJ_QUERY_FAILED));
        return (1);
    }
    if (object != null) {
        /*
             * Print the object.
             */
        ObjMgrPrinter omp = new ObjMgrPrinter(2, 4);
        omp.printJMSObject(object);
        Globals.stdOutPrintln("");
        ObjMgrPrinter.printReadOnly(((AdministeredObject) object).isReadOnly());
    } else {
        // object == null
        // Should not happen, since if the object cannot be retrieved,
        // it should throw NameNotFoundException
        Globals.stdErrPrintln(ar.getKString(ar.E_CANNOT_LOC_OBJ, lookupName));
        exitcode = 1;
    }
    if (exitcode == 0) {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_QUERIED));
    } else {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_QUERY_FAILED));
    }
    return (exitcode);
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) AdministeredObject(com.sun.messaging.AdministeredObject) GeneralNamingException(com.sun.messaging.jmq.admin.objstore.GeneralNamingException) AuthenticationNotSupportedException(com.sun.messaging.jmq.admin.objstore.AuthenticationNotSupportedException) MissingVersionNumberException(com.sun.messaging.naming.MissingVersionNumberException) ReadOnlyPropertyException(com.sun.messaging.ReadOnlyPropertyException) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) InitializationException(com.sun.messaging.jmq.admin.objstore.InitializationException) AuthenticationException(com.sun.messaging.jmq.admin.objstore.AuthenticationException) SchemaViolationException(com.sun.messaging.jmq.admin.objstore.SchemaViolationException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException) UnsupportedVersionNumberException(com.sun.messaging.naming.UnsupportedVersionNumberException) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) NoPermissionException(com.sun.messaging.jmq.admin.objstore.NoPermissionException) CommunicationException(com.sun.messaging.jmq.admin.objstore.CommunicationException) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)

Example 10 with ObjStoreAttrs

use of com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs in project openmq by eclipse-ee4j.

the class CmdRunner method runUpdateCommand.

private int runUpdateCommand(ObjMgrProperties objMgrProps) {
    int exitcode = 0;
    String input = null;
    Object object = null;
    String type = null;
    ObjStore os;
    String yes, yesShort, no, noShort;
    yes = ar.getString(ar.Q_RESPONSE_YES);
    yesShort = ar.getString(ar.Q_RESPONSE_YES_SHORT);
    no = ar.getString(ar.Q_RESPONSE_NO);
    noShort = ar.getString(ar.Q_RESPONSE_NO_SHORT);
    /*
         * Get the lookup name
         */
    String lookupName = objMgrProps.getLookupName();
    /*
         * Check if -f (force) was specified on cmd line.
         */
    boolean force = objMgrProps.forceModeSet();
    ObjStoreAttrs osa = objMgrProps.getObjStoreAttrs();
    /*
         * Check for any mandatory bind attrs and display warning, if necessary.
         */
    checkObjStoreAttrs(osa);
    Properties objProps = objMgrProps.getObjProperties();
    type = objMgrProps.getObjType();
    Attributes bindAttrs = objMgrProps.getBindAttrs();
    printUpdateCmdDescription(type, lookupName, objProps, osa, objMgrProps.readOnlyValue());
    os = createStore(osa);
    if (os == null) {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_UPDATE_FAILED));
        return (1);
    }
    /*
         * Prompt for missing authentication info BEFORE opening the store.
         */
    if (!force) {
        // Update ObjStoreAttrs in ths ObjStore if some security
        // info was missing.
        os = promptForAuthentication(os);
    }
    /*
         * Open/Initialize the object store.
         */
    try {
        openStore(os);
    } catch (Exception e) {
        handleRunCommandExceptions(e, lookupName);
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_UPDATE_FAILED));
        return (1);
    }
    /*
         * Updates only work if the object already exists so check if one already exists.
         */
    try {
        object = os.retrieve(lookupName);
    } catch (NameNotFoundException nnfe) {
        Globals.stdErrPrintln(ar.getKString(ar.E_CANNOT_LOC_OBJ, lookupName));
        Globals.stdOutPrintln("");
        Globals.stdErrPrintln(ar.getString(ar.I_OBJ_UPDATE_FAILED));
        return (1);
    } catch (Exception e) {
        handleRunCommandExceptions(e, lookupName);
        Globals.stdOutPrintln("");
        Globals.stdErrPrintln(ar.getString(ar.I_OBJ_UPDATE_FAILED));
        return (1);
    }
    /*
         * Check here if the type being updated and the type specified match.
         */
    if (object != null) {
        type = checkObjectType(object, type);
        if (type == null) {
            Globals.stdOutPrintln("");
            Globals.stdErrPrintln(ar.getString(ar.I_OBJ_UPDATE_FAILED));
            return (1);
        }
    } else {
        // object == null
        // Should not happen, since if the object cannot be retrieved,
        // it should throw NameNotFoundException
        Globals.stdErrPrintln(ar.getKString(ar.E_CANNOT_LOC_OBJ, lookupName));
        Globals.stdOutPrintln("");
        Globals.stdErrPrintln(ar.getString(ar.I_OBJ_UPDATE_FAILED));
        return (1);
    }
    if (!force) {
        // was the case.
        if (object instanceof AdministeredObject) {
            AdministeredObject adminObj = (AdministeredObject) object;
            String curVersion = adminObj.getVERSION();
            String objVersion = adminObj.getStoredVersion();
            if (!adminObj.isStoredVersionCompatible()) {
                Globals.stdErrPrintln(ar.getString(ar.W_INCOMPATIBLE_OBJ, objVersion, curVersion));
            }
        }
        input = getUserInput(ar.getString(ar.Q_UPDATE_OK), noShort);
    }
    if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_UPDATED));
    /*
             * Case where user typed 'y' or 'yes' to overwrite OR case where object doesn't exist yet so no confirmation needed OR
             * case where user used -f.
             */
    } else if (((yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input)) || (force))) {
        /*
             * Update the object with the new properties.
             */
        Object updatedObject = updateObject(object, type, objMgrProps);
        if (updatedObject == null)
            return 1;
        /*
             * Add the object to object store.
             */
        try {
            if (bindAttrs.size() > 0)
                os.add(lookupName, updatedObject, bindAttrs, true);
            else
                os.add(lookupName, updatedObject, true);
        } catch (NameAlreadyExistsException naee) {
            // Should never happen, since we pass true to add
            exitcode = 1;
        } catch (Exception e) {
            handleRunCommandExceptions(e, lookupName);
            exitcode = 1;
        }
        if (exitcode == 0) {
            if (!force)
                Globals.stdErrPrintln("");
            Globals.stdOutPrintln(ar.getString(ar.I_OBJ_UPDATED));
        } else {
            Globals.stdErrPrintln("");
            Globals.stdErrPrintln(ar.getString(ar.I_OBJ_UPDATE_FAILED));
        }
    } else {
        Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
        Globals.stdErrPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_UPDATED));
        exitcode = 1;
    }
    return (exitcode);
}
Also used : AdministeredObject(com.sun.messaging.AdministeredObject) ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) Attributes(javax.naming.directory.Attributes) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) AdministeredObject(com.sun.messaging.AdministeredObject) Properties(java.util.Properties) GeneralNamingException(com.sun.messaging.jmq.admin.objstore.GeneralNamingException) AuthenticationNotSupportedException(com.sun.messaging.jmq.admin.objstore.AuthenticationNotSupportedException) MissingVersionNumberException(com.sun.messaging.naming.MissingVersionNumberException) ReadOnlyPropertyException(com.sun.messaging.ReadOnlyPropertyException) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) InitializationException(com.sun.messaging.jmq.admin.objstore.InitializationException) AuthenticationException(com.sun.messaging.jmq.admin.objstore.AuthenticationException) SchemaViolationException(com.sun.messaging.jmq.admin.objstore.SchemaViolationException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException) UnsupportedVersionNumberException(com.sun.messaging.naming.UnsupportedVersionNumberException) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) NoPermissionException(com.sun.messaging.jmq.admin.objstore.NoPermissionException) CommunicationException(com.sun.messaging.jmq.admin.objstore.CommunicationException) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)

Aggregations

ObjStoreAttrs (com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)27 ObjStore (com.sun.messaging.jmq.admin.objstore.ObjStore)13 InvalidPropertyException (com.sun.messaging.InvalidPropertyException)8 InvalidPropertyValueException (com.sun.messaging.InvalidPropertyValueException)8 ReadOnlyPropertyException (com.sun.messaging.ReadOnlyPropertyException)7 ObjStoreException (com.sun.messaging.jmq.admin.objstore.ObjStoreException)7 AuthenticationException (com.sun.messaging.jmq.admin.objstore.AuthenticationException)6 NameAlreadyExistsException (com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)6 NameNotFoundException (com.sun.messaging.jmq.admin.objstore.NameNotFoundException)6 AdministeredObject (com.sun.messaging.AdministeredObject)5 AuthenticationNotSupportedException (com.sun.messaging.jmq.admin.objstore.AuthenticationNotSupportedException)5 CommunicationException (com.sun.messaging.jmq.admin.objstore.CommunicationException)5 GeneralNamingException (com.sun.messaging.jmq.admin.objstore.GeneralNamingException)5 InitializationException (com.sun.messaging.jmq.admin.objstore.InitializationException)5 NoPermissionException (com.sun.messaging.jmq.admin.objstore.NoPermissionException)5 SchemaViolationException (com.sun.messaging.jmq.admin.objstore.SchemaViolationException)5 MissingVersionNumberException (com.sun.messaging.naming.MissingVersionNumberException)5 UnsupportedVersionNumberException (com.sun.messaging.naming.UnsupportedVersionNumberException)5 Enumeration (java.util.Enumeration)4 Properties (java.util.Properties)4