1 17 18 19 20 package org.apache.lenya.cms.cocoon.acting; 21 22 import java.util.Collections ; 23 import java.util.Map ; 24 25 import org.apache.avalon.framework.parameters.ParameterException; 26 import org.apache.avalon.framework.parameters.Parameters; 27 import org.apache.cocoon.acting.AbstractAction; 28 import org.apache.cocoon.environment.Redirector; 29 import org.apache.cocoon.environment.SourceResolver; 30 import org.apache.lenya.cms.publication.PageEnvelope; 31 import org.apache.lenya.cms.publication.PageEnvelopeException; 32 import org.apache.lenya.cms.publication.PageEnvelopeFactory; 33 import org.apache.lenya.cms.publication.Publication; 34 import org.apache.lenya.cms.publication.SiteTree; 35 import org.apache.lenya.cms.publication.SiteTreeException; 36 37 42 public class DocumentIdExistsAction extends AbstractAction { 43 44 64 65 public static final String DOCUMENT_ID_PARAMETER_NAME = "document-id"; 66 public static final String AREA_PARAMETER_NAME="area"; 67 68 public Map act( 69 Redirector redirector, 70 SourceResolver resolver, 71 Map objectModel, 72 String source, 73 Parameters parameters) 74 throws PageEnvelopeException, SiteTreeException, ParameterException{ 75 76 if (!parameters.isParameter(DOCUMENT_ID_PARAMETER_NAME)) 77 return null; 78 String documentId = parameters.getParameter(DOCUMENT_ID_PARAMETER_NAME); 79 80 81 String area = parameters.getParameter(AREA_PARAMETER_NAME, Publication.AUTHORING_AREA); 82 83 PageEnvelope pageEnvelope = 84 PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel); 85 86 SiteTree siteTree = 87 pageEnvelope.getPublication().getTree(area); 88 89 if (siteTree.getNode(documentId) != null) { 90 return Collections.EMPTY_MAP; 91 } else { 92 return null; 93 } 94 } 95 } 96 | Popular Tags |