Package org.apache.lenya.cms.publication

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


    /**
     * @see org.apache.avalon.framework.activity.Initializable#initialize()
     */
    public final void initialize() throws Exception {
        super.initialize();
        DocumentIdentityMap map = new DocumentIdentityMap(this.manager, getLogger());
        getUnitOfWork().setIdentityMap(map);
        Request request = ContextHelper.getRequest(this.context);
        Session session = request.getSession(true);
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());
        getUnitOfWork().setIdentity(identity);
View Full Code Here


    public void setup(SourceResolver _resolver, Map _objectModel, String _source,
            Parameters _parameters) throws ProcessingException, SAXException, IOException {
        super.setup(_resolver, _objectModel, _source, _parameters);

        try {
            this.identityMap = new DocumentIdentityMap(this.manager, getLogger());
            PageEnvelope envelope = PageEnvelopeFactory.getInstance()
                    .getPageEnvelope(this.identityMap, _objectModel);
            this.currentDocument = envelope.getDocument();
        } catch (final PageEnvelopeException e1) {
            throw new ProcessingException(e1);
View Full Code Here

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

        DocumentIdentityMap identityMap = getSourceDocument().getIdentityMap();

        String nodeId = getParameterAsString(NODE_ID);
        DocumentManager documentManager = null;
        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            if (!documentManager.isValidDocumentName(nodeId)) {
                addErrorMessage("The document ID is not valid.");
            } else {
                Document parent = identityMap.getParent(getSourceDocument());
                Publication publication = getSourceDocument().getPublication();
                Document document = identityMap.get(publication,
                        getSourceDocument().getArea(),
                        parent.getId() + "/" + nodeId,
                        getSourceDocument().getLanguage());
                if (document.exists()) {
                    addErrorMessage("The document does already exist.");
View Full Code Here

     */
    protected Document moveAllLanguageVersions(Document document) throws DocumentException,
            DocumentBuildException, PublicationException, ServiceException {
        Document newDocument = null;

        DocumentIdentityMap identityMap = document.getIdentityMap();
        String newDocumentId = getNewDocumentId();

        String[] availableLanguages = document.getLanguages();

        DocumentManager documentManager = null;
        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            for (int i = 0; i < availableLanguages.length; i++) {
                Document languageVersion = identityMap.get(document.getPublication(), document
                        .getArea(), document.getId(), availableLanguages[i]);

                Document newLanguageVersion = identityMap.get(document.getPublication(), document
                        .getArea(), newDocumentId, availableLanguages[i]);

                Transactionable[] nodes = newLanguageVersion.getRepositoryNodes();
                for (int j = 0; j < nodes.length; j++) {
                    nodes[j].lock();
View Full Code Here

            log.debug("No workflow event.");
        } else {
            log.debug("Workflow event: [" + eventName + "]");
            // check for workflow instance first (task can initialize the workflow history)
            try {
                DocumentIdentityMap map = new DocumentIdentityMap(this.manager, new ConsoleLogger());
                this.document = map.getFromURL(webappUrl);
            } catch (DocumentBuildException e) {
                throw new ExecutionException(e);
            }
        }
    }
View Full Code Here

            documentTypeBuilder = (DocumentTypeBuilder) this.manager
                    .lookup(DocumentTypeBuilder.ROLE);

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

            DocumentIdentityMap map = (DocumentIdentityMap) getUnitOfWork().getIdentityMap();
            Document document = map.get(getPublication(),
                    getArea(),
                    getNewDocumentId(),
                    getParameterAsString(LANGUAGE));

            Document initialDocument = getInitialDocument();
View Full Code Here

        if (!sourceAreas.contains(getSourceDocument().getArea())) {
            addErrorMessage("This usecase can only be invoked in the authoring area!");
        } else {

            Document document = getSourceDocument();
            DocumentIdentityMap identityMap = getDocumentIdentityMap();

            DocumentSet set = SiteUtil.getSubSite(this.manager, document);
            Document[] documents = set.getDocuments();
            for (int i = 0; i < documents.length; i++) {
                Document liveVersion = identityMap.getAreaVersion(documents[i],
                        Publication.LIVE_AREA);
                if (liveVersion.exists()) {
                    addErrorMessage("delete-doc-live", new String[] { liveVersion.getId() });
                }
            }
View Full Code Here

     */
    public void rewriteLinks(Document originalTargetDocument, Document newTargetDocument) {

        Publication publication = originalTargetDocument.getPublication();
        String area = originalTargetDocument.getArea();
        DocumentIdentityMap identityMap = originalTargetDocument.getIdentityMap();

        Document[] documents;

        ServiceSelector selector = null;
        SiteManager siteManager = null;
        try {
            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
            siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
            documents = siteManager.getDocuments(identityMap, publication, area);
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (selector != null) {
                if (siteManager != null) {
                    selector.release(siteManager);
                }
                this.manager.release(selector);
            }
        }

        Request request = ObjectModelHelper.getRequest(this.objectModel);
        String contextPath = request.getContextPath();

        try {
            for (int documentIndex = 0; documentIndex < documents.length; documentIndex++) {

                Document examinedDocument = documents[documentIndex];
                if (examinedDocument.exists()) {

                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("Rewriting links in document [" + examinedDocument + "]");
                    }

                    boolean linksRewritten = false;

                    DocumentType doctype = examinedDocument.getResourceType();
                    String[] xPaths = doctype.getLinkAttributeXPaths();

                    try {

                        org.w3c.dom.Document xmlDocument = SourceUtil.readDOM(examinedDocument.getSourceURI(), this.manager);

                        for (int xPathIndex = 0; xPathIndex < xPaths.length; xPathIndex++) {
                            NodeList nodes = XPathAPI.selectNodeList(xmlDocument,
                                    xPaths[xPathIndex]);
                            for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
                                Node node = nodes.item(nodeIndex);
                                if (node.getNodeType() != Node.ATTRIBUTE_NODE) {
                                    throw new RuntimeException("The XPath [" + xPaths[xPathIndex]
                                            + "] may only match attribute nodes!");
                                }
                                Attr attribute = (Attr) node;
                                final String url = attribute.getValue();

                                if (url.startsWith(contextPath + "/" + publication.getId())) {
                                    final String webappUrl = url.substring(contextPath.length());

                                    if (identityMap.isDocument(webappUrl)) {
                                        Document targetDocument = identityMap.getFromURL(webappUrl);

                                        if (matches(targetDocument, originalTargetDocument)) {
                                            String newTargetUrl = getNewTargetURL(targetDocument,
                                                    originalTargetDocument,
                                                    newTargetDocument);
View Full Code Here

   
    private DocumentIdentityMap documentIdentityMap;
   
    protected DocumentIdentityMap getDocumentIdentityMap() {
        if (this.documentIdentityMap == null) {
            this.documentIdentityMap = new DocumentIdentityMap(this.manager, getLogger());
        }
        return this.documentIdentityMap;
    }
View Full Code Here

        String contextPath = request.getContextPath();
        Context context = ObjectModelHelper.getContext(objectModel);
        String servletContextPath = context.getRealPath("");

        try {
            DocumentIdentityMap map = getDocumentIdentityMap();
            envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(map,
                    contextPath,
                    webappUrl,
                    new File(servletContextPath));
        } catch (Exception e) {
View Full Code Here

TOP

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

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.