Minor code improvements
This commit is contained in:
parent
60017600a3
commit
d87bb782eb
4 changed files with 58 additions and 116 deletions
|
@ -46,6 +46,7 @@ public class OperationUtils {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (setterMethod != null) {
|
||||||
Object[] arglist = new Object[1];
|
Object[] arglist = new Object[1];
|
||||||
if (isInt)
|
if (isInt)
|
||||||
arglist[0] = Integer.decode(value);
|
arglist[0] = Integer.decode(value);
|
||||||
|
@ -61,6 +62,7 @@ public class OperationUtils {
|
||||||
log.error(field + " " + arglist[0]);
|
log.error(field + " " + arglist[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes a bean and clones it using reflection. Any fields without standard
|
* Takes a bean and clones it using reflection. Any fields without standard
|
||||||
|
|
|
@ -480,7 +480,7 @@ class Stemmer
|
||||||
outputStr.append(u);
|
outputStr.append(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
return outputStr == null || outputStr.length() == 0 ? null : outputStr.toString().trim();
|
return outputStr.length() == 0 ? null : outputStr.toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -32,16 +32,11 @@ public class GadgetSpec {
|
||||||
|
|
||||||
// Load gadgets from the DB first
|
// Load gadgets from the DB first
|
||||||
if (!unknownGadget) {
|
if (!unknownGadget) {
|
||||||
Connection conn = null;
|
|
||||||
Statement stmt = null;
|
|
||||||
ResultSet rset = null;
|
|
||||||
|
|
||||||
try {
|
String sqlCommand = "select page, viewer_req, owner_req, view, chromeId, opt_params, display_order from orng_app_views where appId = " + appId;
|
||||||
String sqlCommand = "select page, viewer_req, owner_req, view, chromeId, opt_params, display_order from orng_app_views where appId = "
|
try (Connection conn = ds.getConnection()) {
|
||||||
+ appId;
|
try (Statement stmt = conn.createStatement()) {
|
||||||
conn = ds.getConnection();
|
try (ResultSet rset = stmt.executeQuery(sqlCommand)) {
|
||||||
stmt = conn.createStatement();
|
|
||||||
rset = stmt.executeQuery(sqlCommand);
|
|
||||||
while (rset.next()) {
|
while (rset.next()) {
|
||||||
viewRequirements.put(
|
viewRequirements.put(
|
||||||
rset.getString(1),
|
rset.getString(1),
|
||||||
|
@ -50,18 +45,7 @@ public class GadgetSpec {
|
||||||
.getString(4), rset.getString(5), rset
|
.getString(4), rset.getString(5), rset
|
||||||
.getString(6), rset.getInt(7)));
|
.getString(6), rset.getInt(7)));
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
rset.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
stmt.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
conn.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,31 +111,15 @@ public class GadgetSpec {
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
Connection conn = null;
|
String sqlCommand = "select count(*) from orng_app_registry where appId = " + getAppId() + " and personId = '" + personId + "';";
|
||||||
Statement stmt = null;
|
|
||||||
ResultSet rset = null;
|
|
||||||
|
|
||||||
try {
|
try (Connection conn = ds.getConnection()) {
|
||||||
String sqlCommand = "select count(*) from orng_app_registry where appId = "
|
try (Statement stmt = conn.createStatement()) {
|
||||||
+ getAppId() + " and personId = '" + personId + "';";
|
try (ResultSet rset = stmt.executeQuery(sqlCommand)) {
|
||||||
conn = ds.getConnection();
|
|
||||||
stmt = conn.createStatement();
|
|
||||||
rset = stmt.executeQuery(sqlCommand);
|
|
||||||
while (rset.next()) {
|
while (rset.next()) {
|
||||||
count = rset.getInt(1);
|
count = rset.getInt(1);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
rset.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
stmt.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
conn.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,28 +294,17 @@ public class OpenSocialManager {
|
||||||
|
|
||||||
public void postActivity(int userId, String title, String body,
|
public void postActivity(int userId, String title, String body,
|
||||||
String xtraId1Type, String xtraId1Value) throws SQLException {
|
String xtraId1Type, String xtraId1Value) throws SQLException {
|
||||||
Connection conn = null;
|
|
||||||
Statement stmt = null;
|
|
||||||
String sqlCommand = "INSERT INTO orng_activity (userId, activity, xtraId1Type, xtraId1Value) VALUES ('"
|
String sqlCommand = "INSERT INTO orng_activity (userId, activity, xtraId1Type, xtraId1Value) VALUES ('"
|
||||||
+ userId + "','<activity xmlns=\"http://ns.opensocial.org/2008/opensocial\"><postedTime>"
|
+ userId + "','<activity xmlns=\"http://ns.opensocial.org/2008/opensocial\"><postedTime>"
|
||||||
+ System.currentTimeMillis() + "</postedTime><title>" + title + "</title>"
|
+ System.currentTimeMillis() + "</postedTime><title>" + title + "</title>"
|
||||||
+ (body != null ? "<body>" + body + "</body>" : "") + "</activity>','"
|
+ (body != null ? "<body>" + body + "</body>" : "") + "</activity>','"
|
||||||
+ xtraId1Type + "','" + xtraId1Value + "');";
|
+ xtraId1Type + "','" + xtraId1Value + "');";
|
||||||
try {
|
|
||||||
conn = dataSource.getConnection();
|
|
||||||
stmt = conn.createStatement();
|
|
||||||
stmt.executeUpdate(sqlCommand);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
stmt.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
conn.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
try (Connection conn = dataSource.getConnection()) {
|
||||||
|
try (Statement stmt = conn.createStatement()) {
|
||||||
|
stmt.executeUpdate(sqlCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String socketSendReceive(String viewer, String owner, String gadget)
|
private String socketSendReceive(String viewer, String owner, String gadget)
|
||||||
|
@ -388,17 +377,11 @@ public class OpenSocialManager {
|
||||||
Map<String, GadgetSpec> allDBGadgets = useCache ? gadgetCache : null;
|
Map<String, GadgetSpec> allDBGadgets = useCache ? gadgetCache : null;
|
||||||
if (allDBGadgets == null) {
|
if (allDBGadgets == null) {
|
||||||
allDBGadgets = new HashMap<String, GadgetSpec>();
|
allDBGadgets = new HashMap<String, GadgetSpec>();
|
||||||
Connection conn = null;
|
|
||||||
Statement stmt = null;
|
|
||||||
ResultSet rset = null;
|
|
||||||
try {
|
|
||||||
|
|
||||||
String sqlCommand = "select appId, name, url, channels, enabled from orng_apps";
|
String sqlCommand = "select appId, name, url, channels, enabled from orng_apps";
|
||||||
|
|
||||||
conn = dataSource.getConnection();
|
try (Connection conn = dataSource.getConnection()) {
|
||||||
stmt = conn.createStatement();
|
try (Statement stmt = conn.createStatement()) {
|
||||||
rset = stmt.executeQuery(sqlCommand);
|
try (ResultSet rset = stmt.executeQuery(sqlCommand)) {
|
||||||
|
|
||||||
while (rset.next()) {
|
while (rset.next()) {
|
||||||
String channelsStr = rset.getString(4);
|
String channelsStr = rset.getString(4);
|
||||||
List<String> channels = Arrays.asList(channelsStr != null && channelsStr.length() > 0 ? channelsStr.split(" ") : new String[0]);
|
List<String> channels = Arrays.asList(channelsStr != null && channelsStr.length() > 0 ? channelsStr.split(" ") : new String[0]);
|
||||||
|
@ -409,20 +392,9 @@ public class OpenSocialManager {
|
||||||
allDBGadgets.put(gadgetFileName, spec);
|
allDBGadgets.put(gadgetFileName, spec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
rset.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
stmt.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
conn.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useCache) {
|
if (useCache) {
|
||||||
gadgetCache = allDBGadgets;
|
gadgetCache = allDBGadgets;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue