Search in sources :

Example 1 with ObjStore

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

the class ObjAdminHandler method doAddConnFactory.

private void doAddConnFactory(ObjAdminEvent oae, ConsoleObj selObj) {
    Object object = null;
    ObjStore os = oae.getObjStore();
    int factoryType = oae.getFactoryType();
    String lookupName = oae.getLookupName();
    Properties objProps = oae.getObjProperties();
    boolean readOnly = oae.isReadOnly();
    boolean overwrite = false;
    if (os.isOpen()) {
        Object newObj = null;
        try {
            if (factoryType == ObjAdminEvent.QCF) {
                newObj = JMSObjFactory.createQueueConnectionFactory(objProps);
            } else if (factoryType == ObjAdminEvent.TCF) {
                newObj = JMSObjFactory.createTopicConnectionFactory(objProps);
            } else if (factoryType == ObjAdminEvent.CF) {
                newObj = JMSObjFactory.createConnectionFactory(objProps);
            } else if (factoryType == ObjAdminEvent.XAQCF) {
                newObj = JMSObjFactory.createXAQueueConnectionFactory(objProps);
            } else if (factoryType == ObjAdminEvent.XATCF) {
                newObj = JMSObjFactory.createXATopicConnectionFactory(objProps);
            } else if (factoryType == ObjAdminEvent.XACF) {
                newObj = JMSObjFactory.createXAConnectionFactory(objProps);
            }
        } catch (Exception e) {
            handleExceptions(e, acr.I_ADD_OBJSTORE_CF);
            return;
        }
        /*
             * Set this newly created obj to read-only if specified.
             */
        if (readOnly) {
            JMSObjFactory.doReadOnlyForAdd(newObj, "true");
        } else {
            JMSObjFactory.doReadOnlyForAdd(newObj, "false");
        }
        // 
        try {
            object = os.retrieve(lookupName);
        } catch (NameNotFoundException nnfe) {
        // Make sure that this exception is NOT treated as an error for add
        } catch (Exception ex) {
            JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_ADD_OBJSTORE_CF), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            return;
        }
        // Object already exists so confirm with user.
        if (object != null) {
            int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_LOOKUP_NAME_EXISTS, lookupName), acr.getString(acr.I_ADD_OBJSTORE_CF), JOptionPane.YES_NO_OPTION);
            if (result == JOptionPane.NO_OPTION) {
                return;
            } else {
                overwrite = true;
            }
        }
        try {
            os.add(lookupName, newObj, true);
        } catch (Exception ex) {
            JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_ADD_OBJSTORE_CF), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            return;
        }
        /*
             * If already exists, the delete old tree node before adding.
             */
        if (overwrite) {
            removeChild(selObj, lookupName);
            removeChild((ConsoleObj) selObj.getParent().getChildAt(0), lookupName);
        }
        ObjStoreConFactoryCObj conFacCObj = new ObjStoreConFactoryCObj((ObjStoreCObj) selObj.getParent(), lookupName, newObj);
        app.getExplorer().addToParent(selObj, conFacCObj);
        app.getInspector().refresh();
        app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_ADD_CF, lookupName, os.getID()));
        if (oae.isOKAction()) {
            objStoreConFactoryAddDialog.setVisible(false);
        }
    }
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) Properties(java.util.Properties) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) AuthenticationException(com.sun.messaging.jmq.admin.objstore.AuthenticationException) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)

Example 2 with ObjStore

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

the class ObjStoreConFactoryPropsDialog method doOK.

