Package org.apache.lenya.cms.publication

Examples of org.apache.lenya.cms.publication.ResourceType$Sample


    protected boolean getVisibleInNav() {
        return true;
    }

    protected String getDocumentTypeName() {
        ResourceType resourceType = null;
        ServiceSelector selector = null;
        String docType = "";
        try {
            selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
            resourceType = lookUpExtension(getSourceExtension(), selector);
            docType = resourceType.getName();
        } catch (ServiceException e) {
            throw new RuntimeException(e);
        } finally {
            if (selector != null) {
                this.manager.release(selector);
View Full Code Here


     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
     */
    protected void doExecute() throws Exception {
        // super.doExecute();
        SourceResolver resolver = null;
        ResourceType resourceType = null;

        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);

            Document doc = getSourceDocument();
            // sanity check
            if (doc == null)
                throw new IllegalArgumentException("illegal usage, source document may not be null");

            if (!doc.exists()) {
                DocumentManager documentManager = null;
                ServiceSelector selector = null;
                try {
                    selector = (ServiceSelector) this.manager
                            .lookup(ResourceType.ROLE + "Selector");

                    documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);

                    DocumentFactory map = getDocumentFactory();
                    String path = doc.getPath();

                    resourceType = (ResourceType) selector.select(TYPE);
                    ResourceType.Sample sample = resourceType.getSample(resourceType.getSampleNames()[0]);
                    doc = documentManager.add(map, resourceType, sample.getUri(), getPublication(), doc
                            .getArea(), path, doc.getLanguage(), EXTENSION, doc.getName(), true);
                    doc.setMimeType(sample.getMimeType());

                    setMetaData(doc);
View Full Code Here

        Document sourceDoc = getSourceDocument();

        String sourceUri = getParameterAsString(SOURCE_URI);
        org.w3c.dom.Document xmlDoc = SourceUtil.readDOM(sourceUri, this.manager);

        ResourceType resourceType = sourceDoc.getResourceType();
        Schema schema = resourceType.getSchema();
        ValidationUtil.validate(this.manager, xmlDoc, schema, new UsecaseErrorHandler(this));

        if (!hasErrors()) {
            SourceUtil.writeDOM(xmlDoc, sourceDoc.getOutputStream());
            String event = getParameterAsString(EVENT, DEFAULT_EVENT);
View Full Code Here

            validate(xml);
        }
    }

    protected void validate(Document xml) throws Exception {
        ResourceType resourceType = getSourceDocument().getResourceType();
        Schema schema = resourceType.getSchema();
        ValidationUtil.validate(this.manager, xml, schema, new UsecaseErrorHandler(this));
    }
View Full Code Here

        String contentUri = baseUri + path + "/index_" + language;
        String metaUri = contentUri + ".meta";

        DocumentManager docManager = null;
        ServiceSelector selector = null;
        ResourceType resourceType = null;
        SourceResolver resolver = null;
        try {

            org.w3c.dom.Document xml = SourceUtil.readDOM(metaUri, this.manager);
            NamespaceHelper helper = new NamespaceHelper(
View Full Code Here

            validate(getContent(), encoding);
        }
    }

    protected void validate(String xmlString, String encoding) throws Exception {
        ResourceType resourceType = getSourceDocument().getResourceType();
        Schema schema = resourceType.getSchema();
        if (schema == null) {
            getLogger().info(
                    "No schema declared for resource type [" + resourceType.getName()
                            + "], skipping validation.");
        } else {
            deleteParameter(PARAM_VALIDATION_ERRORS);
            byte bytes[] = xmlString.getBytes(encoding);
            ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
View Full Code Here

    }

    protected Document createCollectionDocument(Publication pub) throws ServiceException,
            DocumentBuildException, PublicationException {
        ServiceSelector typeSelector = null;
        ResourceType type = null;
        DocumentManager docMgr = null;
        Document doc;
        try {
            typeSelector = (ServiceSelector) getManager().lookup(ResourceType.ROLE + "Selector");
            type = (ResourceType) typeSelector.select("collection");
            docMgr = (DocumentManager) getManager().lookup(DocumentManager.ROLE);
            ResourceType.Sample sample = type.getSample(type.getSampleNames()[0]);
            doc = docMgr.add(getFactory(), type, sample.getUri(), pub, "authoring", "en", "xml");
            doc.setMimeType(sample.getMimeType());
           
        } finally {
            if (docMgr != null) {
View Full Code Here

        boolean linksRewritten = false;
        try {

            String prefix = useContextPath ? getContextPath() : "";

            ResourceType type = examinedDocument.getResourceType();
            String[] xPaths = type.getLinkAttributeXPaths();

            if (xPaths.length == 0) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug(
                            "Convert links: No XPaths for resource type [" + type.getName() + "]");
                }
            } else {
                Publication pub = examinedDocument.getPublication();
                ChainLinkRewriter incomingRewriter = new ChainLinkRewriter();
                incomingRewriter.add(new RelativeToAbsoluteLinkRewriter(examinedDocument.getCanonicalWebappURL()));
View Full Code Here

     * @return The name of the workflow schema.
     */
    protected String getWorkflowSchema() {
        String workflowName = null;
        try {
            ResourceType doctype = document.getResourceType();
            if (doctype != null) {
                workflowName = document.getPublication().getWorkflowSchema(doctype);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

            String webappUrl = ServletHelper.getWebappURI(request);
            Document document = null;
            if (map.isDocument(webappUrl)) {
                document = map.getFromURL(webappUrl);
                ResourceType doctype = document.getResourceType();
                if (document.getPublication().getWorkflowSchema(doctype) != null) {
                    setHasWorkflow(true);
                    workflowManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
                } else {
                    setHasWorkflow(false);
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.publication.ResourceType$Sample

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.