Package org.apache.lenya.cms.metadata

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


    private Map namespace2metadata = new HashMap();

    public MetaData getMetaData(String namespaceUri) throws MetaDataException {

        MetaData meta = (MetaData) this.namespace2metadata.get(namespaceUri);
        if (meta == null) {
           
            MetaDataRegistry registry = null;
            try {
                registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE);
View Full Code Here


            Element dcElement = helper.getFirstChild(metaElement, "dc");
            NamespaceHelper dcHelper = new NamespaceHelper(dcNamespace, "dc", xml);
            Element[] dcElements = dcHelper.getChildren(dcElement);

            MetaData meta = newDoc.getMetaData(dcNamespace);
            for (int i = 0; i < dcElements.length; i++) {
                String key = dcElements[i].getLocalName();
                String value = DocumentHelper.getSimpleElementText(dcElements[i]);
                meta.setValue(key, value);
            }
           
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
View Full Code Here

    /**
     * @see org.apache.lenya.workflow.Workflowable#getVersions()
     */
    public Version[] getVersions() {
        try {
            MetaData meta = this.document.getMetaData(METADATA_NAMESPACE);
            if (this.versions == null || meta.getLastModified() > this.lastModified) {
                String[] versionStrings = meta.getValues(METADATA_VERSION);
                this.versions = new Version[versionStrings.length];
               
                SortedMap number2version = new TreeMap();
               
                for (int i = 0; i < versionStrings.length; i++) {
                    String string = versionStrings[i];
                    int spaceIndex = string.indexOf(" ");
                    String numberString = string.substring(0, spaceIndex);
                    int number = Integer.parseInt(numberString);
                    String versionString = string.substring(spaceIndex + 1);
                    Version version = decodeVersion(versionString);
                    number2version.put(new Integer(number), version);
                }
               
                int number = 0;
                for (Iterator i = number2version.keySet().iterator(); i.hasNext(); ) {
                    Version version = (Version) number2version.get(i.next());
                    this.versions[number] = version;
                    number++;
                }
               
                this.lastModified = meta.getLastModified();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return this.versions;
View Full Code Here

        try {
            String[] areas = getDocument().getPublication().getAreaNames();
            for (int i = 0; i < areas.length; i++) {
                if (getDocument().existsAreaVersion(areas[i])) {
                    Document doc = getDocument().getAreaVersion(areas[i]);
                    MetaData meta = doc.getMetaData(METADATA_NAMESPACE);
                    meta.addValue(METADATA_VERSION, versionString);
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
View Full Code Here

     */
    public Date getExpires() throws DocumentException {
        Date expires = null;
        long secs = 0;

        MetaData metaData = null;
        String expiresMeta = null;
        try {
            metaData = this.getMetaData(METADATA_NAMESPACE);
            expiresMeta = metaData.getFirstValue("expires");
        } catch (MetaDataException e) {
            throw new DocumentException(e);
        }
        if (expiresMeta != null) {
            secs = Long.parseLong(expiresMeta);
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

            List keyList = new ArrayList();

            String[] namespaces = registry.getNamespaceUris();

            for (int nsIndex = 0; nsIndex < namespaces.length; nsIndex++) {
                MetaData meta = getSourceDocument().getMetaData(namespaces[nsIndex]);
                String[] keys = meta.getPossibleKeys();
                for (int keyIndex = 0; keyIndex < keys.length; keyIndex++) {
                    String key = "ns" + nsIndex + "." + keys[keyIndex];
                    String[] values = meta.getValues(keys[keyIndex]);
                    Element element = meta.getElementSet().getElement(keys[keyIndex]);
                    setParameter(key, new MetaDataWrapper(element, values));
                    keyList.add(key);
                }
                numbers.add("" + nsIndex);
                num2namespace.put("" + nsIndex, namespaces[nsIndex]);
View Full Code Here

        Document document = getSourceDocument();
        String[] namespaces = document.getMetaDataNamespaceUris();

        for (int nsIndex = 0; nsIndex < namespaces.length; nsIndex++) {
            MetaData meta = document.getMetaData(namespaces[nsIndex]);
            String orgNsIndex = (String) namespace2num.get(namespaces[nsIndex]);

            String[] keys = meta.getPossibleKeys();
            for (int keyIndex = 0; keyIndex < keys.length; keyIndex++) {
                String key = keys[keyIndex];
                Element element = meta.getElementSet().getElement(key);
                if (element.isEditable()) {
                    Object value = getParameter("ns" + orgNsIndex + "." + key);
                    if (value != null && value instanceof String) {
                        meta.setValue(key, (String) value);
                    }
                }
            }
        }
View Full Code Here

            document.setResourceType(documentType);
            document.setSourceExtension(extension);
            document.setMimeType(mimeType);

            // Write Lenya-internal meta-data
            MetaData lenyaMetaData = document.getMetaData(DocumentImpl.METADATA_NAMESPACE);
            lenyaMetaData.setValue(DocumentImpl.METADATA_CONTENT_TYPE, "xml");

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Create");
                getLogger().debug("    document:     [" + document + "]");
            }
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.