Search in sources :

Example 11 with ObjStoreAttrs

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

the class CmdPreviewer method previewListCommand.

/*
     * Preview list command
     */
private void previewListCommand(ObjMgrProperties objMgrProps) {
    /*
         * Get object type, props object, and lookup name
         */
    String type = objMgrProps.getObjType();
    ObjStoreAttrs osa = objMgrProps.getObjStoreAttrs();
    // String lookupName = objMgrProps.getLookupName();
    String typeString = Utils.getObjTypeString(type);
    if (typeString != null) {
        Globals.stdOutPrintln(ar.getString(ar.I_PREVIEW_LIST_TYPE, typeString));
    } else {
        Globals.stdOutPrintln(ar.getString(ar.I_PREVIEW_LIST));
    }
    Globals.stdOutPrintln("");
    ObjMgrPrinter omp = new ObjMgrPrinter(osa, 2, 4);
    omp.print();
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_LISTED));
}
Also used : ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)

Example 12 with ObjStoreAttrs

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

the class CmdPreviewer method previewUpdateCommand.

/*
     * Preview update command
     */
private void previewUpdateCommand(ObjMgrProperties objMgrProps) {
    /*
         * Get object type, props object, and lookup name
         */
    String type = objMgrProps.getObjType();
    Properties objProps = objMgrProps.getObjProperties();
    ObjStoreAttrs osa = objMgrProps.getObjStoreAttrs();
    String lookupName = objMgrProps.getLookupName();
    /*
         * Check if -f (force) was specified on cmd line.
         */
    boolean force = objMgrProps.forceModeSet();
    String typeString = Utils.getObjTypeString(type);
    if (force)
        Globals.stdOutPrintln(ar.getString(ar.I_PROMPT_OFF));
    else
        Globals.stdOutPrintln(ar.getString(ar.I_PROMPT_ON));
    Globals.stdOutPrintln("");
    if (typeString != null) {
        /*
             * Create JMS Object with the specified properties. We don't really need to print all the object's attributes since we
             * only want to show the attributes that will be updated. These attributes are stored in 'objProps'. The JMS Object is
             * created here so we can get a hold of the attribute/property labels.
             */
        try {
            if (type.equals(OBJMGR_TYPE_QUEUE)) {
                JMSObjFactory.createQueue(objProps);
            } else if (type.equals(OBJMGR_TYPE_TOPIC)) {
                JMSObjFactory.createTopic(objProps);
            } else if (type.equals(OBJMGR_TYPE_XQCF)) {
                JMSObjFactory.createXAQueueConnectionFactory(objProps);
            } else if (type.equals(OBJMGR_TYPE_XTCF)) {
                JMSObjFactory.createXATopicConnectionFactory(objProps);
            } else if (type.equals(OBJMGR_TYPE_XCF)) {
                JMSObjFactory.createXAConnectionFactory(objProps);
            } else if (type.equals(OBJMGR_TYPE_QCF)) {
                JMSObjFactory.createQueueConnectionFactory(objProps);
            } else if (type.equals(OBJMGR_TYPE_TCF)) {
                JMSObjFactory.createTopicConnectionFactory(objProps);
            } else if (type.equals(OBJMGR_TYPE_CF)) {
                JMSObjFactory.createConnectionFactory(objProps);
            }
        } catch (Exception e) {
            handleRunCommandExceptions(e, lookupName);
            Globals.stdOutPrintln("");
            Globals.stdOutPrintln(ar.getString(ar.I_OBJ_PREV_UPDATE_FAILED));
            return;
        }
        Globals.stdOutPrintln(ar.getString(ar.I_PREVIEW_UPDATE_TYPE, typeString));
        Globals.stdOutPrintln("");
        ObjMgrPrinter omp = new ObjMgrPrinter(objProps, 2, 4);
        omp.print();
    } else {
        Globals.stdOutPrintln(ar.getString(ar.I_PREVIEW_UPDATE));
        Globals.stdOutPrintln("");
        ObjMgrPrinter omp = new ObjMgrPrinter(objProps, 2, 4);
        omp.print();
    }
    Globals.stdOutPrintln("");
    ObjMgrPrinter.printReadOnly(objMgrProps.readOnlyValue());
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_WITH_LOOKUP_NAME));
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(lookupName);
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_UPDATE_CMD_DESC_STORE));
    Globals.stdOutPrintln("");
    ObjMgrPrinter omp = new ObjMgrPrinter(osa, 2, 4);
    omp.print();
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_UPDATED));
}
Also used : ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) Properties(java.util.Properties) ReadOnlyPropertyException(com.sun.messaging.ReadOnlyPropertyException) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException)

Example 13 with ObjStoreAttrs

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

the class CmdPreviewer method previewAddCommand.

