Author: deepal
Date: Tue Feb 5 04:08:53 2008
New Revision: 13269
Log:
removing few code duplicates
Modified:
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
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
Tue Feb 5 04:08:53 2008
@@ -106,20 +106,7 @@
// get resource properties
- String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE
P.AID=?";
- PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, resource.getId());
- ResultSet propResults = s3.executeQuery();
-
- Properties props = new Properties();
- while (propResults.next()) {
- String key =
propResults.getString(DatabaseConstants.PROPERTY_KEY_FIELD);
- String value =
propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
- props.put(key, value);
- }
- resource.setProperties(props);
-
- return resource;
+ return getResourceWithProperties(conn, resource);
}
public Resource getResourceByID(long artifactID, long versionNumber,
Connection conn)
@@ -182,6 +169,10 @@
// get resource properties
+ return getResourceWithProperties(conn, resource);
+ }
+
+ private Resource getResourceWithProperties(Connection conn, Resource
resource) throws SQLException {
String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE
P.AID=?";
PreparedStatement s3 = conn.prepareStatement(propSQL);
s3.setLong(1, resource.getId());
@@ -272,19 +263,7 @@
}
// get resource properties
- String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE
P.AID=?";
- PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, resource.getId());
- ResultSet propResults = s3.executeQuery();
-
- Properties props = new Properties();
- while (propResults.next()) {
- String key =
propResults.getString(DatabaseConstants.PROPERTY_KEY_FIELD);
- String value =
propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
- props.put(key, value);
- }
- resource.setProperties(props);
- return resource;
+ return getResourceWithProperties(conn, resource);
}
/**
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev