Search in sources :

Example 1 with MessageCatalog

use of com.vmware.vim.vasa._1_0.data.xsd.MessageCatalog in project coprhd-controller by CoprHD.

the class ContextManagerImpl method compileCatalogInformation.

private List<MessageCatalog> compileCatalogInformation(File catalog, List<MessageCatalog> mcList) throws StorageFault {
    final String methodName = "compileCatalogInformation(): ";
    log.trace(methodName + "Entry with input(s) catalog[" + catalog + "] mcList of size[" + mcList.size() + "]");
    if (catalog != null && catalog.exists()) {
        if (catalog.isDirectory()) {
            String[] children = catalog.list();
            for (int i = 0; i < children.length; i++) {
                compileCatalogInformation(new File(catalog, children[i]), mcList);
            }
        } else {
            try {
                MessageCatalog mc = new MessageCatalog();
                mc.setModuleName(Constants.VASA_BOURNE_PROVIDER_CATAGLOG_NAME);
                mc.setCatalogVersion(Constants.VASA_BOURNE_PROVIDER_CATAGLOG_VERSION);
                // Catalog Locale
                String catalogLocale = catalog.toURI().toString();
                catalogLocale = catalogLocale.substring(catalogLocale.indexOf("catalog") + 8, catalogLocale.lastIndexOf("/"));
                mc.setLocale(catalogLocale);
                // only event and alarm catalogs are required.
                if (catalog.getName().equalsIgnoreCase("event.vmsg")) {
                    mc.setCatalogName(StorageCatalogEnum.Event.getValue());
                } else if (catalog.getName().equalsIgnoreCase("alarm.vmsg")) {
                    mc.setCatalogName(StorageCatalogEnum.Alarm.getValue());
                } else if (catalog.getName().equalsIgnoreCase("fault.vmsg")) {
                    mc.setCatalogName(StorageCatalogEnum.Fault.getValue());
                } else {
                    log.warn(methodName + "catalog: " + catalog.getName() + " is not supported!");
                    log.trace(methodName + "Exit returning message catalog list of size[" + mcList.size() + "]");
                    return mcList;
                }
                // Catalog URI
                String catalogURI = CATALOG_CONTEXT_URI + catalogLocale + "/" + catalog.getName();
                mc.setCatalogUri(catalogURI);
                // Catalog Last Modified
                Calendar calendar = Calendar.getInstance();
                calendar.setTimeInMillis(catalog.lastModified());
                mc.setLastModified(calendar);
                mcList.add(mc);
            } catch (Exception e) {
                log.error(methodName + "Exception attempting to locate catalog files", e);
                throw FaultUtil.StorageFault("runtime", e);
            }
        }
    }
    log.trace(methodName + "Exit returning message catalog list of size[" + mcList.size() + "]");
    return mcList;
}
Also used : Calendar(java.util.Calendar) MessageCatalog(com.vmware.vim.vasa._1_0.data.xsd.MessageCatalog) File(java.io.File) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) CertificateExpiredException(java.security.cert.CertificateExpiredException)

Example 2 with MessageCatalog

use of com.vmware.vim.vasa._1_0.data.xsd.MessageCatalog in project coprhd-controller by CoprHD.

the class ContextManagerImpl method queryCatalog.

@Override
public MessageCatalog[] queryCatalog() throws StorageFault, InvalidSession {
    final String methodName = "queryCatalog(): ";
    log.debug(methodName + "Entry");
    // verify valid SSL and VASA Sessions.
    List<MessageCatalog> mcList = new ArrayList<MessageCatalog>();
    String fs = System.getProperty("file.separator");
    final String productHome = System.getProperty("product.home");
    final String catalogDirPath = productHome + fs + "lib" + fs + "storageos-vasasvc" + fs + "catalog";
    // Determine base Catalog directory
    String catalogDirStr = "";
    String catalinaHome = System.getProperty("server.home");
    if (catalinaHome != null) {
        // Ex: O:\Program Files\Apache\Tomcat 6.0
        catalogDirStr = catalogDirPath;
    } else {
        try {
            // Get the base dir of the running code
            URL url = getClass().getProtectionDomain().getCodeSource().getLocation();
            File catalogDir = new File(url.getPath());
            catalogDirStr = catalogDir.getCanonicalPath();
            if (catalogDirStr.contains("%20")) {
                catalogDirStr = catalogDirStr.replace("%20", " ");
            }
        } catch (Exception e) {
            log.error(methodName + "Exception attempting to locate catalog files", e);
            throw FaultUtil.StorageFault("runtime", e);
        }
    }
    if (catalogDirStr != null && catalogDirStr.length() > 0) {
        File catalogDir = new File(catalogDirStr);
        mcList = compileCatalogInformation(catalogDir, mcList);
    }
    log.debug(methodName + "Exit returning message catalog list of size[" + mcList.size() + "]");
    return (MessageCatalog[]) mcList.toArray(new MessageCatalog[0]);
}
Also used : ArrayList(java.util.ArrayList) MessageCatalog(com.vmware.vim.vasa._1_0.data.xsd.MessageCatalog) File(java.io.File) URL(java.net.URL) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) CertificateExpiredException(java.security.cert.CertificateExpiredException)

Aggregations

MessageCatalog (com.vmware.vim.vasa._1_0.data.xsd.MessageCatalog)2 File (java.io.File)2 CertificateExpiredException (java.security.cert.CertificateExpiredException)2 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1