Package com.volantis.mcs.repository

Examples of com.volantis.mcs.repository.RepositoryException


                Document customDefinitions =
                        createNewDocument(new BufferedInputStream(input));
                mergeDefinitionDocuments(xmlDefinitionsDocument, customDefinitions);
            }
        } else {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-repository-file-missing",
                            DeviceRepositoryConstants.DEFINITIONS_XML));
        }

        // Read in a JDOM document for the hierarchy from the archive.
        input = repositoryArchive.getInputFrom(DeviceRepositoryConstants.HIERARCHY_XML);
        if (input != null) {
            xmlHierarchyDocument = createNewDocument(
                    new BufferedInputStream(input));
        } else {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-repository-file-missing",
                            DeviceRepositoryConstants.HIERARCHY_XML));
        }

        // Read in a JDOM document for device identification from the archive.
        input = repositoryArchive.getInputFrom(DeviceRepositoryConstants.IDENTIFICATION_XML);
        if (input != null) {
            xmlIdentificationDocument = createNewDocument(
                    new BufferedInputStream(input));
        } else {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-repository-file-missing",
                            DeviceRepositoryConstants.IDENTIFICATION_XML));
        }

        // Read in a JDOM document for device TAC identification from the
        // archive.
        input = repositoryArchive.getInputFrom(DeviceRepositoryConstants.TAC_IDENTIFICATION_XML);
        if (input != null) {
            xmlTACIdentificationDocument = createNewDocument(
                    new BufferedInputStream(input));
        } else {
            // No TAC file was found - this is not an error, as TAC data is
            // not available in all repositories. Ignore this and leave the
            // document null.
        }

        // Read in a JDOM document for repository from the archive.
        revision = retrieveRevision(repositoryArchive, factory);

        try {
            properties = createMergedProperties(repositoryArchive);
        } catch (IOException ioe) {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-repository-file-missing",
                            "policies.properties"),
                    ioe);
        }
View Full Code Here


                    new BufferedInputStream(is), factory, true, true);
            revision = repositoryDocument.getRootElement().
                    getAttributeValue(DeviceRepositorySchemaConstants.
                    REVISION_ATTRIBUTE_NAME);
        } else {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-repository-file-missing",
                            DeviceRepositoryConstants.REPOSITORY_XML));
        }
View Full Code Here

        String version = null;
        try {
            // Check that the version.txt file is present and correct.
            is = repositoryArchive.getInputFrom(DeviceRepositoryConstants.VERSION_FILENAME);
            if (is == null) {
                throw new RepositoryException(
                        exceptionLocalizer.format(
                                "device-repository-file-missing",
                                DeviceRepositoryConstants.VERSION_FILENAME));
            }
            version = retrieveVersion(is);
            return version;
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    logger.error("unexpected-ioexception", e);
                    if (version != null) {
                        // A null version 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

            throws RepositoryException {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        try {
            IOUtils.copy(is, buffer);
        } catch (IOException e) {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-repository-file-missing",
                            DeviceRepositoryConstants.VERSION_FILENAME),
                    e);
        }
View Full Code Here

        String path = getXMLFilePath(directory, filename);
        OutputStream output = archive.getOutputTo(path);
        try {
            writeDocument(document, output);
        } catch (IOException e) {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-repository-update-failure",
                            path),
                    e);
        }
View Full Code Here

                    "newParentDevice cannot be null");
        }
        // check that both devices actually exist
        Element deviceElement = getHierarchyDeviceElement(device);
        if (deviceElement == null) {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-definition-missing",
                            device));
        }
        Element parentElement = getHierarchyDeviceElement(newParentDevice);
        if (parentElement == null) {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "device-definition-missing",
                            newParentDevice));
        }
View Full Code Here

                    mergeDeviceDocuments(deviceDocument, customDocument);
                }

            } else {
                // No standard device. This is bad since this is mandatory.
                throw new RepositoryException(
                        exceptionLocalizer.format(
                                "device-definition-missing",
                                deviceName));
            }
View Full Code Here

        }
        Element element = getHierarchyDeviceElement(deviceName);
        if (element != null) {
            removeDevice(element);
        } else {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "cannot-delete-device",
                            deviceName));
        }
    }
View Full Code Here

            throws RepositoryException {

        String path = getXMLFilePath(directory, filename);
        boolean deleted = archive.delete(path);
        if (mandatory && !deleted) {
            throw new RepositoryException(
                    exceptionLocalizer.format(
                            "cannot-delete-file",
                            path));
        }
    }
View Full Code Here

     *                             compatible, or if an error occurs reading
     *                             the device repository.
     */
    public boolean willBeModifiedOnLoad() throws RepositoryException {
        if (!isCompatible()) {
            throw new RepositoryException(EXCEPTION_LOCALIZER.format(
                    "device-repository-incompatible"));
        }
        boolean willBeModified = false;
        if (VERSION_3_0.equals(
                EclipseDeviceRepository.getRequiredMDPRVersion())) {
            if (logger.isDebugEnabled()) {
                logger.debug("modified: version 3.0");
            }
            ZipFile zf = null;
            try {
                zf = new ZipFile(archiveFileName);
                ZipEntry ze = zf.getEntry(TAC_IDENTIFICATION_FILE_3_0);
                if (ze == null) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("modified: no tac id file");
                    }
                    if (transformerFactory != null) {
                        if (logger.isDebugEnabled()) {
                            logger.debug("modified: has transformer factory");
                        }
                        willBeModified = true;
                    }
                }
            } catch (IOException ioe) {
                throw new RepositoryException(ioe);
            } finally {
                if (zf != null) {
                    try {
                        zf.close();
                    } catch (IOException ioe) {
                        throw new RepositoryException(ioe);
                    }
                }
            }
        }
        return willBeModified;
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.