Search in sources :

Example 16 with ObjStoreAttrs

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

the class CmdPreviewer method previewQueryCommand.

/*
     * Preview query command
     */
private void previewQueryCommand(ObjMgrProperties objMgrProps) {
    /*
         * Get object type, props object, and lookup name
         */
    // String type = objMgrProps.getObjType();
    ObjStoreAttrs osa = objMgrProps.getObjStoreAttrs();
    String lookupName = objMgrProps.getLookupName();
    Globals.stdOutPrintln(ar.getString(ar.I_PREVIEW_QUERY));
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(lookupName);
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_QUERY_CMD_DESC_STORE));
    Globals.stdOutPrintln("");
    ObjMgrPrinter omp = new ObjMgrPrinter(osa, 2, 4);
    omp.print();
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_QUERIED));
}
Also used : ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)

Example 17 with ObjStoreAttrs

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

the class CmdPreviewer method previewDeleteCommand.

/*
     * Preview delete command
     */
private void previewDeleteCommand(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();
    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_DELETE));
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(lookupName);
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_DELETE_CMD_DESC_STORE));
    Globals.stdOutPrintln("");
    ObjMgrPrinter omp = new ObjMgrPrinter(osa, 2, 4);
    omp.print();
    Globals.stdOutPrintln("");
    Globals.stdOutPrintln(ar.getString(ar.I_OBJ_NOT_DELETED));
}
Also used : ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)

Example 18 with ObjStoreAttrs

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

the class ObjStoreListProperties method getObjStoreAttrs.

/**
 * Returns a ObjStoreAttrs object containing the attributes that are relevant for creating an object store. These
 * attributes are normalized e.g. the preceding <EM>objstore.attrs.</EM> is stripped.
 *
 * @param index Index for specifying the object store in question.
 *
 * @return A ObjStoreAttrs object containing attributes needed for creation of an object store.
 */
public ObjStoreAttrs getObjStoreAttrs(int index) {
    // ObjStoreAttrs osa = new ObjStoreAttrs();
    ObjStoreAttrs osa;
    String basePropName, objstoreAttrsStr, idPropName, descPropName;
    String id, desc;
    int objstoreAttrsStrLen;
    basePropName = PROP_NAME_OBJSTORE_BASENAME + Integer.toString(index) + ".";
    idPropName = basePropName + PROP_NAME_OBJSTORE_ID_PREFIX;
    id = getProperty(idPropName, "");
    descPropName = basePropName + PROP_NAME_OBJSTORE_DESC_PREFIX;
    desc = getProperty(descPropName, "");
    osa = new ObjStoreAttrs(id, desc);
    /*
         * Construct string: objstore1.attrs.
         */
    objstoreAttrsStr = PROP_NAME_OBJSTORE_BASENAME + Integer.toString(index) + "." + PROP_NAME_OBJSTORE_ATTR_PREFIX + ".";
    objstoreAttrsStrLen = objstoreAttrsStr.length();
    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);
}
Also used : Enumeration(java.util.Enumeration) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)

Example 19 with ObjStoreAttrs

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

the class ConsoleObjStoreManager method writeObjStoresToFile.

/**
 * Writes ObjStores to files.
 */
public void writeObjStoresToFile() throws UserPropertiesException {
    // Must call ObjStoreAttrs.prepareToTerminate() prior to
    // storing
    Enumeration e = objStores.elements();
    ObjStoreListProperties oslProps = new ObjStoreListProperties();
    while (e.hasMoreElements()) {
        ObjStore os = (ObjStore) e.nextElement();
        ObjStoreAttrs osa = os.getObjStoreAttrs();
        osa.prepareToTerminate();
        oslProps.addObjStoreAttrs(osa);
    }
    writeToFile(oslProps);
}
Also used : Enumeration(java.util.Enumeration) ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)

Example 20 with ObjStoreAttrs

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

the class ObjAdminHandler method updateStore.

private ObjStore updateStore(ObjStore prevOs, String newName, ObjStoreManager osMgr, ObjStoreAttrs osa, boolean attemptToConnect) {
    ObjStore os = null;
    boolean created = false;
    if (osMgr == null || osa == null) {
        JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_PROCESS), acr.getString(acr.I_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_PROCESS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return (null);
    }
    /*
         * Update ObjStore
         */
    ObjStoreAttrs prevAttrs = prevOs.getObjStoreAttrs();
    os = osMgr.getStore(prevOs.getID());
    if (os == null) {
        JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_PROCESS), acr.getString(acr.I_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_PROCESS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
    }
    // 
    try {
        if (newName != null && os != null && !newName.equals(os.getID())) {
            os = osMgr.createStore(osa);
            created = true;
        } else if (os != null) {
            os.setObjStoreAttrs(osa);
        }
    } catch (Exception ex) {
        JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_OBJSTORE_PROPS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return null;
    }
    /*
         * Now try connecting to it (if they want to try). Then read in the objects from the store.
         */
    if (attemptToConnect) {
        try {
            if (os != null) {
                os.open();
            }
        } catch (Exception e) {
            JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_INSUFFICIENT_INFO, e.toString()), acr.getString(acr.I_OBJSTORE_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_INSUFFICIENT_INFO), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            // Don't update it, undo everything
            try {
                if (created) {
                    osMgr.destroyStore(osa.getID());
                } else {
                    // Reset old attrs back
                    os.setObjStoreAttrs(prevAttrs);
                }
            } catch (Exception ex) {
            }
            return null;
        }
    }
    // 
    if (os != null && created) {
        try {
            if (prevOs.isOpen()) {
                prevOs.close();
            }
            osMgr.destroyStore(prevOs.getID());
            if (!attemptToConnect && os.isOpen()) {
                os.close();
            }
        } catch (Exception ex) {
        }
    }
    // 
    if (os != null && !attemptToConnect && os.isOpen()) {
        try {
            os.close();
        } catch (Exception ex) {
        }
    }
    return (os);
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) 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

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