/*
(non-Javadoc)
@see org.fcrepo.server.access.FedoraAPIA#resumeFindObjects(String
sessionToken )*
1940
@Override
    public org.fcrepo.server.types.gen.FieldSearchResult resumeFindObjects(String sessionToken) {
        MessageContext ctx = context.getMessageContext();
        Context context = ReadOnlyContext.getSoapContext(ctx);
        assertInitialized();
        try {
            org.fcrepo.server.search.FieldSearchResult result =
                    m_access.resumeFindObjects(context, sessionToken);
            return TypeUtility
                    .convertFieldSearchResultToGenFieldSearchResult(result);
        } catch (Throwable th) {
            LOG.error("Error resuming finding objects", th);
            throw CXFUtility.getFault(th);
        }
    }
464122
final void stop() {

        final String methodName = "stop";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName);
        }

        try {

            // Make sure we have a session and that it hasn't already been stopped
            // If an MDB is stopped by the system due to messages failing to be delivered 
            // the session will be stopped and the consumerSessionStopped method on the
            // StoppableAsynchConsumerCallback interface on this class will be called.
            // This will cause the _sessionStopped field to be set to true (which indicates
            // that this listener is in the process of shutting down). We do not then 
            // need to call stop again as the session is already stopped. When the MDB is 
            // resumed a new SibRaListener object is created and so we don't need to reset 
            // the _sessionStopped variable.
            if ((_session != null) && (!_sessionStopped))
            {
                sessionStarted = false;
                stopIfRequired();
            }

        } catch (final SIException exception) {

            FFDCFilter.processException(exception, CLASS_NAME + "."
                                                   + methodName, "1:878:1.68", this);
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }

        } catch (final SIErrorException exception) {

            FFDCFilter.processException(exception, CLASS_NAME + "."
                                                   + methodName, "1:886:1.68", this);
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }

        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
635509
private function resume()
	{
		$this->debug->groupCollapsed(__METHOD__);
		if (isset($_SESSION)) {
			$this->user = ArrayUtil::pathGet($_SESSION, $this->cfg['sessionPath']);
		}
		/*
			Session?
		*/
		if (!empty($this->user)) {
			$this->debug->info('resuming from session');
			if (isset($this->user['_ts_cur'])) {
				$this->user['lastactivity'] = $this->user['_ts_cur'];
			}
			$this->userid = $this->user['userid'];
			$this->auth_via = 'session';
			$this->auth = 2;
			if ($this->user['lastactivity'] + $this->cfg['maxIdle'] < time()) {
				$this->debug->warn('idle');
				$this->debug->log('lastactivity', $this->user['lastactivity']);
				$this->auth = 0;
			} else {
				$this->update(array('lastactivity'=>'NOW()'));
			}
		}
		/*
			Persist cookie?
		*/
		if (empty($this->auth) && isset($_COOKIE[ $this->cfg['persistCookie']['name'] ])) {
			$persist_vals = Cookie::get($this->cfg['persistCookie']['name']);
			$userid = isset($persist_vals['username']) && isset($persist_vals['token'])
				? $this->verifyPersistToken($persist_vals['username'], $persist_vals['token'])	// drops from db if found
				: null;
			if ($userid) {
				$this->debug->info('resuming from persist token');
				$this->setCurrent($userid);
				$this->setPersistToken();
				$this->auth_via = 'cookie';
				$this->auth = 1;
			}
		}
		/*
			Social Cookie?
		*/
		if (empty($this->auth)) {
		}
		if (!empty($this->auth)) {
			$this->user['_ts_cur'] = time();
		}
		$this->debug->groupEnd();
	}
691667
public void setReturnSessionOrObject(PrintWriter out, Object objReturn)
    {
        String strID = null;
        String strSessionClass = null;
        if (objReturn instanceof RemoteTable)
        {
            strSessionClass = REMOTE_TABLE;
            strID = this.add(new TableHolder(this, (RemoteTable)objReturn));
        }
        else if (objReturn instanceof RemoteSession)
        {
            strSessionClass = REMOTE_SESSION;
            strID = this.add(new SessionHolder(this, (RemoteSession)objReturn));
        }
        else if (objReturn instanceof RemoteBaseSession)
        {
            strSessionClass = REMOTE_BASE_SESSION;
            strID = this.add(new BaseSessionHolder(this, (RemoteBaseSession)objReturn));
        }
        if (strID != null)
            this.setReturnString(out, strSessionClass + CLASS_SEPARATOR + strID);
        else
            this.setReturnObject(out, objReturn);
    }
