]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
ba9388a2cce1959b05f0437d2b5a420058abdb2c
[tmp/jakarta-migration.git] /
1 /**
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:
5
6  *  http://www.collectionspace.org
7  *  http://wiki.collectionspace.org
8
9  *  Copyright 2009 University of California at Berkeley
10
11  *  Licensed under the Educational Community License (ECL), Version 2.0.
12  *  You may not use this file except in compliance with this License.
13
14  *  You may obtain a copy of the ECL 2.0 License at
15
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt
17
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.
23  */
24 package org.collectionspace.services.common.context;
25
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30 import javax.ws.rs.core.MultivaluedMap;
31 import javax.ws.rs.core.UriInfo;
32
33 import org.collectionspace.authentication.spi.AuthNContext;
34 import org.collectionspace.services.client.IQueryManager;
35 import org.collectionspace.services.client.workflow.WorkflowClient;
36 import org.collectionspace.services.common.ServiceMain;
37 import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon;
38 import org.collectionspace.services.common.config.PropertyItemUtils;
39 import org.collectionspace.services.common.config.ServiceConfigUtils;
40 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
41 import org.collectionspace.services.common.document.DocumentHandler;
42 import org.collectionspace.services.common.document.DocumentFilter;
43 import org.collectionspace.services.common.document.ValidatorHandler;
44 import org.collectionspace.services.common.security.SecurityContext;
45 import org.collectionspace.services.common.security.SecurityContextImpl;
46 import org.collectionspace.services.common.security.UnauthorizedException;
47 import org.collectionspace.services.config.ClientType;
48 import org.collectionspace.services.config.service.ObjectPartType;
49 import org.collectionspace.services.config.service.ServiceBindingType;
50 import org.collectionspace.services.config.tenant.RepositoryDomainType;
51 import org.collectionspace.services.config.tenant.TenantBindingType;
52 import org.collectionspace.services.config.types.PropertyItemType;
53 import org.collectionspace.services.config.types.PropertyType;
54 import org.slf4j.Logger;
55 import org.slf4j.LoggerFactory;
56
57 /**
58  * AbstractServiceContext
59  *
60  * $LastChangedRevision: $
61  * $LastChangedDate: $
62  */
63 /**
64  * @author pschmitz
65  *
66  * @param <IT>
67  * @param <OT>
68  */
69 /**
70  * @author pschmitz
71  *
72  * @param <IT>
73  * @param <OT>
74  */
75 public abstract class AbstractServiceContextImpl<IT, OT>
76         implements ServiceContext<IT, OT> {
77
78     /** The logger. */
79     final Logger logger = LoggerFactory.getLogger(AbstractServiceContextImpl.class);
80     /** The properties. */
81     Map<String, Object> properties = new HashMap<String, Object>();
82     /** The object part map. */
83     Map<String, ObjectPartType> objectPartMap = new HashMap<String, ObjectPartType>();
84     /** The service binding. */
85     protected ServiceBindingType serviceBinding;
86     /** The tenant binding. */
87     private TenantBindingType tenantBinding;
88     /** repository domain used by the service */
89     private RepositoryDomainType repositoryDomain;
90         /** The override document type. */
91     private String overrideDocumentType = null;
92     /** The val handlers. */
93     private List<ValidatorHandler<IT, OT>> valHandlers = null;
94     /** The doc handler. */
95     private DocumentHandler docHandler = null;
96     /** security context */
97     private SecurityContext securityContext;
98     /** The sessions JAX-RS URI information */
99     private UriInfo uriInfo;
100     /** The current repository session */
101     private Object currentRepositorySession;
102     /** A reference count for the current repository session */
103     private int currentRepoSesssionRefCount = 0;
104
105     /**
106      * Instantiates a new abstract service context impl.
107      */
108     private AbstractServiceContextImpl() {
109         // private constructor for singleton pattern
110     }
111     // request query params
112     /** The query params. */
113     private MultivaluedMap<String, String> queryParams;
114
115     /**
116      * Instantiates a new abstract service context impl.
117      * 
118      * @param serviceName the service name
119      * 
120      * @throws UnauthorizedException the unauthorized exception
121      */
122     protected AbstractServiceContextImpl(String serviceName, UriInfo uriInfo) throws UnauthorizedException {
123
124         //establish security context
125         securityContext = new SecurityContextImpl(uriInfo);
126         //make sure tenant context exists
127         checkTenantContext();
128
129         String tenantId = securityContext.getCurrentTenantId();
130         if (AuthorizationCommon.ALL_TENANTS_MANAGER_TENANT_ID.equals(tenantId) ||
131                         AuthNContext.ANONYMOUS_TENANT_ID.equals(tenantId)) {
132                 // Tenant Manager has no tenant binding, so don't bother...
133                 tenantBinding = null;
134                 serviceBinding = null;
135                 repositoryDomain = null;
136         } else {
137                 //retrieve service bindings
138                 TenantBindingConfigReaderImpl tReader =
139                         ServiceMain.getInstance().getTenantBindingConfigReader();
140                 tenantBinding = tReader.getTenantBinding(tenantId);
141                 if (tenantBinding == null) {
142                     String msg = "No tenant binding found for tenantId=" + tenantId
143                             + " while processing request for service= " + serviceName;
144                     logger.error(msg);
145                     throw new IllegalStateException(msg);
146                 }
147                 serviceBinding = tReader.getServiceBinding(tenantId, serviceName);
148                 if (serviceBinding == null) {
149                     String msg = "No service binding found while processing request for "
150                             + serviceName + " for tenant id=" + getTenantId()
151                             + " name=" + getTenantName();
152                     logger.error(msg);
153                     throw new IllegalStateException(msg);
154                 }
155                 if (logger.isDebugEnabled()) {
156                     logger.debug("tenantId=" + tenantId
157                             + " service binding=" + serviceBinding.getName());
158                 }
159                 repositoryDomain = tReader.getRepositoryDomain(tenantId, serviceName);
160                 if (repositoryDomain != null) {
161                     if (logger.isDebugEnabled()) {
162                         logger.debug("tenantId=" + tenantId
163                                 + " repository doamin=" + repositoryDomain.getName());
164                     }
165                 }
166         }
167     }
168
169     /* (non-Javadoc)
170      * @see org.collectionspace.services.common.context.ServiceContext#getCommonPartLabel()
171      */
172     @Override
173     public String getCommonPartLabel() {
174         return getCommonPartLabel(getServiceName());
175     }
176
177     /* (non-Javadoc)
178      * @see org.collectionspace.services.common.context.ServiceContext#getCommonPartLabel(java.lang.String)
179      */
180     public String getCommonPartLabel(String schemaName) {
181         return schemaName.toLowerCase() + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
182     }
183
184     /* (non-Javadoc)
185      * @see org.collectionspace.services.common.context.ServiceContext#getPartsMetadata()
186      */
187     @Override
188     public Map<String, ObjectPartType> getPartsMetadata() {
189         if (objectPartMap.size() != 0) {
190             return objectPartMap;
191         }
192         ServiceBindingUtils.getPartsMetadata(getServiceBinding(), objectPartMap);
193         return objectPartMap;
194     }
195
196     /**
197      * Gets the properties for part.
198      * 
199      * @param partLabel the part label
200      * 
201      * @return the properties for part
202      */
203     public List<PropertyItemType> getPropertiesForPart(String partLabel) {
204         Map<String, ObjectPartType> partMap = getPartsMetadata();
205         ObjectPartType part = partMap.get(partLabel);
206         if (part == null) {
207             throw new RuntimeException("No such part found: " + partLabel);
208         }
209         List<PropertyType> propNodeList = part.getProperties();
210         return propNodeList.isEmpty() ? null : propNodeList.get(0).getItem();
211     }
212
213     /**
214      * @param partLabel The name of the scehma part to search in
215      * @param propName The name of the property (or properties) to find
216      * @param qualified Whether the returned values should be qualified with the
217      *          partLabel. This is when the property values are schema field references.
218      * @return List of property values for the matched property on the named schema part.
219      */
220     public List<String> getPropertyValuesForPart(String partLabel, String propName, boolean qualified) {
221         List<PropertyItemType> allProps = getPropertiesForPart(partLabel);
222         return PropertyItemUtils.getPropertyValuesByName(allProps, propName,
223                 (qualified ? (partLabel + ":") : null));
224     }
225
226     /**
227      * @param propName The name of the property (or properties) to find
228      * @param qualified Whether the returned values should be qualified with the
229      *          partLabel. This is when the property values are schema field references.
230      * @return List of property values for the matched property on any schema part.
231      */
232     public List<String> getAllPartsPropertyValues(String propName, boolean qualified) {
233         return ServiceBindingUtils.getAllPartsPropertyValues(getServiceBinding(), propName, qualified);
234     }
235
236     /* (non-Javadoc)
237      * @see org.collectionspace.services.common.context.ServiceContext#getServiceBindingPropertyValue(java.lang.String)
238      */
239     public String getServiceBindingPropertyValue(String propName) {
240         return ServiceBindingUtils.getPropertyValue(getServiceBinding(), propName);
241     }
242
243     /**
244      * Gets the common part properties.
245      * 
246      * @return the common part properties
247      */
248     public List<PropertyItemType> getCommonPartProperties() {
249         return getPropertiesForPart(getCommonPartLabel());
250     }
251
252     /**
253      * @param propName The name of the property (or properties) to find
254      * @param qualified Whether the returned values should be qualified with the
255      *          partLabel. This is when the property values are schema field references.
256      * @return List of property values for the matched property on the common schema part.
257      */
258     public List<String> getCommonPartPropertyValues(String propName, boolean qualified) {
259         return getPropertyValuesForPart(getCommonPartLabel(), propName, qualified);
260     }
261
262     /* (non-Javadoc)
263      * @see org.collectionspace.services.common.context.ServiceContext#getQualifiedServiceName()
264      */
265     @Override
266     public String getQualifiedServiceName() {
267         return TenantBindingConfigReaderImpl.getTenantQualifiedServiceName(getTenantId(), getServiceName());
268     }
269
270     /* (non-Javadoc)
271      * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryClientName()
272      */
273     @Override
274     public String getRepositoryClientName() {
275         if (repositoryDomain == null) {
276             return null;
277         }
278         return repositoryDomain.getRepositoryClient();
279     }
280
281     /* (non-Javadoc)
282      * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryClientType()
283      */
284     @Override
285     public ClientType getRepositoryClientType() {
286         //assumption: there is only one repository client configured
287         return ServiceMain.getInstance().getClientType();
288     }
289
290     /* (non-Javadoc)
291      * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryDomainName()
292      */
293     @Override
294     public String getRepositoryDomainName() {
295         if (repositoryDomain == null) {
296             return null;
297         }
298         return repositoryDomain.getName();
299     }
300
301     /* (non-Javadoc)
302      * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryDomainName()
303      */
304     @Override
305     public String getRepositoryDomainStorageName() {
306         if (repositoryDomain == null) {
307             return null;
308         }
309         return repositoryDomain.getStorageName();
310     }
311
312     /* (non-Javadoc)
313      * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryWorkspaceId()
314      */
315     @Override
316     public String getRepositoryWorkspaceId() {
317         return ServiceMain.getInstance().getWorkspaceId(getTenantId(), getServiceName());
318     }
319
320     /* (non-Javadoc)
321      * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryWorkspaceName()
322      */
323     @Override
324     public String getRepositoryWorkspaceName() {
325         //service name is workspace name by convention
326         return serviceBinding.getName();
327     }
328
329     /* (non-Javadoc)
330      * @see org.collectionspace.services.common.context.ServiceContext#getServiceBinding()
331      */
332     @Override
333     public ServiceBindingType getServiceBinding() {
334         return serviceBinding;
335     }
336
337     /* (non-Javadoc)
338      * @see org.collectionspace.services.common.context.ServiceContext#getServiceName()
339      */
340     @Override
341     public String getServiceName() {
342         return serviceBinding.getName();
343     }
344
345     /* (non-Javadoc)
346      * @see org.collectionspace.services.common.context.ServiceContext#getDocumentType()
347      */
348     @Override
349     public String getDocumentType() {
350         // If they have not overridden the setting, use the type of the service
351         // object.
352         return (overrideDocumentType != null) ? overrideDocumentType : serviceBinding.getObject().getName();
353     }
354     
355     @Override
356     public String getTenantQualifiedDoctype(String docType) {
357         // If they have not overridden the setting, use the type of the service
358         // object.
359         String result = ServiceBindingUtils.getTenantQualifiedDocType(this.getTenantId(), docType);
360         
361         return result;
362     }
363     
364     @Override
365     public String getTenantQualifiedDoctype() {
366         String docType = (overrideDocumentType != null) ? overrideDocumentType : serviceBinding.getObject().getName();
367         return getTenantQualifiedDoctype(docType);
368     }
369
370     /* (non-Javadoc)
371      * @see org.collectionspace.services.common.context.ServiceContext#setDocumentType(java.lang.String)
372      */
373     @Override
374     public void setDocumentType(String docType) {
375         overrideDocumentType = docType;
376     }
377
378     /* (non-Javadoc)
379      * @see org.collectionspace.services.common.context.ServiceContext#getSecurityContext()
380      */
381     @Override
382     public SecurityContext getSecurityContext() {
383         return securityContext;
384     }
385
386     /* (non-Javadoc)
387      * @see org.collectionspace.services.common.context.ServiceContext#getUserId()
388      */
389     @Override
390     public String getUserId() {
391         return securityContext.getUserId();
392     }
393
394     /* (non-Javadoc)
395      * @see org.collectionspace.services.common.context.ServiceContext#getTenantId()
396      */
397     @Override
398     public String getTenantId() {
399         return securityContext.getCurrentTenantId();
400     }
401
402     /* (non-Javadoc)
403      * @see org.collectionspace.services.common.context.ServiceContext#getTenantName()
404      */
405     @Override
406     public String getTenantName() {
407         return securityContext.getCurrentTenantName();
408     }
409
410     /* (non-Javadoc)
411      * @see org.collectionspace.services.common.context.ServiceContext#getInput()
412      */
413     @Override
414     public abstract IT getInput();
415
416     /* (non-Javadoc)
417      * @see org.collectionspace.services.common.context.ServiceContext#setInput(java.lang.Object)
418      */
419     @Override
420     public abstract void setInput(IT input);
421
422     /* (non-Javadoc)
423      * @see org.collectionspace.services.common.context.ServiceContext#getOutput()
424      */
425     @Override
426     public abstract OT getOutput();
427
428     /* (non-Javadoc)
429      * @see org.collectionspace.services.common.context.ServiceContext#setOutput(java.lang.Object)
430      */
431     @Override
432     public abstract void setOutput(OT output);
433
434     /* (non-Javadoc)
435      * @see org.collectionspace.services.common.context.ServiceContext#getProperties()
436      */
437     @Override
438     public Map<String, Object> getProperties() {
439         return properties;
440     }
441
442     /* (non-Javadoc)
443      * @see org.collectionspace.services.common.context.ServiceContext#setProperties(java.util.Map)
444      */
445     @Override
446     public void setProperties(Map<String, Object> props) {
447         properties.putAll(props);
448     }
449
450     /* (non-Javadoc)
451      * @see org.collectionspace.services.common.context.ServiceContext#getProperty(java.lang.String)
452      */
453     public Object getProperty(String name) {
454         return properties.get(name);
455     }
456
457     /* (non-Javadoc)
458      * @see org.collectionspace.services.common.context.ServiceContext#setProperty(java.lang.String, java.lang.Object)
459      */
460     public void setProperty(String name, Object o) {
461         properties.put(name, o);
462     }
463
464     /**
465      * checkTenantContext makss sure tenant context exists
466      *
467      * @return the string
468      *
469      * @throws UnauthorizedException the unauthorized exception
470      */
471     private void checkTenantContext() throws UnauthorizedException {
472
473         String tenantId = securityContext.getCurrentTenantId();
474         if (tenantId == null) {
475             String msg = "Could not find tenant context";
476             logger.error(msg);
477             throw new UnauthorizedException(msg);
478         }
479     }
480
481     private static String buildWorkflowWhereClause(MultivaluedMap<String, String> queryParams) {
482         String result = null;
483         
484         String includeDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_NONDELETED);
485         if (includeDeleted != null && includeDeleted.equalsIgnoreCase(Boolean.FALSE.toString())) {      
486                 result = "ecm:currentLifeCycleState <> 'deleted'";
487         }
488         
489         return result;
490     }
491     
492     /**
493      * Creates the document handler instance.
494      * 
495      * @return the document handler
496      * 
497      * @throws Exception the exception
498      */
499     private DocumentHandler createDocumentHandlerInstance() throws Exception {
500         docHandler = ServiceConfigUtils.createDocumentHandlerInstance(tenantBinding, serviceBinding);
501         //
502         // Create a default document filter
503         //
504         docHandler.setServiceContext(this);
505         DocumentFilter docFilter = docHandler.createDocumentFilter();
506         //
507         // If the context was created with query parameters,
508         // reflect the values of those parameters in the document filter
509         // to specify sort ordering, pagination, etc.
510         //
511         if (this.getQueryParams() != null) {
512           docFilter.setSortOrder(this.getQueryParams());
513           docFilter.setPagination(this.getQueryParams());
514           String workflowWhereClause = buildWorkflowWhereClause(queryParams);
515           if (workflowWhereClause != null) {
516                   docFilter.appendWhereClause(workflowWhereClause, IQueryManager.SEARCH_QUALIFIER_AND);                 
517           }            
518
519         }
520         docHandler.setDocumentFilter(docFilter);
521
522         return docHandler;
523     }
524
525     /* (non-Javadoc)
526      * @see org.collectionspace.services.common.context.ServiceContext#getDocumentHandler()
527      */
528     @Override
529     public DocumentHandler getDocumentHandler() throws Exception {
530         DocumentHandler result = docHandler;
531         // create a new instance if one does not yet exist
532         if (result == null) {
533             result = createDocumentHandlerInstance();
534         }
535         return result;
536     }
537
538     @Override
539     public void setDocumentHandler(DocumentHandler handler) throws Exception {
540         if (handler != null) {
541                 docHandler = handler;
542         }
543     }
544
545     /* (non-Javadoc)
546      * @see org.collectionspace.services.common.context.ServiceContext#getDocumentHanlder(javax.ws.rs.core.MultivaluedMap)
547      */
548     @Override
549     public DocumentHandler getDocumentHandler(MultivaluedMap<String, String> queryParams) throws Exception {
550         DocumentHandler result = getDocumentHandler();
551         DocumentFilter documentFilter = result.getDocumentFilter(); //to see results in debugger variables view
552         documentFilter.setPagination(queryParams);
553         return result;
554     }
555     
556     /*
557      * If this element is set in the service binding then use it otherwise
558      * assume that asserts are NOT disabled.
559      */
560     private boolean disableValidationAsserts() {
561         boolean result;
562         Boolean disableAsserts = getServiceBinding().isDisableAsserts();
563         result = (disableAsserts != null) ? disableAsserts : false;
564         return result;
565     }
566     
567     /* (non-Javadoc)
568      * @see org.collectionspace.services.common.context.ServiceContext#getValidatorHandlers()
569      */
570     @Override
571     public List<ValidatorHandler<IT, OT>> getValidatorHandlers() throws Exception {
572         if (valHandlers != null) {
573             return valHandlers;
574         }
575         List<String> handlerClazzes = getServiceBinding().getValidatorHandler();
576         List<ValidatorHandler<IT, OT>> handlers = new ArrayList<ValidatorHandler<IT, OT>>(handlerClazzes.size());
577         ClassLoader tccl = Thread.currentThread().getContextClassLoader();
578         for (String clazz : handlerClazzes) {
579             clazz = clazz.trim();
580             Class<?> c = tccl.loadClass(clazz);
581             if (disableValidationAsserts() == false) {
582                 // enable validation assertions
583                 tccl.setClassAssertionStatus(clazz, true);
584             }
585             if (ValidatorHandler.class.isAssignableFrom(c)) {
586                 handlers.add((ValidatorHandler) c.newInstance());
587             }
588         }
589         valHandlers = handlers;
590         return valHandlers;
591     }
592     
593     @Override
594     public void addValidatorHandler(ValidatorHandler<IT, OT> validator) throws Exception {
595         if (valHandlers == null) {
596             valHandlers = new ArrayList<ValidatorHandler<IT, OT>>();
597         }
598         valHandlers.add(validator);
599     }
600
601     /* (non-Javadoc)
602      * @see java.lang.Object#toString()
603      */
604     @Override
605     public String toString() {
606         StringBuilder msg = new StringBuilder();
607         msg.append("AbstractServiceContext [");
608         msg.append("service name=" + serviceBinding.getName() + " ");
609         msg.append("service version=" + serviceBinding.getVersion() + " ");
610         msg.append("tenant id=" + tenantBinding.getId() + " ");
611         msg.append("tenant name=" + tenantBinding.getName() + " ");
612         msg.append(tenantBinding.getDisplayName() + " ");
613         if (repositoryDomain != null) {
614             msg.append("tenant repository domain=" + repositoryDomain.getName());
615         }
616         for (Map.Entry<String, Object> entry : properties.entrySet()) {
617             msg.append("property name=" + entry.getKey() + " value=" + entry.getValue().toString());
618         }
619         msg.append("]");
620         return msg.toString();
621     }
622
623     /* (non-Javadoc)
624      * @see org.collectionspace.services.common.context.ServiceContext#getQueryParams()
625      */
626     @Override
627     public MultivaluedMap<String, String> getQueryParams() {
628
629          if (queryParams == null){
630               if (this.uriInfo != null){
631                 queryParams = this.uriInfo.getQueryParameters();
632             }
633          }
634          if (queryParams == null){
635              queryParams = new org.jboss.resteasy.specimpl.MultivaluedMapImpl<String,String>();
636         }
637         return this.queryParams;
638     }
639
640     @Override
641      public MultivaluedMap<String, String> getQueryParamsPtr() {
642            return this.queryParams;
643     }
644
645     /* (non-Javadoc)
646      * @see org.collectionspace.services.common.context.ServiceContext#setQueryParams(javax.ws.rs.core.MultivaluedMap)
647      */
648     @Override
649     public void setQueryParams(MultivaluedMap<String, String> theQueryParams) {
650         this.queryParams = theQueryParams;
651     }
652
653     @Override
654     public void setUriInfo(UriInfo ui){
655         this.uriInfo = ui;
656     }
657
658         @Override
659         public UriInfo getUriInfo() {
660                 return this.uriInfo;
661         }
662         
663         /*
664          * We expect the 'currentRepositorySession' member to be set only once per instance.  Also, we expect only one open repository session
665          * per HTTP request.  We'll log an error if we see more than one attempt to set a service context's current repo session.
666          * (non-Javadoc)
667          * @see org.collectionspace.services.common.context.ServiceContext#setCurrentRepositorySession(java.lang.Object)
668          */
669         @Override
670         public void setCurrentRepositorySession(Object repoSession) throws Exception {
671                 if (repoSession == null) {
672                         String errMsg = "Setting a service context's repository session to null is not allowed.";
673                         logger.error(errMsg);
674                         throw new Exception(errMsg);
675                 } else if (currentRepositorySession != null && currentRepositorySession != repoSession) {
676                         String errMsg = "The current service context's repository session was replaced.  This may cause unexpected behavior and/or data loss.";
677                         logger.error(errMsg);
678                         throw new Exception(errMsg);
679                 }
680                 
681                 currentRepositorySession = repoSession;
682                 this.currentRepoSesssionRefCount++;
683         }
684         
685         @Override
686         public void clearCurrentRepositorySession() {
687                 if (this.currentRepoSesssionRefCount > 0) {
688                         currentRepoSesssionRefCount--;
689                 }
690                 
691                 if (currentRepoSesssionRefCount == 0) {
692                         this.currentRepositorySession = null;
693                 }
694         }
695         
696         @Override
697         public Object getCurrentRepositorySession() {
698                 // TODO Auto-generated method stub
699                 return currentRepositorySession;
700         }       
701
702         @Override       
703         public RepositoryDomainType getRepositoryDomain() {
704                 return repositoryDomain;
705         }
706
707         @Override       
708         public void setRepositoryDomain(RepositoryDomainType repositoryDomain) {
709                 this.repositoryDomain = repositoryDomain;
710         }
711 }