// private static final String \r
public void contextInitialized(ServletContextEvent event) {\r
if (true) {\r
- System.out.print("Pausing 1 seconds in RESTEasy bootstrap for you to attached the debugger");\r
+ System.out.print("Pausing 10 seconds in RESTEasy bootstrap for you to attached the debugger");\r
long startTime, currentTime;\r
currentTime = startTime = System.currentTimeMillis();\r
- long stopTime = startTime + 1 * 1000; //5 seconds\r
+ long stopTime = startTime + 10 * 1000; //5 seconds\r
do {\r
if (currentTime % 1000 == 0) {\r
System.out.print(".");\r
<parent>\r
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.main</artifactId>\r
- <version>1.12-SNAPSHOT</version>\r
+ <version>1.14-SNAPSHOT</version>\r
</parent>\r
\r
<modelVersion>4.0.0</modelVersion>\r
<name>services.authority</name>\r
<packaging>pom</packaging>\r
\r
- <modules>\r
+ <dependencies>\r
+ <!-- CollectionSpace dependencies\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.common-api</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.jaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.client</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.common</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.authentication.jaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.authentication.service</artifactId>\r
+ <version>${project.version}</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.authorization.service</artifactId>\r
+ <version>${project.version}</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.relation.service</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.relation.client</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ -->\r
+\r
+\r
+ <!-- Utilities -->\r
+\r
+ <!--\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-api</artifactId>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-log4j12</artifactId>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ -->\r
+ <dependency>\r
+ <groupId>log4j</groupId>\r
+ <artifactId>log4j</artifactId>\r
+ <version>1.2.14</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.apache.commons</groupId>\r
+ <artifactId>commons-jexl</artifactId>\r
+ <version>2.0.1</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>commons-codec</groupId>\r
+ <artifactId>commons-codec</artifactId>\r
+ <version>1.4</version>\r
+ </dependency>\r
+\r
+ <!-- javax -->\r
+ <dependency>\r
+ <groupId>javax.servlet</groupId>\r
+ <artifactId>servlet-api</artifactId>\r
+ <version>2.5</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>javax.security</groupId>\r
+ <artifactId>jaas</artifactId>\r
+ <version>1.0.01</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>javax.security</groupId>\r
+ <artifactId>jacc</artifactId>\r
+ <version>1.0</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <!--\r
+ <dependency>\r
+ <groupId>dom4j</groupId>\r
+ <artifactId>dom4j</artifactId>\r
+ <version>1.6.1</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ -->\r
+ <dependency>\r
+ <groupId>mysql</groupId>\r
+ <artifactId>mysql-connector-java</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>postgresql</groupId>\r
+ <artifactId>postgresql</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>javax.persistence</groupId>\r
+ <artifactId>persistence-api</artifactId>\r
+ </dependency>\r
+\r
+ <!-- jboss -->\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>jaxrs-api</artifactId>\r
+ </dependency> \r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxrs</artifactId>\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>tjws</groupId>\r
+ <artifactId>webserver</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxb-provider</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-multipart-provider</artifactId>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.hibernate</groupId>\r
+ <artifactId>hibernate-entitymanager</artifactId>\r
+ </dependency>\r
+ <!-- jboss -->\r
+ <dependency>\r
+ <groupId>jboss</groupId>\r
+ <artifactId>jbosssx</artifactId>\r
+ <version>4.2.3.GA</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>jboss</groupId>\r
+ <artifactId>jboss-remoting</artifactId>\r
+ <version>2.2.2.SP8</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <!-- nuxeo -->\r
+<!-- \r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.platform</groupId>\r
+ <artifactId>nuxeo-platform-mimetype-api</artifactId>\r
+ <version>${nuxeo.platform.version}</version>\r
+ </dependency> \r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.platform</groupId>\r
+ <artifactId>nuxeo-platform-imaging-api</artifactId>\r
+ <version>${nuxeo.platform.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.platform</groupId>\r
+ <artifactId>nuxeo-platform-filemanager-api</artifactId>\r
+ <version>${nuxeo.platform.version}</version> \r
+ </dependency>\r
+--> \r
+ <!--\r
+ <dependency>\r
+ <groupId>org.nuxeo.common</groupId>\r
+ <artifactId>nuxeo-common</artifactId>\r
+ <version>${nuxeo.core.version}</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.nuxeo.runtime</groupId>\r
+ <artifactId>nuxeo-runtime</artifactId>\r
+ <version>${nuxeo.core.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-api</artifactId>\r
+ <version>${nuxeo.core.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-client</artifactId>\r
+ <version>${nuxeo.core.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-query</artifactId>\r
+ <version>${nuxeo.core.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-schema</artifactId>\r
+ <version>${nuxeo.core.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-io</artifactId>\r
+ <version>${nuxeo.core.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-io</artifactId>\r
+ <version>${nuxeo.core.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.nuxeo.runtime</groupId>\r
+ <artifactId>nuxeo-runtime-osgi</artifactId>\r
+ <version>${nuxeo.core.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.osgi</groupId>\r
+ <artifactId>org.osgi.core</artifactId>\r
+ <version>4.1.0</version>\r
+ </dependency>\r
+ -->\r
+ </dependencies>\r
+ \r
+ <modules>\r
<module>jaxb</module>\r
<module>service</module>\r
</modules>\r
-</project>\r
+ \r
+ </project>\r
\r
#url of the collectionspace server\r
-cspace.url=http://localhost:8180/cspace-services/\r
+cspace.url=http://localhost:8081/cspace-services/\r
#cspace.url=http://nightly.collectionspace.org:8180/cspace-services/\r
\r
#cspace.url=http://localhost:8200/cspace-services/\r
private static final String DEFAULT_READER_PASSWORD = "reader";\r
private static final String SERVER_HOME_PROPERTY = "catalina.home";\r
\r
- private static DataSource cspaceDataSource = null;\r
- private static DataSource nuxeoDataSource = null;\r
- \r
private ServiceMain() {\r
//empty\r
}\r
// Invoke all post-initialization handlers, passing in a DataSource instance of the Nuxeo db.\r
// Typically, these handlers modify column types and add indexes to the Nuxeo db schema.\r
//\r
- firePostInitHandlers(ServiceMain.nuxeoDataSource);\r
+ firePostInitHandlers(JDBCTools.getDataSource(JDBCTools.NUXEO_REPOSITORY_NAME));\r
} catch(Exception e) {\r
logger.error("ServiceMain.initialize firePostInitHandlers failed on exception: " + e.getLocalizedMessage());\r
}\r
return null;\r
}\r
\r
- private Connection getConnection() throws LoginException, SQLException {\r
+ private Connection getConnection() throws NamingException, SQLException {\r
return JDBCTools.getConnection(JDBCTools.CSPACE_REPOSITORY_NAME);\r
}\r
\r
* static members.\r
*/\r
private void setDataSources() throws NamingException {\r
- ServiceMain.cspaceDataSource = JDBCTools.getDataSource(JDBCTools.CSPACE_REPOSITORY_NAME);\r
- ServiceMain.nuxeoDataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_REPOSITORY_NAME);\r
+ //\r
+ // As a side-effect of calling JDBCTools.getDataSource(...), the DataSource instance will be\r
+ // cached in a static hash map of the JDBCTools class. This will speed up lookups as well as protect our\r
+ // code from JNDI lookup problems -for example, if the JNDI context gets stepped on or corrupted.\r
+ //\r
+ DataSource cspaceDataSource = JDBCTools.getDataSource(JDBCTools.CSPACE_REPOSITORY_NAME);\r
+ DataSource nuxeoDataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_REPOSITORY_NAME);\r
+ //\r
+ // Set our AuthN's datasource to be the cspaceDataSource\r
+ //\r
AuthN.setDataSource(cspaceDataSource);\r
}\r
\r
import java.sql.ResultSet;\r
import java.sql.SQLException;\r
import java.sql.Statement;\r
+import java.util.HashMap;\r
\r
/**\r
* User: laramie\r
* $LastChangedDate: $\r
*/\r
public class JDBCTools {\r
+ public static HashMap<String, DataSource> cachedDataSources = new HashMap<String, DataSource>();\r
public static String CSPACE_REPOSITORY_NAME = "CspaceDS";\r
public static String NUXEO_REPOSITORY_NAME = "NuxeoDS";\r
- public static String DEFAULT_REPOSITORY_NAME = NUXEO_REPOSITORY_NAME;\r
+ //\r
+ // Private constants\r
+ //\r
+ private static String DEFAULT_REPOSITORY_NAME = NUXEO_REPOSITORY_NAME;\r
private static String DBProductName = null;\r
private static DatabaseProductType DBProductType = DatabaseProductType.UNRECOGNIZED;\r
\r
//todo: make sure this will get instantiated in the right order\r
final static Logger logger = LoggerFactory.getLogger(JDBCTools.class);\r
- \r
+ \r
public static DataSource getDataSource(String repositoryName) throws NamingException {\r
DataSource result = null;\r
- InitialContext ctx = new InitialContext();\r
- Context envCtx = null;\r
\r
- if (logger.isDebugEnabled() == true) {\r
- logger.debug("Looking up datasource in JNDI with name: " + repositoryName);\r
- }\r
- \r
- try {\r
- envCtx = (Context) ctx.lookup("java:comp/env");\r
- DataSource ds = (DataSource) envCtx.lookup("jdbc/" + repositoryName);\r
- if (ds == null) {\r
- throw new IllegalArgumentException("datasource not found: " + repositoryName);\r
- } else {\r
- result = ds;\r
+ //\r
+ // First, see if we already have this DataSource instance cached\r
+ //\r
+ result = cachedDataSources.get(repositoryName);\r
+ if (result == null) { \r
+ InitialContext ctx = new InitialContext();\r
+ Context envCtx = null;\r
+\r
+ if (logger.isDebugEnabled() == true) {\r
+ logger.debug("Looking up DataSource instance in JNDI with name: " + repositoryName);\r
}\r
- } finally {\r
- if (ctx != null) {\r
- try {\r
- ctx.close();\r
- } catch (Exception e) {\r
- logger.error("Error getting DataSource for: " + repositoryName, e);\r
- }\r
- }\r
- if (envCtx != null) {\r
- try {\r
- envCtx.close();\r
- } catch (Exception e) {\r
- logger.error("Error getting DataSource for: " + repositoryName, e);\r
- }\r
- }\r
+ \r
+ try {\r
+ envCtx = (Context) ctx.lookup("java:comp/env");\r
+ DataSource ds = (DataSource) envCtx.lookup("jdbc/" + repositoryName);\r
+ if (ds == null) {\r
+ throw new IllegalArgumentException("DataSource instance not found: " + repositoryName);\r
+ } else {\r
+ result = ds;\r
+ // now cache this DataSource instance for future references\r
+ cachedDataSources.put(repositoryName, result);\r
+ }\r
+ } finally {\r
+ if (ctx != null) {\r
+ try {\r
+ ctx.close();\r
+ } catch (Exception e) {\r
+ logger.error("Error getting DataSource for: " + repositoryName, e);\r
+ }\r
+ }\r
+ if (envCtx != null) {\r
+ try {\r
+ envCtx.close();\r
+ } catch (Exception e) {\r
+ logger.error("Error getting DataSource for: " + repositoryName, e);\r
+ }\r
+ }\r
+ }\r
}\r
+ \r
return result;\r
}\r
\r
return result;\r
}\r
\r
- public static Connection getConnection(String repositoryName) throws LoginException, SQLException {\r
+ public static Connection getConnection(String repositoryName) throws NamingException, SQLException {\r
Connection result = null;\r
\r
if (Tools.isEmpty(repositoryName)) {\r
repositoryName = getDefaultRepositoryName();\r
+ if (logger.isWarnEnabled() == true) {\r
+ logger.warn("getConnection() method was called with an empty or null repository name. Using " + repositoryName + " instead.");\r
+ }\r
}\r
\r
- Connection conn = null;\r
- try {\r
- DataSource ds = getDataSource(repositoryName);\r
- conn = ds.getConnection();\r
- result = conn;\r
- } catch (NamingException ex) {\r
- LoginException le = new LoginException("Error looking up DataSource from: " + repositoryName);\r
- le.initCause(ex);\r
- throw le;\r
- } catch (SQLException e) {\r
- throw e;\r
- }\r
+ DataSource ds = getDataSource(repositoryName);\r
+ Connection conn = getConnection(ds);\r
+ result = conn;\r
\r
return result;\r
}\r
\r
-\r
/* THIS IS BROKEN - If you close the statement, it closes the ResultSet!!!\r
public static ResultSet executeQuery(String repoName, String sql) throws Exception {\r
Connection conn = null;\r
return DBProductType;\r
}\r
\r
- public static String getDefaultRepositoryName() {\r
+ private static String getDefaultRepositoryName() {\r
return DEFAULT_REPOSITORY_NAME;\r
}\r
\r
DocumentFilter filter = handler.getDocumentFilter();
String oldOrderBy = filter.getOrderByClause();
if (isClauseEmpty(oldOrderBy) == true){
- filter.setOrderByClause(DocumentFilter.ORDER_BY_LAST_UPDATED); //per http://issues.collectionspace.org/browse/CSPACE-705
+ filter.setOrderByClause(DocumentFilter.ORDER_BY_LAST_UPDATED); //per http://issues.collectionspace.org/browse/CSPACE-705 (Doesn't this conflict with what happens with the QueryContext instance that we create below?)
}
QueryContext queryContext = new QueryContext(ctx, handler);
RepositoryInstance repoSession = null;
import java.sql.Statement;
import java.util.LinkedHashMap;
import java.util.Map;
+
+import javax.naming.NamingException;
import javax.security.auth.login.LoginException;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentNotFoundException;
* @throws DocumentNotFoundException if the requested ID generator could not be found.
*/
public void updateLastID(String csid, String lastId)
- throws IllegalStateException, DocumentNotFoundException, LoginException, SQLException {
+ throws IllegalStateException, DocumentNotFoundException, NamingException, SQLException {
logger.debug("> in updateLastID");
conn.close();
}
} catch (SQLException e) {
+ logger.error("Error closing JDBC connection: ", e);
// Do nothing here
}
}
* @throws LoginException
* @throws SQLException if a storage-related error occurred.
*/
- public Connection getJdbcConnection() throws LoginException, SQLException {
+ public Connection getJdbcConnection() throws NamingException, SQLException {
logger.debug("> in getJdbcConnection");
Connection conn = null;
try {
conn = JDBCTools.getConnection(JDBCTools.NUXEO_REPOSITORY_NAME);
- } catch (LoginException e) {
+ } catch (NamingException e) {
throw e;
} catch (SQLException e) {
throw e;
<module>common-api</module>
<module>authentication</module>
<module>authorization</module>
+ <!--
<module>blob</module>
+ -->
<module>client</module>
<module>jaxb</module>
<module>hyperjaxb</module>
<module>intake</module>
<module>loanin</module>
<module>loanout</module>
+ <!--
<module>media</module>
+ -->
<module>objectexit</module>
<module>batch</module>
<module>imports</module>
import org.collectionspace.services.common.api.Tools;\r
import org.collectionspace.services.relation.RelationsCommon;\r
\r
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
-\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
//import org.testng.Assert;\r
\r
-public class RelationValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, PoxPayloadOut> {\r
+public class RelationValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, PoxPayloadOut> {\r
\r
/** The logger. */\r
private final Logger logger = LoggerFactory.getLogger(RelationValidatorHandler.class);\r
*/\r
private static final String VALIDATION_ERROR = "The relation record payload was invalid. See log file for more details.";\r
private static final String SUBJECT_EQUALS_OBJECT_ERROR = "The subject ID and object ID cannot be the same.";\r
-\r
+ \r
@Override\r
protected Class<?> getCommonPartClass() {\r
- return RelationsCommon.class;\r
+ return RelationsCommon.class;\r
}\r
-\r
+ \r
@Override\r
protected void handleCreate()\r
- throws InvalidDocumentException {\r
- try {\r
- RelationsCommon relationsCommon = (RelationsCommon) getCommonPart();\r
- assert (relationsCommon != null);\r
- if (logger.isTraceEnabled() == true) {\r
- logger.trace(relationsCommon.toString());\r
- }\r
-\r
+ throws InvalidDocumentException{\r
+ try {\r
+ RelationsCommon relationsCommon = (RelationsCommon)getCommonPart();\r
+ CS_ASSERT(relationsCommon != null);\r
+ if (logger.isTraceEnabled() == true) {\r
+ logger.trace(relationsCommon.toString());\r
+ }\r
+ \r
String subjectCsid = getSubjectCsid(relationsCommon);\r
String objectCsid = getObjectCsid(relationsCommon);\r
-\r
+ \r
// If no CSID for a subject or object is included in the create payload,\r
// a refName must be provided for that subject or object as an alternate identifier.\r
- assert (hasCsid(subjectCsid) || hasSubjectRefname(relationsCommon));\r
- assert (hasCsid(objectCsid) || hasObjectRefname(relationsCommon));\r
-\r
+ CS_ASSERT(hasCsid(subjectCsid) || hasSubjectRefname(relationsCommon));\r
+ CS_ASSERT(hasCsid(objectCsid) || hasObjectRefname(relationsCommon));\r
+ \r
// The Subject identifier and Object ID must not be identical:\r
// that is, a resource cannot be related to itself.\r
if (hasCsid(subjectCsid) && hasCsid(objectCsid)) {\r
- assert (subjectCsid.trim().equalsIgnoreCase(objectCsid.trim()) == false) :\r
- SUBJECT_EQUALS_OBJECT_ERROR;\r
+ CS_ASSERT (subjectCsid.trim().equalsIgnoreCase(objectCsid.trim()) == false,\r
+ SUBJECT_EQUALS_OBJECT_ERROR);\r
}\r
\r
// A relationship type must be provided.\r
- assert (relationsCommon.getRelationshipType() != null);\r
-\r
- } catch (AssertionError e) {\r
- if (logger.isErrorEnabled() == true) {\r
- logger.error(e.getMessage(), e);\r
- }\r
- throw new InvalidDocumentException(VALIDATION_ERROR, e);\r
- }\r
+ CS_ASSERT(relationsCommon.getRelationshipType() != null);\r
+\r
+ } catch (AssertionError e) {\r
+ if (logger.isErrorEnabled() == true) {\r
+ logger.error(e.getMessage(), e);\r
+ }\r
+ throw new InvalidDocumentException(VALIDATION_ERROR, e);\r
+ }\r
}\r
\r
- @Override\r
- protected void handleGet() {\r
- // TODO Auto-generated method stub\r
- }\r
+ @Override\r
+ protected void handleGet() {\r
+ // TODO Auto-generated method stub\r
+ }\r
\r
- @Override\r
- protected void handleGetAll() {\r
- // TODO Auto-generated method stub\r
- }\r
+ @Override\r
+ protected void handleGetAll() {\r
+ // TODO Auto-generated method stub\r
+ }\r
\r
- @Override\r
- protected void handleUpdate() {\r
- // TODO Auto-generated method stub\r
- }\r
+ @Override\r
+ protected void handleUpdate() {\r
+ // TODO Auto-generated method stub\r
+ }\r
\r
- @Override\r
- protected void handleDelete() {\r
- // TODO Auto-generated method stub\r
+ @Override\r
+ protected void handleDelete() {\r
+ // TODO Auto-generated method stub\r
}\r
-\r
+ \r
private String getSubjectCsid(RelationsCommon relationsCommon) {\r
String subjectCsid = relationsCommon.getSubjectCsid();\r
// FIXME: Remove this entire 'if' statement when legacy fields are removed from the Relation record:\r
if (Tools.isBlank(subjectCsid)) {\r
subjectCsid = relationsCommon.getDocumentId1();\r
- }\r
+ }\r
return subjectCsid;\r
}\r
\r
// FIXME: Remove this entire 'if' statement when legacy fields are removed from the Relation record:\r
if (Tools.isBlank(objectCsid)) {\r
objectCsid = relationsCommon.getDocumentId2();\r
- }\r
+}\r
return objectCsid;\r
}\r
\r
import org.collectionspace.services.common.invocable.Invocable.InvocationError;
import org.collectionspace.services.common.query.QueryManager;
import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.storage.JDBCTools;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.slf4j.Logger;
@Produces("application/xml")
//@Produces("application/xml;charset=UTF-8")
public class ReportResource extends ResourceBase {
- private static String REPOSITORY_NAME = "NuxeoDS";
+ private static String REPOSITORY_NAME = JDBCTools.NUXEO_REPOSITORY_NAME;
private static String REPORTS_FOLDER = "reports";
private static String CSID_LIST_SEPARATOR = ",";
final Logger logger = LoggerFactory.getLogger(ReportResource.class);
}
}
- private Connection getConnection() throws LoginException, SQLException {
- InitialContext ctx = null;
- Connection conn = null;
- try {
- ctx = new InitialContext();
- DataSource ds = (DataSource) ctx.lookup(REPOSITORY_NAME);
- if (ds == null) {
- throw new IllegalArgumentException("datasource not found: " + REPOSITORY_NAME);
- }
- conn = ds.getConnection();
- return conn;
- } catch (NamingException ex) {
- LoginException le = new LoginException("Error looking up DataSource from: " + REPOSITORY_NAME);
- le.initCause(ex);
- throw le;
- } finally {
- if (ctx != null) {
- try {
- ctx.close();
- } catch (Exception e) {
- }
- }
- }
+ private Connection getConnection() throws NamingException, SQLException {
+ return JDBCTools.getConnection(REPOSITORY_NAME);
}
+
}