1007261
@Override
    protected void onSessionClose(long sessionId, Map<Long, Object> responses) {
        SessionSemaphoreState state = sessionStates.get(sessionId);
        if (state != null) {
            // remove the session after release() because release() checks existence of the session
            if (state.acquiredPermits > 0) {
                SemaphoreEndpoint endpoint = new SemaphoreEndpoint(sessionId, 0);
                ReleaseResult result = release(endpoint, newUnsecureUUID(), state.acquiredPermits);
                assert result.cancelled.isEmpty();
                for (AcquireInvocationKey key : result.acquired) {
                    responses.put(key.commitIndex(), Boolean.TRUE);
                }
            }

            sessionStates.remove(sessionId);
        }
    }
812304
@Override
    @SuppressWarnings("unchecked")
    protected void restoreState(Object[] objects) {
        if (objects != null && objects.length != 0) {
            variable = (Variable) objects[0];
            constants = (List<Variable>) objects[1];
            lastObjectHash = (Map<String, Object>) objects[2];
        }
    }
594306
public void sessionAttributeRemoved(ISession source, Object key, Object value, Boolean oldIsBindingListener) {
        // ArrayList sessionStateObservers = null;

        /*
         * Check to see if there is a non-empty list of sessionStateObservers.
         */
        if (_sessionStateObservers == null || _sessionStateObservers.size() < 1) {
            return;
        }

        // synchronized(_sessionStateObservers) {
        // sessionStateObservers = (ArrayList)_sessionStateObservers.clone();
        // }

        ISessionStateObserver sessionStateObserver = null;
        for (int i = 0; i < _sessionStateObservers.size(); i++) {
            sessionStateObserver = (ISessionStateObserver) _sessionStateObservers.get(i);
            sessionStateObserver.sessionAttributeRemoved(source, key, value, oldIsBindingListener);
        }

    }
922972
public String getResumeToken() {
        SharedPreferences settings = mContext.getSharedPreferences(PREF_DDPINFO, Context.MODE_PRIVATE);
        return settings.getString(PREF_RESUMETOKEN, null);
    }
1145901
@Override
    public synchronized void refreshCredentials() {
        GetSessionTokenResult sessionTokenResult = securityTokenService
                .getSessionToken(new GetSessionTokenRequest().withDurationSeconds(sessionDurationSeconds));
        sessionCredentials = sessionTokenResult.getCredentials();
    }
1217072
@Override
    public void afterConnectionEstablished(final WebSocketSession webSocketSession) {
        logger.debug("[afterConnectionEstablished] id = {}", webSocketSession.getId());
        this.session = webSocketSession;

        synchronized (notifyConnectionObject) {
            notifyConnectionObject.notifyAll();
        }
    }
334767
@Override
    public void resume() throws PauseableComponentException {
        try {
            shouldActivate = true;
            if (ivState == INACTIVE_STATE) {
                activateEndpoint();
            } else if (ivState == ACTIVE_STATE) {
                Tr.info(tc, "MDB_ENDPOINT_ALREADY_ACTIVE_CNTR4118I", beanMetaData.enterpriseBeanName, beanMetaData.getModuleMetaData().getName(),
                        beanMetaData.getModuleMetaData().getApplicationMetaData().getName());
            } else {
                throw new PauseableComponentException(Tr.formatMessage(tc, "MDB_ENDPOINT_DID_NOT_RESUME_CNTR4120W", beanMetaData.enterpriseBeanName,
                                                                       beanMetaData.getModuleMetaData().getName(),
                                                                       beanMetaData.getModuleMetaData().getApplicationMetaData().getName()));
            }
        } catch (ResourceException re) {
            throw new PauseableComponentException(re);
        }

    }
1008622
private void readObject(java.io.ObjectInputStream objectInputStreamIn)
                    throws java.io.IOException
                    , java.lang.ClassNotFoundException
    {

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "readObject"
                        , "objectInputStreamIn=" + objectInputStreamIn + "(java.io.ObjectInputStream)"
                            );

        objectInputStreamIn.defaultReadObject();
        availableSize = size; // Start as last commited.
        managedObjectsToAdd = new java.util.HashSet(1);
        managedObjectsToReplace = new java.util.HashSet();
        tokensToNotify = new java.util.HashSet(1); // Holds the set of tokens to notify about replacements. 

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "readObject"
                            );

    }
