Package com.volantis.mcs.repository

Examples of com.volantis.mcs.repository.RepositoryException


                // (which is called by the constructor).
                standardPropsOut = archive.getOutputTo(standardPropertiesPath);
                try {
                    standardProps.store(standardPropsOut, null);
                } catch (IOException e) {
                    throw new RepositoryException(e);
                }

                if (customProps.size() > 0) {
                    // The properties path will already be set if there were
                    // any custom properties in the repository. Otherwise,
                    // these are the first custom properties to be defined and
                    // written, so set the custom path to a suitable default.
                    if (customPropertiesPath == null) {
                        customPropertiesPath =
                                DeviceRepositoryConstants.CUSTOM_POLICIES_PROPERTIES_PREFIX +
                                DeviceRepositoryConstants.POLICIES_PROPERTIES_SUFFIX;
                    }
                    customPropsOut = archive.getOutputTo(customPropertiesPath);
                    try {
                        customProps.store(customPropsOut, null);
                    } catch (IOException e) {
                        throw new RepositoryException(e);
                    }
                }

                repositoryArchive = archive;
            }
        } finally {
            if (standardPropsOut != null) {
                try {
                    standardPropsOut.close();
                } catch (IOException e) {
                    throw new RepositoryException(e);
                }
            }
            if (customPropsOut != null) {
                try {
                    customPropsOut.close();
                } catch (IOException e) {
                    throw new RepositoryException(e);
                }
            }
        }
    }
View Full Code Here


            throw new IllegalArgumentException(
                    "deviceName cannot be null or empty.");
        }
        // We do not permit more than one device to have the same name...
        if (deviceExists(deviceName)) {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-already-exists",
                            deviceName));
        }
        // Verify that we have a valid fallback. If the fallback is null
        // assume that we are adding the device to the root.
        Element parent = null;
        if (fallback == null) {
            parent = xmlHierarchyDocument.getRootElement();

            // Cannot add more that one root device name.
            List children = parent.getChildren();
            if ((children != null) && (children.size() > 0)) {
                throw new RepositoryException(
                        exceptionLocalizer.format(
                                "device-hierarchy-only-one-root"));
            }
        } else {
            parent = getHierarchyDeviceElement(fallback);
        }
        if (parent != null) {
            // create the device element and add it to it's parent
            parent.addContent(createDeviceElement(
                    deviceName,
                    xmlHierarchyDocument.getRootElement().getNamespace()));
        } else {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-fallback-invalid",
                            new Object[]{fallback,
                                         deviceName}));
        }
View Full Code Here

        }

        try {
            result = builder.build(inputStream);
        } catch (JDOMException e) {
            throw new RepositoryException(e);
        } catch (IOException e) {
            throw new RepositoryException(e);
        }
        return result;
    }
View Full Code Here

    private static String queryRepository(File repositoryFile,
                                          String zipEntryName,
                                          DeviceRepositoryQuery query)
            throws RepositoryException {
        if (!repositoryFile.canRead()) {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "file-cannot-be-read",
                            repositoryFile));
        }

        InputStream is = null;
        String queryResult = null;
        try {
            ZipFile repositoryZip =
                    new ZipFile(repositoryFile, ZipFile.OPEN_READ);
            ZipEntry versionEntry = repositoryZip.getEntry(zipEntryName);
            is = repositoryZip.getInputStream(versionEntry);
            queryResult = query.doQuery(is);
        } catch (IOException e) {
            logger.error("unexpected-ioexception", e);
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "unexpected-ioexception"),
                    e);
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    logger.error("unexpected-ioexception", e);
                    if (queryResult != null) {
                        // A null queryResult would indicate that another exception
                        // was thrown so only throw on a close() exception if this
                        // has not happened to avoid hiding the real problem.
                        throw new RepositoryException(
                                exceptionLocalizer.format(
                                        "unexpected-ioexception"),
                                e);
                    }
                }
View Full Code Here

            // Read the document file and create the document using the
            // xml document factory provided.
            document = createNewDocument(new BufferedInputStream(input),
                    jdomFactory, false, false);
        } else {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-repository-file-missing",
                            documentFile));
        }
View Full Code Here

        }

        InternalDevice device = deviceReader.getDevice(deviceName);

        if (device == null) {
            throw new RepositoryException(exceptionLocalizer.format(
                    "unknown-device-exception",
                    deviceName));
        }

        return device;
View Full Code Here

        Policy policy;
        try {
          policy = srcPolicyAccessor.retrievePolicy(name);
        } catch (RepositoryException e) {
            // Try to report the name of the policy we couldn't read
            throw new RepositoryException(
                    exceptionLocalizer.format("policy-read-failure",
                                              name),
                    e);
        }
        if (policy == null) {
View Full Code Here

            throws RepositoryException {
        try {
            accessor.updatePolicy(policy);
        } catch (RepositoryException e) {
            // Try and report the object we failed to update.
            throw new RepositoryException(
                    exceptionLocalizer.format("policy-update-failure",
                    policy.getName()),
                    e);
        }
    }
View Full Code Here

        throws RepositoryException {

        String dirName = args.getValue(SOURCE_DIR);
            File dir = new File(dirName);
            if(!dir.exists()) {
                RepositoryException re =
                    new RepositoryException(
                            exceptionLocalizer.format(
                                    "directory-non-existant",
                                    dir.getAbsolutePath()));
                if (verbose) {
                    exception("unexpected-exception", re);
                }
                throw re;
            }
            if(!dir.canRead()) {
                RepositoryException re =
                    new RepositoryException(
                            exceptionLocalizer.format(
                                    "directory-cannot-be-read",
                                    dir.getAbsolutePath()));
                if (verbose) {
                    exception("unexpected-exception", re);
View Full Code Here

            throws RepositoryException {
        // Delete all the policy descriptors.
        try {
            accessor.removeAllPolicyDescriptors();
        } catch (RepositoryException e) {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "cannot-remove-all-policy-descriptors"),
                    e);
        }
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.repository.RepositoryException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.