001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2007
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.war.webdav;
034:
035: import javax.servlet.http.HttpServletRequest;
036: import javax.servlet.http.HttpServletResponse;
037: import java.io.IOException;
038:
039: /**
040: * Unlock operation.
041: *
042: * @author Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
043: * @version $Rev: 1 $
044: */
045: class OperationUnlock extends Operation {
046:
047: public OperationUnlock(HttpServletRequest req,
048: HttpServletResponse resp, boolean readonly) {
049: super (req, resp, readonly);
050: }
051:
052: void writeResponse() throws IOException {
053: if (readonly) {
054: response.sendError(FxWebDavStatus.SC_FORBIDDEN);
055: } else {
056: response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
057: }
058: }
059:
060: /**
061: * UNLOCK Method.
062:
063: protected void doUnlock(HttpServletRequest req, HttpServletResponse resp)
064: throws ServletException, IOException {
065:
066: if (readOnly) {
067: resp.sendError(FxWebDavStatus.SC_FORBIDDEN);
068: return;
069: }
070:
071: if (isLocked(req)) {
072: resp.sendError(FxWebDavStatus.SC_LOCKED);
073: return;
074: }
075:
076: String path = getRelativePath(req);
077:
078: String lockTokenHeader = req.getHeader("Lock-Token");
079: if (lockTokenHeader == null)
080: lockTokenHeader = "";
081:
082: // Checking resource locks
083:
084: LockInfo lock = resourceLocks.get(path);
085: Enumeration tokenList;
086: if (lock != null) {
087:
088: // At least one of the tokens of the locks must have been given
089:
090: tokenList = lock.tokens.elements();
091: while (tokenList.hasMoreElements()) {
092: String token = (String) tokenList.nextElement();
093: if (lockTokenHeader.indexOf(token) != -1) {
094: lock.tokens.removeElement(token);
095: }
096: }
097:
098: if (lock.tokens.isEmpty()) {
099: resourceLocks.remove(path);
100: // Removing any lock-null resource which would be present
101: lockNullResources.remove(path);
102: }
103:
104: }
105:
106: // Checking inheritable collection locks
107:
108: Enumeration collectionLocksList = collectionLocks.elements();
109: while (collectionLocksList.hasMoreElements()) {
110: lock = (LockInfo) collectionLocksList.nextElement();
111: if (path.equals(lock.path)) {
112:
113: tokenList = lock.tokens.elements();
114: while (tokenList.hasMoreElements()) {
115: String token = (String) tokenList.nextElement();
116: if (lockTokenHeader.indexOf(token) != -1) {
117: lock.tokens.removeElement(token);
118: break;
119: }
120: }
121:
122: if (lock.tokens.isEmpty()) {
123: collectionLocks.removeElement(lock);
124: // Removing any lock-null resource which would be present
125: lockNullResources.remove(path);
126: }
127:
128: }
129: }
130:
131: resp.setStatus(FxWebDavStatus.SC_NO_CONTENT);
132:
133: }*/
134: }
|