/*
@see VirtualConnection#requestPermissionToClose()
162863
@Override
    public boolean requestPermissionToClose(long waitForPermission) {
        synchronized (this) {
            if ((currentState & CLOSE_NOT_ALLOWED_MASK) == 0) {

                if ((currentState & READ_OUTSTANDING) != 0) {
                    readOutWithClosePending = true;
                } else {
                    readOutWithClosePending = false;
                }
                if ((currentState & WRITE_OUTSTANDING) != 0) {
                    writeOutWithClosePending = true;
                } else {
                    writeOutWithClosePending = false;
                }

                currentState = CLOSE_PENDING;

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "requestPermissionToClose returning true");
                }
                return true;
            }

            if (waitForPermission <= 0) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "requestPermissionToClose returning false");
                }
                return false;
            }

            long waitTillTime = (System.nanoTime() / ONE_MILLISECOND_IN_NANOSECONDS) + waitForPermission; //Measured in ms
            long waitTime = waitForPermission;
            while (true) {
                // wait for a state change that will allow closing
                try {
                    closeWaiting = true;
                    this.wait(waitTime);
                    closeWaiting = false;

                    // See if Permission can be granted
                    if ((currentState & CLOSE_NOT_ALLOWED_MASK) == 0) {

                        if ((currentState & READ_OUTSTANDING) != 0) {
                            readOutWithClosePending = true;
                        } else {
                            readOutWithClosePending = false;
                        }
                        if ((currentState & WRITE_OUTSTANDING) != 0) {
                            writeOutWithClosePending = true;
                        } else {
                            writeOutWithClosePending = false;
                        }
                        currentState = CLOSE_PENDING;

                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "requestPermissionToClose returning(2) true");
                        }
                        return true;
                    }
                    waitTime = (waitTillTime - (System.nanoTime() / ONE_MILLISECOND_IN_NANOSECONDS));
                    if (waitTime <= 0) {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "requestPermissionToClose returning(2) false");
                        }
                        return false;
                    }
                    continue;
                } catch (InterruptedException x) {
                    // See if Permission can be granted
                    if ((currentState & CLOSE_NOT_ALLOWED_MASK) == 0) {

                        if ((currentState & READ_OUTSTANDING) != 0) {
                            readOutWithClosePending = true;
                        } else {
                            readOutWithClosePending = false;
                        }
                        if ((currentState & WRITE_OUTSTANDING) != 0) {
                            writeOutWithClosePending = true;
                        } else {
                            writeOutWithClosePending = false;
                        }
                        currentState = CLOSE_PENDING;

                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "requestPermissionToClose returning(3) true");
                        }
                        return true;
                    }
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "requestPermissionToClose returning(3) false");
                    }
                    return false;
                }
            } // end-while
        } // end-sync
    }
716394
public void alertClose() {
        if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  
            logger.logp(Level.FINE, CLASS_NAME,"alertClose()", "");
        }
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        _srtRequestHelper._InputStreamClosed=true;
    }
424021
void savePermissions() {

        try {
            ensureLock();
            for (CmsPermissionBean bean : m_permissionToChange) {
                if (bean.isDeleted()) {
                    m_cms.rmacc(m_cms.getSitePath(m_resource), bean.getPrincipalType(), bean.getPrincipalName());

                } else {
                    if (bean.getPermissionString() == null) {
                        m_cms.chacc(
                            m_cms.getSitePath(m_resource),
                            bean.getPrincipalType(),
                            bean.getPrincipalName(),
                            bean.getAllowed(),
                            bean.getDenied(),
                            bean.getFlags());
                    } else {
                        m_cms.chacc(
                            m_cms.getSitePath(m_resource),
                            bean.getPrincipalType(),
                            bean.getPrincipalName(),
                            bean.getPermissionString());
                    }
                }
            }
        } catch (CmsException e) {
            m_context.error(e);
        }
    }
269746
@Override
    protected void handlePermission(@NonNull File path) {
//         Should we show an explanation?
//        if (shouldShowRequestPermissionRationale(
//                Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
//             Explain to the user why we need permission
//        }

        mRequestedPath = path;
        requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
    }
1135641
@Override
    public void close() {
        synchronized (this.lock) {
            if (this.closed) {
                return;
            }

            this.closed = true;

            // Cancel all pending reads and unregister them.
            ArrayList<Request> toClose = new ArrayList<>(this.pendingRequests.values());
            toClose.forEach(Request::cancel);
        }
    }
779233
public void forceClose() {
        // Move all elements from usedInstances to unusedInstances in a threadsafe way
        for (final T usedInstance : new ArrayList<>(usedInstances)) {
            if (usedInstances.remove(usedInstance)) {
                unusedInstances.add(usedInstance);
            }
        }
        close();
    }
641736
protected void actionClose() throws IOException, JspException, ServletException {

        try {
            if (Boolean.valueOf(getParamDirectedit()).booleanValue()) {
                // editor is in direct edit mode
                if (CmsStringUtil.isNotEmpty(getParamBacklink())) {
                    // set link to the specified back link target
                    setParamCloseLink(getJsp().link(getParamBacklink()));
                } else {
                    // set link to the edited resource
                    setParamCloseLink(getJsp().link(getParamResource()));
                }
                // save initialized instance of this class in request attribute for included sub-elements
                getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
                // load the common JSP close dialog
                getJsp().include(FILE_DIALOG_CLOSE);
            } else {
                if (CmsStringUtil.isNotEmpty(getParamBacklink())) {
                    // set link to the specified back link target
                    setParamCloseLink(getJsp().link(getParamBacklink()));
                    // save initialized instance of this class in request attribute for included sub-elements
                    getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
                    // load the common JSP close dialog
                    getJsp().include(FILE_DIALOG_CLOSE);
                } else {
                    // forward to the workplace explorer view
                    sendForward(CmsVaadinUtils.getWorkplaceLink(), new HashMap<String, String[]>());
                }
            }
        } finally {
            clearEditorSessionInfo();
        }
    }
550030
public void close(int requestNumber)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "close", requestNumber);

      // Deregister any error callback created for this connection.
      if (asynchReader != null)
      {
              try
              {
                 mainConsumer.getConsumerSession().getConnection().removeConnectionListener(asynchReader);
              }
              catch (SIException e)
              {
            //No FFDC code needed
            //Only FFDC if we haven't received a meTerminated event.
            if(!((ConversationState)getConversation().getAttachment()).hasMETerminated())
            {
               FFDCFilter.processException(e, CLASS_NAME + ".close",
                     CommsConstants.CATSESSSYNCHCONSUMER_CLOSE_01, this);
            }

                 if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.exception(this, tc, e);
              }

        if (asynchReader.isCurrentlyDoingReceiveWithWait()) asynchReader.sendNoMessageToClient();
      }
      super.close(requestNumber);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "close");
   }
1150323
synchronized public void closeInbound() throws SSLException {
        /*
         * Currently closes the outbound side as well.  The IETF TLS
         * working group has expressed the opinion that 1/2 open
         * connections are not allowed by the spec.  May change
         * someday in the future.
         */
        if ((debug != null) && Debug.isOn("ssl")) {
            System.out.println(threadName() + ", called closeInbound()");
        }

        /*
         * No need to throw an Exception if we haven't even started yet.
         */
        if ((connectionState != cs_START) && !recvCN) {
            recvCN = true;  // Only receive the Exception once
            fatal(Alerts.alert_internal_error,
                "Inbound closed before receiving peer's close_notify: " +
                "possible truncation attack?");
        } else {
            /*
             * Currently, this is a no-op, but in case we change
             * the close inbound code later.
             */
            closeInboundInternal();
        }
    }
