Unlocks the container-page in a synchronized RPC call.<p>
9326
protected void unlockContainerpage() {

        if (getData().getDetailContainerPage() != null) {

            CmsCoreProvider.get().unlock(getData().getDetailContainerPage());
        } else if (unlockResource(CmsCoreProvider.get().getStructureId())) {
            CmsDebugLog.getInstance().printLine(Messages.get().key(Messages.GUI_NOTIFICATION_PAGE_UNLOCKED_0));
        }
    }
610780
@SuppressWarnings("unchecked")
    protected void doLock(HttpServletRequest req, HttpServletResponse resp) throws IOException {

        String path = getRelativePath(req);

        // Check if webdav is set to read only
        if (m_readOnly) {

            resp.setStatus(CmsWebdavStatus.SC_FORBIDDEN);

            if (LOG.isDebugEnabled()) {
                LOG.debug(Messages.get().getBundle().key(Messages.LOG_WEBDAV_READ_ONLY_0));
            }

            return;
        }

        // Check if resource is locked
        if (isLocked(req)) {

            resp.setStatus(CmsWebdavStatus.SC_LOCKED);

            if (LOG.isDebugEnabled()) {
                LOG.debug(Messages.get().getBundle().key(Messages.LOG_ITEM_LOCKED_1, path));
            }

            return;
        }

        CmsRepositoryLockInfo lock = new CmsRepositoryLockInfo();

        // Parsing depth header
        String depthStr = req.getHeader(HEADER_DEPTH);
        if (depthStr == null) {
            lock.setDepth(CmsRepositoryLockInfo.DEPTH_INFINITY_VALUE);
        } else {
            if (depthStr.equals("0")) {
                lock.setDepth(0);
            } else {
                lock.setDepth(CmsRepositoryLockInfo.DEPTH_INFINITY_VALUE);
            }
        }

        // Parsing timeout header
        int lockDuration = CmsRepositoryLockInfo.TIMEOUT_INFINITE_VALUE;
        lock.setExpiresAt(System.currentTimeMillis() + (lockDuration * 1000));

        int lockRequestType = LOCK_CREATION;

        Element lockInfoNode = null;

        try {
            SAXReader saxReader = new SAXReader();
            Document document = saxReader.read(new InputSource(req.getInputStream()));

            // Get the root element of the document
            Element rootElement = document.getRootElement();
            lockInfoNode = rootElement;
        } catch (Exception e) {
            lockRequestType = LOCK_REFRESH;
        }

        if (lockInfoNode != null) {

            // Reading lock information
            Iterator<Element> iter = lockInfoNode.elementIterator();

            Element lockScopeNode = null;
            Element lockTypeNode = null;
            Element lockOwnerNode = null;

            while (iter.hasNext()) {
                Element currentElem = iter.next();
                switch (currentElem.getNodeType()) {
                    case Node.TEXT_NODE:
                        break;
                    case Node.ELEMENT_NODE:
                        String nodeName = currentElem.getName();
                        if (nodeName.endsWith(TAG_LOCKSCOPE)) {
                            lockScopeNode = currentElem;
                        }
                        if (nodeName.endsWith(TAG_LOCKTYPE)) {
                            lockTypeNode = currentElem;
                        }
                        if (nodeName.endsWith(TAG_OWNER)) {
                            lockOwnerNode = currentElem;
                        }
                        break;
                    default:
                        break;
                }
            }

            if (lockScopeNode != null) {

                iter = lockScopeNode.elementIterator();
                while (iter.hasNext()) {
                    Element currentElem = iter.next();
                    switch (currentElem.getNodeType()) {
                        case Node.TEXT_NODE:
                            break;
                        case Node.ELEMENT_NODE:
                            String tempScope = currentElem.getName();
                            if (tempScope.indexOf(':') != -1) {
                                lock.setScope(tempScope.substring(tempScope.indexOf(':') + 1));
                            } else {
                                lock.setScope(tempScope);
                            }
                            break;
                        default:
                            break;
                    }
                }

                if (lock.getScope() == null) {

                    // Bad request
                    resp.setStatus(CmsWebdavStatus.SC_BAD_REQUEST);
                }

            } else {

                // Bad request
                resp.setStatus(CmsWebdavStatus.SC_BAD_REQUEST);
            }

            if (lockTypeNode != null) {

                iter = lockTypeNode.elementIterator();
                while (iter.hasNext()) {
                    Element currentElem = iter.next();
                    switch (currentElem.getNodeType()) {
                        case Node.TEXT_NODE:
                            break;
                        case Node.ELEMENT_NODE:
                            String tempType = currentElem.getName();
                            if (tempType.indexOf(':') != -1) {
                                lock.setType(tempType.substring(tempType.indexOf(':') + 1));
                            } else {
                                lock.setType(tempType);
                            }
                            break;
                        default:
                            break;
                    }
                }

                if (lock.getType() == null) {

                    // Bad request
                    resp.setStatus(CmsWebdavStatus.SC_BAD_REQUEST);
                }

            } else {

                // Bad request
                resp.setStatus(CmsWebdavStatus.SC_BAD_REQUEST);
            }

            if (lockOwnerNode != null) {

                iter = lockOwnerNode.elementIterator();
                while (iter.hasNext()) {
                    Element currentElem = iter.next();
                    switch (currentElem.getNodeType()) {
                        case Node.TEXT_NODE:
                            lock.setOwner(lock.getOwner() + currentElem.getStringValue());
                            break;
                        case Node.ELEMENT_NODE:
                            lock.setOwner(lock.getOwner() + currentElem.getStringValue());
                            break;
                        default:
                            break;
                    }
                }

                if (lock.getOwner() == null) {

                    // Bad request
                    resp.setStatus(CmsWebdavStatus.SC_BAD_REQUEST);
                }

            } else {
                lock.setOwner("");
            }

        }

        lock.setPath(path);
        lock.setUsername(m_username);

        if (lockRequestType == LOCK_REFRESH) {

            CmsRepositoryLockInfo currentLock = m_session.getLock(path);
            if (currentLock == null) {
                lockRequestType = LOCK_CREATION;
            }
        }

        if (lockRequestType == LOCK_CREATION) {

            try {

                if (LOG.isDebugEnabled()) {
                    LOG.debug(Messages.get().getBundle().key(Messages.LOG_LOCK_ITEM_1, lock.getOwner()));
                }

                boolean result = m_session.lock(path, lock);
                if (result) {

                    // Add the Lock-Token header as by RFC 2518 8.10.1
                    // - only do this for newly created locks
                    resp.addHeader(HEADER_LOCKTOKEN, "<opaquelocktoken:" + generateLockToken(req, lock) + ">");

                    if (LOG.isDebugEnabled()) {
                        LOG.debug(Messages.get().getBundle().key(Messages.LOG_LOCK_ITEM_FAILED_0));
                    }

                } else {

                    resp.setStatus(CmsWebdavStatus.SC_LOCKED);

                    if (LOG.isDebugEnabled()) {
                        LOG.debug(Messages.get().getBundle().key(Messages.LOG_LOCK_ITEM_SUCCESS_0));
                    }

                    return;
                }
            } catch (CmsVfsResourceNotFoundException rnfex) {
                resp.setStatus(CmsWebdavStatus.SC_NOT_FOUND);

                if (LOG.isDebugEnabled()) {
                    LOG.debug(Messages.get().getBundle().key(Messages.LOG_ITEM_NOT_FOUND_1, path));
                }

                return;
            } catch (CmsSecurityException sex) {
                resp.setStatus(CmsWebdavStatus.SC_FORBIDDEN);

                if (LOG.isDebugEnabled()) {
                    LOG.debug(Messages.get().getBundle().key(Messages.LOG_NO_PERMISSION_0));
                }

                return;
            } catch (CmsException ex) {
                resp.setStatus(CmsWebdavStatus.SC_INTERNAL_SERVER_ERROR);

                if (LOG.isErrorEnabled()) {
                    LOG.error(Messages.get().getBundle().key(Messages.LOG_REPOSITORY_ERROR_2, "LOCK", path), ex);
                }

                return;
            }
        }

        // Set the status, then generate the XML response containing
        // the lock information
        Document doc = DocumentHelper.createDocument();
        Element propElem = doc.addElement(new QName(TAG_PROP, Namespace.get(DEFAULT_NAMESPACE)));

        Element lockElem = addElement(propElem, TAG_LOCKDISCOVERY);
        addLockElement(lock, lockElem, generateLockToken(req, lock));

        resp.setStatus(CmsWebdavStatus.SC_OK);
        resp.setContentType("text/xml; charset=UTF-8");

        Writer writer = resp.getWriter();
        doc.write(writer);
        writer.close();
    }
