Search in sources :

Example 6 with ObjStore

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

the class ObjAdminHandler method doUpdateCredentials.

private void doUpdateCredentials(ObjAdminEvent oae, ConsoleObj selObj) {
    ObjStore os = oae.getObjStore();
    boolean success = finishDoConnectObjStore(selObj, os);
    if (success) {
        app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_CONNECT, selObj.toString()));
    }
    // Remove missing info that we just added.
    ObjStoreAttrs osa = oae.getObjStoreAttrs();
    Vector missingInfo = oae.getMissingAuthInfo();
    for (int i = 0; i < missingInfo.size(); i++) {
        String key = (String) missingInfo.elementAt(i);
        osa.remove(key);
    }
    try {
        os.setObjStoreAttrs(osa);
    } catch (ObjStoreException ose) {
        JOptionPane.showOptionDialog(app.getFrame(), ose.toString(), acr.getString(acr.I_OBJSTORE), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
    }
    if (success && oae.isOKAction()) {
        objStorePasswdDialog.setVisible(false);
    }
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) Vector(java.util.Vector)

Example 7 with ObjStore

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

the class ObjAdminHandler method doAddObjStore.

private void doAddObjStore(ObjAdminEvent oae) {
    ObjStoreAttrs osa = oae.getObjStoreAttrs();
    ObjStoreManager osMgr = app.getObjStoreListCObj().getObjStoreManager();
    boolean connect = oae.isConnectAttempt();
    ConsoleObj osCObj = null;
    /*
         * Create store and connect (if requested).
         */
    ObjStore os = createStore(osMgr, osa, connect);
    /*
         * If valid object store, then now try reading in any existing objects.
         */
    if (os != null) {
        osCObj = new ObjStoreCObj(os);
        if (os.isOpen()) {
            readObjStore(osCObj, os);
        }
    }
    /*
         * If os is still valid, then add it to the tree list.
         */
    if (osCObj != null) {
        app.getExplorer().addObjStore(osCObj);
        app.getInspector().refresh();
        app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_ADD, osCObj.toString()));
    }
    /*
         * Bring down the dialog if successful, otherwise keep it up.
         */
    if (oae.isOKAction() && os != null) {
        objStoreAddDialog.setVisible(false);
    }
    saveObjStoreList();
}
Also used : ObjStoreManager(com.sun.messaging.jmq.admin.objstore.ObjStoreManager) ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)

Example 8 with ObjStore

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

the class ObjStorePropsDialog method constructAttrs.