82850
public void truncate() throws IOException {
    getDatabase().checkSecurity(ODatabaseSecurityResources.CLASS, ORole.PERMISSION_UPDATE);

    getDatabase().getStorage().callInLock(new Callable<Object>() {
      public Object call() throws Exception {
        for (int id : clusterIds) {
          getDatabase().getStorage().getClusterById(id).truncate();
        }

        for (OIndex<?> index : getClassIndexes()) {
          index.clear();
        }
        return null;
      }
    }, true);
  }
1208161
@RequestMapping(value = "/deletePermission", method = RequestMethod.POST)
    public void deletePermission(
            @RequestParam("principal") String principal,
            @RequestParam("owner") String owner,
            @RequestParam("activity") String activity,
            @RequestParam("target") String target,
            HttpServletRequest request,
            HttpServletResponse response)
            throws Exception {

        // ensure the current user is authorized to update and view permissions
        final IPerson currentUser = personManager.getPerson((HttpServletRequest) request);

        if (!permissionAdministrationHelper.canEditPermission(currentUser, target)
                || !permissionAdministrationHelper.canViewPermission(currentUser, target)) {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
            return;
        }
        JsonEntityBean bean = groupListHelper.getEntityForPrincipal(principal);

        if (bean != null) {

            IAuthorizationPrincipal p = groupListHelper.getPrincipalForEntity(bean);

            IPermission[] directPermissions =
                    permissionStore.select(owner, p.getPrincipalString(), activity, target, null);
            this.authorizationService.removePermissions(directPermissions);

        } else {
            log.warn(
                    "Unable to resolve the following principal (will "
                            + "be omitted from the list of assignments):  "
                            + principal);
        }

        response.setStatus(HttpServletResponse.SC_OK);
        return;
    }
148707
private void endWaitingForUsage() {
        synchronized (permanentUserReadWriteLock) {
            if (permissionWithoutUsageLimit != null)
                permissionWithoutUsageLimit = null;
            if (permissionWithoutUsageCloseThread != null) {
                permissionWithoutUsageCloseThread.cancel(true);
                permissionWithoutUsageLimit = null;
            }
        }
    }
27551
@Override
    public void delete(IPermission[] perms) throws AuthorizationException {
        if (perms.length > 0) {
            try {
                primDelete(perms);
            } catch (Exception ex) {
                log.error("Exception deleting permissions " + Arrays.toString(perms), ex);
                throw new AuthorizationException(
                        "Exception deleting permissions " + Arrays.toString(perms), ex);
            }
        }
    }
46308
public final <T extends ReleasableInputStream> T disableClose() {
        this.closeDisabled = true;
        @SuppressWarnings("unchecked")
        T t = (T)this;
        return t;
    }
17748
public void close(VirtualConnection inVC, Exception e) {

        // when the channel above calls close() on the outbound connection then
        // we are done... no need to purge anything off the socket like we do
        // on the inbound side (purge request body if they never read it)

        // pass the close down the chain.
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Closing this outbound link: " + this + " " + getVirtualConnection());
        }
        setAllowReconnect(false);
        if (!this.earlyReconnectDestroy) {
            super.close(inVC, e);
        } else {
            destroy(e);
        }
    }
262366
public void setRemove(java.util.Collection<LoadPermissionRequest> remove) {
        if (remove == null) {
            this.remove = null;
            return;
        }

        this.remove = new com.amazonaws.internal.SdkInternalList<LoadPermissionRequest>(remove);
    }
1194441
@Override
    public void transportClosed(boolean closedByRemotePeer, boolean mayBlock)
    {
    	parentListener.unregisterClient(this);
        try
        {
            if (localConnection != null)
                localConnection.close();
        }
        catch (Exception e)
        {
            log.error("#"+id+" Could not close local connection",e);
        }
        finally
        {
        	localConnection = null;
        }
    }