You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ed...@apache.org on 2003/12/18 18:01:18 UTC
cvs commit: cocoon-lenya/src/webapp/lenya/xslt/info info.xsl
edith 2003/12/18 09:01:18
Modified: src/webapp/lenya/xslt/rc rollback.xsl
src/java/org/apache/lenya/cms/rc RCML.java
RevisionController.java
src/webapp/lenya/xslt/info info.xsl
Log:
fixed the backup:
-in the revision view appears only the existing versions
-time version
Revision Changes Path
1.12 +36 -40 cocoon-lenya/src/webapp/lenya/xslt/rc/rollback.xsl
Index: rollback.xsl
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/xslt/rc/rollback.xsl,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- rollback.xsl 17 Nov 2003 00:09:11 -0000 1.11
+++ rollback.xsl 18 Dec 2003 17:01:18 -0000 1.12
@@ -28,46 +28,25 @@
<th>Checked in by</th>
</tr>
- <xsl:for-each select="CheckIn">
-
- <xsl:choose>
-
- <xsl:when test="position()=1">
- <tr bgcolor="#bbbbbb">
- <td>Current version</td>
- <td> </td>
- <xsl:apply-templates select="Time"/>
- <xsl:apply-templates select="Identity"/>
- </tr>
- </xsl:when>
-
- <!-- Note, important: The timestamp we're inserting into the anchor
- in each row is actually the one from the *previous* version, thus the
- position()-1 calculation. This is because in order to roll back
- to a given version, we need to reactivate the backup file which was
- written *before* that version was checked in.
- -->
-
- <xsl:when test="position()>1">
- <xsl:variable name="timeIndex" select="position() - 1"/>
- <tr bgcolor="#bbbbbb">
- <td>
- <xsl:element name="a">
- <xsl:attribute name="href"><xsl:value-of select="$requestUri"/>?lenya.usecase=<xsl:value-of select="$usecase"/>&lenya.step=rollback&documentid=<xsl:value-of select="$documentId"/>&rollbackTime=<xsl:value-of select="../CheckIn[$timeIndex]/Time"/></xsl:attribute>Rollback to this version</xsl:element>
-
- </td>
- <td>
- <xsl:element name="a">
- <xsl:attribute name="href"><xsl:value-of select="$requestUri"/>?lenya.usecase=<xsl:value-of select="$usecase"/>&lenya.step=view&documentid=<xsl:value-of select="$documentId"/>&rollbackTime=<xsl:value-of select="../CheckIn[$timeIndex]/Time"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute>View</xsl:element>
-
- </td>
- <xsl:apply-templates select="Time"/>
- <xsl:apply-templates select="Identity"/>
- </tr>
- </xsl:when>
- </xsl:choose>
-
- </xsl:for-each>
+ <xsl:for-each select="CheckIn">
+
+ <xsl:choose>
+
+ <xsl:when test="position()=1">
+ <tr>
+ <td>Current version</td>
+ <td> </td>
+ <xsl:apply-templates select="Time"/>
+ <xsl:apply-templates select="Identity"/>
+ </tr>
+ </xsl:when>
+
+ <xsl:when test="position()>1">
+ <xsl:apply-templates select="Backup"/>
+ </xsl:when>
+ </xsl:choose>
+
+ </xsl:for-each>
</table>
</body>
@@ -80,6 +59,23 @@
<xsl:template match="Identity">
<td><xsl:apply-templates/></td>
+</xsl:template>
+
+<xsl:template match="Backup">
+ <tr>
+ <td>
+ <xsl:element name="a">
+ <xsl:attribute name="href">?lenya.usecase=rollback&lenya.step=rollback&rollbackTime=<xsl:value-of select="../Time"/></xsl:attribute>Rollback to this version</xsl:element>
+
+ </td>
+ <td>
+ <xsl:element name="a">
+ <xsl:attribute name="href">?lenya.usecase=rollback&lenya.step=view&rollbackTime=<xsl:value-of select="../Time"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute>View</xsl:element>
+
+ </td>
+ <xsl:apply-templates select="../Time"/>
+ <xsl:apply-templates select="../Identity"/>
+ </tr>
</xsl:template>
</xsl:stylesheet>
1.20 +14 -10 cocoon-lenya/src/java/org/apache/lenya/cms/rc/RCML.java
Index: RCML.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/rc/RCML.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- RCML.java 15 Dec 2003 16:22:34 -0000 1.19
+++ RCML.java 18 Dec 2003 17:01:18 -0000 1.20
@@ -129,11 +129,11 @@
initDocument();
- // Create a "fake" checkin entry so it looks like the
- // system checked the document in. We use the filesystem
- // modification date as checkin time.
- //
- checkOutIn(RCML.ci, RevisionController.systemUsername, lastModified);
+ // Create a "fake" checkin entry so it looks like the
+ // system checked the document in. We use the filesystem
+ // modification date as checkin time.
+ //
+ checkOutIn(RCML.ci, RevisionController.systemUsername, lastModified, false);
File parent = new File(rcmlFile.getParent());
parent.mkdirs();
@@ -150,7 +150,7 @@
*/
public void initDocument() {
DOMParserFactory dpf = new DOMParserFactory();
- document = dpf.getDocument();
+ document = dpf.getDocument();
Element root = dpf.newElementNode(document, "XPSRevisionControl");
document.appendChild(root);
@@ -193,7 +193,7 @@
* @throws IOException if an error occurs
* @throws Exception if an error occurs
*/
- public void checkOutIn(short type, String identity, long time)
+ public void checkOutIn(short type, String identity, long time, boolean backup)
throws IOException, Exception {
DOMParserFactory dpf = new DOMParserFactory();
@@ -218,10 +218,14 @@
checkOutElement.appendChild(identityElement);
checkOutElement.appendChild(timeElement);
+ if (backup) {
+ Element backupElement = dpf.newElementNode(document, "Backup");
+ checkOutElement.appendChild(backupElement);
+ }
+
Element root = document.getDocumentElement();
- root.insertBefore(dpf.newTextNode(document, "\n"), root.getFirstChild());
+ root.insertBefore(dpf.newTextNode(document, "\n"), root.getFirstChild());
root.insertBefore(checkOutElement, root.getFirstChild());
- root.insertBefore(dpf.newTextNode(document, "\n"), root.getFirstChild());
setDirty();
1.25 +15 -18 cocoon-lenya/src/java/org/apache/lenya/cms/rc/RevisionController.java
Index: RevisionController.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/rc/RevisionController.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- RevisionController.java 15 Dec 2003 16:22:34 -0000 1.24
+++ RevisionController.java 18 Dec 2003 17:01:18 -0000 1.25
@@ -145,12 +145,6 @@
* @throws Exception if an error occurs
*/
public RCML getRCML(String source) throws FileNotFoundException, IOException, Exception {
-/*
- File file = new File(rootDir + source);
- if (!file.isFile()) {
- throw new FileNotFoundException(file.getAbsolutePath());
- }
-*/
return new RCML(rcmlDir, source, rootDir);
}
@@ -181,15 +175,17 @@
// The same user is allowed to check out repeatedly without
// having to check back in first.
//
- log.debug("entry: " + entry);
- log.debug("entry.type:" + entry.getType());
- log.debug("entry.identity" + entry.getIdentity());
+ if (entry != null) {
+ log.debug("entry: " + entry);
+ log.debug("entry.type:" + entry.getType());
+ log.debug("entry.identity" + entry.getIdentity());
+ }
if ((entry != null) && (entry.getType() != RCML.ci) && !entry.getIdentity().equals(identity)) {
throw new FileReservedCheckOutException(rootDir + source, rcml);
}
- rcml.checkOutIn(RCML.co, identity, new Date().getTime());
+ rcml.checkOutIn(RCML.co, identity, new Date().getTime(), false);
return file;
}
@@ -287,7 +283,7 @@
out.close();
}
- rcml.checkOutIn(RCML.ci, identity, time);
+ rcml.checkOutIn(RCML.ci, identity, time, backup);
rcml.pruneEntries(backupDir);
rcml.write();
@@ -348,12 +344,6 @@
//
reservedCheckOut(destination, identity);
- // Try to check back in, this might cause
- // a backup of the current version to be created if
- // desired by the user.
- //
- long newtime = reservedCheckIn(destination, identity, backupFlag);
-
// Now roll back to the old state
//
FileInputStream in = new FileInputStream(backup.getAbsolutePath());
@@ -367,6 +357,13 @@
}
out.close();
+
+ // Try to check back in, this might cause
+ // a backup of the current version to be created if
+ // desired by the user.
+ //
+ long newtime = reservedCheckIn(destination, identity, backupFlag);
+
return newtime;
}
1.50 +15 -18 cocoon-lenya/src/webapp/lenya/xslt/info/info.xsl
Index: info.xsl
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/xslt/info/info.xsl,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- info.xsl 8 Dec 2003 13:15:00 -0000 1.49
+++ info.xsl 18 Dec 2003 17:01:18 -0000 1.50
@@ -217,33 +217,30 @@
</xsl:when>
<xsl:when test="position()>1">
- <!-- Note, important: The timestamp we're inserting into the anchor
- in each row is actually the one from the *previous* version, thus the
- position()-1 calculation. This is because in order to roll back
- to a given version, we need to reactivate the backup file which was
- written *before* that version was checked in.
- -->
- <xsl:variable name="timeIndex" select="position() -1 "/>
+ <xsl:apply-templates select="Backup"/>
+ </xsl:when>
+ </xsl:choose>
+
+ </xsl:for-each>
+ </table>
+ </xsl:template>
+
+<xsl:template match="Backup">
<tr>
<td>
<xsl:element name="a">
- <xsl:attribute name="href">?lenya.usecase=rollback&lenya.step=rollback&rollbackTime=<xsl:value-of select="../CheckIn[$timeIndex]/Time"/></xsl:attribute>Rollback to this version</xsl:element>
+ <xsl:attribute name="href">?lenya.usecase=rollback&lenya.step=rollback&rollbackTime=<xsl:value-of select="../Time"/></xsl:attribute>Rollback to this version</xsl:element>
</td>
<td>
<xsl:element name="a">
- <xsl:attribute name="href">?lenya.usecase=rollback&lenya.step=view&rollbackTime=<xsl:value-of select="../CheckIn[$timeIndex]/Time"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute>View</xsl:element>
+ <xsl:attribute name="href">?lenya.usecase=rollback&lenya.step=view&rollbackTime=<xsl:value-of select="../Time"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute>View</xsl:element>
</td>
- <xsl:apply-templates select="Time"/>
- <xsl:apply-templates select="Identity"/>
+ <xsl:apply-templates select="../Time"/>
+ <xsl:apply-templates select="../Identity"/>
</tr>
- </xsl:when>
- </xsl:choose>
-
- </xsl:for-each>
- </table>
- </xsl:template>
+</xsl:template>
<xsl:template match="Time">
<td align="right"><xsl:value-of select="@humanreadable"/></td>
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org