- return "CMS Session " + userDn + " local=" + localSessionId + ", uuid=" + uuid;
- }
-
- public static CmsSessionImpl getByLocalId(String localId) {
- Collection<ServiceReference<CmsSession>> sr;
- try {
- sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_LOCAL_ID + "=" + localId + ")");
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Cannot get CMS session for id " + localId, e);
- }
- ServiceReference<CmsSession> cmsSessionRef;
- if (sr.size() == 1) {
- cmsSessionRef = sr.iterator().next();
- return (CmsSessionImpl) bc.getService(cmsSessionRef);
- } else if (sr.size() == 0) {
- return null;
- } else
- throw new IllegalStateException(sr.size() + " CMS sessions registered for " + localId);
-
- }
-
- public static CmsSessionImpl getByUuid(Object uuid) {
- Collection<ServiceReference<CmsSession>> sr;
- try {
- sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_UUID + "=" + uuid + ")");
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Cannot get CMS session for uuid " + uuid, e);
- }
- ServiceReference<CmsSession> cmsSessionRef;
- if (sr.size() == 1) {
- cmsSessionRef = sr.iterator().next();
- return (CmsSessionImpl) bc.getService(cmsSessionRef);
- } else if (sr.size() == 0) {
- return null;
- } else
- throw new IllegalStateException(sr.size() + " CMS sessions registered for " + uuid);
-
- }
-
- public static void closeInvalidSessions() {
- Collection<ServiceReference<CmsSession>> srs;
- try {
- srs = bc.getServiceReferences(CmsSession.class, null);
- for (ServiceReference<CmsSession> sr : srs) {
- CmsSession cmsSession = bc.getService(sr);
- if (!cmsSession.isValid()) {
- ((CmsSessionImpl) cmsSession).close();
- if (log.isDebugEnabled())
- log.debug("Closed expired CMS session " + cmsSession);
- }
- }
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Cannot get CMS sessions", e);
- }