1328925
private void tryUnlock() {

        if (m_resource != null) {
            try {
                A_CmsUI.getCmsObject().unlockResource(m_resource);
            } catch (CmsException e) {
                LOG.debug("Unlocking resource " + m_resource.getRootPath() + " failed", e);
            }
        }
    }
528868
private void unlockAllUnread() throws SIResourceException, SISessionDroppedException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "unlockAllUnread", new Object[] { new Integer(hashCode()), this });

    int unlockedMessages = 0;

    synchronized(this)
    {
      messageAvailable = false;

      // Only unlock messages if we have reached the end of the list.
      if(firstMsg != null && !endReached)
      {
        LMEMessage pointerMsg = null;

        if (currentMsg == null)
          pointerMsg = firstMsg;
        else
          pointerMsg = currentMsg.next;

        LMEMessage removedMsg = null;

        boolean more = true;

        if (pointerMsg != null)
        {
          while(more)
          {
            // See if this is the last message in the list
            if(pointerMsg == lastMsg)
              more = false;

            // Only unlock messages that are in the MS (and haven't already
            // been unlocked by us)
            if(pointerMsg != currentUnlockedMessage)
            {
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(tc, "Unlocking Message " + pointerMsg);
              if(pointerMsg.isStored)
              {
                try
                {
                  unlockMessage(pointerMsg.message,false);
                }
                catch (SIMPMessageNotLockedException e)
                {
                  // No FFDC code needed
                  SibTr.exception(tc, e);
                  // See defect 387591
                  // We should only get this exception if the message was deleted via
                  // the controllable objects i.e. the admin console. If we are here for
                  // another reason that we have a real error.
                }
              }

              unlockedMessages++;
            }

            removedMsg = pointerMsg;
            pointerMsg = pointerMsg.next;
            // Remove the element from the list
            removeMessage(removedMsg);
          }
        }
      }
    }

    if(unlockedMessages != 0)
      localConsumerPoint.removeActiveMessages(unlockedMessages);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "unlockAllUnread", this);
  }
