Package org.apache.lenya.cms.publication

Examples of org.apache.lenya.cms.publication.DocumentException


        if (elementList.contains(key)) {
            this.elements.put(key, new String[0]);
        } else if (termList.contains(key)) {
            this.terms.put(key, new String[0]);
        } else {
            throw new DocumentException("The key [" + key
                    + "] does not refer to a dublin core element or term!");
        }
    }
View Full Code Here


    public void add(Document document) throws DocumentException {
        documents().add(document);
        try {
            save();
        } catch (TransactionException e) {
            throw new DocumentException(e);
        }
    }
View Full Code Here

    public void add(int position, Document document) throws DocumentException {
        documents().add(position, document);
        try {
            save();
        } catch (TransactionException e) {
            throw new DocumentException(e);
        }
    }
View Full Code Here

    /**
     * @see org.apache.lenya.cms.publication.util.Collection#remove(org.apache.lenya.cms.publication.Document)
     */
    public void remove(Document document) throws DocumentException {
        if (!documents().contains(document)) {
            throw new DocumentException("Collection [" + this + "] does not contain document ["
                    + document + "]");
        }
        documents().remove(document);
        try {
            save();
        } catch (TransactionException e) {
            throw new DocumentException(e);
        }
    }
View Full Code Here

     * Loads the collection from its XML source.
     * @throws DocumentException when something went wrong.
     */
    protected void load() throws DocumentException {
        if (!this.isLoaded) {
            getLogger().debug("Loading: ", new DocumentException());
            NamespaceHelper helper;
            try {
                helper = getNamespaceHelper();

                Element collectionElement = helper.getDocument().getDocumentElement();
                Element[] documentElements = helper
                        .getChildren(collectionElement, ELEMENT_DOCUMENT);

                for (int i = 0; i < documentElements.length; i++) {
                    Element documentElement = documentElements[i];
                    Document document = loadDocument(documentElement);
                    this.documentsList.add(document);
                }
            } catch (DocumentException e) {
                throw e;
            } catch (Exception e) {
                throw new DocumentException(e);
            }
            this.isLoaded = true;
        }
    }
View Full Code Here

        try {
            Element documentElement = helper.createElement(ELEMENT_DOCUMENT);
            documentElement.setAttributeNS(null, ATTRIBUTE_ID, document.getId());
            return documentElement;
        } catch (final DOMException e) {
            throw new DocumentException(e);
        }
    }
View Full Code Here

     * @see org.apache.lenya.cms.publication.util.Collection#getFirstPosition(org.apache.lenya.cms.publication.Document)
     */
    public int getFirstPosition(Document document) throws DocumentException {
        load();
        if (!contains(document)) {
            throw new DocumentException("The collection [" + this
                    + "] does not contain the document [" + document + "]");
        }
        return documents().indexOf(document);
    }
View Full Code Here

        Publication publication = document.getPublication();

        String[] languages = document.getLanguages();

        if (languages.length == 0) {
            throw new DocumentException("The document [" + document
                    + "] does not exist in any language!");
        }

        List languageList = Arrays.asList(languages);

        String existingLanguage = null;

        if (languageList.contains(preferredLanguage)) {
            existingLanguage = preferredLanguage;
        } else if (languageList.contains(publication.getDefaultLanguage())) {
            existingLanguage = publication.getDefaultLanguage();
        } else {
            existingLanguage = languages[0];
        }

        Document existingVersion = null;
        try {
            existingVersion = document.getTranslation(existingLanguage);
        } catch (DocumentException e) {
            throw new DocumentException(e);
        }

        return existingVersion;
    }
View Full Code Here

                Document languageVersion;
                try {
                    languageVersion = document.getFactory()
                            .getLanguageVersion(document, languages[i]);
                } catch (DocumentBuildException e) {
                    throw new DocumentException(e);
                }
                add(languageVersion);
            }
        }
    }
View Full Code Here

        DefaultSiteTree tree = null;
        tree = getPublication().getSiteTree(area);
        SiteTreeNode node = tree.getNode(documentid);

        if (node == null) {
            throw new DocumentException(
                "Document-id " + documentid + " not found.");
        }
        //if node is visible change to fale and vice versa
        String visibility = "false";
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.publication.DocumentException

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.