/*
     * Preview add command
     */
private void previewAddCommand(ObjMgrProperties objMgrProps) {
    /*
         * Get object type, props object, and lookup name
         */
    String type = objMgrProps.getObjType();
    Properties objProps = objMgrProps.getObjProperties();
    ObjStoreAttrs osa = objMgrProps.getObjStoreAttrs();
    String lookupName = objMgrProps.getLookupName();
    /*
         * 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_XQCF)) {
            newObj = JMSObjFactory.createXAQueueConnectionFactory(objProps);
        } else if (type.equals(OBJMGR_TYPE_XTCF)) {
            newObj = JMSObjFactory.createXATopicConnectionFactory(objProps);
        } else if (type.equals(OBJMGR_TYPE_XCF)) {
            newObj = JMSObjFactory.createXAConnectionFactory(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);
        }
    } catch (Exception e) {
        handleRunCommandExceptions(e, lookupName);
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_PREV_ADD_FAILED));
        return;
    }
    if (force)
        Globals.stdOutPrintln(ar.getString(ar.I_PROMPT_OFF));
    else
        Globals.stdOutPrintln(ar.getString(ar.I_PROMPT_ON));
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_PREVIEW_ADD, Utils.getObjTypeString(type)));
    Globals.stdOutPrintln("");
    ObjMgrPrinter omp = new ObjMgrPrinter(2, 4);
    omp.printObjPropertiesFromObj((AdministeredObject) newObj);
    Globals.stdOutPrintln("");
    ObjMgrPrinter.printReadOnly(objMgrProps.readOnlyValue());
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_ADD_CMD_DESC_LOOKUP));
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(lookupName);
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_ADD_CMD_DESC_STORE));
    Globals.stdOutPrintln("");
    ObjMgrPrinter omp2 = new ObjMgrPrinter(osa, 2, 4);
    omp2.print();
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_ADDED));
}
Also used : ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) AdministeredObject(com.sun.messaging.AdministeredObject) Properties(java.util.Properties) ReadOnlyPropertyException(com.sun.messaging.ReadOnlyPropertyException) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException)

Example 14 with ObjStoreAttrs

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

the class ObjMgrProperties method getObjStoreAttrs.

/**
 * Returns a ObjStoreAttrs object containing the attributes that are relevant for creating an object store. These
 * attributes are also normalized e.g. the preceding <EM>objstore.attrs.</EM> is stripped.
 *
 * @param commandIndex Index for specifyng which command (for the case where multiple commands exist in the same
 * ObjMgrProperties object).
 *
 * @return A ObjStoreAttrs object containing attributes needed for creation of an object store.
 */
public ObjStoreAttrs getObjStoreAttrs(int commandIndex) {
    ObjStoreAttrs osa = new ObjStoreAttrs();
    String objstoreAttrsStr = OBJMGR_OBJSTORE_ATTRS_PROP_NAME + ".";
    int objstoreAttrsStrLen = objstoreAttrsStr.length();
    if (commandIndex == -1) {
        for (Enumeration e = propertyNames(); e.hasMoreElements(); ) {
            String propName = (String) e.nextElement();
            if (propName.startsWith(objstoreAttrsStr)) {
                String newPropName, value;
                newPropName = propName.substring(objstoreAttrsStrLen);
                value = getProperty(propName);
                osa.put(newPropName, value);
            }
        }
        return (osa);
    }
    return (null);
}
Also used : Enumeration(java.util.Enumeration) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)

Example 15 with ObjStoreAttrs

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

the class CmdRunner method runListCommand.

private int runListCommand(ObjMgrProperties objMgrProps) {
    int exitcode = 0;
    /*
         * Check if a type was specified otherwise just list all jms objs.
         */
    ObjStore os;
    String type = objMgrProps.getObjType();
    ObjStoreAttrs osa = objMgrProps.getObjStoreAttrs();
    /*
         * Check for any mandatory bind attrs and display warning, if necessary.
         */
    checkObjStoreAttrs(osa);
    /*
         * Check if -f (force) was specified on cmd line.
         */
    boolean force = objMgrProps.forceModeSet();
    printListCmdDescription(type, osa);
    os = createStore(osa);
    if (os == null) {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_LIST_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);
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_LIST_FAILED));
        return (1);
    }
    if (type != null) {
        exitcode = listByType(os, type);
    } else {
        exitcode = listAll(os);
    }
    if (exitcode == 0) {
        Globals.stdOutPrintln("");
        Globals.stdOutPrintln(ar.getString(ar.I_OBJ_LISTED));
    } else {
        Globals.stdOutPrintln("");
        Globals.stdErrPrintln(ar.getString(ar.I_OBJ_LIST_FAILED));
    }
    return (exitcode);
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) 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