perfsonar-dev - perfsonar: r5424 - in branches/new-structure-with-base2/ps-mdm-ls: contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/functionalTests contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/stressTests packaging src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/components src/main/java/org/perfsonar/service/lookupservice/servlets src/main/java/org/perfsonar/service/lookupservice/storage src/main/java/org/perfsonar/service/lookupservice/storage/exist src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao src/main/resources/perfsonar/conf src/test/java/org/perfsonar/tests/actions src/test/java/org/perfsonar/tests/dao src/test/java/org/perfsonar/tests/utilities
Subject: perfsonar development work
List archive
perfsonar: r5424 - in branches/new-structure-with-base2/ps-mdm-ls: contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/functionalTests contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/stressTests packaging src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/components src/main/java/org/perfsonar/service/lookupservice/servlets src/main/java/org/perfsonar/service/lookupservice/storage src/main/java/org/perfsonar/service/lookupservice/storage/exist src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao src/main/resources/perfsonar/conf src/test/java/org/perfsonar/tests/actions src/test/java/org/perfsonar/tests/dao src/test/java/org/perfsonar/tests/utilities
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5424 - in branches/new-structure-with-base2/ps-mdm-ls: contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/functionalTests contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/stressTests packaging src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/components src/main/java/org/perfsonar/service/lookupservice/servlets src/main/java/org/perfsonar/service/lookupservice/storage src/main/java/org/perfsonar/service/lookupservice/storage/exist src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao src/main/resources/perfsonar/conf src/test/java/org/perfsonar/tests/actions src/test/java/org/perfsonar/tests/dao src/test/java/org/perfsonar/tests/utilities
- Date: Thu, 17 Dec 2009 06:07:38 -0500
Author: trzaszcz
Date: 2009-12-17 06:07:38 -0500 (Thu, 17 Dec 2009)
New Revision: 5424
Added:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/components/
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/components/DataSourceComponent.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/components/XMLDBComponent.java
Removed:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/CommonExistDAOImpl.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistDbManager.java
Modified:
branches/new-structure-with-base2/ps-mdm-ls/contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/functionalTests/QueryTest.py
branches/new-structure-with-base2/ps-mdm-ls/contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/stressTests/Main.py
branches/new-structure-with-base2/ps-mdm-ls/packaging/package.conf
branches/new-structure-with-base2/ps-mdm-ls/packaging/package.sh
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/EchoServiceEngine.java
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/LookupServiceDAO.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAOFactory.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryDAOSupportImpl.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao/SingleFileDAOImpl.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao/SummarizationDAOImpl.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/actions/QueryActionTests.java
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/ExistDbManagerTests.java
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/SummarizationDaoTests.java
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/XQueryExistDAOImplTests.java
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
Log:
changes in configuration file, refactoring, javadocs added, shell packaging
script enhancement
Modified:
branches/new-structure-with-base2/ps-mdm-ls/contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/functionalTests/QueryTest.py
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/functionalTests/QueryTest.py
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/functionalTests/QueryTest.py
2009-12-17 11:07:38 UTC (rev 5424)
@@ -18,7 +18,7 @@
messages=[]
for c in urlPostfixes :
-
message=soap_template_content.replace("QUERY","data(/nmwg:store[@type='LSStore']/nmwg:metadata[@id='http://localhost:8180/"+str(c)+"'])")
+
message=soap_template_content.replace("QUERY","/nmwg:store[@type='LSStore']/nmwg:metadata[@id='http://localhost:8180/"+str(c)+"']")
messages.append(message)
testService=TestService("127.0.0.1:8080",
"/perfsonar-java-xml-ls/services/LookupService",
"../../../../../results/q-ls2.txt")
Modified:
branches/new-structure-with-base2/ps-mdm-ls/contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/stressTests/Main.py
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/stressTests/Main.py
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/stressTests/Main.py
2009-12-17 11:07:38 UTC (rev 5424)
@@ -24,7 +24,7 @@
# free ids prepared for registration
f_list=range(1,1000)
-
regThread=RegistrationThread(0.005,200,140,url,url_path,"../../../../../inputs/LSRegistrationRequest100.xml",r_list,f_list);
+
regThread=RegistrationThread(0.005,400,140,url,url_path,"../../../../../inputs/LSRegistrationRequest100.xml",r_list,f_list);
deregThread=DeregistrationThread(0.050,url,url_path,"../../../../../inputs/LSDeregisterRequest.xml",r_list,f_list);
qThread=QueryingThread(0.001,url,url_path,"../../../../../inputs/LSQueryRequest.xml",r_list,f_list);
Modified: branches/new-structure-with-base2/ps-mdm-ls/packaging/package.conf
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/packaging/package.conf
2009-12-17 10:53:50 UTC (rev 5423)
+++ branches/new-structure-with-base2/ps-mdm-ls/packaging/package.conf
2009-12-17 11:07:38 UTC (rev 5424)
@@ -6,6 +6,7 @@
# important for correct build of RPM package ! (must be the same as in .spec
file)
RPM_VERSION="2.0"
+RPM_SPEC_NAME="perfsonar-java-xml-ls.specs"
SERVICE_NAME="perfsonar-java-xml-ls"
Modified: branches/new-structure-with-base2/ps-mdm-ls/packaging/package.sh
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/packaging/package.sh
2009-12-17 10:53:50 UTC (rev 5423)
+++ branches/new-structure-with-base2/ps-mdm-ls/packaging/package.sh
2009-12-17 11:07:38 UTC (rev 5424)
@@ -119,7 +119,7 @@
mv -v webapps/$SERVICE_NAME-$RPM_VERSION.tar.gz rpm/rpmbuild/SOURCES
echo "[ ] Copy RPM .specs file"
- cp -v ../rpm/$SERVICE_NAME.specs rpm/rpmbuild
+ cp -v ../rpm/$RPM_SPEC_NAME rpm/rpmbuild
echo
echo
}
@@ -130,7 +130,7 @@
build_rpm_package() {
echo " CREATE RPM PACKAGE"
cd rpm
- rpmbuild -bb rpmbuild/$SERVICE_NAME.specs
+ rpmbuild -bb rpmbuild/$RPM_SPEC_NAME
echo
echo
}
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/EchoServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/EchoServiceEngine.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/EchoServiceEngine.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -10,7 +10,7 @@
import org.perfsonar.base2.xml.nmwg.EventType;
import org.perfsonar.base2.xml.nmwg.Message;
import org.perfsonar.base2.xml.nmwg.Metadata;
-import org.perfsonar.service.lookupservice.storage.exist.CommonExistDAOImpl;
+import
org.perfsonar.service.lookupservice.storage.exist.XQueryDAOSupportImpl;
/**
* Handling EchoRequest for Echo (Ping) and SelfTest
@@ -207,7 +207,7 @@
try {
boolean test = dao
-
.isDBCollection(CommonExistDAOImpl.LS_STORE_CONTROL_COLLECTION_TYPE);
+
.isDBCollection(XQueryDAOSupportImpl.LS_STORE_CONTROL_COLLECTION_TYPE);
if (test){
prefixResult="success";
@@ -240,7 +240,7 @@
String prefixResult="success";
try {
- boolean test =
dao.isDBCollection(CommonExistDAOImpl.LS_STORE_SUMMARY_COLLECTION_TYPE);
+ boolean test =
dao.isDBCollection(XQueryDAOSupportImpl.LS_STORE_SUMMARY_COLLECTION_TYPE);
if (test){
prefixResult="success";
messageDescription="collection
LSStore-summary exists and is accessible";
Added:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/components/DataSourceComponent.java
Added:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/components/XMLDBComponent.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/servlets/ExistDbInitializerServlet.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/servlets/ExistDbInitializerServlet.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -16,7 +16,7 @@
import org.exist.xmldb.XmldbURI;
import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
-import org.perfsonar.base2.service.storage.xml.XMLDBComponent;
+import org.perfsonar.service.lookupservice.components.DataSourceComponent;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
@@ -61,7 +61,8 @@
* main function which initializes database
*
*
- * @param dbContentDirPath - path to directory where database
resource files are stored
+ * @param dbContentDirPath
+ * - path to directory where database resource files are
stored
* @param configManager
* @return
* @throws IOException
@@ -74,14 +75,12 @@
Class cl =
Class.forName("org.exist.xmldb.DatabaseImpl");
Database database = (Database) cl.newInstance();
- XMLDBComponent existDbComponent = (XMLDBComponent)
configManager
-
.getConfiguration().getAuxiliaryComponent("exist");
+ DataSourceComponent existDbComponent =
(DataSourceComponent) configManager
+ .getConfiguration()
+
.getAuxiliaryComponent("existDataSource");
- XMLDBComponent existRODbComponent = (XMLDBComponent)
configManager
-
.getConfiguration().getAuxiliaryComponent("exist-ro");
+ String dbUrl = existDbComponent.getUrl();
- String dbUrl =
existDbComponent.getUri().replace("http", "xmldb:exist").concat("/xmlrpc/db");
-
DatabaseManager.registerDatabase(database);
Collection collection =
DatabaseManager.getCollection(dbUrl,
"admin", "");
@@ -94,38 +93,38 @@
Collection lsCollection =
colMngmtService.createCollection("ls");
Collection copyCollection = colMngmtService
.createCollection("copy");
-
- // removes all existing resources from store
collection (remove old registered service stored in collection)
- Collection
storeCollection=colMngmtService.createCollection("ls/store");
-
- for(String
resourceName:storeCollection.listResources()){
-
storeCollection.removeResource(storeCollection.getResource(resourceName));
+
+ // removes all existing resources from store
collection (remove old
+ // registered service stored in collection)
+ Collection storeCollection = colMngmtService
+ .createCollection("ls/store");
+
+ for (String resourceName :
storeCollection.listResources()) {
+ storeCollection.removeResource(storeCollection
+ .getResource(resourceName));
}
- User user = new User(
-
existDbComponent.getCredential().getUsername(),
-
existDbComponent.getCredential().getPassword());
+ User user = new User(existDbComponent.getUsername(),
+ existDbComponent.getPassword());
user.addGroup("dba");
-
user.setHome(XmldbURI.xmldbUriFor("ls"));
- User userRO = new
User(existRODbComponent.getCredential()
- .getUsername(),
existRODbComponent.getCredential()
- .getPassword());
- userRO.addGroup("guest");
+ if (existDbComponent.hasReadOnlyUser()) {
+ User userRO = new
User(existDbComponent.getUsernameRO(),
+
existDbComponent.getPasswordRO());
+ userRO.addGroup("guest");
+ usrMngmtService.addUser(userRO);
+ }
usrMngmtService.addUser(user);
- usrMngmtService.addUser(userRO);
+ // uploadFile("LSStore.xml", dbContentDirPath,
lsCollection);
-
-// uploadFile("LSStore.xml", dbContentDirPath,
lsCollection);
-
uploadFile("LSStore-control.xml", dbContentDirPath,
lsCollection);
uploadFile("LSStore-summary.xml", dbContentDirPath,
lsCollection);
uploadFile("LSStore-summary.xml", dbContentDirPath,
copyCollection);
-
+
return true;
} catch (ClassNotFoundException e) {
throw new PerfSONARException(e.getMessage());
@@ -141,7 +140,7 @@
throw new PerfSONARException(e.getMessage());
}
}
-
+
/**
* checks if the user is allowed to invoke this servlet
*
@@ -153,11 +152,11 @@
*/
protected boolean allowUser(String auth, String username, String
password)
throws IOException {
- if (auth == null){
+ if (auth == null) {
return false;
}
- if (!auth.toUpperCase(Locale.getDefault()).startsWith("BASIC
")){
+ if (!auth.toUpperCase(Locale.getDefault()).startsWith("BASIC
")) {
return false;
}
@@ -172,7 +171,6 @@
return false;
}
-
@SuppressWarnings("static-access")
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
@@ -182,25 +180,27 @@
ConfigurationManager configManager;
try {
configManager = ConfigurationManager.getInstance();
- XMLDBComponent existDbComponent = (XMLDBComponent)
configManager
-
.getConfiguration().getAuxiliaryComponent("exist");
-
+ DataSourceComponent dataSource =
(DataSourceComponent) configManager
+ .getConfiguration()
+
.getAuxiliaryComponent("existDataSource");
+
String auth = req.getHeader("Authorization");
- if (!allowUser(auth,
existDbComponent.getCredential().getUsername(),
-
existDbComponent.getCredential().getPassword())) {
+ if (!allowUser(auth, dataSource.getUsername(),
dataSource
+ .getPassword())) {
resp.setHeader("WWW-Authenticate", "BASIC
realm=\"users\"");
resp.sendError(resp.SC_UNAUTHORIZED);
} else {
File dir = new File(".");
- String dbContentDirPath =
dir.getCanonicalPath() + "/../webapps" + req.getContextPath() + "/db";
- try{
+ String dbContentDirPath =
dir.getCanonicalPath()
+ + "/../webapps" +
req.getContextPath() + "/db";
+ try {
initializeDatabase(dbContentDirPath,
configManager);
out.append("DbInitializer - success");
- }catch(PerfSONARException ex){
+ } 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/LookupServiceDAO.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAO.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAO.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -1,16 +1,12 @@
package org.perfsonar.service.lookupservice.storage;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
-import org.perfsonar.base2.service.storage.xml.DataCredential;
import org.perfsonar.base2.xml.nmwg.Data;
import org.perfsonar.base2.xml.nmwg.Metadata;
public interface LookupServiceDAO extends XQueryDAOSupport{
-
- // --------------------------------------------------------- Public
methods
-
/**
* Puts Lookup Information into LSStore database
*/
@@ -50,18 +46,6 @@
public void setControlParameter(String metadataId, String parameter,
String value) throws PerfSONARException;
/**
- * Sets username and password
- * @param dc
- */
- public void setDataCredential(DataCredential dc);
-
- /**
- * Sets collection
- * @param collection
- */
- public void setDataCollection(String collection);
-
- /**
* checks whether collection exists
* @param collection
* @return
@@ -73,4 +57,4 @@
*/
public boolean isDBConnectivity() throws PerfSONARException;
-} //LookupServiceDAO
+}
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAOFactory.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAOFactory.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAOFactory.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -1,12 +1,12 @@
package org.perfsonar.service.lookupservice.storage;
import org.apache.log4j.Logger;
+import org.perfsonar.base2.service.configuration.Component;
import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
public class LookupServiceDAOFactory {
-
private static Logger
logger=Logger.getLogger(LookupServiceDAOFactory.class);
private static volatile LookupServiceDAO dao = null;
@@ -35,13 +35,13 @@
}
public static LookupServiceDAO getRODAO() throws PerfSONARException {
-
if (daoRO != null) {
return daoRO;
} else {
try {
- daoRO = (LookupServiceDAO)
ConfigurationManager.getInstance()
-
.getConfiguration().getAuxiliaryComponent(LS_DAO_RO);
+ Component
comp=ConfigurationManager.getInstance()
+
.getConfiguration().getAuxiliaryComponent(LS_DAO_RO);
+ daoRO = (LookupServiceDAO) comp;
return daoRO;
} catch (Exception ex) {
logger.error(ex);
Deleted:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/CommonExistDAOImpl.java
Deleted:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistDbManager.java
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryDAOSupportImpl.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryDAOSupportImpl.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryDAOSupportImpl.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -1,30 +1,69 @@
package org.perfsonar.service.lookupservice.storage.exist;
+import org.perfsonar.base2.service.configuration.Component;
+import org.perfsonar.base2.service.configuration.ConfigurationManager;
+import org.perfsonar.base2.service.configuration.Option;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.storage.xml.XMLDBResult;
+import org.perfsonar.service.lookupservice.components.XMLDBComponent;
import org.perfsonar.service.lookupservice.storage.XQueryDAOSupport;
-public abstract class XQueryDAOSupportImpl extends CommonExistDAOImpl
implements
+public abstract class XQueryDAOSupportImpl extends Component implements
XQueryDAOSupport{
protected static final String UPDATE_FOR = " for $i in ";
protected static final String UPDATE_REMOVE = " return (update delete
$i, 'removed')";
protected static final String UPDATE_INSERT = " update insert ";
protected static final String UPDATE_INTO = " into ";
+ public static final String LS_STORE_COLLECTION_TYPE = "LSStore";
+ public static final String LS_STORE_CONTROL_COLLECTION_TYPE =
"LSStore-control";
+ public static final String LS_STORE_SUMMARY_COLLECTION_TYPE =
"LSStore-summary";
+ public final static String DECLARE_NMWG_NAMESPACE = "declare
namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/'; \n";
+ /**
+ * Namespaces declaration for perfSONAR
+ */
+ public final static String XQUERY_DECLARE_NAMESPACES = "declare
namespace perfsonar='http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/'; \n"
+ + DECLARE_NMWG_NAMESPACE
+ + "declare namespace
psservice='http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/'; \n"
+ + "declare namespace
nmwgt='http://ggf.org/ns/nmwg/topology/2.0/'; \n"
+ + "declare namespace
netutil='http://ggf.org/ns/nmwg/characteristic/utilization/2.0/'; \n\n";
- public void uploadStoreFile(String name,String content){
- ExistDbManager.uploadStoreFile(name, content);
+
+ private XMLDBComponent dbComponent;
+
+ public void init() throws PerfSONARException {}
+
+ public void destroy() throws PerfSONARException {}
+
+ public void run() {}
+
+ public XMLDBComponent getDBAccessManager() throws PerfSONARException{
+ if(dbComponent==null){
+ Option option=getOption("dbAccessManager-ref");
+ if(option==null){
+ throw new PerfSONARException("lack of
dbAccessManager-ref in configuration");
+ }else{
+
dbComponent=(XMLDBComponent)ConfigurationManager.getInstance().getConfiguration().getAuxiliaryComponent(option.getValue());
+
+ }
+ }
+ return dbComponent;
}
+
+ public void uploadStoreFile(String name,String content) throws
PerfSONARException{
+ getDBAccessManager().uploadStoreFile(name, content);
+ }
+
public XMLDBResult performXQuery(String xquery) throws
PerfSONARException {
- XMLDBResult result=ExistDbManager.performXQuery(xquery);
+ XMLDBResult result=getDBAccessManager().performXQuery(xquery);
return result;
}
- public void removeFile(String fileName){
- ExistDbManager.removeFile(fileName);
+ public void removeFile(String fileName) throws PerfSONARException{
+ getDBAccessManager().removeFile(fileName);
}
public boolean isDBCollection(String collection) throws
PerfSONARException {
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao/SingleFileDAOImpl.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao/SingleFileDAOImpl.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao/SingleFileDAOImpl.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -23,10 +23,7 @@
*/
public class SingleFileDAOImpl extends XQueryDAOSupportImpl implements
LookupServiceDAO{
- //
---------------------------------------------------------------constants
-
-
protected static final String UPDATE_LSSTORE = "
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "'] ";
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao/SummarizationDAOImpl.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao/SummarizationDAOImpl.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao/SummarizationDAOImpl.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -30,15 +30,7 @@
+ LS_STORE_SUMMARY_COLLECTION_TYPE + "']";
public void removeSummaryData() throws PerfSONARException {
-
- StringBuffer sb = new StringBuffer();
-
- // performance improvement
- // sb.append(LOCK);
- sb.append("xmldb:copy('/db/copy/', '/db/ls/',
'LSStore-summary.xml')");
- // sb.append(")");
- performXQuery(sb.toString());
-
+ performXQuery("xmldb:copy('/db/copy/', '/db/ls/',
'LSStore-summary.xml')");
}
public void putSummaryData(Element m) throws PerfSONARException {
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
2009-12-17 11:07:38 UTC (rev 5424)
@@ -71,51 +71,45 @@
<!-- Additional auxiliary components -->
<auxiliaryComponents>
-
- <!-- exist configuration -->
- <component name="exist"
-
className="org.perfsonar.base2.service.storage.xml.XMLDBComponent">
- <option name="dataStorageClassName"
-
value="org.perfsonar.base2.service.storage.xml.exist.ExistHTTPDataStorage"/>
- <option name="uri" value="http://localhost:8080/exist/"/>
+
+ <!-- exist datasource contains optionally read-only credentials -->
+ <component name="existDataSource"
+
className="org.perfsonar.service.lookupservice.components.DataSourceComponent">
+ <option name="url"
value="xmldb:exist://localhost:8080/exist/xmlrpc/db"/>
<option name="username" value="lookupservice"/>
<option name="password" value="sonar"/>
- </component>
+ <option name="usernameRO" value="guest"/>
+ <option name="passwordRO" value="guest"/>
+ </component>
+
+ <!-- provides access to ExistDb with all permissions -->
+ <component name="existAccessManager"
className="org.perfsonar.service.lookupservice.components.XMLDBComponent">
+ <option name="dataSource-ref" value="existDataSource"/>
+ </component>
+
+ <!-- provides access to ExistDb with read-only permissions -->
+ <component name="existAccessManagerRO"
className="org.perfsonar.service.lookupservice.components.XMLDBComponent">
+ <option name="dataSource-ref" value="existDataSource"/>
+ <option name="readOnly" value="true"/>
+ </component>
-
- <!-- exist configuration with read-only permission -->
- <component name="exist-ro"
-
className="org.perfsonar.base2.service.storage.xml.XMLDBComponent">
- <option name="dataStorageClassName"
-
value="org.perfsonar.base2.service.storage.xml.exist.ExistHTTPDataStorage"/>
- <option name="uri" value="http://localhost:8080/exist"/>
- <option name="username" value="guest"/>
- <option name="password" value="guest"/>
- </component>
-
-
<!-- Lookup Service DAO -->
- <component name="lsdao"
-
className="org.perfsonar.service.lookupservice.storage.exist.dao.MultipleFilesDAOImpl">
- <option name="exist-config" value="exist"/> <!-- reference to eXist
DB XML config-->
+ <component name="lsdao"
className="org.perfsonar.service.lookupservice.storage.exist.dao.MultipleFilesDAOImpl">
+ <option name="dbAccessManager-ref" value="existAccessManager"/>
</component>
<!-- Lookup Service DAO with read-only permission. It is used in
LSQueryRequest -->
- <component name="lsdao-ro"
-
className="org.perfsonar.service.lookupservice.storage.exist.dao.MultipleFilesDAOImpl">
- <option name="exist-config" value="exist-ro"/> <!-- reference to
eXist DB XML config-->
+ <component name="lsdao-ro"
className="org.perfsonar.service.lookupservice.storage.exist.dao.MultipleFilesDAOImpl">
+ <option name="dbAccessManager-ref" value="existAccessManagerRO"/>
</component>
<!-- Summarization Service DAO -->
- <component name="summarizationdao"
-
className="org.perfsonar.service.lookupservice.storage.exist.dao.SummarizationDAOImpl">
- <option name="exist-config" value="exist"/> <!-- reference to eXist
DB XML config-->
+ <component name="summarizationdao"
className="org.perfsonar.service.lookupservice.storage.exist.dao.SummarizationDAOImpl">
+ <option name="dbAccessManager-ref" value="existAccessManager"/>
</component>
<!-- contains a nr of changes in DB - is used to synchronization -->
- <component name="modificationCounterComponent"
-
className="org.perfsonar.service.lookupservice.summarization.ModificationCounterComponent">
- </component>
+ <component name="modificationCounterComponent"
className="org.perfsonar.service.lookupservice.summarization.ModificationCounterComponent"/>
<!-- Scheduler -->
<component name="scheduling"
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/actions/QueryActionTests.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/actions/QueryActionTests.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/actions/QueryActionTests.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -39,12 +39,32 @@
meta.addChild(subject);
meta.addChild(eventType);
meta.addChild(params);
-
+
msg.addChild(data);
return msg;
}
+ public void testPermissionDenied() throws PerfSONARException {
+
+ LSQueryServiceEngine engine = new LSQueryServiceEngine();
+ ServiceMessage serviceRequest = new ServiceMessage(
+ getQueryRequest(
+
"http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/query/xquery/2.0",
+ "xmldb:remove('/db/ls/',
'LSStore-summary.xml')"));
+ ServiceMessage serviceResponse = new ServiceMessage();
+
+ try {
+ engine.takeAction(serviceRequest, serviceResponse);
+ fail();
+ } catch (PerfSONARException ex) {
+
if(!ex.getResultCode().equals("http://perfsonar.net/result/error/ls/query")){
+ fail();
+ }
+ }
+
+ }
+
public void testQueryRequestProcessing() throws PerfSONARException {
LSQueryServiceEngine engine = new LSQueryServiceEngine();
@@ -77,12 +97,12 @@
}
}
-
- public void testIncorrectEventType() throws PerfSONARException{
+
+ public void testIncorrectEventType() throws PerfSONARException {
LSQueryServiceEngine engine = new LSQueryServiceEngine();
ServiceMessage serviceResponse = new ServiceMessage();
- ServiceMessage serviceRequest = new
ServiceMessage(getQueryRequest("DUMMY_EVENT_TYPE",
- "\"1\""));
+ ServiceMessage serviceRequest = new
ServiceMessage(getQueryRequest(
+ "DUMMY_EVENT_TYPE", "\"1\""));
try {
engine.takeAction(serviceRequest, serviceResponse);
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/ExistDbManagerTests.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/ExistDbManagerTests.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/ExistDbManagerTests.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -2,7 +2,9 @@
import junit.framework.TestCase;
-import org.perfsonar.service.lookupservice.storage.exist.ExistDbManager;
+import org.perfsonar.base2.service.configuration.ConfigurationManager;
+import org.perfsonar.base2.service.exceptions.PerfSONARException;
+import org.perfsonar.service.lookupservice.components.XMLDBComponent;
import org.xmldb.api.base.ResourceIterator;
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.modules.XPathQueryService;
@@ -11,9 +13,14 @@
private final String FILE_NAME = "xxxx.xml";
- private void uploadFile() {
- ExistDbManager.uploadStoreFile(FILE_NAME, "<a>text</a>");
+ private XMLDBComponent getDBManager() throws PerfSONARException{
+ return
(XMLDBComponent)ConfigurationManager.getInstance().getConfiguration().getAuxiliaryComponent("existAccessManager");
}
+
+
+ private void uploadFile() throws Exception{
+ getDBManager().uploadStoreFile(FILE_NAME, "<a>text</a>");
+ }
private Integer getDocumentCount(XPathQueryService service) throws
Exception {
ResourceSet rs =
service.query("count(collection('/db/ls/store/')/a)");
@@ -30,7 +37,9 @@
public void testUpload() throws Exception {
- XPathQueryService service = ExistDbManager.getService();
+ XMLDBComponent xmlDBComponent=getDBManager();
+
+ XPathQueryService service = xmlDBComponent.getService();
uploadFile();
@@ -38,16 +47,22 @@
assertTrue(count > 0);
- ExistDbManager.removeFile(FILE_NAME);
+ xmlDBComponent.removeFile(FILE_NAME);
+
+ count = getDocumentCount(service);
+
+ assertTrue(count == 0);
}
public void testRemove() throws Exception {
- XPathQueryService service = ExistDbManager.getService();
+ XMLDBComponent xmlDBComponent=getDBManager();
+ XPathQueryService service = xmlDBComponent.getService();
+
uploadFile();
- ExistDbManager.removeFile(FILE_NAME);
+ xmlDBComponent.removeFile(FILE_NAME);
Integer count = getDocumentCount(service);
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/SummarizationDaoTests.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/SummarizationDaoTests.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/SummarizationDaoTests.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -47,7 +47,6 @@
SummarizationDAO summarizationDAO=getSummarizationDao();
- summarizationDAO.removeSummaryData();
Metadata meta1=new Metadata();
meta1.setId("Id1");
@@ -62,6 +61,8 @@
elements.add(meta1);
elements.add(meta2);
+ summarizationDAO.removeSummaryData();
+
summarizationDAO.putBatchData(elements);
assertTrue(summarizationDAO.getSummaryData().getTotal()==elements.size());
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/XQueryExistDAOImplTests.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/XQueryExistDAOImplTests.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/dao/XQueryExistDAOImplTests.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -13,15 +13,10 @@
import org.perfsonar.base2.xml.nmwg.Parameter;
import org.perfsonar.base2.xml.nmwg.Parameters;
import org.perfsonar.service.lookupservice.storage.LookupServiceDAO;
-import org.perfsonar.service.lookupservice.storage.exist.CommonExistDAOImpl;
-import org.perfsonar.service.lookupservice.storage.exist.ExistDbManager;
+import
org.perfsonar.service.lookupservice.storage.exist.XQueryDAOSupportImpl;
public class XQueryExistDAOImplTests extends TestCase {
- public XQueryExistDAOImplTests() throws PerfSONARException {
- ExistDbManager.getService();
- }
-
private LookupServiceDAO getXQueryExistDAOImplDao()
throws PerfSONARException {
return (LookupServiceDAO) ConfigurationManager
@@ -29,8 +24,10 @@
.getAuxiliaryComponent("lsdao");
}
+
private void insertExampleData(LookupServiceDAO dao, String
metadataId)
throws PerfSONARException {
+
Metadata meta = new Metadata();
meta.setId(metadataId);
@@ -46,11 +43,11 @@
}
public void testSaveDeleteData() throws PerfSONARException {
-
+
LookupServiceDAO dao = getXQueryExistDAOImplDao();
- assertNotNull(dao);
String metadataId = "222";
+ assertNotNull(dao);
insertExampleData(dao, metadataId);
assertTrue(dao.isLookupInfo(metadataId));
@@ -60,7 +57,7 @@
}
public void testQueryLookupInformation() throws PerfSONARException {
-
+
LookupServiceDAO dao = getXQueryExistDAOImplDao();
assertNotNull(dao);
String metadataId = "id";
@@ -70,7 +67,7 @@
assertTrue(dao.isLookupInfo(metadataId));
ArrayList<Element> elements = (ArrayList<Element>)
dao.performXQuery(
- CommonExistDAOImpl.DECLARE_NMWG_NAMESPACE
+ XQueryDAOSupportImpl.DECLARE_NMWG_NAMESPACE
+ "
/nmwg:store[@type='LSStore']/nmwg:metadata[@id='"
+ metadataId +
"']").getResults();
assertEquals(1, elements.size());
@@ -95,7 +92,7 @@
dao.setControlParameter(metadataId, paramName, paramValue);
ArrayList<Element> elements = (ArrayList<Element>) dao
.performXQuery(
-
CommonExistDAOImpl.DECLARE_NMWG_NAMESPACE
+
XQueryDAOSupportImpl.DECLARE_NMWG_NAMESPACE
+ "
/nmwg:store[@type='LSStore-control']/nmwg:metadata[@id='"
+ metadataId
+ "']").getResults();
Modified:
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/ExistDBInitializerTests.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/utilities/ExistDBInitializerTests.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -1,26 +1,34 @@
package org.perfsonar.tests.utilities;
+import junit.framework.TestCase;
+
import org.perfsonar.base2.service.configuration.ConfigurationManager;
+import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.storage.xml.XMLDBResult;
+import org.perfsonar.service.lookupservice.components.XMLDBComponent;
import
org.perfsonar.service.lookupservice.servlets.ExistDbInitializerServlet;
-import org.perfsonar.service.lookupservice.storage.exist.ExistDbManager;
-import junit.framework.TestCase;
+public class ExistDBInitializerTests extends TestCase {
-public class ExistDBInitializerTests extends TestCase {
-
+ public XMLDBComponent getDBAccessManager() throws PerfSONARException {
+ return (XMLDBComponent) ConfigurationManager.getInstance()
+
.getConfiguration().getAuxiliaryComponent("existAccessManager");
+ }
+
public void testExitDbInitializer() throws Exception {
+ XMLDBComponent component = getDBAccessManager();
+
ExistDbInitializerServlet emt = new
ExistDbInitializerServlet();
emt.initializeDatabase("db", ConfigurationManager
.getInstanceWithoutRunningComponents());
- ExistDbManager.performXQuery("xmldb:remove('/db/ls')");
+ component.performXQuery("xmldb:remove('/db/ls')");
emt.initializeDatabase("db", ConfigurationManager
.getInstanceWithoutRunningComponents());
- XMLDBResult rs = ExistDbManager
+ XMLDBResult rs = component
.performXQuery("xmldb:collection-exists('/db/ls')");
assertEquals("true", rs.getTextResults()[0]);
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/utilities/ExistDBManagerTests.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/utilities/ExistDBManagerTests.java
2009-12-17 10:53:50 UTC (rev 5423)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/test/java/org/perfsonar/tests/utilities/ExistDBManagerTests.java
2009-12-17 11:07:38 UTC (rev 5424)
@@ -2,17 +2,27 @@
import junit.framework.TestCase;
+import org.perfsonar.base2.service.configuration.ConfigurationManager;
+import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.storage.xml.XMLDBResult;
-import org.perfsonar.service.lookupservice.storage.exist.ExistDbManager;
+import org.perfsonar.service.lookupservice.components.XMLDBComponent;
public class ExistDBManagerTests extends TestCase {
+ public XMLDBComponent getDBAccessManager() throws PerfSONARException {
+ return (XMLDBComponent) ConfigurationManager.getInstance()
+
.getConfiguration().getAuxiliaryComponent("existAccessManager");
+ }
+
public void testExistDbManager() throws Exception {
- ExistDbManager.performXQuery("xmldb:remove('/db/ls')");
- XMLDBResult rs = ExistDbManager.performXQuery(
- "xmldb:collection-exists('/db/ls')");
+ XMLDBComponent dbComponent = getDBAccessManager();
+
+ dbComponent.performXQuery("xmldb:remove('/db/ls')");
+
+ XMLDBResult rs = dbComponent
+
.performXQuery("xmldb:collection-exists('/db/ls')");
assertEquals("false", rs.getTextResults()[0]);
}
-
+
}
- perfsonar: r5424 - in branches/new-structure-with-base2/ps-mdm-ls: contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/functionalTests contrib/SOAPRequestAuxilary/src/pl/psnc/trzaszczka/stressTests packaging src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/components src/main/java/org/perfsonar/service/lookupservice/servlets src/main/java/org/perfsonar/service/lookupservice/storage src/main/java/org/perfsonar/service/lookupservice/storage/exist src/main/java/org/perfsonar/service/lookupservice/storage/exist/dao src/main/resources/perfsonar/conf src/test/java/org/perfsonar/tests/actions src/test/java/org/perfsonar/tests/dao src/test/java/org/perfsonar/tests/utilities, svnlog, 12/17/2009
Archive powered by MHonArc 2.6.16.