<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>hyperjaxb3-ejb-runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.hyperjaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
Used for: JAXB binding between XML and Java objects
$LastChangedRevision: 916 $
- $LastChangedDate: 2009-11-05 16:59:20 -0800 (Thu, 05 Nov 2009) $
+ $LastChangedDate: 2009-11-05 16:59:20 -0800 (Fri, 06 Nov 2009) $
-->
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ jaxb:version="1.0" elementFormDefault="unqualified"
xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:ns="http://collectionspace.org/services/account"
</xs:complexType>
</xs:element>
+ <!-- This is the base class for paginated lists -->
+ <xs:complexType name="abstractCommonList">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.hyperjaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
<xs:element name="accounts-common-list">
<xs:complexType>
<xs:annotation>
<hj:ignored/>
</xs:appinfo>
</xs:annotation>
- <xs:sequence>
- <xs:element name="account-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:annotation>
- <xs:appinfo>
- <hj:ignored/>
- </xs:appinfo>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="screenName" type="xs:string" minOccurs="1"/>
- <xs:element name="personRefName" type="xs:string" minOccurs="1" />
- <xs:element name="email" type="xs:string" minOccurs="1" />
- <xs:element name="status" type="status" minOccurs="1" />
- <!-- uri to retrive collection object details -->
- <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
- <xs:element name="csid" type="xs:string" minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="account-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <hj:ignored/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="screenName" type="xs:string" minOccurs="1"/>
+ <xs:element name="personRefName" type="xs:string" minOccurs="1" />
+ <xs:element name="email" type="xs:string" minOccurs="1" />
+ <xs:element name="status" type="status" minOccurs="1" />
+ <!-- uri to retrive collection object details -->
+ <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
+ <xs:element name="csid" type="xs:string" minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
</xs:complexType>
</xs:element>
@Context UriInfo ui) {
AccountsCommonList accountList = new AccountsCommonList();
try {
- ServiceContext<AccountsCommon, AccountsCommon> ctx = createServiceContext((AccountsCommon) null, AccountsCommon.class);
- DocumentHandler handler = createDocumentHandler(ctx);
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter();
- myFilter.setPagination(queryParams);
- myFilter.setQueryParams(queryParams);
- handler.setDocumentFilter(myFilter);
+ ServiceContext<AccountsCommon, AccountsCommon> ctx = createServiceContext((AccountsCommon) null,
+ queryParams, AccountsCommon.class);
+ DocumentHandler handler = createDocumentHandler(ctx);
+ handler.getDocumentFilter().setQueryParams(queryParams);
+// DocumentFilter myFilter = handler.createDocumentFilter();
+// myFilter.setPagination(queryParams);
+// myFilter.setQueryParams(queryParams);
+// handler.setDocumentFilter(myFilter);
getStorageClient(ctx).getFiltered(ctx, handler);
accountList = (AccountsCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
import java.util.Date;
import java.util.List;
import java.util.UUID;
+
import org.collectionspace.services.account.AccountTenant;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.account.AccountsCommonList;
import org.collectionspace.services.account.AccountsCommonList.AccountListItem;
import org.collectionspace.services.account.Status;
+
+import org.collectionspace.services.common.storage.jpa.JpaDocumentHandler;
import org.collectionspace.services.common.context.ServiceContext;
-import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.document.JaxbUtils;
import org.collectionspace.services.common.security.SecurityUtils;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @author
*/
public class AccountDocumentHandler
- extends AbstractDocumentHandlerImpl<AccountsCommon, AccountsCommonList, AccountsCommon, List> {
+ extends JpaDocumentHandler<AccountsCommon, AccountsCommonList, AccountsCommon, List> {
private final Logger logger = LoggerFactory.getLogger(AccountDocumentHandler.class);
private AccountsCommon account;
DocumentWrapper<List> wrapDoc)
throws Exception {
- AccountsCommonList accList = new AccountsCommonList();
+ AccountsCommonList accList = this.extractPagingInfo(new AccountsCommonList(), wrapDoc);
+// AccountsCommonList accList = new AccountsCommonList();
List<AccountsCommonList.AccountListItem> list = accList.getAccountListItem();
for (Object obj : wrapDoc.getWrappedObject()) {
import org.collectionspace.services.authorization.RoleValue;
import org.collectionspace.services.authorization.SubjectType;
import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.storage.jpa.JpaDocumentHandler;
import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.context.ServiceContextProperties;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @author
*/
public class AccountRoleDocumentHandler
- extends AbstractDocumentHandlerImpl<AccountRole, PermissionsRolesList, List<AccountRoleRel>, List<AccountRoleRel>> {
+ extends JpaDocumentHandler<AccountRole, PermissionsRolesList, List<AccountRoleRel>, List<AccountRoleRel>> {
private final Logger logger = LoggerFactory.getLogger(AccountRoleDocumentHandler.class);
private AccountRole accountRole;
import java.util.List;
import java.util.UUID;
+import org.collectionspace.services.authorization.AccountRole;
+import org.collectionspace.services.authorization.AccountRoleRel;
import org.collectionspace.services.authorization.Permission;
import org.collectionspace.services.authorization.PermissionAction;
import org.collectionspace.services.authorization.PermissionsList;
+import org.collectionspace.services.authorization.PermissionsRolesList;
import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.document.JaxbUtils;
import org.collectionspace.services.common.security.SecurityUtils;
+import org.collectionspace.services.common.storage.jpa.JpaDocumentHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @author
*/
public class PermissionDocumentHandler
- extends AbstractDocumentHandlerImpl<Permission, PermissionsList, Permission, List> {
+ extends JpaDocumentHandler<Permission, PermissionsList, Permission, List> {
private final Logger logger = LoggerFactory.getLogger(PermissionDocumentHandler.class);
private Permission permission;
import java.util.ArrayList;
import java.util.List;
+import org.collectionspace.services.authorization.Permission;
import org.collectionspace.services.authorization.PermissionRole;
import org.collectionspace.services.authorization.PermissionRoleRel;
import org.collectionspace.services.authorization.PermissionValue;
+import org.collectionspace.services.authorization.PermissionsList;
import org.collectionspace.services.authorization.PermissionsRolesList;
import org.collectionspace.services.authorization.RoleValue;
import org.collectionspace.services.authorization.SubjectType;
import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.storage.jpa.JpaDocumentHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @author
*/
public class PermissionRoleDocumentHandler
- extends AbstractDocumentHandlerImpl<PermissionRole, PermissionsRolesList, List<PermissionRoleRel>, List<PermissionRoleRel>> {
+ extends JpaDocumentHandler<PermissionRole, PermissionsRolesList, List<PermissionRoleRel>, List<PermissionRoleRel>> {
private final Logger logger = LoggerFactory.getLogger(PermissionRoleDocumentHandler.class);
private PermissionRole permissionRole;
import org.collectionspace.services.authorization.Role;
import org.collectionspace.services.authorization.RolesList;
-import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.document.JaxbUtils;
import org.collectionspace.services.common.security.SecurityUtils;
+import org.collectionspace.services.common.storage.jpa.JpaDocumentHandler;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @author
*/
public class RoleDocumentHandler
- extends AbstractDocumentHandlerImpl<Role, RolesList, Role, List> {
-
+ extends JpaDocumentHandler<Role, RolesList, Role, List> {
private final Logger logger = LoggerFactory.getLogger(RoleDocumentHandler.class);
private Role role;
private RolesList rolesList;
<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.hyperjaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.client</artifactId>\r
+import org.nuxeo.ecm.core.api.DocumentModelList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public abstract TL extractCommonPartList(DocumentWrapper<WTL> wrapDoc)
throws Exception;
+
+ @Override
+ public abstract TL extractPagingInfo(TL theCommonList, DocumentWrapper<WTL> wrapDoc)
+ throws Exception;
@Override
public abstract T getCommonPart();
* @throws Exception
*/
public TL extractCommonPartList(DocumentWrapper<WTL> docWrap) throws Exception;
+
+ /**
+ * Extract paging info.
+ *
+ * @param theCommonList the the common list
+ * @param wrapDoc the wrap doc
+ * @return the tL
+ * @throws Exception the exception
+ */
+ public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WTL> wrapDoc) throws Exception;
/**
* fillCommonPartList sets list common part of CS object into given document
import java.util.Date;
import java.util.List;
+
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
-import org.collectionspace.services.common.context.ServiceContext;
+
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentException;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.document.DocumentWrapperImpl;
import org.collectionspace.services.common.document.JaxbUtils;
+
import org.collectionspace.services.common.storage.StorageClient;
import org.collectionspace.services.common.context.ServiceContextProperties;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.query.QueryContext;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public void getFiltered(ServiceContext ctx, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException {
- if (ctx == null) {
- throw new IllegalArgumentException(
- "getFiltered: ctx is missing");
- }
- if (handler == null) {
- throw new IllegalArgumentException(
- "getFiltered: handler is missing");
- }
-
+ QueryContext queryContext = new QueryContext(ctx, handler);
+
DocumentFilter docFilter = handler.getDocumentFilter();
if (docFilter == null) {
docFilter = handler.createDocumentFilter();
EntityManager em = null;
try {
handler.prepare(Action.GET_ALL);
-
StringBuilder queryStrBldr = new StringBuilder("SELECT a FROM ");
queryStrBldr.append(getEntityName(ctx));
queryStrBldr.append(" a");
+
List<DocumentFilter.ParamBinding> params = docFilter.buildWhereForSearch(queryStrBldr);
emf = JpaStorageUtils.getEntityManagerFactory();
em = emf.createEntityManager();
* @return the tL
* @throws Exception the exception
*/
- protected TL extractPagingInfo(TL theCommonList, DocumentWrapper<DocumentModelList> wrapDoc)
+ public TL extractPagingInfo(TL theCommonList, DocumentWrapper<DocumentModelList> wrapDoc)
throws Exception {
AbstractCommonList commonList = (AbstractCommonList) theCommonList;
import java.util.List;
import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.query.IQueryManager;
+import org.collectionspace.services.common.query.QueryContext;
+import org.collectionspace.services.common.repository.RepositoryClient;
+import org.collectionspace.services.common.profile.Profiler;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentException;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.document.DocumentWrapperImpl;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.collectionspace.services.common.query.IQueryManager;
-import org.collectionspace.services.common.repository.RepositoryClient;
-import org.collectionspace.services.common.profile.Profiler;
-
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+
import org.nuxeo.common.utils.IdUtils;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
*/
public class RepositoryJavaClientImpl implements RepositoryClient {
- /**
- * The Class QueryContext.
- */
- private class QueryContext {
-
- /** The doc type. */
- String docType;
- /** The doc filter. */
- DocumentFilter docFilter;
- /** The where clause. */
- String whereClause;
- /** The order by clause. */
- String orderByClause;
- /** The domain. */
- String domain;
- /** The tenant id. */
- String tenantId;
-
- /**
- * Instantiates a new query context.
- *
- * @param ctx the ctx
- * @throws DocumentNotFoundException the document not found exception
- * @throws DocumentException the document exception
- */
- QueryContext(ServiceContext<MultipartInput, MultipartOutput> ctx) throws DocumentNotFoundException, DocumentException {
- docType = ctx.getDocumentType();
- if (docType == null) {
- throw new DocumentNotFoundException(
- "Unable to find DocumentType for service " + ctx.getServiceName());
- }
- domain = ctx.getRepositoryDomainName();
- if (domain == null) {
- throw new DocumentNotFoundException(
- "Unable to find Domain for service " + ctx.getServiceName());
- }
- tenantId = ctx.getTenantId();
- if (tenantId == null) {
- throw new IllegalArgumentException(
- "Service context has no Tenant ID specified.");
- }
- }
-
- /**
- * Instantiates a new query context.
- *
- * @param ctx the ctx
- * @param theWhereClause the where clause
- * @throws DocumentNotFoundException the document not found exception
- * @throws DocumentException the document exception
- */
- QueryContext(ServiceContext<MultipartInput, MultipartOutput> ctx,
- String theWhereClause) throws DocumentNotFoundException, DocumentException {
- this(ctx);
- whereClause = theWhereClause;
- }
-
- /**
- * Instantiates a new query context.
- *
- * @param ctx the ctx
- * @param handler the handler
- * @throws DocumentNotFoundException the document not found exception
- * @throws DocumentException the document exception
- */
- QueryContext(ServiceContext<MultipartInput, MultipartOutput> ctx,
- DocumentHandler handler) throws DocumentNotFoundException, DocumentException {
- this(ctx);
- if (handler == null) {
- throw new IllegalArgumentException(
- "Document handler is missing.");
- }
- docFilter = handler.getDocumentFilter();
- if (docFilter == null) {
- throw new IllegalArgumentException(
- "Document handler has no Filter specified.");
- }
- whereClause = docFilter.getWhereClause();
- orderByClause = docFilter.getOrderByClause();
- }
- }
/** The logger. */
private final Logger logger = LoggerFactory.getLogger(RepositoryJavaClientImpl.class);
// private final Logger profilerLogger = LoggerFactory.getLogger("remperf");
@Override
public void getFiltered(ServiceContext ctx, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException {
-
QueryContext queryContext = new QueryContext(ctx, handler);
RepositoryInstance repoSession = null;
Profiler profiler = new Profiler(this, 2);
profiler.log("Executing NXQL query: " + query.toString());
profiler.start();
- if ((queryContext.docFilter.getOffset() > 0) || (queryContext.docFilter.getPageSize() > 0)) {
+ if ((queryContext.getDocFilter().getOffset() > 0) || (queryContext.getDocFilter().getPageSize() > 0)) {
docList = repoSession.query(query, null,
- queryContext.docFilter.getPageSize(), queryContext.docFilter.getOffset(), true);
+ queryContext.getDocFilter().getPageSize(), queryContext.getDocFilter().getOffset(), true);
} else {
docList = repoSession.query(query);
}
//
query.append(/*IQueryManager.SEARCH_QUALIFIER_AND +*/ " WHERE " + DocumentModelHandler.COLLECTIONSPACE_CORE_SCHEMA + ":"
+ DocumentModelHandler.COLLECTIONSPACE_CORE_TENANTID
- + " = " + queryContext.tenantId);
+ + " = " + queryContext.getTenantId());
//
// Finally, append the incoming where clause
//
- String whereClause = queryContext.whereClause;
+ String whereClause = queryContext.getWhereClause();
if (whereClause != null && ! whereClause.trim().isEmpty()) {
// Due to an apparent bug/issue in how Nuxeo translates the NXQL query string
// into SQL, we need to parenthesize our 'where' clause
*/
private final void appendNXQLOrderBy(StringBuilder query, QueryContext queryContext) {
// Append the incoming ORDER BY clause
- String orderByClause = queryContext.orderByClause;
+ String orderByClause = queryContext.getOrderByClause();
if (orderByClause != null && ! orderByClause.trim().isEmpty()) {
// FIXME Verify whether enclosing parentheses may be required, and add
// them if so, as is being done in appendNXQLWhere.
*/
private final String buildNXQLQuery(QueryContext queryContext) {
StringBuilder query = new StringBuilder("SELECT * FROM ");
- query.append(queryContext.docType);
+ query.append(queryContext.getDocType());
appendNXQLWhere(query, queryContext);
appendNXQLOrderBy(query, queryContext);
return query.toString();
<name>services.hyperjaxb</name>\r
\r
<dependencies> \r
- <dependency>\r
- <groupId>com.sun.xml.bind</groupId>\r
- <artifactId>jaxb-impl</artifactId>\r
- </dependency>\r
- \r
- <dependency>\r
- <groupId>org.jvnet.jaxb2-commons</groupId>\r
- <artifactId>property-listener-injector</artifactId>\r
- </dependency>\r
- \r
- <dependency>\r
- <groupId>org.jvnet.jaxb2_commons</groupId>\r
- <artifactId>runtime</artifactId>\r
- </dependency>\r
- \r
+ <dependency>\r
+ <groupId>com.sun.xml.bind</groupId>\r
+ <artifactId>jaxb-impl</artifactId>\r
+ </dependency> \r
+ <dependency>\r
+ <groupId>org.jvnet.jaxb2-commons</groupId>\r
+ <artifactId>property-listener-injector</artifactId>\r
+ </dependency> \r
+ <dependency>\r
+ <groupId>org.jvnet.jaxb2_commons</groupId>\r
+ <artifactId>runtime</artifactId>\r
+ </dependency>\r
+ <!-- Dependencies for HyperJaxB -->\r
+ <dependency>\r
+ <groupId>javax.persistence</groupId>\r
+ <artifactId>persistence-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.hibernate</groupId>\r
+ <artifactId>hibernate-entitymanager</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jvnet.hyperjaxb3</groupId>\r
+ <artifactId>hyperjaxb3-ejb-runtime</artifactId>\r
+ </dependency> \r
</dependencies>\r
\r
<build>\r
- <finalName>collectionspace-services-jaxb</finalName>\r
+ <finalName>collectionspace-services-hyperjaxb</finalName>\r
<defaultGoal>install</defaultGoal>\r
+\r
<plugins>\r
- \r
- <plugin>\r
- <groupId>org.jvnet.jaxb2.maven2</groupId>\r
- <artifactId>maven-jaxb2-plugin</artifactId>\r
- </plugin>\r
+ <plugin>\r
+ <groupId>org.jvnet.hyperjaxb3</groupId>\r
+ <artifactId>maven-hyperjaxb3-plugin</artifactId>\r
+ </plugin>\r
</plugins>\r
</build>\r
\r
<module>authorization</module>
<module>client</module>
<module>jaxb</module>
+ <module>hyperjaxb</module>
<module>common</module>
<module>authorization-mgt</module> <!-- relies on authorization -->
<module>common-test</module>