Package org.apache.lenya.cms.publication

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


   * Copy the resources files belongs to the documents corresponding to this node
   * 
   * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
   */
  public void visitSiteTreeNode(SiteTreeNode node) {
    Publication publication = getPublication();
    DocumentBuilder builder = publication.getDocumentBuilder();

    String srcDocumentid = node.getAbsoluteId();
    String destDocumentid =
      srcDocumentid.replaceFirst(
        getFirstdocumentid(),
View Full Code Here


  /** (non-Javadoc)
   * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
   */
  public void visitSiteTreeNode(SiteTreeNode node) {
    Publication publication = getPublication();
    DocumentBuilder builder = publication.getDocumentBuilder();

    String destDocumentid = node.getAbsoluteId();
    String srcDocumentid =
      destDocumentid.replaceFirst(
        getSecdocumentid(),
View Full Code Here

      log("document-id for the source :" + this.getFirstdocumentid());
      log("area for the source :" + this.getFirstarea());
      log("document-id for the destination :" + this.getSecdocumentid());
      log("area for the destination :" + this.getSecarea());

      Publication publication = getPublication();
      SiteTree tree = publication.getTree(this.getSecarea());
      SiteTreeNode node = tree.getNode(this.getSecdocumentid());
      node.acceptReverseSubtree(this);
    } catch (Exception e) {
      throw new BuildException(e);
    }
View Full Code Here

  public void execute() throws BuildException {
    try {
      log("document-id for the source" + this.getFirstdocumentid());
      log("area for the source" + this.getFirstarea());

      Publication publication= getPublication();
      SiteTree tree = publication.getTree(getFirstarea());
      SiteTreeNode node = tree.getNode(getFirstdocumentid());

      node.acceptSubtree(this);
    } catch (Exception e) {
      throw new BuildException(e);
View Full Code Here

        Parameters parameters)
        throws PageEnvelopeException, DocumentDoesNotExistException, DocumentException, SiteTreeException, DocumentBuildException {

        PageEnvelope pageEnvelope =
            PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
        Publication publication = pageEnvelope.getPublication();
        String area = pageEnvelope.getDocument().getArea();
        String language = pageEnvelope.getDocument().getLanguage();
        String id = pageEnvelope.getDocument().getId();

        SiteTree siteTree = publication.getTree(area);
        SiteTreeNode node = siteTree.getNode(id);

        if (node == null) {
            throw new DocumentDoesNotExistException("The document " + pageEnvelope.getDocument().getId() + " does not exist. Check sitetree, it might need to be reloaded.");
        }
       
        SiteTreeNode[] children = node.getChildren(language);
        if (children.length > 0) {

            String childNodeId = children[0].getId();
            String childId = id + "/" + childNodeId;
            DocumentBuilder builder = publication.getDocumentBuilder();
            String url = builder.buildCanonicalUrl(publication, area, childId, language);
            Document childDocument = builder.buildDocument(publication, url);

            if (!childDocument.existsInAnyLanguage()) {
                throw new NoChildDocumentExistException("The document " + childId + " does not exist. Check sitetree, it might need to be reloaded.");
View Full Code Here

     * @param contextPath The servlet context path.
     */
    public void rewriteLinks(Document originalTargetDocument, Document newTargetDocument,
            String contextPath) {

        Publication publication = originalTargetDocument.getPublication();
        String area = originalTargetDocument.getArea();
        File[] files = getDocumentFiles(publication, area);

        DocumentBuilder builder = publication.getDocumentBuilder();

        try {
            for (int fileIndex = 0; fileIndex < files.length; fileIndex++) {
                org.w3c.dom.Document xmlDocument = DocumentHelper.readDocument(files[fileIndex]);
                boolean linksRewritten = false;

                String[] xPaths = publication.getRewriteAttributeXPaths();
                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 (builder.isDocument(publication, webappUrl)) {
                                Document targetDocument = builder.buildDocument(publication, webappUrl);

View Full Code Here

  /** (non-Javadoc)
   * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
   */
  public void visitSiteTreeNode(SiteTreeNode node) {
    Publication publication = getPublication();
    DocumentBuilder builder = publication.getDocumentBuilder();

    Label[] labels = node.getLabels();
    for (int i = 0 ; i < labels.length; i++){
      String language = labels[i].getLanguage();

View Full Code Here

     * @return A document.
     * @throws ExecutionException when something went wrong.
     */
    protected Document getDocument(String documentId, String area, String language)
        throws ExecutionException {
        Publication publication = getPublication();
        DocumentBuilder builder = publication.getDocumentBuilder();
        String url = builder.buildCanonicalUrl(publication, area, documentId, language);
        Document document;
        try {
            document = builder.buildDocument(publication, url);
        } catch (Exception e) {
View Full Code Here

     * @param area The area in which is the sitetree.
     * @return newdocumentid The unique document id.
     */
  protected String computeUniqueId(String documentid, String area) {

    Publication publication = getPublication();

    UniqueDocumentId uniqueDocumentId = new UniqueDocumentId();
        String newdocumentid = uniqueDocumentId.computeUniqueDocumentId(publication, area, documentid);
    return newdocumentid;

View Full Code Here

        String id = pubidAndArea[0];
        String area = pubidAndArea[1];
      String contextPath = ObjectModelHelper.getContext(objectModel).getRealPath("");
     
      try {
      Publication pub = PublicationFactory.getPublication(id, contextPath);
      return pub.getContentDirectory(area);
    } catch (PublicationException e) {
            throw new ConfigurationException("Obtaining value for [" + name + "] failed: ", e);
    }
     
    }
View Full Code Here

TOP

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

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.