1 17 18 19 20 package org.apache.lenya.cms.publication.task; 21 22 import org.apache.lenya.cms.publication.Document; 23 import org.apache.lenya.cms.publication.DocumentBuilder; 24 import org.apache.lenya.cms.publication.Publication; 25 import org.apache.lenya.cms.task.ExecutionException; 26 27 30 public abstract class DocumentTask extends PublicationTask { 31 32 public static final String PARAMETER_DOCUMENT_ID = "document-id"; 33 public static final String PARAMETER_DOCUMENT_AREA = "document-area"; 34 public static final String PARAMETER_DOCUMENT_LANGUAGE = "document-language"; 35 36 42 protected Document getDocument() throws ExecutionException { 43 Document document; 44 try { 45 String id = getParameters().getParameter(PARAMETER_DOCUMENT_ID); 46 String area = getParameters().getParameter(PARAMETER_DOCUMENT_AREA); 47 String language = getParameters().getParameter(PARAMETER_DOCUMENT_LANGUAGE); 48 document = getDocument(id, area, language); 49 } catch (Exception e) { 50 throw new ExecutionException(e); 51 } 52 return document; 53 } 54 55 63 protected Document getDocument(String documentId, String area, String language) 64 throws ExecutionException { 65 Publication publication = getPublication(); 66 DocumentBuilder builder = publication.getDocumentBuilder(); 67 String url = builder.buildCanonicalUrl(publication, area, documentId, language); 68 Document document; 69 try { 70 document = builder.buildDocument(publication, url); 71 } catch (Exception e) { 72 throw new ExecutionException(e); 73 } 74 return document; 75 } 76 77 } 78 | Popular Tags |