Package org.apache.lenya.cms.publication

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


    }

    protected void prepareUsecase() throws Exception {
        super.prepareUsecase();

  DocumentManager docMgr = null;
  try {
      docMgr = (DocumentManager) getManager().lookup(DocumentManager.ROLE);

      Publication pub = getPublication("test");
      Area area = pub.getArea(Publication.AUTHORING_AREA);
      Area trashArea = pub.getArea("trash");
      SiteStructure site = area.getSite();
      SiteNode node = site.getNode(PATH);
      Document doc_en = node.getLink("en").getDocument();
      Document doc_de = node.getLink("de").getDocument();

      DocumentLocator loc = DocumentLocator.getLocator(pub.getId(), "trash", PATH, doc_en.getLanguage());

      docMgr.copyAll(area, PATH, trashArea, PATH);

      SiteStructure trashSite = trashArea.getSite();
      assertTrue(trashSite.contains(PATH));
  } finally {
      if (docMgr != null) {
View Full Code Here


    protected void publish(Document authoringDocument) throws DocumentException, SiteException,
            PublicationException {

        createAncestorNodes(authoringDocument);

        DocumentManager documentManager = null;

        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            documentManager.copyToArea(authoringDocument, Publication.LIVE_AREA);

            boolean notify = Boolean.valueOf(getBooleanCheckboxParameter(PARAM_SEND_NOTIFICATION))
                    .booleanValue();
            if (notify) {
                sendNotification(authoringDocument);
View Full Code Here

    }

    protected void checkPublication(Session session, DocumentFactory factory, Publication pub)
            throws ServiceException, SiteException, DocumentBuildException, PublicationException,
            RepositoryException {
        DocumentManager docManager = null;
        ServiceSelector selector = null;
        SiteManager siteManager = null;
        ServiceSelector resourceTypeSelector = null;

        try {
            selector = (ServiceSelector) getManager().lookup(SiteManager.ROLE + "Selector");
            siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
            SiteStructure structure = siteManager.getSiteStructure(factory, pub,
                    Publication.AUTHORING_AREA);

            docManager = (DocumentManager) getManager().lookup(DocumentManager.ROLE);

            resourceTypeSelector = (ServiceSelector) getManager().lookup(
                    ResourceType.ROLE + "Selector");
            ResourceType type = (ResourceType) resourceTypeSelector.select("entry");
            String contentSourceUri = "context://sitemap.xmap";

            Document doc = docManager.add(factory, type, contentSourceUri, pub,
                    Publication.AUTHORING_AREA, "en", "xml");

            structure.add(PATH, doc);
            assertTrue(structure.contains(PATH));
            Document linkDoc = structure.getNode(PATH).getLink("en").getDocument();
View Full Code Here

    private void migrateDocument(Document doc) throws Exception {

        getLogger().info("Migrating document [" + doc + "]");

        DocumentManager docManager = null;
        SiteManager siteManager = null;
        ServiceSelector selector = null;
        SourceResolver resolver = null;
        try {
            docManager = (DocumentManager) getManager().lookup(DocumentManager.ROLE);
View Full Code Here

    protected void publish(Document authoringDocument) throws DocumentException, SiteException,
            PublicationException {

        createAncestorNodes(authoringDocument);

        DocumentManager documentManager = null;

        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            documentManager.copyToArea(authoringDocument, Publication.LIVE_AREA);

            boolean notify = Boolean.valueOf(getBooleanCheckboxParameter(SEND_NOTIFICATION))
                    .booleanValue();
            if (notify) {
                sendNotification(authoringDocument);
View Full Code Here

     */
    protected void deactivate(Document authoringDocument) {

        boolean success = false;

        DocumentManager documentManager = null;
        try {
            Document liveDocument = authoringDocument.getAreaVersion(Publication.LIVE_AREA);

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

            success = true;
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
View Full Code Here

        // create new document
        // implementation note: since blog does not have a hierarchy,
        // document id (full path) and document id-name (this leaf's id)
        // are the same
        DocumentManager documentManager = null;
        ServiceSelector selector = null;
        ResourceType resourceType = null;

        try {
            selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
            resourceType = (ResourceType) selector.select(getDocumentTypeName());

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

            DocumentFactory map = getDocumentFactory();

            String documentId = getDocumentID();
           
            String sampleName = resourceType.getSampleNames()[0];
            String sampleUri = resourceType.getSample(sampleName).getUri();

            Document document = documentManager.add(map,
                    resourceType,
                    sampleUri,
                    getSourceDocument().getPublication(),
                    getSourceDocument().getArea(),
                    documentId,
View Full Code Here

            if (doc == null)
                throw new IllegalArgumentException("illegal usage, source document may not be null");

            // create new doc from PUT input
            if (!doc.exists()) {
                DocumentManager documentManager = null;
                ServiceSelector selector = null;
                ResourceType resourceType = null;
                try {
                    selector = (ServiceSelector) this.manager
                            .lookup(ResourceType.ROLE + "Selector");

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

                    DocumentFactory map = getDocumentFactory();
                    String path = doc.getPath();
                    // lookupResourceType(extension)
                    resourceType = lookUpExtension(extension, selector);
                    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);
                } finally {
                    if (documentManager != null) {
View Full Code Here

    /**
     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
     */
    protected void doExecute() throws Exception {
        DocumentManager documentManager = null;
        try {
            Document authoringDocument = getSourceDocument();
            if (authoringDocument.getResourceType().getName().equals("entry")) {
                updateBlogEntry(authoringDocument);
            }
            updateFeed();
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            documentManager.copyToArea(authoringDocument, Publication.LIVE_AREA);
            WorkflowUtil.invoke(this.manager, getSession(), getLogger(), authoringDocument,
                    getEvent());
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
View Full Code Here

    /**
     * Deletes a document.
     * @param document The document to delete.
     */
    protected void delete(Document document) {
        DocumentManager documentManager = null;
        boolean success = false;
        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            documentManager.delete(document);      
            WorkflowUtil.invoke(this.manager,
                    getSession(),
                    getLogger(),
                    document,
                    getEvent());
View Full Code Here

TOP

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

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.