You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/11/13 18:44:17 UTC
svn commit: r474413 [3/3] - in /lenya/trunk/src:
impl/java/org/apache/lenya/cms/publication/
impl/test/org/apache/lenya/cms/rc/ java/org/apache/lenya/cms/cocoon/acting/
java/org/apache/lenya/cms/cocoon/components/modules/input/
java/org/apache/lenya/cm...
Added: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRevision.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRevision.java?view=auto&rev=474413
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRevision.java (added)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRevision.java Mon Nov 13 09:44:15 2006
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.repository;
+
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.metadata.MetaData;
+import org.apache.lenya.cms.metadata.MetaDataException;
+import org.apache.lenya.cms.rc.CheckInEntry;
+import org.apache.lenya.cms.rc.RCML;
+import org.apache.lenya.cms.rc.RCMLEntry;
+
+/**
+ * Revision implementation.
+ */
+public class SourceNodeRevision implements Revision {
+
+ private SourceNode node;
+ private int number;
+ private ServiceManager manager;
+
+ /**
+ * @param node The node.
+ * @param number The revision number.
+ * @param manager The service manager.
+ */
+ public SourceNodeRevision(SourceNode node, int number, ServiceManager manager) {
+ this.node = node;
+ this.number = number;
+ this.manager = manager;
+ }
+
+ private long time = -1;
+
+ protected long getTime() {
+ try {
+ if (this.time == -1) {
+ SourceNodeRCML rcml = (SourceNodeRCML) this.node.getRcml();
+ Vector entries = rcml.getEntries();
+ for (Iterator i = entries.iterator(); i.hasNext();) {
+ RCMLEntry entry = (RCMLEntry) i.next();
+ if (entry.getType() == RCML.ci
+ && ((CheckInEntry) entry).getVersion() == this.number) {
+ this.time = entry.getTime();
+ }
+ }
+ }
+ if (this.time == -1) {
+ throw new RuntimeException("No entry found for [" + this.node.getSourceURI()
+ + "], revision [" + this.number + "]");
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return this.time;
+ }
+
+ public InputStream getInputStream() {
+ Source source = null;
+ SourceResolver resolver = null;
+ try {
+ String sourceUri = getSourceURI();
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+ source = resolver.resolveURI(sourceUri);
+ if (source.exists()) {
+ return source.getInputStream();
+ } else {
+ throw new RuntimeException("No check-in entry found for ["
+ + this.node.getSourceURI() + "], revision [" + this.number + "]");
+ }
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ this.manager.release(resolver);
+ }
+ }
+ }
+
+ public String getSourceURI() {
+ SourceNodeRCML rcml = (SourceNodeRCML) this.node.getRcml();
+ String sourceUri = rcml.getBackupSourceUri(getTime());
+ return sourceUri;
+ }
+
+ public int getNumber() {
+ return this.number;
+ }
+
+ public MetaData getMetaData(String namespaceUri) throws MetaDataException {
+ return getMetaDataHandler().getMetaData(namespaceUri);
+ }
+
+ private SourceNodeMetaDataHandler metaDataHandler = null;
+
+ protected SourceNodeMetaDataHandler getMetaDataHandler() {
+ if (this.metaDataHandler == null) {
+ this.metaDataHandler = new SourceNodeMetaDataHandler(this.manager, getMetaSourceUri());
+ }
+ return this.metaDataHandler;
+ }
+
+ protected String getMetaSourceUri() {
+ return this.node.getMetaSourceUri() + "." + getTime() + ".bak";
+ }
+
+ public String[] getMetaDataNamespaceUris() throws MetaDataException {
+ return getMetaDataHandler().getMetaDataNamespaceUris();
+ }
+
+ public boolean exists() throws RepositoryException {
+ try {
+ return SourceUtil.exists(getSourceURI(), this.manager);
+ } catch (Exception e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public long getContentLength() throws RepositoryException {
+ try {
+ return SourceUtil.getContentLength(getSourceURI(), this.manager);
+ } catch (Exception e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public long getLastModified() throws RepositoryException {
+ try {
+ return SourceUtil.getLastModified(getSourceURI(), this.manager);
+ } catch (Exception e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public String getMimeType() throws RepositoryException {
+ try {
+ return SourceUtil.getMimeType(getSourceURI(), this.manager);
+ } catch (Exception e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+}
Modified: lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/FilePropfind.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/FilePropfind.java?view=diff&rev=474413&r1=474412&r2=474413
==============================================================================
--- lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/FilePropfind.java (original)
+++ lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/FilePropfind.java Mon Nov 13 09:44:15 2006
@@ -17,7 +17,6 @@
*/
package org.apache.lenya.cms.usecases.webdav;
-import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Vector;
@@ -26,10 +25,8 @@
import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.publication.PublicationUtil;
import org.apache.lenya.cms.publication.URLInformation;
-import org.apache.lenya.cms.rc.RCEnvironment;
import org.apache.lenya.cms.rc.RCML;
import org.apache.lenya.cms.rc.RCMLEntry;
-import org.apache.lenya.cms.rc.RevisionController;
import org.apache.lenya.cms.site.usecases.SiteUsecase;
/**
@@ -50,34 +47,17 @@
protected void initParameters() {
super.initParameters();
- Publication _publication = this.getPublication();
-
Vector docs = new Vector();
Vector checkedOut = new Vector();
String request = getSourceURL();
try {
- // get Parameters for RC
- String publicationPath = _publication.getDirectory().getCanonicalPath();
- RCEnvironment rcEnvironment = RCEnvironment.getInstance(_publication.getServletContext()
- .getCanonicalPath());
- String rcmlDirectory = rcEnvironment.getRCMLDirectory();
- rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
- String backupDirectory = rcEnvironment.getBackupDirectory();
- backupDirectory = publicationPath + File.separator + backupDirectory;
-
- // Initialize Revision Controller
- RevisionController rc = new RevisionController(rcmlDirectory,
- backupDirectory,
- publicationPath);
Document doc = getTargetDocument(false);
docs.add(doc);
- String filename = doc.getFile().getCanonicalPath();
- filename = filename.substring(publicationPath.length());
- RCMLEntry entry = rc.getRCML(filename).getLatestEntry();
+ RCMLEntry entry = doc.getRepositoryNode().getRcml().getLatestEntry();
if ((entry != null) && (entry.getType() == RCML.co))
checkedOut.add(entry);
else
Modified: lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java?view=diff&rev=474413&r1=474412&r2=474413
==============================================================================
--- lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java (original)
+++ lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java Mon Nov 13 09:44:15 2006
@@ -17,7 +17,6 @@
*/
package org.apache.lenya.cms.usecases.webdav;
-import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
@@ -28,10 +27,8 @@
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.publication.PublicationUtil;
-import org.apache.lenya.cms.rc.RCEnvironment;
import org.apache.lenya.cms.rc.RCML;
import org.apache.lenya.cms.rc.RCMLEntry;
-import org.apache.lenya.cms.rc.RevisionController;
import org.apache.lenya.cms.site.SiteManager;
import org.apache.lenya.cms.site.usecases.SiteUsecase;
@@ -78,19 +75,6 @@
request = request.replaceFirst("webdav", "authoring");
}
try {
- // get Parameters for RC
- String publicationPath = _publication.getDirectory().getCanonicalPath();
- RCEnvironment rcEnvironment = RCEnvironment.getInstance(_publication.getServletContext()
- .getCanonicalPath());
- String rcmlDirectory = rcEnvironment.getRCMLDirectory();
- rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
- String backupDirectory = rcEnvironment.getBackupDirectory();
- backupDirectory = publicationPath + File.separator + backupDirectory;
-
- // Initialize Revision Controller
- RevisionController rc = new RevisionController(rcmlDirectory,
- backupDirectory,
- publicationPath);
siteManagerSelector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE
+ "Selector");
@@ -110,9 +94,7 @@
if (test.equals(request)) {
docs.add(documents[i]);
- String filename = documents[i].getFile().getCanonicalPath();
- filename = filename.substring(publicationPath.length());
- RCMLEntry entry = rc.getRCML(filename).getLatestEntry();
+ RCMLEntry entry = documents[i].getRepositoryNode().getRcml().getLatestEntry();
if ((entry != null) && (entry.getType() == RCML.co))
checkedOut.add(entry);
else
Modified: lenya/trunk/src/modules/xhtml/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/xhtml/sitemap.xmap?view=diff&rev=474413&r1=474412&r2=474413
==============================================================================
--- lenya/trunk/src/modules/xhtml/sitemap.xmap (original)
+++ lenya/trunk/src/modules/xhtml/sitemap.xmap Mon Nov 13 09:44:15 2006
@@ -69,8 +69,11 @@
<!-- View Revision? -->
<map:match pattern="*.xml">
<map:match type="step" pattern="view-revision">
+ <!--
<map:generate type="serverpages" src="fallback://lenya/content/rc/view.xsp">
</map:generate>
+ -->
+ <map:generate src="lenya-document:{page-envelope:document-uuid},lang={page-envelope:document-language},rev={request-param:rev}"/>
<map:transform src="fallback://lenya/xslt/rc/toDoc.xsl"/>
<map:transform src="fallback://lenya/modules/xhtml/xslt/xhtml2xhtml.xsl">
<map:parameter name="rendertype" value="{1}"/>
Modified: lenya/trunk/src/pubs/blog/java/src/org/apache/cocoon/generation/BlogGenerator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/blog/java/src/org/apache/cocoon/generation/BlogGenerator.java?view=diff&rev=474413&r1=474412&r2=474413
==============================================================================
--- lenya/trunk/src/pubs/blog/java/src/org/apache/cocoon/generation/BlogGenerator.java (original)
+++ lenya/trunk/src/pubs/blog/java/src/org/apache/cocoon/generation/BlogGenerator.java Mon Nov 13 09:44:15 2006
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.Date;
import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
@@ -28,6 +29,7 @@
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
@@ -128,8 +130,14 @@
Document[] docs = siteManager.getDocuments(map, publication, area);
Arrays.sort((Object[]) docs, new Comparator() {
public int compare(Object o1, Object o2) {
- return ((Document) o2).getLastModified()
- .compareTo(((Document) o1).getLastModified());
+ try {
+ Date d1 = new Date(((Document) o2).getLastModified());
+ Date d2 = new Date(((Document) o1).getLastModified());
+ return d2.compareTo(d1);
+ }
+ catch (DocumentException e) {
+ throw new RuntimeException(e);
+ }
}
});
@@ -144,7 +152,7 @@
LASTMOD_ATTR_NAME,
LASTMOD_ATTR_NAME,
"CDATA",
- String.valueOf(docs[i].getLastModified().getTime()));
+ String.valueOf(docs[i].getLastModified()));
this.contentHandler.startElement(URI, ENTRY_NODE_NAME, PREFIX + ':'
+ ENTRY_NODE_NAME, attributes);
Modified: lenya/trunk/src/pubs/blog/java/src/org/apache/cocoon/generation/BlogOverviewGenerator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/blog/java/src/org/apache/cocoon/generation/BlogOverviewGenerator.java?view=diff&rev=474413&r1=474412&r2=474413
==============================================================================
--- lenya/trunk/src/pubs/blog/java/src/org/apache/cocoon/generation/BlogOverviewGenerator.java (original)
+++ lenya/trunk/src/pubs/blog/java/src/org/apache/cocoon/generation/BlogOverviewGenerator.java Mon Nov 13 09:44:15 2006
@@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.Date;
import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
@@ -298,7 +299,13 @@
return 1;
} else if (day1 == day2) {
/* newest first */
- return d2.getLastModified().compareTo(d1.getLastModified());
+ try {
+ Date date1 = new Date(d1.getLastModified());
+ Date date2 = new Date(d2.getLastModified());
+ return date2.compareTo(date1);
+ } catch (DocumentException e) {
+ throw new RuntimeException(e);
+ }
} else {
return -1;
}
@@ -395,7 +402,7 @@
attributes.addAttribute("", TITLE_ATTR_NAME,
TITLE_ATTR_NAME, "CDATA",DocumentHelper.getSimpleElementText(element));
attributes.addAttribute("", LASTMOD_ATTR_NAME,
- LASTMOD_ATTR_NAME, "CDATA", String.valueOf(doc.getLastModified().getTime()));
+ LASTMOD_ATTR_NAME, "CDATA", String.valueOf(doc.getLastModified()));
DocumentHelper.getSimpleElementText(element);
this.contentHandler.startElement(URI, ENTRY_NODE_NAME,
PREFIX + ':' + ENTRY_NODE_NAME, attributes);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org