1018048
@Override
    public void pause(String targets) throws PauseableComponentControllerRequestFailedException {

        Tr.info(tc, "info.server.pause.request.received", targets);

        Set<String> foundTargets = new HashSet<String>();

        Set<String> targetList = createTargetList(targets);

        if (targetList.isEmpty()) {
            Tr.warning(tc, "warning.server.pause.invalid.targets");
            throw new PauseableComponentControllerRequestFailedException(Tr.formatMessage(tc, "warning.server.pause.invalid.targets"));
        }

        Set<String> failed = new HashSet<String>();

        //Add each pauseable component to this list. If the tracked values get modified
        //while we are iterating and we start over, skip anyone already in this list
        Set<PauseableComponent> processedList = new HashSet<PauseableComponent>();

        // Sync with other methods changing/querying states for PauseableComponents
        synchronized (this) {
            while (true) {
                try {
                    for (PauseableComponent pauseableComponent : tracker.getTracked().values()) {

                        if (processedList.add(pauseableComponent)) {

                            if (targetList.contains(pauseableComponent.getName())) {
                                foundTargets.add(pauseableComponent.getName());

                                try {
                                    pauseableComponent.pause();

                                } catch (Throwable t) {
                                    // Catch anything and mark a failed Add it to the failed list.
                                    failed.add(pauseableComponent.getName());
                                }
                            }
                        }
                    }

                    break;
                } catch (Throwable t) {
                    // Someone modified our list of services. Retry.
                }
            }
        }

        //Check which (if any) targets were not found
        boolean targetsNotFound = false;
        targetList.removeAll(foundTargets);
        if (!targetList.isEmpty()) {
            targetsNotFound = true;
            Tr.warning(tc, "warning.server.pause.missing.targets", Arrays.toString(targetList.toArray()));
        }

        //Check if we had any failures and throw an exception back with a list of failed pauseable components.
        if (!failed.isEmpty()) {

            Tr.error(tc, "error.server.pause.failed", Arrays.toString(failed.toArray()));

            throw new PauseableComponentControllerRequestFailedException(Tr.formatMessage(tc, "error.server.pause.failed", Arrays.toString(failed.toArray())));

        } else {
            Tr.info(tc, "info.server.pause.request.completed");

            if (targetsNotFound) {
                throw new PauseableComponentControllerRequestFailedException(Tr.formatMessage(tc, "warning.server.pause.missing.targets", Arrays.toString(targetList.toArray())));
            }
        }

    }
763756
final void sessionClosed(final JmsJcaSessionImpl session) {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "sessionClosed", session);
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
            SibTr.debug(this, TRACE, "Sending connection closed events to the "
                                     + _connectionListeners.size() + " listeners");
        }

        final ConnectionEvent event = new ConnectionEvent(this,
                        ConnectionEvent.CONNECTION_CLOSED);
        event.setConnectionHandle(session);

        // Copy list to protect against concurrent modification by listener
        final List<ConnectionEventListener> copy;
        synchronized (_connectionListeners) {
            copy = new ArrayList<ConnectionEventListener>(_connectionListeners);
        }

        for (final Iterator iterator = copy.iterator(); iterator.hasNext();) {
            final Object object = iterator.next();
            if (object instanceof ConnectionEventListener) {
                ((ConnectionEventListener) object).connectionClosed(event);
            }
        }

        _sessions.remove(session);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "sessionClosed");
        }

    }
152089
@Override
    protected void onSessionClose(long sessionId, Map<Long, Object> responses) {
        removeInvocationRefUids(sessionId);

        if (owner != null && owner.sessionId() == sessionId) {
            ReleaseResult result = doRelease(owner.endpoint(), newUnsecureUUID(), lockCount);
            for (LockInvocationKey key : result.completedWaitKeys()) {
                responses.put(key.commitIndex(), result.ownership().getFence());
            }
        }
    }
1013123
public void sessionLastAccessTimeSet(ISession session, long old, long newaccess) {
        // ArrayList sessionStateObservers = null;

        /*
         * Check to see if there is a non-empty list of sessionStateObservers.
         */
        if (_sessionStateObservers == null || _sessionStateObservers.size() < 1) {
            return;
        }

        // synchronized(_sessionStateObservers) {
        // sessionStateObservers = (ArrayList)_sessionStateObservers.clone();
        // }

        ISessionStateObserver sessionStateObserver = null;
        for (int i = 0; i < _sessionStateObservers.size(); i++) {
            sessionStateObserver = (ISessionStateObserver) _sessionStateObservers.get(i);
            sessionStateObserver.sessionLastAccessTimeSet(session, old, newaccess);
        }

    }
305659
public void resumeTriggers (final GroupMatcher <TriggerKey> matcher) throws SchedulerException
  {
    validateState ();

    final ICommonsCollection <String> pausedGroups = m_aResources.getJobStore ()
                                                                 .resumeTriggers (_getOrDefault (matcher));
    notifySchedulerThread (0L);
    for (final String pausedGroup : pausedGroups)
    {
      notifySchedulerListenersResumedTriggers (pausedGroup);
    }
  }