2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2009 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
24 package org.collectionspace.services.common.context;
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
30 import java.util.Properties;
32 import javax.ws.rs.core.MultivaluedMap;
33 import javax.ws.rs.core.UriInfo;
35 import org.collectionspace.authentication.spi.AuthNContext;
36 import org.collectionspace.services.client.AuthorityClient;
37 import org.collectionspace.services.client.CollectionSpaceClient;
38 import org.collectionspace.services.client.IClientQueryParams;
39 import org.collectionspace.services.client.IQueryManager;
40 import org.collectionspace.services.client.workflow.WorkflowClient;
41 import org.collectionspace.services.common.ServiceMain;
42 import org.collectionspace.services.common.api.Tools;
43 import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon;
44 import org.collectionspace.services.common.config.PropertyItemUtils;
45 import org.collectionspace.services.common.config.ServiceConfigUtils;
46 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
47 import org.collectionspace.services.common.document.DocumentHandler;
48 import org.collectionspace.services.common.document.DocumentFilter;
49 import org.collectionspace.services.common.document.ValidatorHandler;
50 import org.collectionspace.services.common.security.SecurityContext;
51 import org.collectionspace.services.common.security.SecurityContextImpl;
52 import org.collectionspace.services.common.security.UnauthorizedException;
53 import org.collectionspace.services.config.ClientType;
54 import org.collectionspace.services.config.service.ObjectPartType;
55 import org.collectionspace.services.config.service.ServiceBindingType;
56 import org.collectionspace.services.config.tenant.RemoteClientConfig;
57 import org.collectionspace.services.config.tenant.RepositoryDomainType;
58 import org.collectionspace.services.config.tenant.TenantBindingType;
59 import org.collectionspace.services.config.types.PropertyItemType;
60 import org.collectionspace.services.config.types.PropertyType;
61 import org.slf4j.Logger;
62 import org.slf4j.LoggerFactory;
65 * AbstractServiceContext
67 * $LastChangedRevision: $
82 @SuppressWarnings("rawtypes")
83 public abstract class AbstractServiceContextImpl<IT, OT>
84 implements ServiceContext<IT, OT> {
87 final Logger logger = LoggerFactory.getLogger(AbstractServiceContextImpl.class);
89 /** The properties. */
90 Map<String, Object> properties = new HashMap<String, Object>();
91 /** The object part map. */
92 Map<String, ObjectPartType> objectPartMap = new HashMap<String, ObjectPartType>();
93 /** The service binding. */
94 protected ServiceBindingType serviceBinding;
95 /** The tenant binding. */
96 private TenantBindingType tenantBinding;
97 /** repository domain used by the service */
98 private RepositoryDomainType repositoryDomain;
99 /** The override document type. */
100 private String overrideDocumentType = null;
101 /** The val handlers. */
102 private List<ValidatorHandler<IT, OT>> valHandlers = null;
103 /** The authority client -use for shared authority server */
104 private AuthorityClient authorityClient = null;
105 /** The doc handler. */
106 private DocumentHandler docHandler = null;
107 /** security context */
108 private SecurityContext securityContext;
109 /** The sessions JAX-RS URI information */
110 private UriInfo uriInfo;
111 /** The current repository session */
112 private Object currentRepositorySession;
113 /** A reference count for the current repository session */
114 private int currentRepoSesssionRefCount = 0;
117 * Instantiates a new abstract service context impl.
119 private AbstractServiceContextImpl() {
120 // private constructor for singleton pattern
122 // request query params
123 /** The query params. */
124 private MultivaluedMap<String, String> queryParams;
127 * Instantiates a new abstract service context impl.
129 * @param serviceName the service name
131 * @throws UnauthorizedException the unauthorized exception
133 protected AbstractServiceContextImpl(String serviceName, UriInfo uriInfo) throws UnauthorizedException {
135 //establish security context
136 securityContext = new SecurityContextImpl(uriInfo);
137 //make sure tenant context exists
138 checkTenantContext();
140 String tenantId = securityContext.getCurrentTenantId();
141 if (AuthorizationCommon.ALL_TENANTS_MANAGER_TENANT_ID.equals(tenantId) ||
142 AuthNContext.ANONYMOUS_TENANT_ID.equals(tenantId)) {
143 // Tenant Manager has no tenant binding, so don't bother...
144 tenantBinding = null;
145 serviceBinding = null;
146 repositoryDomain = null;
148 //retrieve service bindings
149 TenantBindingConfigReaderImpl tReader =
150 ServiceMain.getInstance().getTenantBindingConfigReader();
151 tenantBinding = tReader.getTenantBinding(tenantId);
152 if (tenantBinding == null) {
153 String msg = "No tenant binding found for tenantId=" + tenantId
154 + " while processing request for service= " + serviceName;
156 throw new IllegalStateException(msg);
158 serviceBinding = tReader.getServiceBinding(tenantId, serviceName);
159 if (serviceBinding == null) {
160 String msg = "No service binding found while processing request for "
161 + serviceName + " for tenant id=" + getTenantId()
162 + " name=" + getTenantName();
164 throw new IllegalStateException(msg);
166 if (logger.isDebugEnabled()) {
167 logger.debug("tenantId=" + tenantId
168 + " service binding=" + serviceBinding.getName());
170 repositoryDomain = tReader.getRepositoryDomain(tenantId, serviceName);
171 if (repositoryDomain != null) {
172 if (logger.isDebugEnabled()) {
173 logger.debug("tenantId=" + tenantId
174 + " repository doamin=" + repositoryDomain.getName());
180 public int getTimeoutParam(UriInfo ui) {
181 int result = DEFAULT_TX_TIMEOUT;
183 MultivaluedMap<String, String> queryParams = (ui == null) ? null : ui.getQueryParameters();
184 if (queryParams != null) {
185 String timeoutString = queryParams.getFirst(IClientQueryParams.IMPORT_TIMEOUT_PARAM);
186 if (timeoutString != null)
188 result = Integer.parseInt(timeoutString);
189 } catch (NumberFormatException e) {
190 logger.warn("Transaction timeout period parameter could not be parsed. The characters in the parameter string must all be decimal digits. The Import service will use the default timeout period instead.",
199 public int getTimeoutSecs() {
200 UriInfo uriInfo = this.getUriInfo();
201 return this.getTimeoutParam(uriInfo);
205 * Returns TRUE unless the "recordUpdates" query param is set with a value of either "false", "FALSE", or "0"
209 public boolean shouldUpdateCoreValues() {
210 boolean recordUpdates = true;
212 MultivaluedMap<String, String> queryParams = getQueryParams();
213 String paramValue = queryParams.getFirst(IClientQueryParams.UPDATE_CORE_VALUES);
214 if (paramValue != null && paramValue.equalsIgnoreCase(Boolean.FALSE.toString())) { // Find our if the caller wants us to record updates
215 recordUpdates = false;
216 } else if (paramValue != null && paramValue.equals(Long.toString(0))) {
217 recordUpdates = false;
220 return recordUpdates;
224 * @see org.collectionspace.services.common.context.ServiceContext#getCommonPartLabel()
227 public String getCommonPartLabel() {
228 return getCommonPartLabel(getServiceName());
232 * @see org.collectionspace.services.common.context.ServiceContext#getCommonPartLabel(java.lang.String)
234 public String getCommonPartLabel(String schemaName) {
235 return schemaName.toLowerCase() + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
239 * @see org.collectionspace.services.common.context.ServiceContext#getPartsMetadata()
242 public Map<String, ObjectPartType> getPartsMetadata() {
243 if (objectPartMap.size() != 0) {
244 return objectPartMap;
246 ServiceBindingUtils.getPartsMetadata(getServiceBinding(), objectPartMap);
247 return objectPartMap;
251 * Gets the properties for part.
253 * @param partLabel the part label
255 * @return the properties for part
257 public List<PropertyItemType> getPropertiesForPart(String partLabel) {
258 Map<String, ObjectPartType> partMap = getPartsMetadata();
259 ObjectPartType part = partMap.get(partLabel);
261 throw new RuntimeException("No such part found: " + partLabel);
263 List<PropertyType> propNodeList = part.getProperties();
264 return propNodeList.isEmpty() ? null : propNodeList.get(0).getItem();
268 * @param partLabel The name of the scehma part to search in
269 * @param propName The name of the property (or properties) to find
270 * @param qualified Whether the returned values should be qualified with the
271 * partLabel. This is when the property values are schema field references.
272 * @return List of property values for the matched property on the named schema part.
274 public List<String> getPropertyValuesForPart(String partLabel, String propName, boolean qualified) {
275 List<PropertyItemType> allProps = getPropertiesForPart(partLabel);
276 return PropertyItemUtils.getPropertyValuesByName(allProps, propName,
277 (qualified ? (partLabel + ":") : null));
281 * @param propName The name of the property (or properties) to find
282 * @param qualified Whether the returned values should be qualified with the
283 * partLabel. This is when the property values are schema field references.
284 * @return List of property values for the matched property on any schema part.
286 public List<String> getAllPartsPropertyValues(String propName, boolean qualified) {
287 return ServiceBindingUtils.getAllPartsPropertyValues(getServiceBinding(), propName, qualified);
291 * @see org.collectionspace.services.common.context.ServiceContext#getServiceBindingPropertyValue(java.lang.String)
293 public String getServiceBindingPropertyValue(String propName) {
294 return ServiceBindingUtils.getPropertyValue(getServiceBinding(), propName);
298 * Gets the common part properties.
300 * @return the common part properties
302 public List<PropertyItemType> getCommonPartProperties() {
303 return getPropertiesForPart(getCommonPartLabel());
307 * @param propName The name of the property (or properties) to find
308 * @param qualified Whether the returned values should be qualified with the
309 * partLabel. This is when the property values are schema field references.
310 * @return List of property values for the matched property on the common schema part.
312 public List<String> getCommonPartPropertyValues(String propName, boolean qualified) {
313 return getPropertyValuesForPart(getCommonPartLabel(), propName, qualified);
317 * @see org.collectionspace.services.common.context.ServiceContext#getQualifiedServiceName()
320 public String getQualifiedServiceName() {
321 return TenantBindingConfigReaderImpl.getTenantQualifiedServiceName(getTenantId(), getServiceName());
325 * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryClientName()
328 public String getRepositoryClientName() {
329 if (repositoryDomain == null) {
332 return repositoryDomain.getRepositoryClient();
336 * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryClientType()
339 public ClientType getRepositoryClientType() {
340 //assumption: there is only one repository client configured
341 return ServiceMain.getInstance().getClientType();
345 * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryDomainName()
348 public String getRepositoryDomainName() {
349 if (repositoryDomain == null) {
352 return repositoryDomain.getName();
356 * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryDomainName()
359 public String getRepositoryDomainStorageName() {
360 if (repositoryDomain == null) {
363 return repositoryDomain.getStorageName();
367 * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryWorkspaceId()
370 public String getRepositoryWorkspaceId() {
371 return ServiceMain.getInstance().getWorkspaceId(getTenantId(), getServiceName());
375 * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryWorkspaceName()
378 public String getRepositoryWorkspaceName() {
379 //service name is workspace name by convention
380 return serviceBinding.getName();
384 * @see org.collectionspace.services.common.context.ServiceContext#getServiceBinding()
387 public ServiceBindingType getServiceBinding() {
388 return serviceBinding;
392 * @see org.collectionspace.services.common.context.ServiceContext#getServiceName()
395 public String getServiceName() {
396 return serviceBinding.getName();
400 * @see org.collectionspace.services.common.context.ServiceContext#getDocumentType()
403 public String getDocumentType() {
404 // If they have not overridden the setting, use the type of the service
406 return (overrideDocumentType != null) ? overrideDocumentType : serviceBinding.getObject().getName();
410 public String getTenantQualifiedDoctype(String docType) {
411 // If they have not overridden the setting, use the type of the service
413 String result = ServiceBindingUtils.getTenantQualifiedDocType(this.getTenantId(), docType);
419 public String getTenantQualifiedDoctype() {
420 String docType = (overrideDocumentType != null) ? overrideDocumentType : serviceBinding.getObject().getName();
421 return getTenantQualifiedDoctype(docType);
425 * @see org.collectionspace.services.common.context.ServiceContext#setDocumentType(java.lang.String)
428 public void setDocumentType(String docType) {
429 overrideDocumentType = docType;
433 * @see org.collectionspace.services.common.context.ServiceContext#getSecurityContext()
436 public SecurityContext getSecurityContext() {
437 return securityContext;
441 * @see org.collectionspace.services.common.context.ServiceContext#getUserId()
444 public String getUserId() {
445 return securityContext.getUserId();
449 * @see org.collectionspace.services.common.context.ServiceContext#getTenantId()
452 public String getTenantId() {
453 return securityContext.getCurrentTenantId();
457 * @see org.collectionspace.services.common.context.ServiceContext#getTenantName()
460 public String getTenantName() {
461 return securityContext.getCurrentTenantName();
465 * @see org.collectionspace.services.common.context.ServiceContext#getInput()
468 public abstract IT getInput();
471 * @see org.collectionspace.services.common.context.ServiceContext#setInput(java.lang.Object)
474 public abstract void setInput(IT input);
477 * @see org.collectionspace.services.common.context.ServiceContext#getOutput()
480 public abstract OT getOutput();
483 * @see org.collectionspace.services.common.context.ServiceContext#setOutput(java.lang.Object)
486 public abstract void setOutput(OT output);
489 * @see org.collectionspace.services.common.context.ServiceContext#getProperties()
492 public Map<String, Object> getProperties() {
497 * @see org.collectionspace.services.common.context.ServiceContext#setProperties(java.util.Map)
500 public void setProperties(Map<String, Object> props) {
501 properties.putAll(props);
505 * @see org.collectionspace.services.common.context.ServiceContext#getProperty(java.lang.String)
507 public Object getProperty(String name) {
508 return properties.get(name);
512 * @see org.collectionspace.services.common.context.ServiceContext#setProperty(java.lang.String, java.lang.Object)
514 public void setProperty(String name, Object o) {
515 properties.put(name, o);
519 * checkTenantContext makss sure tenant context exists
523 * @throws UnauthorizedException the unauthorized exception
525 private void checkTenantContext() throws UnauthorizedException {
527 String tenantId = securityContext.getCurrentTenantId();
528 if (tenantId == null) {
529 String msg = "Could not find tenant context";
531 throw new UnauthorizedException(msg);
536 * Helps to filter for queries that either want to include or exclude documents in deleted workflow states.
541 private static String buildWorkflowWhereClause(MultivaluedMap<String, String> queryParams) {
542 String result = null;
544 String includeDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_NONDELETED);
545 String includeOnlyDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_ONLY_DELETED);
547 if (includeDeleted != null && includeDeleted.equalsIgnoreCase(Boolean.FALSE.toString())) {
548 result = String.format("(ecm:currentLifeCycleState <> '%s' AND ecm:currentLifeCycleState <> '%s' AND ecm:currentLifeCycleState <> '%s')",
549 WorkflowClient.WORKFLOWSTATE_DELETED, WorkflowClient.WORKFLOWSTATE_LOCKED_DELETED, WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED);
550 } else if (includeOnlyDeleted != null && includeOnlyDeleted.equalsIgnoreCase(Boolean.TRUE.toString())) {
551 result = String.format("(ecm:currentLifeCycleState <> '%s' AND ecm:currentLifeCycleState <> '%s' AND ecm:currentLifeCycleState <> '%s')",
552 WorkflowClient.WORKFLOWSTATE_PROJECT, WorkflowClient.WORKFLOWSTATE_LOCKED, WorkflowClient.WORKFLOWSTATE_REPLICATED);
559 * Creates the document handler instance.
561 * @return the document handler
563 * @throws Exception the exception
565 private DocumentHandler createDocumentHandlerInstance() throws Exception {
566 docHandler = ServiceConfigUtils.createDocumentHandlerInstance(tenantBinding, serviceBinding);
568 // Create a default document filter
570 docHandler.setServiceContext(this);
571 DocumentFilter docFilter = docHandler.createDocumentFilter();
573 // If the context was created with query parameters,
574 // reflect the values of those parameters in the document filter
575 // to specify sort ordering, pagination, etc.
577 MultivaluedMap<String, String> queryParameters = this.getQueryParams();
578 if (queryParameters != null) {
579 docFilter.setSortOrder(queryParameters);
580 docFilter.setPagination(queryParameters);
581 String workflowWhereClause = buildWorkflowWhereClause(queryParameters);
582 if (workflowWhereClause != null) {
583 docFilter.appendWhereClause(workflowWhereClause, IQueryManager.SEARCH_QUALIFIER_AND);
587 docHandler.setDocumentFilter(docFilter);
593 * @see org.collectionspace.services.common.context.ServiceContext#getDocumentHandler()
596 public DocumentHandler getDocumentHandler() throws Exception {
597 DocumentHandler result = docHandler;
598 // create a new instance if one does not yet exist
599 if (result == null) {
600 result = createDocumentHandlerInstance();
606 public void setDocumentHandler(DocumentHandler handler) throws Exception {
607 if (handler != null) {
608 docHandler = handler;
613 * @see org.collectionspace.services.common.context.ServiceContext#getDocumentHanlder(javax.ws.rs.core.MultivaluedMap)
616 public DocumentHandler getDocumentHandler(MultivaluedMap<String, String> queryParams) throws Exception {
617 DocumentHandler result = getDocumentHandler();
618 DocumentFilter documentFilter = result.getDocumentFilter(); //to see results in debugger variables view
619 documentFilter.setPagination(queryParams);
624 * If this element is set in the service binding then use it otherwise
625 * assume that asserts are NOT disabled.
627 private boolean disableValidationAsserts() {
629 Boolean disableAsserts = getServiceBinding().isDisableAsserts();
630 result = (disableAsserts != null) ? disableAsserts : false;
635 * @see org.collectionspace.services.common.context.ServiceContext#getValidatorHandlers()
638 public List<ValidatorHandler<IT, OT>> getValidatorHandlers() throws Exception {
639 if (valHandlers != null) {
642 List<String> handlerClazzes = getServiceBinding().getValidatorHandler();
643 List<ValidatorHandler<IT, OT>> handlers = new ArrayList<ValidatorHandler<IT, OT>>(handlerClazzes.size());
644 ClassLoader tccl = Thread.currentThread().getContextClassLoader();
645 for (String clazz : handlerClazzes) {
646 clazz = clazz.trim();
648 Class<?> c = tccl.loadClass(clazz);
649 if (disableValidationAsserts() == false) {
650 // enable validation assertions
651 tccl.setClassAssertionStatus(clazz, true);
653 if (ValidatorHandler.class.isAssignableFrom(c)) {
654 handlers.add((ValidatorHandler) c.newInstance());
656 } catch (ClassNotFoundException e) {
657 String msg = String.format("Missing document validation handler: '%s'.", clazz);
659 logger.trace(msg, e);
662 valHandlers = handlers;
667 * If one doesn't already exist, use the default properties filename to load a set of properties that
668 * will be used to create an HTTP client to a CollectionSpace instance.
671 public AuthorityClient getClient() throws Exception {
672 AuthorityClient result = authorityClient;
674 if (authorityClient == null) {
675 result = authorityClient = getClient(CollectionSpaceClient.DEFAULT_CLIENT_PROPERTIES_FILENAME);
682 * Use the properties filename passed in to load the URL and credentials that will be used
683 * to create a new HTTP client.
685 * Never uses or resets the this.authorityClient member. Always creates a new HTTP client using
686 * the loaded properties.
689 * @see org.collectionspace.services.common.context.ServiceContext#getClient(java.lang.String)
692 public AuthorityClient getClient(String clientPropertiesFilename) throws Exception {
693 AuthorityClient result = null;
695 Properties inProperties = Tools.loadProperties(clientPropertiesFilename, true);
696 result = getClient(inProperties);
701 public AuthorityClient getClient(Properties inProperties) throws Exception {
702 AuthorityClient result = null;
704 String authorityClientClazz = getServiceBinding().getClientHandler();
705 ClassLoader tccl = Thread.currentThread().getContextClassLoader();
706 authorityClientClazz = authorityClientClazz.trim();
708 Class<?> c = tccl.loadClass(authorityClientClazz);
709 if (AuthorityClient.class.isAssignableFrom(c)) {
710 result = authorityClient = ((AuthorityClient) c.newInstance());
711 result.setClientProperties(inProperties);
713 logger.error(String.format("The service binding clientHandler class '%s' for '%s' service was not of type AuthorityClient.",
714 authorityClientClazz, this.getServiceName()));
716 } catch (ClassNotFoundException e) {
717 String msg = String.format("Missing document validation handler: '%s'.", authorityClientClazz);
719 logger.trace(msg, e);
726 public AuthorityClient getClient(RemoteClientConfig remoteClientConfig) throws Exception {
727 AuthorityClient result = null;
729 Properties properties = new Properties();
730 properties.setProperty(AuthorityClient.URL_PROPERTY, remoteClientConfig.getUrl());
731 properties.setProperty(AuthorityClient.USER_PROPERTY, remoteClientConfig.getUser());
732 properties.setProperty(AuthorityClient.PASSWORD_PROPERTY, remoteClientConfig.getPassword());
733 properties.setProperty(AuthorityClient.SSL_PROPERTY, remoteClientConfig.getSsl());
734 properties.setProperty(AuthorityClient.AUTH_PROPERTY, remoteClientConfig.getAuth());
737 String tenantId = remoteClientConfig.getTenantId();
738 if (tenantId != null) {
739 properties.setProperty(AuthorityClient.TENANT_ID_PROPERTY, tenantId);
741 String tenantName = remoteClientConfig.getTenantName();
742 if (tenantName != null) {
743 properties.setProperty(AuthorityClient.TENANT_NAME_PROPERTY, tenantName);
746 result = getClient(properties);
752 public void addValidatorHandler(ValidatorHandler<IT, OT> validator) throws Exception {
753 if (valHandlers == null) {
754 valHandlers = new ArrayList<ValidatorHandler<IT, OT>>();
756 valHandlers.add(validator);
760 * @see java.lang.Object#toString()
763 public String toString() {
764 StringBuilder msg = new StringBuilder();
765 msg.append("AbstractServiceContext [");
766 msg.append("service name=" + serviceBinding.getName() + " ");
767 msg.append("service version=" + serviceBinding.getVersion() + " ");
768 msg.append("tenant id=" + tenantBinding.getId() + " ");
769 msg.append("tenant name=" + tenantBinding.getName() + " ");
770 msg.append(tenantBinding.getDisplayName() + " ");
771 if (repositoryDomain != null) {
772 msg.append("tenant repository domain=" + repositoryDomain.getName());
774 for (Map.Entry<String, Object> entry : properties.entrySet()) {
775 msg.append("property name=" + entry.getKey() + " value=" + entry.getValue().toString());
778 return msg.toString();
782 * @see org.collectionspace.services.common.context.ServiceContext#getQueryParams()
785 public MultivaluedMap<String, String> getQueryParams() {
787 if (queryParams == null){
788 if (this.uriInfo != null){
789 queryParams = this.uriInfo.getQueryParameters();
792 if (queryParams == null){
793 queryParams = new org.jboss.resteasy.specimpl.MultivaluedMapImpl<String,String>();
795 return this.queryParams;
799 public MultivaluedMap<String, String> getQueryParamsPtr() {
800 return this.queryParams;
804 * @see org.collectionspace.services.common.context.ServiceContext#setQueryParams(javax.ws.rs.core.MultivaluedMap)
807 public void setQueryParams(MultivaluedMap<String, String> theQueryParams) {
808 this.queryParams = theQueryParams;
812 public void setUriInfo(UriInfo ui){
817 public UriInfo getUriInfo() {
822 * We expect the 'currentRepositorySession' member to be set only once per instance. Also, we expect only one open repository session
823 * per HTTP request. We'll log an error if we see more than one attempt to set a service context's current repo session.
825 * @see org.collectionspace.services.common.context.ServiceContext#setCurrentRepositorySession(java.lang.Object)
828 public void setCurrentRepositorySession(Object repoSession) throws Exception {
829 if (repoSession == null) {
830 String errMsg = "Setting a service context's repository session to null is not allowed.";
831 logger.error(errMsg);
832 throw new Exception(errMsg);
833 } else if (currentRepositorySession != null && currentRepositorySession != repoSession) {
834 String errMsg = "The current service context's repository session was replaced. This may cause unexpected behavior and/or data loss.";
835 logger.error(errMsg);
836 throw new Exception(errMsg);
839 currentRepositorySession = repoSession;
840 this.currentRepoSesssionRefCount++;
844 public void clearCurrentRepositorySession() {
845 if (this.currentRepoSesssionRefCount > 0) {
846 currentRepoSesssionRefCount--;
849 if (currentRepoSesssionRefCount == 0) {
850 this.currentRepositorySession = null;
855 public Object getCurrentRepositorySession() {
856 // TODO Auto-generated method stub
857 return currentRepositorySession;
861 public RepositoryDomainType getRepositoryDomain() {
862 return repositoryDomain;
866 public void setRepositoryDomain(RepositoryDomainType repositoryDomain) {
867 this.repositoryDomain = repositoryDomain;