Author: andreas
Date: Sun Aug 12 05:50:57 2007
New Revision: 565057
URL: http://svn.apache.org/viewvc?view=rev&rev=565057
Log:
[refactoring] better code re-use in DocumentFactoryImpl
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java?view=diff&rev=565057&r1=565056&r2=565057
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java Sun Aug 12 05:50:57 2007
@@ -27,7 +27,6 @@
import org.apache.lenya.cms.repository.RepositoryException;
import org.apache.lenya.cms.repository.RepositoryItem;
import org.apache.lenya.cms.repository.Session;
-import org.apache.lenya.cms.repository.UUIDGenerator;
import org.apache.lenya.cms.site.SiteStructure;
import org.apache.lenya.cms.site.SiteUtil;
@@ -217,17 +216,14 @@
* @return A key.
*/
public String getKey(String webappUrl) {
- DocumentLocator locator = getLocator(webappUrl);
- String area = locator.getArea();
- String uuid = null;
try {
- Publication publication = getPublication(locator.getPublicationId());
- if (SiteUtil.isDocument(this, webappUrl)) {
- uuid = publication.getArea(area).getSite().getNode(locator.getPath()).getUuid();
- } else {
- UUIDGenerator generator = (UUIDGenerator) this.manager.lookup(UUIDGenerator.ROLE);
- uuid = generator.nextUUID();
+ if (!isDocument(webappUrl)) {
+ throw new RuntimeException("No document for URL [" + webappUrl + "] found.");
}
+ DocumentLocator locator = getLocator(webappUrl);
+ Publication publication = getPublication(locator.getPublicationId());
+ String area = locator.getArea();
+ String uuid = publication.getArea(area).getSite().getNode(locator.getPath()).getUuid();
return getKey(publication, area, uuid, locator.getLanguage());
} catch (Exception e) {
throw new RuntimeException(e);
@@ -287,8 +283,8 @@
}
/**
- * Creates a new document object. Override this method to create specific
- * document objects, e.g., for different document IDs.
+ * Creates a new document object. Override this method to create specific document objects,
+ * e.g., for different document IDs.
* @param map The identity map.
* @param identifier The identifier.
* @param builder The document builder.
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.