private ObjStoreAttrs constructAttrs(String osName) {
    ObjStore os = osCObj.getObjStore();
    // 
    // If they changed the os name to something else,
    // make sure it doesn't already exist.
    // 
    String prevOsName = os.getID();
    if (// they changed it
    !prevOsName.equals(osName) && osMgr != null && osMgr.getStore(osName) != null) {
        JOptionPane.showOptionDialog(this, acr.getString(acr.E_OBJSTORE_NAME_IN_USE, osName), acr.getString(acr.I_OBJSTORE_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OBJSTORE_NAME_IN_USE), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        osText.requestFocus();
        osText.selectAll();
        return (null);
    }
    ObjStoreAttrs osa = new ObjStoreAttrs(osName, osName);
    if (jndiProps == null) {
        return (osa);
    }
    // Check for any properties that MUST be set.
    if (checkMandatoryProps() == 0) {
        return null;
    }
    for (java.util.Enumeration e = jndiProps.propertyNames(); e.hasMoreElements(); ) {
        String propName = (String) e.nextElement();
        osa.put(propName, jndiProps.getProperty(propName));
    }
    return (osa);
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)

Example 9 with ObjStore

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

the class ObjStoreDestPropsDialog method doOK.

@Override
public void doOK() {
    Object object = osDestCObj.getObject();
    // was the case.
    if (object instanceof AdministeredObject) {
        AdministeredObject adminObj = (AdministeredObject) object;
        String curVersion = adminObj.getVERSION();
        String objVersion = adminObj.getStoredVersion();
        if (!adminObj.isStoredVersionCompatible()) {
            int response = JOptionPane.showOptionDialog(this, acr.getString(acr.W_INCOMPATIBLE_OBJ, objVersion, curVersion), acr.getString(acr.I_OBJSTORE_DEST_PROPS) + ": " + acr.getString(acr.I_WARNING_CODE, acr.W_INCOMPATIBLE_OBJ), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, okcancel, okcancel[1]);
            if (response == JOptionPane.NO_OPTION) {
                return;
            }
        }
    }
    String lookupName = lookupLabel.getText();
    lookupName = lookupName.trim();
    if (lookupName == null || lookupName.equals("")) {
        JOptionPane.showOptionDialog(this, acr.getString(acr.E_NO_LOOKUP_NAME), acr.getString(acr.I_OBJSTORE_DEST_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_NO_LOOKUP_NAME), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return;
    }
    int type = ObjAdminEvent.QUEUE;
    AdministeredObject tempObj = null;
    if (destLabel.getText().equals(acr.getString(acr.I_QUEUE))) {
        type = ObjAdminEvent.QUEUE;
        tempObj = new com.sun.messaging.Queue();
    } else if (destLabel.getText().equals(acr.getString(acr.I_TOPIC))) {
        type = ObjAdminEvent.TOPIC;
        tempObj = new com.sun.messaging.Topic();
    }
    /*
         * Object Properties (dest name, ...);
         */
    int i = 0;
    Properties props = tempObj.getConfiguration();
    for (Enumeration e = tempObj.enumeratePropertyNames(); e.hasMoreElements(); i++) {
        String propName = (String) e.nextElement();
        String value = textItems[i].getText();
        value = value.trim();
        // so no need to set to "".
        if (!(value.trim()).equals("")) {
            props.put(propName, value);
        }
    }
    ObjAdminEvent oae = new ObjAdminEvent(this, ObjAdminEvent.UPDATE_DESTINATION);
    ObjStore os = osDestCObj.getObjStore();
    /*
         * Set values in the event.
         */
    oae.setLookupName(lookupName);
    oae.setObjStore(os);
    oae.setDestinationType(type);
    oae.setObjProperties(props);
    if (checkBox.isSelected()) {
        oae.setReadOnly(true);
    } else {
        oae.setReadOnly(false);
    }
    oae.setOKAction(true);
    fireAdminEventDispatched(oae);
}
Also used : Enumeration(java.util.Enumeration) ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjAdminEvent(com.sun.messaging.jmq.admin.apps.console.event.ObjAdminEvent) Properties(java.util.Properties) AdministeredObject(com.sun.messaging.AdministeredObject) AdministeredObject(com.sun.messaging.AdministeredObject)

Example 10 with ObjStore

use of com.sun.messaging.jmq.admin.objstore.ObjStore 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)

Aggregations

ObjStore (com.sun.messaging.jmq.admin.objstore.ObjStore)29 ObjStoreException (com.sun.messaging.jmq.admin.objstore.ObjStoreException)17 NameNotFoundException (com.sun.messaging.jmq.admin.objstore.NameNotFoundException)16 InvalidPropertyException (com.sun.messaging.InvalidPropertyException)15 InvalidPropertyValueException (com.sun.messaging.InvalidPropertyValueException)15 AuthenticationException (com.sun.messaging.jmq.admin.objstore.AuthenticationException)15 NameAlreadyExistsException (com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)15 ObjStoreAttrs (com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)13 AdministeredObject (com.sun.messaging.AdministeredObject)8 Properties (java.util.Properties)8 ReadOnlyPropertyException (com.sun.messaging.ReadOnlyPropertyException)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 ObjAdminEvent (com.sun.messaging.jmq.admin.apps.console.event.ObjAdminEvent)4