1 17 18 19 20 package org.apache.lenya.cms.publication.xsp; 21 22 import java.util.Map ; 23 24 import org.apache.cocoon.ProcessingException; 25 import org.apache.lenya.cms.publication.Document; 26 import org.apache.lenya.cms.publication.DocumentBuilder; 27 import org.apache.lenya.cms.publication.PageEnvelope; 28 import org.apache.lenya.cms.publication.PageEnvelopeException; 29 import org.apache.lenya.cms.publication.PageEnvelopeFactory; 30 31 34 public class DocumentLanguagesHelper { 35 36 private PageEnvelope pageEnvelope = null; 37 38 45 public DocumentLanguagesHelper(Map objectModel) throws ProcessingException { 46 try { 47 this.pageEnvelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel); 48 } catch (PageEnvelopeException e) { 49 throw new ProcessingException(e); 50 } 51 } 52 53 62 public String getUrl(String language) throws ProcessingException { 63 Document doc = getDocument(language); 64 return pageEnvelope.getContext() + doc.getCompleteURL(); 65 } 66 67 76 public String getInfoUrl(String language) throws ProcessingException { 77 Document doc = getDocument(language); 78 return pageEnvelope.getContext() + doc.getCompleteInfoURL(); 79 } 80 81 90 protected Document getDocument(String language) throws ProcessingException { 91 DocumentBuilder builder = pageEnvelope.getPublication().getDocumentBuilder(); 92 Document document = builder.buildLanguageVersion(pageEnvelope.getDocument(), language); 93 return document; 94 } 95 } 96 | Popular Tags |