Package org.apache.lenya.cms.metadata

Examples of org.apache.lenya.cms.metadata.MetaData


        }
        return this.resourceType;
    }

    public MetaData getMetaData(String namespaceUri) throws MetaDataException {
        MetaData meta = getContentHolder().getMetaData(namespaceUri);
        if (getSession().isModifiable()) {
            return meta;
        }
        else {
            String cacheKey = getPublication().getId() + ":" + getArea() + ":"
View Full Code Here


    public void setResourceType(ResourceType resourceType) {
        checkWritability();
        Assert.notNull("resource type", resourceType);
        try {
            MetaData meta = getMetaData(DocumentImpl.METADATA_NAMESPACE);
            meta.setValue(DocumentImpl.METADATA_RESOURCE_TYPE, resourceType.getName());
        } catch (MetaDataException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

    public void setSourceExtension(String extension) {
        checkWritability();
        Assert.notNull("extension", extension);
        Assert.isTrue("extension doesn't start with a dot", !extension.startsWith("."));
        try {
            MetaData meta = getMetaData(DocumentImpl.METADATA_NAMESPACE);
            meta.setValue(DocumentImpl.METADATA_EXTENSION, extension);
        } catch (MetaDataException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

     */
    final public void testModifySaveAndReload() throws DocumentBuildException, DocumentException {
        Publication publication = PublicationHelper.getPublication();
        DocumentIdentityMap map = new DocumentIdentityMap();
        Document doc = map.get(publication, AREA, DOCUMENT_ID, LANGUAGE);
        MetaData dcCore = doc.getMetaDataManager().getDublinCoreMetaData();
        String title = dcCore.getFirstValue(DublinCore.ELEMENT_TITLE);
        String subject = dcCore.getFirstValue(DublinCore.ELEMENT_SUBJECT);
        String creator = dcCore.getFirstValue(DublinCore.ELEMENT_CREATOR);
        String dateIssued = dcCore.getFirstValue(DublinCore.TERM_ISSUED);

        dcCore.setValue(DublinCore.ELEMENT_CREATOR, CREATOR);
        dcCore.save();

        Document doc2 = map.get(publication, AREA, DOCUMENT_ID, LANGUAGE);

        MetaData dcCore2 = doc2.getMetaDataManager().getDublinCoreMetaData();
        assertEquals(title, dcCore2.getFirstValue(DublinCore.ELEMENT_TITLE));
        assertEquals(subject, dcCore2.getFirstValue(DublinCore.ELEMENT_SUBJECT));
        assertEquals(dateIssued, dcCore2.getFirstValue(DublinCore.TERM_ISSUED));
        assertFalse(creator.equals(dcCore2.getFirstValue(DublinCore.ELEMENT_CREATOR)));
        assertEquals(CREATOR, dcCore2.getFirstValue(DublinCore.ELEMENT_CREATOR));
    }
View Full Code Here

            if (languages.length > 0) {
                while (identifier == null && i < languages.length) {
                    Document document = map.get(publication, area, documentId, languages[i]);
                    if (getLogger().isDebugEnabled())
                        getLogger().debug("document file : " + document.getFile().getAbsolutePath());
                    MetaData dublincore = document.getMetaDataManager().getDublinCoreMetaData();
                    if (getLogger().isDebugEnabled())
                        getLogger().debug("dublincore title : "
                            + dublincore.getFirstValue(DublinCore.ELEMENT_TITLE));
                    identifier = dublincore.getFirstValue(DublinCore.ELEMENT_IDENTIFIER);
                    i = i + 1;
                }
            }
            if (languages.length < 1 || identifier == null) {
                MetaData dublincore = baseDocument.getMetaDataManager().getDublinCoreMetaData();
                identifier = dublincore.getFirstValue(DublinCore.ELEMENT_IDENTIFIER);
            }
        } catch (final DocumentException e) {
            throw e;
        } catch (final Exception e) {
            throw new DocumentException(e);
View Full Code Here

        super.initParameters();

        WorkflowManager resolver = null;
        try {
            // read parameters from Dublin Core meta-data
            MetaData dc = getSourceDocument().getMetaDataManager().getDublinCoreMetaData();
            setParameter(DublinCore.ELEMENT_TITLE, dc.getFirstValue(DublinCore.ELEMENT_TITLE));
            setParameter(DublinCore.ELEMENT_DESCRIPTION, dc
                    .getFirstValue(DublinCore.ELEMENT_DESCRIPTION));

            // read parameters from document attributes
            setParameter("languages", getSourceDocument().getLanguages());
            setParameter("lastmodified", getSourceDocument().getLastModified());
View Full Code Here

     */
    protected void initParameters() {
        super.initParameters();

        try {
            MetaData meta = getSourceDocument().getMetaDataManager().getDublinCoreMetaData();

            String[] keys = meta.getPossibleKeys();
            for (int i = 0; i < keys.length; i++) {
                String value = meta.getFirstValue(keys[i]);
                if (value != null) {
                    setParameter(keys[i], value);
                }
            }

View Full Code Here

     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
     */
    protected void doExecute() throws Exception {
        super.doExecute();

        MetaData meta = getSourceDocument().getMetaDataManager().getDublinCoreMetaData();

        String[] keys = meta.getPossibleKeys();
        for (int i = 0; i < keys.length; i++) {
            String value = getParameterAsString(keys[i]);
            if (value != null) {
                meta.setValue(keys[i], value);
            }
        }
        meta.save();

        //TODO set workflow situation to edit here.
    }
View Full Code Here

        try {
            Document document = getEnvelope(objectModel, name).getDocument();
            if (document == null) {
                throw new ConfigurationException("There is no document for this page envelope!");
            }
            MetaData dc = document.getMetaDataManager().getDublinCoreMetaData();

            if (! dc.isValidAttribute(name)) {
                throw new ConfigurationException("The attribute [" + name + "] is not supported!");
            }

            value = dc.getFirstValue(name);
        } catch (Exception e) {
            throw new ConfigurationException("Obtaining dublin core value for [" + name
                    + "] failed: ", e);
        }
View Full Code Here

                setParameter(PARAM_NUMBER_OF_DOCUMENTS, new Integer(area.getDocuments().length));
                setParameter(PARAM_NUMBER_OF_SITE_NODES, new Integer(area.getSite().getNodes().length));
            }
            else {
                // read parameters from Dublin Core meta-data
                MetaData dc = doc.getMetaData(DublinCore.DC_NAMESPACE);
                setParameter(DublinCore.ELEMENT_TITLE, dc.getFirstValue(DublinCore.ELEMENT_TITLE));
                setParameter(DublinCore.ELEMENT_DESCRIPTION, dc
                        .getFirstValue(DublinCore.ELEMENT_DESCRIPTION));

                // read parameters from document attributes
                setParameter(LANGUAGES, doc.getLanguages());
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.metadata.MetaData

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.