@Override
public void doOK() {
    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_CF_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.QCF;
    AdministeredObject tempObj = null;
    if (cfLabel.getText().equals(acr.getString(acr.I_QCF))) {
        type = ObjAdminEvent.QCF;
        tempObj = new com.sun.messaging.QueueConnectionFactory();
    } else if (cfLabel.getText().equals(acr.getString(acr.I_TCF))) {
        type = ObjAdminEvent.TCF;
        tempObj = new com.sun.messaging.TopicConnectionFactory();
    } else if (cfLabel.getText().equals(acr.getString(acr.I_CF))) {
        type = ObjAdminEvent.CF;
        tempObj = new com.sun.messaging.ConnectionFactory();
    } else if (cfLabel.getText().equals(acr.getString(acr.I_XAQCF))) {
        type = ObjAdminEvent.XAQCF;
        tempObj = new com.sun.messaging.XAQueueConnectionFactory();
    } else if (cfLabel.getText().equals(acr.getString(acr.I_XATCF))) {
        type = ObjAdminEvent.XATCF;
        tempObj = new com.sun.messaging.XATopicConnectionFactory();
    } else if (cfLabel.getText().equals(acr.getString(acr.I_XACF))) {
        type = ObjAdminEvent.XACF;
        tempObj = new com.sun.messaging.XAConnectionFactory();
    }
    /*
         * Conn Factory Object Properties. Go through each of the cfProps, get the userdata which is the property name, get the
         * value, set it in props.
         */
    Properties props = tempObj.getConfiguration();
    String propName, propValue, propType = null, propLabel = null;
    for (int i = 0; i < cfProps.size(); i++) {
        LabelledComponent cfItem = (LabelledComponent) cfProps.elementAt(i);
        propName = (String) cfItem.getClientData();
        if (propName == null) {
            continue;
        }
        // Remove this propName from the props, no longer applies.
        if (!(cfItem.getComponent().isEnabled())) {
            props.remove(propName);
            continue;
        }
        try {
            propType = tempObj.getPropertyType(propName);
            propLabel = tempObj.getPropertyLabel(propName);
        } catch (jakarta.jms.JMSException jmsex) {
            JOptionPane.showOptionDialog(this, jmsex.toString(), acr.getString(acr.I_OBJSTORE_CF_PROPS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            return;
        }
        if (propType == null) {
            continue;
        }
        propValue = getValue(cfItem.getComponent(), propType).trim();
        // so no need to set to "".
        if (propValue.equals("")) {
            continue;
        }
        try {
            // Calling setProperty() will verify if this value is valid.
            tempObj.setProperty(propName, propValue.trim());
            props.put(propName, propValue.trim());
        } catch (jakarta.jms.JMSException jmsex) {
            if (jmsex instanceof com.sun.messaging.InvalidPropertyValueException) {
                JOptionPane.showOptionDialog(this, acr.getString(acr.E_INVALID_VALUE, propLabel), acr.getString(acr.I_OBJSTORE_CF_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_INVALID_VALUE), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            } else {
                JOptionPane.showOptionDialog(this, jmsex.toString(), acr.getString(acr.I_OBJSTORE_CF_PROPS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            }
            return;
        }
    }
    ObjAdminEvent oae = new ObjAdminEvent(this, ObjAdminEvent.UPDATE_CONN_FACTORY);
    ObjStore os = osConFactoryCObj.getObjStore();
    /*
         * Set values in the event.
         */
    oae.setLookupName(lookupName);
    oae.setObjStore(os);
    oae.setFactoryType(type);
    oae.setObjProperties(props);
    if (checkBox.isSelected()) {
        oae.setReadOnly(true);
    } else {
        oae.setReadOnly(false);
    }
    oae.setOKAction(true);
    fireAdminEventDispatched(oae);
}
Also used : 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) LabelledComponent(com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent)

Example 3 with ObjStore

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

the class ObjAdminHandler method doDisconnectObjStore.

private void doDisconnectObjStore(ConsoleObj selObj) {
    ObjStore os = ((ObjStoreCObj) selObj).getObjStore();
    if (!os.isOpen()) {
        JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_ALREADY_DISCONNECTED, selObj.toString()), acr.getString(acr.I_DISCONNECT_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_ALREADY_DISCONNECTED), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return;
    }
    try {
        os.close();
    } catch (Exception e) {
        JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_UNABLE_DISCONNECT, selObj.toString()), acr.getString(acr.I_DISCONNECT_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_UNABLE_DISCONNECT), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return;
    }
    /*
         * Remove all destination/connection factory objects from this object store node hierarchy
         */
    clearStore(selObj);
    app.getExplorer().nodeChanged(selObj);
    app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_DISCONNECT, selObj.toString()));
    // XXX This causes selection to go away if selected in inspector
    app.getInspector().refresh();
    app.getInspector().selectedObjectUpdated();
    // Update menu items, buttons.
    controller.setActions(selObj);
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) AuthenticationException(com.sun.messaging.jmq.admin.objstore.AuthenticationException) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)

