[Fwd: [Registry-dev] svn commit r14853
- in branches/registry/1_0/modules/core/src:
main/java/org/wso2/registry main/java/org/wso2/registry/jdbc main/java/org/wso2/registry/jdbc/dao
main/java/org/wso2/registry/jdbc/mediatypes main/java/org/wso2/registry/jdbc/mediatypes/builtin
test/java/org/wso2/registry/jdbc]
Glen Daniels
glen at wso2.com
Sun Mar 16 04:43:53 PDT 2008
Yup, +1. My patch was simply a "band-aid" to allow the Mooshup folks to
get whatever performance gain delayed content-fetching would provide,
without having to pick up the interface changes on the trunk.
--Glen
Chathura C. Ekanayake wrote:
>
> Hi Glen,
>
> I have done similar work in the trunk to create the content input
> stream, only when the resource.getContent() is called. So a resource
> instance only contains metadata until the getContent() is called.
> Although it doesn't give huge performance gain for small contents, it
> will give considerable gain when accessing large number of resources
> containing large contents.
>
> Thanks,
> Chathura
>
>
> -------- Original Message --------
> Subject: [Registry-dev] svn commit r14853 - in
> branches/registry/1_0/modules/core/src: main/java/org/wso2/registry
> main/java/org/wso2/registry/jdbc main/java/org/wso2/registry/jdbc/dao
> main/java/org/wso2/registry/jdbc/mediatypes
> main/java/org/wso2/registry/jdbc/mediatypes/builtin
> test/java/org/wso2/registry/jdbc
> Date: Sat, 15 Mar 2008 12:49:48 -0700
> From: svn at wso2.org
> Reply-To: registry-dev at wso2.org
> To: registry-dev at wso2.org
>
>
>
> Author: glen
> Date: Sat Mar 15 12:49:41 2008
> New Revision: 14853
>
> Log:
>
> Another attempt at performance improvement. Now we don't get the
> content every time we get() a Resource. Instead we stick a
> "ContentProxy" object in there after loading that up with everything it
> needs to get the real content (DataSource, query params), and we only
> execute the content query when Resource.getContent() is called.
>
> Needed to pass around a DataSource a bunch of places to enable this.
>
>
> Added:
>
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/ContentProxy.java
>
> Modified:
>
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/Resource.java
>
>
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
>
>
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
>
>
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java
>
>
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
>
>
> branches/registry/1_0/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
>
>
> Added:
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/ContentProxy.java
>
> ==============================================================================
>
> --- (empty file)
> +++
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/ContentProxy.java
> Sat Mar 15 12:49:41 2008
> @@ -0,0 +1,23 @@
> +/*
> + * Copyright (c) 2007, WSO2 Inc. (http://www.wso2.org) All Rights
> Reserved.
> + *
> + * Licensed 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.wso2.registry;
> +
> +/**
> + * Enables content to be fetched by some internal implementation
> + */
> +public interface ContentProxy {
> + Object getContent() throws RegistryException;
> +}
>
> Modified:
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/Resource.java
>
> ==============================================================================
>
> ---
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/Resource.java
> (original)
> +++
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/Resource.java
> Sat Mar 15 12:49:41 2008
> @@ -19,6 +19,9 @@
>
> package org.wso2.registry;
>
> +import org.apache.commons.logging.Log;
> +import org.apache.commons.logging.LogFactory;
> +
> import java.sql.Timestamp;
> import java.util.Date;
> import java.util.Properties;
> @@ -34,6 +37,7 @@
> * combined with the base URL of the registry server to generate a URI
> for the resource.
> */
> public class Resource {
> + private static final Log log = LogFactory.getLog(Resource.class);
>
> /**
> * Unique identifier of the resource within the registry. Note that
> this is not an UUID.
> @@ -231,6 +235,13 @@
> }
>
> public Object getContent() {
> + try {
> + if (content instanceof ContentProxy)
> + content = ((ContentProxy)content).getContent();
> + } catch (RegistryException e) {
> + log.error("Couldn't get content from proxy", e);
> + return null;
> + }
> return content;
> }
>
>
> Modified:
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
>
> ==============================================================================
>
> ---
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
> (original)
> +++
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
> Sat Mar 15 12:49:41 2008
> @@ -130,7 +130,7 @@
> try {
> conn.setAutoCommit(false);
>
> - Resource root =
> resourceDAO.getLatestVersion(RegistryConstants.ROOT_PATH, conn);
> + Resource root =
> resourceDAO.getLatestVersion(RegistryConstants.ROOT_PATH, conn,
> dataSource);
> if (root == null) {
> root = new Resource();
> root.setPath(RegistryConstants.ROOT_PATH);
> @@ -143,7 +143,7 @@
>
> RegistryConstants.ROOT_PATH,
>
> RegistryConstants.SYSTEM_USER);
>
> - root =
> resourceDAO.getLatestVersion(RegistryConstants.ROOT_PATH, conn);
> + root =
> resourceDAO.getLatestVersion(RegistryConstants.ROOT_PATH, conn,
> dataSource);
> root.setLastUpdaterUserName(RegistryConstants.SYSTEM_USER);
> resourceDAO.addResourceVersion(root, conn);
> }
> @@ -366,7 +366,8 @@
> newPath,
> getConnection(),
> User.getCurrentUser(),
> - defaultRealm);
> + defaultRealm,
> + dataSource);
>
> logsDAO.addLog(resourceID, userID, LogEntry.RENAME,
> currentPath, conn);
>
> @@ -476,7 +477,7 @@
> return versionPaths;
> }
>
> - private Connection getConnection() throws RegistryException {
> + public Connection getConnection() throws RegistryException {
> Connection conn;
> try {
> conn = dataSource.getConnection();
> @@ -508,7 +509,7 @@
>
> long artifactID = resourceDAO.getResourceID(plainPath, conn);
>
> - resourceDAO.restore(artifactID, versionNumber, conn);
> + resourceDAO.restore(artifactID, versionNumber, conn,
> dataSource);
>
> logsDAO.addLog(
> artifactID, userID, LogEntry.RESTORE,
> Long.toString(versionNumber), conn);
> @@ -567,7 +568,7 @@
> throw new RegistryException(
> "Cannot tag on a non-existing resource " +
> resourcePath);
> }
> - Resource resource =
> resourceDAO.getLatestVersion(resourcePath, conn);
> + Resource resource =
> resourceDAO.getLatestVersion(resourcePath, conn, dataSource);
>
> for (int i = 0; i < tags.length; i++) {
>
> @@ -710,7 +711,7 @@
> try {
> conn.setAutoCommit(false);
>
> - Resource taggedResource =
> resourceDAO.getLatestVersion(path, conn);
> + Resource taggedResource =
> resourceDAO.getLatestVersion(path, conn, dataSource);
> if (user.equals(taggedResource.getAuthorUserName())) {
> tagsDAO.removeTag(path, tag, conn);
> } else {
> @@ -766,7 +767,7 @@
> try {
> conn.setAutoCommit(false);
>
> - Resource resource =
> resourceDAO.getLatestVersion(resourcePath, conn);
> + Resource resource =
> resourceDAO.getLatestVersion(resourcePath, conn, dataSource);
> if (resource != null) {
> commentPath = commentsDAO.addComment(resource.getId(),
> userID, comment, conn);
> commentPath = resourcePath + ";comments:" + commentPath;
> @@ -872,7 +873,7 @@
> try {
> conn.setAutoCommit(false);
>
> - Resource resource =
> resourceDAO.getLatestVersion(resourcePath, conn);
> + Resource resource =
> resourceDAO.getLatestVersion(resourcePath, conn, dataSource);
>
> if (resource != null) {
> if (ratingsDAO.ratingExist(resource.getId(), userID,
> conn)) {
> @@ -1008,7 +1009,7 @@
> queryResource.setAuthorUserName(userID);
> queryResource.setContent(query.getBytes());
>
> - Resource resource = resourceDAO.getLatestVersion(queryPath,
> conn);
> + Resource resource = resourceDAO.getLatestVersion(queryPath,
> conn, dataSource);
> if (resource != null) {
> resourceDAO.update(queryPath, queryResource, conn);
> log.info("Updated the predefined query: " + queryPath);
>
> Modified:
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
>
> ==============================================================================
>
> ---
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
> (original)
> +++
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
> Sat Mar 15 12:49:41 2008
> @@ -18,15 +18,13 @@
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> -import org.wso2.registry.RegistryConstants;
> -import org.wso2.registry.RegistryException;
> -import org.wso2.registry.Resource;
> -import org.wso2.registry.User;
> +import org.wso2.registry.*;
> import org.wso2.registry.jdbc.DatabaseConstants;
> import org.wso2.registry.utils.AuthorizationUtil;
> import org.wso2.usermanager.Realm;
>
> import javax.activation.DataHandler;
> +import javax.sql.DataSource;
> import java.io.IOException;
> import java.io.InputStream;
> import java.sql.*;
> @@ -44,12 +42,11 @@
> * @param path : path of the artifact
> * @param versionNumber : Version number
> * @param conn : Connection to DB
> + * @param dataSource
> * @return Resource for the given version number
> * @throws SQLException : If something went wrong
> */
> - public Resource get(String path, long versionNumber, Connection
> conn) throws SQLException {
> -
> - Resource resource = null;
> + public Resource get(String path, long versionNumber, Connection
> conn, DataSource dataSource) throws SQLException {
>
> ResultSet result;
>
> @@ -62,27 +59,26 @@
>
> result = statement.executeQuery();
>
> - if (result.next()) {
> - resource = new Resource();
> -
> - resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
> - resource.setPath(path + "?v=" + versionNumber);
> - resource.setParentPath(getParentPath(resource.getId(),
> versionNumber, conn));
> -
> resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD)
> == 1);
> -
> resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
>
> -
> resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
> -
> resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
>
> -
> resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
>
> -
> resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
>
> - }
> -
> - if (resource == null) {
> + if (!result.next()) {
> return null;
> }
>
> - String sqlVersionedFields = "SELECT CONTENT, AUTHOR,
> UPDATED_TIME FROM VERSIONS WHERE AID=? AND VN=?";
> + final long id = result.getLong(DatabaseConstants.AID_FIELD);
> + Resource resource = new Resource();
> +
> + resource.setId(id);
> + resource.setPath(path + "?v=" + versionNumber);
> + resource.setParentPath(getParentPath(id, versionNumber, conn));
> +
> resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD)
> == 1);
> +
> resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
>
> + resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
> +
> resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
>
> +
> resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
>
> +
> resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
>
> +
> + String sqlVersionedFields = "SELECT AUTHOR, UPDATED_TIME FROM
> VERSIONS WHERE AID=? AND VN=?";
> PreparedStatement versionQuery =
> conn.prepareStatement(sqlVersionedFields);
> - versionQuery.setLong(1, resource.getId());
> + versionQuery.setLong(1, id);
> versionQuery.setLong(2, versionNumber);
>
> ResultSet versionResults = versionQuery.executeQuery();
> @@ -92,15 +88,15 @@
>
> versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
> resource.setLastModified(
>
> versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
> -
> resource.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
>
> }
>
> // get resource children
>
> if (resource.isDirectory()) {
> -
> - String[] children = getChildPaths(resource.getId(),
> versionNumber, conn);
> + String[] children = getChildPaths(id, versionNumber, conn);
> resource.setContent(children);
> + } else {
> + resource.setContent(new DBContentProxy(id, versionNumber,
> dataSource));
> }
>
> // get resource properties
> @@ -108,11 +104,12 @@
> return getResourceWithProperties(conn, resource);
> }
>
> - public Resource getResourceByID(long artifactID, long
> versionNumber, Connection conn)
> + public Resource getResourceByID(long artifactID,
> + long versionNumber,
> + Connection conn,
> + DataSource dataSource)
> throws SQLException {
>
> - Resource resource = null;
> -
> ResultSet result;
>
> // get the resource data from the resource table
> @@ -123,29 +120,28 @@
>
> result = statement.executeQuery();
>
> - if (result.next()) {
> - resource = new Resource();
> -
> - resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
> -
> resource.setPath(result.getString(DatabaseConstants.PATH_FIELD));
> -
> resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD)
> == 1);
> -
> resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
>
> -
> resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
> -
> resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
>
> -
> resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
>
> -
> resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
>
> - }
> -
> - if (resource == null) {
> + if (!result.next()) {
> return null;
> }
>
> + Resource resource = new Resource();
> +
> + resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
> + resource.setPath(result.getString(DatabaseConstants.PATH_FIELD));
> +
> resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD)
> == 1);
> +
> resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
>
> + resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
> +
> resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
>
> +
> resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
>
> +
> resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
>
> +
> if (versionNumber == -1) {
> versionNumber = getLatestVersionNumber(artifactID, conn);
> }
> - String sqlVersionedFields = "SELECT CONTENT, AUTHOR,
> UPDATED_TIME FROM VERSIONS WHERE AID=? AND VN=?";
> + String sqlVersionedFields = "SELECT AUTHOR, UPDATED_TIME FROM
> VERSIONS WHERE AID=? AND VN=?";
> PreparedStatement versionQuery =
> conn.prepareStatement(sqlVersionedFields);
> - versionQuery.setLong(1, resource.getId());
> + final long id = resource.getId();
> + versionQuery.setLong(1, id);
> versionQuery.setLong(2, versionNumber);
>
> ResultSet versionResults = versionQuery.executeQuery();
> @@ -155,15 +151,15 @@
>
> versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
> resource.setLastModified(
>
> versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
> -
> resource.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
>
> }
>
> // get resource children
>
> if (resource.isDirectory()) {
> -
> - String[] children = getChildPaths(resource.getId(),
> versionNumber, conn);
> + String[] children = getChildPaths(id, versionNumber, conn);
> resource.setContent(children);
> + } else {
> + resource.setContent(new DBContentProxy(id, versionNumber,
> dataSource)); }
>
> // get resource properties
> @@ -195,10 +191,11 @@
> *
> * @param path : path of the artifact
> * @param conn :Connection to DB
> + * @param dataSource
> * @return : Result artifact
> * @throws SQLException : if something went wrong
> */
> - public Resource getLatestVersion(String path, Connection conn)
> + public Resource getLatestVersion(String path, Connection conn,
> DataSource dataSource)
> throws RegistryException, SQLException {
> /*
> * when someone give path like "root/wso2/wsas/r1" , then need to
> figure out the latest
> @@ -240,9 +237,10 @@
> long latestVersionNumber =
> getCurrentVersionNumber(resource.getPath(), conn);
>
>
> - String sqlVersionedFields = "SELECT CONTENT, AUTHOR,
> UPDATED_TIME FROM VERSIONS WHERE AID=? AND VN=?";
> + String sqlVersionedFields = "SELECT AUTHOR, UPDATED_TIME FROM
> VERSIONS WHERE AID=? AND VN=?";
> PreparedStatement versionQuery =
> conn.prepareStatement(sqlVersionedFields);
> - versionQuery.setLong(1, resource.getId());
> + final long id = resource.getId();
> + versionQuery.setLong(1, id);
> versionQuery.setLong(2, latestVersionNumber);
>
> ResultSet versionResults = versionQuery.executeQuery();
> @@ -252,14 +250,15 @@
>
> versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
> resource.setLastModified(
>
> versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
> -
> resource.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
>
> }
>
> // get resource children
> if (resource.isDirectory()) {
> - String[] children = getLatestChildPaths(resource.getId(),
> + String[] children = getLatestChildPaths(id,
>
> getCurrentVersionNumber(path, conn), conn);
> resource.setContent(children);
> + } else {
> + resource.setContent(new DBContentProxy(id,
> latestVersionNumber, dataSource));
> }
>
> // get resource properties
> @@ -676,9 +675,10 @@
> String newPath,
> Connection conn,
> String userId,
> - Realm realm) throws SQLException,
> RegistryException {
> + Realm realm,
> + DataSource dataSource) throws
> SQLException, RegistryException {
>
> - Resource resource = getLatestVersion(oldPath, conn);
> + Resource resource = getLatestVersion(oldPath, conn, dataSource);
> String resourcePath = resource.getPath();
> long resourceID = resource.getId();
> //to see whether the patent node is there in the table , if not
> need to add that
> @@ -809,7 +809,7 @@
>
> int lastIndex = path.lastIndexOf("/");
> String parentPath = path.substring(0, lastIndex);
> - Resource parentArtifact = getLatestVersion(parentPath,
> connection);
> + Resource parentArtifact = getLatestVersion(parentPath,
> connection, null);
>
> if (parentArtifact != null) {
> path = parentArtifact.getPath();
> @@ -957,10 +957,11 @@
> return (String[]) versionNumbers.toArray(new
> String[versionNumbers.size()]);
> }
>
> - public void restore(long resourceId, long toVersion, Connection
> connection)
> + public void restore(long resourceId, long toVersion, Connection
> connection,
> + DataSource dataSource)
> throws SQLException, RegistryException {
>
> - Resource oldArtifact = getResourceByID(resourceId, toVersion,
> connection);
> + Resource oldArtifact = getResourceByID(resourceId, toVersion,
> connection, dataSource);
> if (User.getCurrentUser() != null) {
> oldArtifact.setLastUpdaterUserName(User.getCurrentUser());
> }
> @@ -1144,7 +1145,7 @@
>
> String currentPath = RegistryConstants.ROOT_PATH + parts[1];
> for (int i = 2; i < parts.length; i++) {
> - Resource currentCollection = getLatestVersion(currentPath,
> conn);
> + Resource currentCollection = getLatestVersion(currentPath,
> conn, null);
> if (currentCollection == null) {
> currentCollection = new Resource();
> currentCollection.setPath(currentPath);
> @@ -1190,3 +1191,46 @@
> }
>
> }
> +
> +class DBContentProxy implements ContentProxy {
> + private static final Log log =
> LogFactory.getLog(VersionedResourceDAO.class);
> +
> + long artifactID;
> + long version;
> + DataSource dataSource;
> +
> + DBContentProxy(long artifactID, long version, DataSource dataSource) {
> + this.artifactID = artifactID;
> + this.version = version;
> + this.dataSource = dataSource;
> + }
> +
> + public Object getContent() throws RegistryException {
> + if (dataSource == null) {
> + log.info("No DataSource in DBContentProxy!");
> + return null;
> + }
> +
> + String sqlVersionedFields = "SELECT CONTENT FROM VERSIONS WHERE
> AID=" +
> + artifactID + " AND VN=" + version;
> + Connection conn = null;
> + try {
> + conn = dataSource.getConnection();
> + PreparedStatement query =
> conn.prepareStatement(sqlVersionedFields);
> + ResultSet result = query.executeQuery();
> + if (!result.next()) {
> + return null;
> + }
> + return result.getBytes("CONTENT");
> + } catch (SQLException e) {
> + throw new RegistryException("Couldn't get resource
> content", e);
> + } finally {
> + try {
> + if (conn != null) conn.close();
> + } catch (SQLException e) {
> + // do nothing
> + e.printStackTrace();
> + }
> + }
> + }
> +}
> \ No newline at end of file
>
> Modified:
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java
>
> ==============================================================================
>
> ---
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java
> (original)
> +++
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java
> Sat Mar 15 12:49:41 2008
> @@ -277,7 +277,7 @@
> }
>
> try {
> - resource = resourceDAO.getLatestVersion(path, conn);
> + resource = resourceDAO.getLatestVersion(path, conn,
> dataSource);
>
> } catch (SQLException e) {
>
>
> Modified:
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
>
> ==============================================================================
>
> ---
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
> (original)
> +++
> branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
> Sat Mar 15 12:49:41 2008
> @@ -76,10 +76,10 @@
> try {
> //resource = resourceDAO.get(path, conn);
> if (versionNumber == -1) {
> - resource = resourceDAO.getLatestVersion(plainPath, conn);
> + resource = resourceDAO.getLatestVersion(plainPath,
> conn, dataSource);
>
> } else {
> - resource = resourceDAO.get(plainPath, versionNumber,
> conn);
> + resource = resourceDAO.get(plainPath, versionNumber,
> conn, dataSource);
> }
>
> } catch (SQLException e) {
> @@ -118,7 +118,7 @@
> try {
> conn.setAutoCommit(false);
>
> - Resource a = resourceDAO.getLatestVersion(path, conn);
> + Resource a = resourceDAO.getLatestVersion(path, conn,
> dataSource);
> if (a != null) {
>
> // if the parent collections of this resource are in
> deleted state, make them
> @@ -218,7 +218,7 @@
> String currentPath = RegistryConstants.ROOT_PATH + parts[1];
> for (int i = 2; i < parts.length; i++) {
>
> - Resource currentCollection =
> resourceDAO.getLatestVersion(currentPath, conn);
> + Resource currentCollection =
> resourceDAO.getLatestVersion(currentPath, conn, dataSource);
> if (currentCollection == null) {
>
> currentCollection = new Resource();
> @@ -268,7 +268,7 @@
> String currentPath = RegistryConstants.ROOT_PATH + parts[1];
> for (int i = 2; i < parts.length; i++) {
>
> - Resource currentCollection =
> resourceDAO.getLatestVersion(currentPath, conn);
> + Resource currentCollection =
> resourceDAO.getLatestVersion(currentPath, conn, dataSource);
> if (currentCollection == null) {
>
> String msg = "Parent collection: " + currentPath + " of
> the exsiting resource:" +
> @@ -347,7 +347,7 @@
>
> try {
> conn.setAutoCommit(false);
> - Resource resource = resourceDAO.getLatestVersion(path, conn);
> + Resource resource = resourceDAO.getLatestVersion(path,
> conn, dataSource);
> if (resource != null) {
> if (resource.isDirectory()) {
> deleteDirectory(resource, conn);
>
> Modified:
> branches/registry/1_0/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
>
> ==============================================================================
>
> ---
> branches/registry/1_0/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
> (original)
> +++
> branches/registry/1_0/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
> Sat Mar 15 12:49:41 2008
> @@ -409,14 +409,14 @@
>
> public void testResourceRename() throws Exception {
> Resource r1 = new Resource();
> - String conent1 = "Content1";
> - r1.setContent(conent1.getBytes());
> + String content1 = "Content1";
> + r1.setContent(content1.getBytes());
> registry.put("/product/wso2/wsas", r1);
> String[] version = registry.getVersions("/product/wso2");
> String versionString = version[version.length - 1];
> registry.rename("/product/wso2/wsas", "/product/private/esb");
> r1 = registry.get("/product/private/esb");
> - boolean value = Arrays.equals(conent1.getBytes(),
> (byte[])r1.getContent());
> + boolean value = Arrays.equals(content1.getBytes(),
> (byte[])r1.getContent());
> assertTrue(value);
> String conent2 = "Content2";
> r1.setContent(conent2.getBytes());
> @@ -432,7 +432,7 @@
> }
> registry.restoreVersion(versionString);
> r1 = registry.get("/product/wso2/wsas");
> - value = Arrays.equals(conent1.getBytes(),
> (byte[])r1.getContent());
> + value = Arrays.equals(content1.getBytes(),
> (byte[])r1.getContent());
> assertTrue(value);
> r1 = registry.get("/product/private/esb");
> value = Arrays.equals(conent2.getBytes(), (byte[])r1.getContent());
>
> _______________________________________________
> Registry-dev mailing list
> Registry-dev at wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/registry-dev
>
>
>
> _______________________________________________
> Registry-dev mailing list
> Registry-dev at wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/registry-dev
>
More information about the Registry-dev
mailing list