Hi Michi,
thanks for your commits - but I have some comments:
+import org.apache.log4j.Category;
please don't introduce a custom logging concept for single classes.
DefaultDocument is already LogEnabled.
/**
* A typical CMS document.
@@ -42,6 +43,8 @@
*/
public class DefaultDocument extends AbstractLogEnabled implements Document {
+ private Category log = Category.getInstance(DefaultDocument.class);
+
private DocumentIdentifier identifier;
private String sourceURI;
private DocumentIdentityMap identityMap;
@@ -134,11 +137,15 @@
List documentLanguages = new ArrayList();
String[] allLanguages = getPublication().getLanguages();
+ log.debug("Number of languages of this publication: " + allLanguages.length);
Please use
if (getLogger().isDebugEnabled()) { ... }
for performance reasons.
+
for (int i = 0; i < allLanguages.length; i++) {
Document version;
try {
+ log.debug("Try to create document: " + allLanguages[i] + " " +
this);
version = getIdentityMap().getLanguageVersion(this,
allLanguages[i]);
} catch (DocumentBuildException e) {
+ log.warn(e.getMessage());
throw new DocumentException(e);
}
if (version.exists()) {
@@ -191,6 +198,9 @@
return this.extension;
}
+ /**
+ * @see org.apache.lenya.cms.publication.Document#getSourceExtension()
+ */
public String getSourceExtension() {
String extension;
try {
@@ -200,6 +210,7 @@
throw new RuntimeException(e);
}
if (extension == null) {
+ getLogger().warn("No source extension. The extension \"xml\" will be
used as default!");
extension = "xml";
}
return extension;
@@ -264,6 +275,20 @@
public boolean existsInAnyLanguage() throws DocumentException {
boolean exists = false;
+ String[] languages = getLanguages();
+
+ if (languages.length > 0) {
+ log.warn("Document (" + this + ") exists in at least one language:
" + languages.length);
This warning message is not appropriate. Please use debug instead.
Too many warning logs will affect performance.
+ String[] allLanguages = getPublication().getLanguages();
+ if (languages.length == allLanguages.length) log.warn("Document (" +
this + ") exists even in all languages of this publication");
+ return true;
+ } else {
+ log.warn("Document (" + this + ") does NOT exist in any
language");
Same here. A warning is not appropriate here, because it is normal
behaviour.
-- Andreas
+ return false;
+ }
+
+// NOTE: This seems to be unecessary because getLanguage() already creates
these documents
+/*
try {
String[] languages = getLanguages();
for (int i = 0; i < languages.length; i++) {
@@ -274,6 +299,7 @@
throw new DocumentException(e);
}
return exists;
+*/
}
protected DocumentIdentifier getIdentifier() {
@@ -341,16 +367,22 @@
* @see org.apache.lenya.cms.metadata.MetaDataOwner#getMetaDataManager()
*/
public MetaDataManager getMetaDataManager() {
+ log.debug("getSourceURI(): " + getPublication().getSourceURI());
if (this.metaDataManager == null) {
SourceResolver resolver = null;
RepositorySource source = null;
try {
resolver = (SourceResolver)
this.manager.lookup(SourceResolver.ROLE);
+
+ // TODO: This needs to be improved ...
String sourceUri = getPublication().getSourceURI() +
"/content/" + getArea()
+ getId() + "/index_" + getLanguage() + ".xml";
+
+ log.debug("Source URI: " + sourceUri);
source = (RepositorySource) resolver.resolveURI(sourceUri);
this.metaDataManager = source.getNode().getMetaDataManager();
} catch (Exception e) {
+ log.warn(e.getMessage());
throw new RuntimeException(e);
} finally {
if (resolver != null) {
--
Andreas Hartmann
Wyona Inc. - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
[EMAIL PROTECTED] [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]