Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r5366 - in branches/new-structure-with-base2/ps-mdm-ls/src: main/java/org/perfsonar/service/lookupservice/servlets main/java/org/perfsonar/service/lookupservice/storage/exist test/java/org/perfsonar/tests test/java/org/perfsonar/tests/utilities

Subject: perfsonar development work

List archive

perfsonar: r5366 - in branches/new-structure-with-base2/ps-mdm-ls/src: main/java/org/perfsonar/service/lookupservice/servlets main/java/org/perfsonar/service/lookupservice/storage/exist test/java/org/perfsonar/tests test/java/org/perfsonar/tests/utilities


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r5366 - in branches/new-structure-with-base2/ps-mdm-ls/src: main/java/org/perfsonar/service/lookupservice/servlets main/java/org/perfsonar/service/lookupservice/storage/exist test/java/org/perfsonar/tests test/java/org/perfsonar/tests/utilities
  • Date: Tue, 1 Dec 2009 06:48:49 -0500

Author: trzaszcz
Date: 2009-12-01 06:48:49 -0500 (Tue, 01 Dec 2009)
New Revision: 5366

Added:

branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/utilities/

branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/utilities/ExistDBInitializerTests.java

branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/utilities/ExistDBManagerTests.java
Modified:

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/servlets/ExistDbInitializerServlet.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistDbManager.java
Log:
unit tests for ExistDbManager added, refactoring ExistDbInitializationServlet

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/servlets/ExistDbInitializerServlet.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/servlets/ExistDbInitializerServlet.java
2009-12-01 09:56:02 UTC (rev 5365)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/servlets/ExistDbInitializerServlet.java
2009-12-01 11:48:49 UTC (rev 5366)
@@ -27,7 +27,7 @@
/**
* This servlet initializes eXist database
*
- * @author trzaszcz
+ * @author Slawomir Trzaszczka
*
*/
@SuppressWarnings("serial")
@@ -56,9 +56,20 @@
collection.storeResource(document);
}

+ /**
+ *
+ * main function which initializes database
+ *
+ *
+ * @param dbContentDirPath - path to directory where database
resource files are stored
+ * @param configManager
+ * @return
+ * @throws IOException
+ * @throws PerfSONARException
+ */
@SuppressWarnings("unchecked")
- private void initializeDatabase(HttpServletRequest req, PrintWriter
writer,
- ConfigurationManager configManager) throws
IOException {
+ public boolean initializeDatabase(String dbContentDirPath,
+ ConfigurationManager configManager) throws
PerfSONARException {
try {
Class cl =
Class.forName("org.exist.xmldb.DatabaseImpl");
Database database = (Database) cl.newInstance();
@@ -102,39 +113,27 @@

usrMngmtService.addUser(userRO);

- File dir = new File(".");
- String dbPath = dir.getCanonicalPath() + "/../webapps"
- + req.getContextPath() + "/db";

- writer.append("DbInitializer - success");
+// uploadFile("LSStore.xml", dbContentDirPath,
lsCollection);
+
+ uploadFile("LSStore-control.xml", dbContentDirPath,
lsCollection);
+ uploadFile("LSStore-summary.xml", dbContentDirPath,
lsCollection);

-// uploadFile("LSStore.xml", dbPath, lsCollection);
+ uploadFile("LSStore-summary.xml", dbContentDirPath,
copyCollection);

- uploadFile("LSStore-control.xml", dbPath,
lsCollection);
- uploadFile("LSStore-summary.xml", dbPath,
lsCollection);
-
- uploadFile("LSStore-summary.xml", dbPath,
copyCollection);
-
+ return true;
} catch (ClassNotFoundException e) {
- e.printStackTrace();
- writer.append("error :" + e.getMessage());
+ throw new PerfSONARException(e.getMessage());
} catch (InstantiationException e) {
- writer.append("error :" + e.getMessage());
- e.printStackTrace();
+ throw new PerfSONARException(e.getMessage());
} catch (IllegalAccessException e) {
- writer.append("error :" + e.getMessage());
- e.printStackTrace();
+ throw new PerfSONARException(e.getMessage());
} catch (PerfSONARException e) {
- writer.append("error :" + e.getMessage());
- e.printStackTrace();
+ throw new PerfSONARException(e.getMessage());
} catch (XMLDBException e) {
- writer.append("error :" + e.getMessage());
- e.printStackTrace();
+ throw new PerfSONARException(e.getMessage());
} catch (URISyntaxException e) {
- writer.append("error :" + e.getMessage());
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ throw new PerfSONARException(e.getMessage());
}
}

@@ -188,13 +187,19 @@
resp.setHeader("WWW-Authenticate", "BASIC
realm=\"users\"");
resp.sendError(resp.SC_UNAUTHORIZED);
} else {
- initializeDatabase(req, out, configManager);
+ File dir = new File(".");
+ String dbContentDirPath =
dir.getCanonicalPath() + "/../webapps" + req.getContextPath() + "/db";
+ try{
+ initializeDatabase(dbContentDirPath,
configManager);
+ out.append("DbInitializer - success");
+ }catch(PerfSONARException ex){
+ out.append(ex.getMessage());
+ }
+
}
} catch (PerfSONARException e) {
e.printStackTrace();
}

-
-
}
}

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistDbManager.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistDbManager.java
2009-12-01 09:56:02 UTC (rev 5365)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistDbManager.java
2009-12-01 11:48:49 UTC (rev 5366)
@@ -86,10 +86,9 @@
* @throws PerfSONARException
*/
public static XPathQueryService getService() throws
PerfSONARException {
- if(service==null){
- if(! init()){
- throw new
PerfSONARException("http://perfsonar.net/result/internal/error","Cannot
initialize Db access - wrong datasource or db is not initialized");
- }
+ // if service is null - initialize it if initialization
returns false - throw exception
+ if(service==null && ! init()){
+ throw new
PerfSONARException("http://perfsonar.net/result/internal/error","Cannot
initialize Db access - wrong datasource or db is not initialized");
}
return service;
}

Added:
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/utilities/ExistDBInitializerTests.java

Added:
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/utilities/ExistDBManagerTests.java



  • perfsonar: r5366 - in branches/new-structure-with-base2/ps-mdm-ls/src: main/java/org/perfsonar/service/lookupservice/servlets main/java/org/perfsonar/service/lookupservice/storage/exist test/java/org/perfsonar/tests test/java/org/perfsonar/tests/utilities, svnlog, 12/01/2009

Archive powered by MHonArc 2.6.16.

Top of Page