162954
public boolean isLockStateOk() {

        org.opencms.workplace.commons.CmsLock lockDialog = new org.opencms.workplace.commons.CmsLock(getJsp());
        lockDialog.setParamIncluderelated(CmsStringUtil.TRUE);
        lockDialog.setBlockingFilter(getBlockingFilter());
        if (!isDirectPublish()) {
            lockDialog.setParamResource("/");
        }
        if (!lockDialog.getBlockingLockedResources().isEmpty()) {
            // blocking locks found, so show them
            return false;
        }
        if (!isDirectPublish()) {
            // is publish project operation no resource iteration possible
            return true;
        }

        // flag to indicate that all resources are exclusive locked
        boolean locked = true;
        // flag to indicate that all resources are unlocked
        boolean unlocked = true;

        Iterator<String> i = getResourceList().iterator();
        while (i.hasNext()) {
            String resName = i.next();
            try {
                CmsLock lock = getCms().getLock(getCms().readResource(resName, CmsResourceFilter.ALL));
                if (!lock.isUnlocked()) {
                    unlocked = false;
                    if (locked
                        && !lock.isOwnedInProjectBy(
                            getCms().getRequestContext().getCurrentUser(),
                            getCms().getRequestContext().getCurrentProject())) {
                        // locks of another users or locked in another project are blocking
                        locked = false;
                    }
                }
            } catch (CmsException e) {
                // error reading a resource, should usually never happen
                if (LOG.isErrorEnabled()) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            }
        }
        return locked || unlocked;
    }
