Author: andreas
Date: Tue Aug 14 07:06:03 2007
New Revision: 565765
URL: http://svn.apache.org/viewvc?view=rev&rev=565765
Log:
LanguageExistsAction: code simplification, javadoc cleanup
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java?view=diff&rev=565765&r1=565764&r2=565765
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java Tue Aug 14 07:06:03 2007
@@ -20,9 +20,7 @@
package org.apache.lenya.cms.cocoon.acting;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
@@ -31,42 +29,20 @@
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
-import org.apache.lenya.cms.publication.Area;
-import org.apache.lenya.cms.publication.DocumentBuilder;
import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentLocator;
import org.apache.lenya.cms.publication.DocumentUtil;
-import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationUtil;
-import org.apache.lenya.cms.site.SiteNode;
-import org.apache.lenya.cms.site.SiteStructure;
import org.apache.lenya.util.ServletHelper;
/**
- * Action that checks the sitetree if there is a node with the current
- * document-id and the current language, i.e. if the current document has a
- * version in the current language.
+ * Action that checks if the current URL represents an existing document.
*/
public class LanguageExistsAction extends ServiceableAction {
/**
- * Check if the current document-id has a document for the currently
- * requested language.
- *
- * If yes return an empty map, if not return null.
- *
- * @param redirector a <code>Redirector</code> value
- * @param resolver a <code>SourceResolver</code> value
- * @param objectModel a <code>Map</code> value
- * @param source a <code>String</code> value
- * @param parameters a <code>Parameters</code> value
- *
- * @return an empty <code>Map</code> if there is a version of this
- * document for the current language, null otherwiese
+ * Check if the current URL represents an existing document.
+ * @return an empty <code>Map</code> if there is a version of this document for the current
+ * language, <code>null</code> otherwise.
* @throws Exception if an error occurs
- *
- * @exception Exception if the PageEnvelope could not be created or if the
- * language information could not be fetched from the document.
*/
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source,
Parameters parameters) throws Exception {
@@ -75,33 +51,11 @@
DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
String url = ServletHelper.getWebappURI(request);
-
- Publication pub = PublicationUtil.getPublication(this.manager, objectModel);
- if (!pub.exists()) {
- return null;
- }
-
- DocumentBuilder builder = pub.getDocumentBuilder();
- DocumentLocator locator = builder.getLocator(factory, url);
-
- Area area = pub.getArea(locator.getArea());
- SiteStructure site = area.getSite();
-
- List availableLanguages = new ArrayList();
- if (site.contains(locator.getPath())) {
- SiteNode node = site.getNode(locator.getPath());
-
- String[] languages = pub.getLanguages();
- for (int i = 0; i < languages.length; i++) {
- if (node.hasLink(languages[i])) {
- availableLanguages.add(languages[i]);
- }
- }
- }
- if (availableLanguages.contains(locator.getLanguage())) {
+ if (factory.isDocument(url)) {
return Collections.unmodifiableMap(Collections.EMPTY_MAP);
}
-
- return null;
+ else {
+ return null;
+ }
}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.