[Registry-dev] svn commit r16629 - in trunk/registry: .
modules/core modules/core/src/main/java/org/wso2/registry
modules/core/src/main/java/org/wso2/registry/jdbc
modules/core/src/main/java/org/wso2/registry/jdbc/dao
modules/core/src/main/java/org/wso2/registry/jdbc/dataobjects
modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators
modules/core/src/main/resources/database-scripts
modules/core/src/test/java/org/wso2/registry/jdbc
svn at wso2.org
svn at wso2.org
Wed May 7 10:53:26 PDT 2008
Author: chathura
Date: Wed May 7 10:53:04 2008
New Revision: 16629
Log:
Added support for permanent links (permalinks) of resources.
Now it is possible to access the permalink of resources/collections from the Resource interface.
Permalink is only available if the resource is versioned.
Updated the database creation code and database scripts to contain permalink field.
Corrected a spelling mistake in pom.xmls, which causes the build to fail.
Modified:
trunk/registry/modules/core/pom.xml
trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/VersionRepository.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceDAO.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceVersionDAO.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/RestoreUtilDAO.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dataobjects/ResourceDO.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/DerbyDatabaseCreator.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/HSQLDatabaseCreator.java
trunk/registry/modules/core/src/main/resources/database-scripts/derby-complete.sql
trunk/registry/modules/core/src/main/resources/database-scripts/derby-registry.sql
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/VersionHandlingTest.java
trunk/registry/pom.xml
Modified: trunk/registry/modules/core/pom.xml
==============================================================================
--- trunk/registry/modules/core/pom.xml (original)
+++ trunk/registry/modules/core/pom.xml Wed May 7 10:53:04 2008
@@ -163,11 +163,11 @@
<artifactId>derby</artifactId>
</dependency>
<dependency>
- <groupId>elipse</groupId>
+ <groupId>eclipse</groupId>
<artifactId>validateutility</artifactId>
</dependency>
<dependency>
- <groupId>elipse</groupId>
+ <groupId>eclipse</groupId>
<artifactId>eclipse-wsdl-validator</artifactId>
</dependency>
<dependency>
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java Wed May 7 10:53:04 2008
@@ -36,6 +36,15 @@
String getPath();
+ /**
+ * If resource is versioned, the associated version of the resource does not get modified by
+ * any means. Therefore, the path of that version is the permanent path (permalink) of the
+ * current state of the resource.
+ *
+ * @return Permanent path (permalink) of the resource.
+ */
+ String getPermanentPath();
+
String getMediaType();
int getState();
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java Wed May 7 10:53:04 2008
@@ -91,6 +91,10 @@
*/
protected String path;
+ protected long matchingSnapshotID;
+
+ protected String permanentPath;
+
/**
* Media type of the resource. Each resource can have a media type associated with it. This can
* be either a standart MIME media type or a custom media type defined by the users of the
@@ -248,6 +252,24 @@
this.path = preparePath(path);
}
+ public long getMatchingSnapshotID() {
+ return matchingSnapshotID;
+ }
+
+ public void setMatchingSnapshotID(long matchingSnapshotID) {
+ this.matchingSnapshotID = matchingSnapshotID;
+ }
+
+ public String getPermanentPath() {
+
+ if (permanentPath == null) {
+ permanentPath = path + RegistryConstants.URL_SEPARATOR +
+ "version=" + matchingSnapshotID;
+ }
+
+ return permanentPath;
+ }
+
public String getMediaType() {
return mediaType;
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/VersionRepository.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/VersionRepository.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/VersionRepository.java Wed May 7 10:53:04 2008
@@ -53,6 +53,8 @@
String snapshotRootID = resourceDAO.getResourceID(path);
long snapshotID = resourceVersionDAO.addSnapshot(snapshotRootID);
+ resourceDAO.setSnapshotID(snapshotRootID, snapshotID);
+
versionSnapshotNetwork(snapshotID, snapshotRootID);
}
@@ -176,6 +178,10 @@
ResourceDO resourceVersionDO =
resourceVersionDAO.getResourceVersionDO(resourceID, snapshotID);
ResourceDO resourceDO = resourceDAO.getResourceDO(resourceID);
+
+ //long matchingSnapshotID = resourceVersionDAO.
+ // getMatchingSnapshotID(resourceID, resourceVersionDO.getVersion());
+
if (resourceDO != null) {
resourcePath = resourceDO.getPath();
@@ -197,8 +203,8 @@
// collection.
String contentID = restoreUtilDAO.copyContentVersion(resourceVersionDO);
- restoreUtilDAO.mergeResourceVersion(
- resourceDO, resourceVersionDO, contentID);
+ restoreUtilDAO.
+ mergeResourceVersion(resourceDO, resourceVersionDO, contentID);
} else {
// both version to be restored and the current version are resources
@@ -226,7 +232,8 @@
contentID = restoreUtilDAO.copyContentVersion(resourceVersionDO);
}
- restoreUtilDAO.copyResourceVersion(resourceVersionDO, contentID, resourcePath);
+ restoreUtilDAO.copyResourceVersion(
+ resourceVersionDO, contentID, resourcePath);
restoreUtilDAO.copyProperties(resourceID, resourceVersionDO.getVersion());
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceDAO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceDAO.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceDAO.java Wed May 7 10:53:04 2008
@@ -562,7 +562,9 @@
try {
String sql = "SELECT RID, PATH, MEDIA_TYPE, COLLECTION, CREATOR, CREATED_TIME, " +
- "LAST_UPDATOR, LAST_UPDATED_TIME, DESCRIPTION, CONTENT_ID FROM RESOURCE WHERE PATH=?";
+ "LAST_UPDATOR, LAST_UPDATED_TIME, DESCRIPTION, CONTENT_ID, " +
+ "ASSOCIATED_SNAPSHOT_ID " +
+ "FROM RESOURCE WHERE PATH=?";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, path);
@@ -591,6 +593,7 @@
resourceImpl.setLastModified(result.getTimestamp("LAST_UPDATED_TIME"));
resourceImpl.setDescription(result.getString("DESCRIPTION"));
resourceImpl.setContentID(result.getString("CONTENT_ID"));
+ resourceImpl.setMatchingSnapshotID(result.getLong("ASSOCIATED_SNAPSHOT_ID"));
}
ps.close();
@@ -611,7 +614,9 @@
try {
String sql = "SELECT RID, PATH, MEDIA_TYPE, COLLECTION, CREATOR, CREATED_TIME, " +
- "LAST_UPDATOR, LAST_UPDATED_TIME, DESCRIPTION, CONTENT_ID FROM RESOURCE WHERE RID=?";
+ "LAST_UPDATOR, LAST_UPDATED_TIME, DESCRIPTION, CONTENT_ID, " +
+ "ASSOCIATED_SNAPSHOT_ID " +
+ "FROM RESOURCE WHERE RID=?";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, resourceID);
@@ -640,6 +645,7 @@
resourceImpl.setLastModified(result.getTimestamp("LAST_UPDATED_TIME"));
resourceImpl.setDescription(result.getString("DESCRIPTION"));
resourceImpl.setContentID(result.getString("CONTENT_ID"));
+ resourceImpl.setMatchingSnapshotID(result.getLong("ASSOCIATED_SNAPSHOT_ID"));
}
ps.close();
@@ -732,8 +738,8 @@
try {
String sql = "INSERT INTO RESOURCE (RID, PATH, MEDIA_TYPE, COLLECTION, CREATOR, " +
"CREATED_TIME, LAST_UPDATOR, LAST_UPDATED_TIME, DESCRIPTION, " +
- "CONTENT_ID, EQUIVALENT_VERSION) " +
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ "CONTENT_ID, EQUIVALENT_VERSION, ASSOCIATED_SNAPSHOT_ID) " +
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
long now = System.currentTimeMillis();
@@ -748,7 +754,11 @@
ps.setTimestamp(8, new Timestamp(now));
ps.setString(9, resourceImpl.getDescription());
ps.setString(10, resourceImpl.getContentID());
- ps.setInt(11, -1); // this is a new resource. so there is no equivalent version.
+ ps.setLong(11, -1); // this is a new resource. so there is no equivalent version.
+
+ // we are not aware of any snapshots created for this state of the resource. if a
+ // snapshot is created, version repository is responsible for updating this feild.
+ ps.setLong(12, -1);
ps.executeUpdate();
@@ -1153,7 +1163,8 @@
String sql = "SELECT R.RID, R.EQUIVALENT_VERSION, R.PATH, R.MEDIA_TYPE, R.COLLECTION, " +
"R.CREATOR, R.CREATED_TIME, R.LAST_UPDATOR, R.LAST_UPDATED_TIME, " +
- "R.DESCRIPTION, R.CONTENT_ID FROM RESOURCE R WHERE R.RID=?";
+ "R.DESCRIPTION, R.CONTENT_ID, R.ASSOCIATED_SNAPSHOT_ID " +
+ "FROM RESOURCE R WHERE R.RID=?";
try {
PreparedStatement ps = conn.prepareStatement(sql);
@@ -1175,6 +1186,7 @@
resourceDO.setLastUpdatedOn(result.getTimestamp("LAST_UPDATED_TIME"));
resourceDO.setDescription(result.getString("DESCRIPTION"));
resourceDO.setContentID(result.getString("CONTENT_ID"));
+ resourceDO.setAssociatedSnapshotID(result.getLong("ASSOCIATED_SNAPSHOT_ID"));
}
return resourceDO;
@@ -1247,4 +1259,27 @@
throw new RegistryException(msg, e);
}
}
+
+ public void setSnapshotID(String resourceID, long snapshotID) throws RegistryException {
+
+ Connection conn = Transaction.getConnection();
+
+ String sql = "UPDATE RESOURCE SET ASSOCIATED_SNAPSHOT_ID=? WHERE RID=?";
+
+ try {
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ps.setLong(1, snapshotID);
+ ps.setString(2, resourceID);
+ ps.executeUpdate();
+ ps.close();
+
+ } catch (SQLException e) {
+
+ String msg = "Failed to set the snapshot ID for the resource " +
+ resourceID + ". " + e.getMessage();
+ log.error(msg, e);
+ throw new RegistryException(msg, e);
+ }
+
+ }
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceVersionDAO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceVersionDAO.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceVersionDAO.java Wed May 7 10:53:04 2008
@@ -111,8 +111,9 @@
Connection conn = Transaction.getConnection();
String sql = "INSERT INTO RESOURCE_VERSION (RID, VERSION, PATH, MEDIA_TYPE, COLLECTION, " +
- "CREATOR, CREATED_TIME, LAST_UPDATOR, LAST_UPDATED_TIME, DESCRIPTION, CONTENT_ID) " +
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ "CREATOR, CREATED_TIME, LAST_UPDATOR, LAST_UPDATED_TIME, DESCRIPTION, CONTENT_ID, " +
+ "ASSOCIATED_SNAPSHOT_ID) " +
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try {
PreparedStatement ps = conn.prepareStatement(sql);
@@ -128,6 +129,7 @@
ps.setTimestamp(9, new Timestamp(resourceImpl.getLastModified().getTime()));
ps.setString(10, resourceImpl.getDescription());
ps.setString(11, contentVersionID);
+ ps.setLong(12, resourceImpl.getMatchingSnapshotID());
ps.executeUpdate();
ps.close();
@@ -614,7 +616,7 @@
String sql = "SELECT R.RID, R.VERSION, R.PATH, R.MEDIA_TYPE, R.COLLECTION, " +
"R.CREATOR, R.CREATED_TIME, R.LAST_UPDATOR, R.LAST_UPDATED_TIME, " +
- "R.DESCRIPTION, R.CONTENT_ID " +
+ "R.DESCRIPTION, R.CONTENT_ID, R.ASSOCIATED_SNAPSHOT_ID " +
"FROM RESOURCE_VERSION R WHERE R.RID=? AND R.VERSION=" +
"(SELECT S.VERSION FROM SNAPSHOT_RESOURCE_VERSION S " +
"WHERE S.SNAPSHOT_ID=? AND S.RID=?)";
@@ -641,6 +643,7 @@
resourceVersionDO.setLastUpdatedOn(result.getTimestamp("LAST_UPDATED_TIME"));
resourceVersionDO.setDescription(result.getString("DESCRIPTION"));
resourceVersionDO.setContentID(result.getString("CONTENT_ID"));
+ resourceVersionDO.setAssociatedSnapshotID(result.getLong("ASSOCIATED_SNAPSHOT_ID"));
}
return resourceVersionDO;
@@ -684,4 +687,102 @@
return childIDs;
}
+
+ /**
+ * Given a resource ID and a version number there may or may not be a snapshot ID. That is,
+ * whenever a snapshot is created, an associating version of the resource is prepared. But,
+ * when creating a snapshot of a collection, new versions will be created for all dirty child
+ * resources/collections. Such resources/collection versions do not have a matching snapshot ID.
+ * Such versions are just a part of a snapshot of another collection. And it is possible to
+ * have more than one matching snapshot for a given resource ID and a version. A simple
+ * example is creating two snapshots of a resource, without modifying the resource.
+ *
+ * This method returns the latest (highest) snapshot ID for the given resource ID and
+ * the version. If a mathcing snapshot is not found, it will return -1.
+ *
+ * @param resourceID UUID of the resource
+ * @param version Version number of the resource.
+ * @return Matching snapshot number if available. -1 otherwise.
+ * @throws RegistryException
+ */
+ public long getMatchingSnapshotID(String resourceID, long version) throws RegistryException {
+
+ List <Long> actualSnapshotIDs = getSnapshotIDsForResourceID(resourceID);
+ if (actualSnapshotIDs.size() == 0) {
+ return -1;
+ }
+
+ List <Long> possibleSnapshotIDs = getSnapshotIDs(resourceID, version);
+
+ long matchingSID = -1;
+ for (int i = 0; i < actualSnapshotIDs.size(); i++) {
+ long actualSID = actualSnapshotIDs.get(i);
+ if (possibleSnapshotIDs.contains(actualSID)) {
+ matchingSID = actualSID;
+ }
+ }
+
+ return matchingSID;
+ }
+
+ private List<Long> getSnapshotIDsForResourceID(String resourceID) throws RegistryException {
+
+ Connection conn = Transaction.getConnection();
+
+ String sql = "SELECT SNAPSHOT_ID FROM SNAPSHOT WHERE ROOT_ID=? ORDER BY SNAPSHOT_ID DESC";
+
+ try {
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ps.setString(1, resourceID);
+
+ ResultSet results = ps.executeQuery();
+ List <Long> snapshotIDs = new ArrayList <Long> ();
+ while(results.next()) {
+ long snapshotNumber = results.getLong("SNAPSHOT_ID");
+ snapshotIDs.add(snapshotNumber);
+ }
+ ps.close();
+
+ return snapshotIDs;
+
+ } catch (SQLException e) {
+
+ String msg = "Failed to get snapshot numbers of resource " +
+ resourceID + ". " + e.getMessage();
+ log.error(msg, e);
+ throw new RegistryException(msg, e);
+ }
+
+ }
+
+ private List<Long> getSnapshotIDs(String resourceID, long version) throws RegistryException {
+
+ Connection conn = Transaction.getConnection();
+
+ String sql = "SELECT SNAPSHOT_ID FROM SNAPSHOT_RESOURCE_VERSION WHERE RID=? AND VERSION=?";
+
+ try {
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ps.setString(1, resourceID);
+ ps.setLong(2, version);
+
+ ResultSet results = ps.executeQuery();
+
+ List <Long> sids = new ArrayList <Long> ();
+ while (results.next()) {
+ sids.add(results.getLong("SNAPSHOT_ID"));
+ }
+ ps.close();
+
+ return sids;
+
+ } catch (SQLException e) {
+
+ String msg = "Failed to matching snapshot IDs for resource ID " +
+ resourceID + " and version " + version + ". " + e.getMessage();
+ log.error(msg, e);
+ throw new RegistryException(msg, e);
+ }
+
+ }
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/RestoreUtilDAO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/RestoreUtilDAO.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/RestoreUtilDAO.java Wed May 7 10:53:04 2008
@@ -58,7 +58,8 @@
Connection conn = Transaction.getConnection();
String sql = "UPDATE RESOURCE SET EQUIVALENT_VERSION=?, MEDIA_TYPE=?, " +
- "LAST_UPDATOR=?, LAST_UPDATED_TIME=?, DESCRIPTION=?, CONTENT_ID=? WHERE RID=?";
+ "LAST_UPDATOR=?, LAST_UPDATED_TIME=?, DESCRIPTION=?, CONTENT_ID=?, " +
+ "ASSOCIATED_SNAPSHOT_ID=? WHERE RID=?";
try {
PreparedStatement ps = conn.prepareStatement(sql);
@@ -69,7 +70,8 @@
ps.setTimestamp(4, resourceVersionDO.getLastUpdatedOn());
ps.setString(5, resourceVersionDO.getDescription());
ps.setString(6, contentID);
- ps.setString(7, resourceDO.getID());
+ ps.setLong(7, resourceVersionDO.getAssociatedSnapshotID());
+ ps.setString(8, resourceDO.getID());
ps.executeUpdate();
ps.close();
@@ -195,9 +197,10 @@
Connection conn = Transaction.getConnection();
- String sql = "INSERT INTO RESOURCE (RID, PATH, MEDIA_TYPE, COLLECTION, CREATOR, CREATED_TIME, " +
- "LAST_UPDATOR, LAST_UPDATED_TIME, DESCRIPTION, CONTENT_ID, EQUIVALENT_VERSION) " +
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ String sql = "INSERT INTO RESOURCE (RID, PATH, MEDIA_TYPE, COLLECTION, CREATOR, " +
+ "CREATED_TIME, LAST_UPDATOR, LAST_UPDATED_TIME, DESCRIPTION, CONTENT_ID, " +
+ "EQUIVALENT_VERSION, ASSOCIATED_SNAPSHOT_ID) " +
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try {
PreparedStatement ps = conn.prepareStatement(sql);
@@ -213,6 +216,7 @@
ps.setString(9, resourceVersionDO.getDescription());
ps.setString(10, contentID);
ps.setLong(11, resourceVersionDO.getVersion());
+ ps.setLong(12, resourceVersionDO.getAssociatedSnapshotID());
ps.executeUpdate();
ps.close();
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dataobjects/ResourceDO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dataobjects/ResourceDO.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dataobjects/ResourceDO.java Wed May 7 10:53:04 2008
@@ -44,6 +44,8 @@
private String contentID;
+ private long associatedSnapshotID;
+
public String getID() {
return ID;
}
@@ -139,4 +141,12 @@
public void setContentID(String contentID) {
this.contentID = contentID;
}
+
+ public long getAssociatedSnapshotID() {
+ return associatedSnapshotID;
+ }
+
+ public void setAssociatedSnapshotID(long associatedSnapshotID) {
+ this.associatedSnapshotID = associatedSnapshotID;
+ }
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/DerbyDatabaseCreator.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/DerbyDatabaseCreator.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/DerbyDatabaseCreator.java Wed May 7 10:53:04 2008
@@ -33,6 +33,7 @@
"DESCRIPTION VARCHAR (10000)," +
"CONTENT_ID VARCHAR (50)," +
"EQUIVALENT_VERSION INTEGER NOT NULL," +
+ "ASSOCIATED_SNAPSHOT_ID INTEGER NOT NULL," +
"PRIMARY KEY (RID)," +
"FOREIGN KEY (CONTENT_ID) REFERENCES CONTENT (CONTENT_ID)," +
"UNIQUE(PATH))";
@@ -140,6 +141,7 @@
"LAST_UPDATED_TIME TIMESTAMP," +
"DESCRIPTION VARCHAR (10000)," +
"CONTENT_ID VARCHAR (50)," +
+ "ASSOCIATED_SNAPSHOT_ID INTEGER NOT NULL," +
"FOREIGN KEY (CONTENT_ID) REFERENCES CONTENT_VERSION (CONTENT_VERSION_ID)," +
"PRIMARY KEY (RESOURCE_VERSION_ID)," +
"UNIQUE(RID, VERSION))";
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/HSQLDatabaseCreator.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/HSQLDatabaseCreator.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/creators/HSQLDatabaseCreator.java Wed May 7 10:53:04 2008
@@ -36,6 +36,7 @@
"DESCRIPTION VARCHAR (10000)," +
"CONTENT_ID VARCHAR (50)," +
"EQUIVALENT_VERSION INTEGER NOT NULL," +
+ "ASSOCIATED_SNAPSHOT_ID INTEGER NOT NULL," +
"PRIMARY KEY (RID)," +
"FOREIGN KEY (CONTENT_ID) REFERENCES CONTENT (CONTENT_ID)," +
"UNIQUE(PATH));";
@@ -143,6 +144,7 @@
"LAST_UPDATED_TIME TIMESTAMP," +
"DESCRIPTION VARCHAR (10000)," +
"CONTENT_ID VARCHAR (50)," +
+ "ASSOCIATED_SNAPSHOT_ID INTEGER NOT NULL," +
"FOREIGN KEY (CONTENT_ID) REFERENCES CONTENT_VERSION (CONTENT_VERSION_ID)," +
"PRIMARY KEY (RESOURCE_VERSION_ID)," +
"UNIQUE (RID, VERSION))";
Modified: trunk/registry/modules/core/src/main/resources/database-scripts/derby-complete.sql
==============================================================================
--- trunk/registry/modules/core/src/main/resources/database-scripts/derby-complete.sql (original)
+++ trunk/registry/modules/core/src/main/resources/database-scripts/derby-complete.sql Wed May 7 10:53:04 2008
@@ -16,6 +16,7 @@
DESCRIPTION VARCHAR (10000),
CONTENT_ID VARCHAR (50),
EQUIVALENT_VERSION INTEGER NOT NULL,
+ ASSOCIATED_SNAPSHOT_ID INTEGER NOT NULL,
PRIMARY KEY (RID),
FOREIGN KEY (CONTENT_ID) REFERENCES CONTENT (CONTENT_ID),
UNIQUE(PATH));
@@ -98,6 +99,7 @@
LAST_UPDATED_TIME TIMESTAMP,
DESCRIPTION VARCHAR (10000),
CONTENT_ID VARCHAR (50),
+ ASSOCIATED_SNAPSHOT_ID INTEGER NOT NULL,
FOREIGN KEY (CONTENT_ID) REFERENCES CONTENT_VERSION (CONTENT_VERSION_ID),
PRIMARY KEY (RESOURCE_VERSION_ID),
UNIQUE(RID, VERSION));
Modified: trunk/registry/modules/core/src/main/resources/database-scripts/derby-registry.sql
==============================================================================
--- trunk/registry/modules/core/src/main/resources/database-scripts/derby-registry.sql (original)
+++ trunk/registry/modules/core/src/main/resources/database-scripts/derby-registry.sql Wed May 7 10:53:04 2008
@@ -16,6 +16,7 @@
DESCRIPTION VARCHAR (10000),
CONTENT_ID VARCHAR (50),
EQUIVALENT_VERSION INTEGER NOT NULL,
+ ASSOCIATED_SNAPSHOT_ID INTEGER NOT NULL,
PRIMARY KEY (RID),
FOREIGN KEY (CONTENT_ID) REFERENCES CONTENT (CONTENT_ID),
UNIQUE(PATH));
@@ -98,6 +99,7 @@
LAST_UPDATED_TIME TIMESTAMP,
DESCRIPTION VARCHAR (10000),
CONTENT_ID VARCHAR (50),
+ ASSOCIATED_SNAPSHOT_ID INTEGER NOT NULL,
FOREIGN KEY (CONTENT_ID) REFERENCES CONTENT_VERSION (CONTENT_VERSION_ID),
PRIMARY KEY (RESOURCE_VERSION_ID),
UNIQUE(RID, VERSION));
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/VersionHandlingTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/VersionHandlingTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/VersionHandlingTest.java Wed May 7 10:53:04 2008
@@ -312,4 +312,56 @@
String r1e3Content = new String((byte[]) r1e3.getContent());
assertEquals("c11/r1 content should be 'r1c2", r1e3Content, "r1c2");
}
+
+ public void testPermaLinksForResources() throws RegistryException {
+
+ Resource r1 = registry.newResource();
+ r1.setContent("r1c1");
+ registry.put("/test/v13/r1", r1);
+
+ String[] r1Versions = registry.getVersions("/test/v13/r1");
+
+ Resource r1e1 = registry.get("/test/v13/r1");
+ assertEquals("Permalink incorrect", r1e1.getPermanentPath(), r1Versions[0]);
+
+ r1e1.setContent("r1c2");
+ registry.put("/test/v13/r1", r1e1);
+
+ r1Versions = registry.getVersions("/test/v13/r1");
+
+ Resource r1e2 = registry.get("/test/v13/r1");
+ assertEquals("Permalink incorrect", r1e2.getPermanentPath(), r1Versions[0]);
+
+ registry.restoreVersion(r1Versions[1]);
+
+ Resource r1e3 = registry.get("/test/v13/r1");
+ assertEquals("Permalink incorrect", r1e3.getPermanentPath(), r1Versions[1]);
+ }
+
+ public void testPermaLinksForCollections() throws RegistryException {
+
+ Collection c1 = registry.newCollection();
+ registry.put("/test/v14/c1", c1);
+
+ registry.createVersion("/test/v14/c1");
+
+ String[] c1Versions = registry.getVersions("/test/v14/c1");
+ Resource c1e1 = registry.get("/test/v14/c1");
+ assertEquals("Permalink incorrect", c1e1.getPermanentPath(), c1Versions[0]);
+
+ Resource r1 = registry.newResource();
+ r1.setContent("r1c1");
+ registry.put("/test/v14/c1/r1", r1);
+
+ registry.createVersion("/test/v14/c1");
+
+ c1Versions = registry.getVersions("/test/v14/c1");
+ Resource c1e2 = registry.get("/test/v14/c1");
+ assertEquals("Permalink incorrect", c1e2.getPermanentPath(), c1Versions[0]);
+
+ registry.restoreVersion(c1Versions[1]);
+
+ Resource c1e3 = registry.get("/test/v14/c1");
+ assertEquals("Permalink incorrect", c1e3.getPermanentPath(), c1Versions[1]);
+ }
}
Modified: trunk/registry/pom.xml
==============================================================================
--- trunk/registry/pom.xml (original)
+++ trunk/registry/pom.xml Wed May 7 10:53:04 2008
@@ -302,12 +302,12 @@
</dependency>
<!--Eclipse dependency-->
<dependency>
- <groupId>elipse</groupId>
+ <groupId>eclipse</groupId>
<artifactId>validateutility</artifactId>
<version>0.95</version>
</dependency>
<dependency>
- <groupId>elipse</groupId>
+ <groupId>eclipse</groupId>
<artifactId>eclipse-wsdl-validator</artifactId>
<version>3.395</version>
</dependency>
More information about the Registry-dev
mailing list