109698
public synchronized void unlock()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "unlock", this);

    // If the subscription locks are down to zero then notify the threads waiting
    // for the subscriptionTable lock.
    synchronized (iMutex)
    {
      // If we are exclusively locked, then just return, as long as
      // the thread that is calling is the thread that holds the
      // exclusive lock.
      if (iExclusivelyLocked && iExclusiveLockHolder == Thread.currentThread())
      {
        if (tc.isEntryEnabled())
          SibTr.exit(tc, "unlock");
        return;
      }

      // Decrement the lock count and notify the other threads if no 
      // one holds the lock any more.
      if (--iLockCount == 0)
        notifyAll();
        
      if (iLockCount < 0)
      {      
        if (tc.isEntryEnabled()) 
          SibTr.exit(tc, "unlock", "SIErrorException");
        
        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.utils.LockManager",
            "1:196:1.19" });
          
        throw new SIErrorException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0001",
            new Object[] {
              "com.ibm.ws.sib.processor.utils.LockManager",
              "1:203:1.19" },
            null));
      }        
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "unlock");
  }
154833
public synchronized boolean removeLock(Object bookmark, SessionInfo sessionInfo)
    {
        Utility.getLogger().info("Unlock: " + bookmark + ", Session: " + sessionInfo.m_iSessionID + " success: " + sessionInfo.equals(this.get(bookmark)));
        if (!sessionInfo.equals(this.get(bookmark)))
            return false;   // Not my session - error.
        if (this.getWaitlist(bookmark, false) != null)
        	if (this.getWaitlist(bookmark, false).size() > 0)
        {   // Notify this person that the wait is over
    		SessionInfo sessionInfoToUnlock = this.getWaitlist(bookmark, true).get(0);
            if (sessionInfoToUnlock == null)
            	return false;	// Never
            synchronized (sessionInfoToUnlock)
            {
        		if (sessionInfoToUnlock != this.popWaitlistSession(bookmark))
                	return false;	// Never since the only remove is this (synchronized line)
                boolean bSuccess = sessionInfo.equals(this.remove(bookmark));
                if (bSuccess)	// Always
                	sessionInfoToUnlock.notify();	// Tell locked session to continue
            	return bSuccess;
            }
        }
        return sessionInfo.equals(this.remove(bookmark));
    }
765811
public boolean unlock(final CmsUUID structureId) {

        // lock the sitemap
        CmsRpcAction<String> unlockAction = new CmsRpcAction<String>() {

            /**
            * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
            */
            @Override
            public void execute() {

                start(200, false);
                getService().unlock(structureId, this);
            }

            /**
            * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
            */
            @Override
            public void onResponse(String result) {

                stop(false);
                if (result == null) {
                    // ok
                    return;
                }
                // unable to lock
                String text = Messages.get().key(Messages.GUI_UNLOCK_NOTIFICATION_2, structureId.toString(), result);
                CmsNotification.get().send(CmsNotification.Type.WARNING, text);
            }
        };
        return unlockAction.executeSync() == null;
    }
1092517
private void tryUnlock(CmsResource resource) {

        try {
            m_cms.unlockResource(resource);
        } catch (Exception unlockError) {
            LOG.debug(unlockError.getLocalizedMessage(), unlockError);
        }
    }
213355
private void unlock(Object holder) throws PSQLException {
    if (lockedFor != holder) {
      throw new PSQLException(GT.tr("Tried to break lock on database connection"),
          PSQLState.OBJECT_NOT_IN_STATE);
    }
    lockedFor = null;
    this.notify();
  }
1053606
public I_CmsContainerpageServiceAsync getContainerpageService() {

        if (m_containerpageService == null) {
            m_containerpageService = GWT.create(I_CmsContainerpageService.class);
            String serviceUrl = CmsCoreProvider.get().link("org.opencms.ade.containerpage.CmsContainerpageService.gwt");
            ((ServiceDefTarget)m_containerpageService).setServiceEntryPoint(serviceUrl);
        }
        return m_containerpageService;
    }