Example 4 with ObjStore

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

the class ObjAdminHandler method doConnectObjStore.

private void doConnectObjStore(ConsoleObj selObj) {
    ObjStore os = ((ObjStoreCObj) selObj).getObjStore();
    if (os.isOpen()) {
        JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_ALREADY_CONNECTED, selObj.toString()), acr.getString(acr.I_CONNECT_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_ALREADY_CONNECTED), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return;
    }
    /*
         * 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();
    if (missingAuthInfoSize > 0) {
        if (objStorePasswdDialog == null && missingAuthInfoSize > 0) {
            objStorePasswdDialog = new ObjStorePasswdDialog(app.getFrame());
            objStorePasswdDialog.addAdminEventListener(this);
            objStorePasswdDialog.setLocationRelativeTo(app.getFrame());
        }
        if (missingAuthInfoSize > 0) {
            objStorePasswdDialog.show(os, missingAuthInfo);
        }
    } else {
        boolean success = finishDoConnectObjStore(selObj, os);
        if (success) {
            app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_CONNECT, selObj.toString()));
        }
    }
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) Vector(java.util.Vector)

Example 5 with ObjStore

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

the class ObjAdminHandler method doAddDestination.

private void doAddDestination(ObjAdminEvent oae, ConsoleObj selObj) {
    Object object = null;
    ObjStore os = oae.getObjStore();
    int destType = oae.getDestinationType();
    String lookupName = oae.getLookupName();
    Properties objProps = oae.getObjProperties();
    boolean readOnly = oae.isReadOnly();
    boolean overwrite = false;
    if (os.isOpen()) {
        Object newObj = null;
        try {
            if (destType == ObjAdminEvent.TOPIC) {
                newObj = JMSObjFactory.createTopic(objProps);
            } else if (destType == ObjAdminEvent.QUEUE) {
                newObj = JMSObjFactory.createQueue(objProps);
            }
        } catch (Exception e) {
            handleExceptions(e, acr.I_ADD_OBJSTORE_DEST);
            return;
        }
        /*
             * Set this newly created obj to read-only if specified.
             */
        if (readOnly) {
            JMSObjFactory.doReadOnlyForAdd(newObj, "true");
        } else {
            JMSObjFactory.doReadOnlyForAdd(newObj, "false");
        }
        // 
        try {
            object = os.retrieve(lookupName);
        } catch (NameNotFoundException nnfe) {
        // Make sure that this exception is NOT treated as an error for add
        } catch (Exception ex) {
            JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_ADD_OBJSTORE_DEST), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            return;
        }
        // Object already exists so confirm with user.
        if (object != null) {
            int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_LOOKUP_NAME_EXISTS, lookupName), acr.getString(acr.I_ADD_OBJSTORE_DEST), JOptionPane.YES_NO_OPTION);
            if (result == JOptionPane.NO_OPTION) {
                return;
            } else {
                overwrite = true;
            }
        }
        try {
            os.add(lookupName, newObj, true);
        } catch (Exception ex) {
            JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_ADD_OBJSTORE_DEST), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            return;
        }
        /*
             * If already exists, the delete old tree node before adding.
             */
        if (overwrite) {
            removeChild(selObj, lookupName);
            removeChild((ConsoleObj) selObj.getParent().getChildAt(1), lookupName);
        }
        ObjStoreDestCObj destCObj = new ObjStoreDestCObj((ObjStoreCObj) selObj.getParent(), lookupName, newObj);
        app.getExplorer().addToParent(selObj, destCObj);
        app.getInspector().refresh();
        app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_ADD_DEST, lookupName, os.getID()));
        if (oae.isOKAction()) {
            objStoreDestAddDialog.setVisible(false);
        }
    }
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) Properties(java.util.Properties) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) AuthenticationException(com.sun.messaging.jmq.admin.objstore.AuthenticationException) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) 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