916125
public void saveContainerpage(final Runnable... afterSaveActions) {

        if (hasPageChanged()) {
            final CmsRpcAction<Long> action = new CmsRpcAction<Long>() {

                /**
                 * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
                 */
                @Override
                public void execute() {

                    start(500, true);
                    if (getData().getDetailContainerPage() != null) {
                        getContainerpageService().saveDetailContainers(
                            getData().getDetailId(),
                            getData().getDetailContainerPage(),
                            getPageContent(),
                            this);
                    } else {
                        getContainerpageService().saveContainerpage(
                            CmsCoreProvider.get().getStructureId(),
                            getPageContent(),
                            this);
                    }
                }

                /**
                 * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
                 */
                @Override
                protected void onResponse(Long result) {

                    setLoadTime(result);
                    stop(false);
                    setPageChanged(false, false);
                    CmsContainerpageController.get().fireEvent(new CmsContainerpageEvent(EventType.pageSaved));
                    for (Runnable afterSaveAction : afterSaveActions) {
                        afterSaveAction.run();
                    }
                }
            };
            if (getData().getDetailContainerPage() != null) {
                action.execute();
            } else {
                lockContainerpage(new I_CmsSimpleCallback<Boolean>() {

                    public void execute(Boolean arg) {

                        if (arg.booleanValue()) {
                            action.execute();
                        }
                    }
                });
            }
        }
    }
1014056
public void uncacheContainerPage(CmsUUID structureId, boolean online) {

        try {
            m_lock.writeLock().lock();
            if (online) {
                m_containerPagesOnline.remove(getCacheKey(structureId, true));
                m_containerPagesOnline.remove(getCacheKey(structureId, false));
            } else {
                m_containerPagesOffline.remove(getCacheKey(structureId, true));
                m_containerPagesOffline.remove(getCacheKey(structureId, false));
            }
        } finally {
            m_lock.writeLock().unlock();
        }
    }
51522
public synchronized void unlock()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "unlock", this);

    // If the subscription locks are down to zero then notify the threads waiting
    // for the subscriptionTable lock.
    synchronized (iMutex)
    {
      if (readLockCount == 0)
      {
        if (tc.isEntryEnabled()) 
          SibTr.exit(tc, "unlock", "SIErrorException");
        
        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.utils.AdvancedLockManager",
            "1:237:1.3" });
          
        throw new SIErrorException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0001",
            new Object[] {
              "com.ibm.ws.sib.processor.utils.AdvancedLockManager",
              "1:244:1.3" },
            null));
      }
      
      decrementThreadLockCount();
      // Decrement the lock count and notify the other threads if no 
      // one holds the lock any more.
      if (readLockCount == 0)
        notifyAll();        
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "unlock");
  }
1204206
public static CmsLockActionRecord ensureLock(CmsObject cms, CmsResource resource) throws CmsException {

        LockChange change = LockChange.unchanged;
        List<CmsResource> blockingResources = cms.getBlockingLockedResources(resource);
        if ((blockingResources != null) && !blockingResources.isEmpty()) {
            throw new CmsException(
                Messages.get().container(
                    Messages.ERR_RESOURCE_HAS_BLOCKING_LOCKED_CHILDREN_1,
                    cms.getSitePath(resource)));
        }
        CmsUser user = cms.getRequestContext().getCurrentUser();
        CmsLock lock = cms.getLock(resource);
        if (!lock.isOwnedBy(user)) {
            cms.lockResourceTemporary(resource);
            change = LockChange.locked;
            lock = cms.getLock(resource);
        } else if (!lock.isOwnedInProjectBy(user, cms.getRequestContext().getCurrentProject())) {
            cms.changeLock(resource);
            change = LockChange.changed;
            lock = cms.getLock(resource);
        }
        return new CmsLockActionRecord(lock, change);
    }
241968
private CmsLock getSiblingsLock(List<CmsResource> siblings, String resourcename) {

        for (int i = 0; i < siblings.size(); i++) {
            CmsResource sibling = siblings.get(i);
            CmsLock exclusiveLock = getDirectLock(sibling.getRootPath());
            if (exclusiveLock != null) {
                // a sibling is already locked
                return internalSiblingLock(exclusiveLock, resourcename);
            }
        }
        // no locked siblings found
        return null;

    }
733831
@Override
	public final void unlock(int handle) throws DataStoreException 
    {
        if (SAFE_MODE) checkHandle(handle);
        if (locks.flip(handle))
        {
            locks.flip(handle); // Restore state
            throw new DataStoreException("Handle was not locked : "+handle);
        }
    }