001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019:
020: package org.openharmonise.dav.server.managers;
021:
022: import java.util.*;
023: import java.util.logging.*;
024:
025: import javax.xml.parsers.*;
026:
027: import org.openharmonise.commons.xml.namespace.NamespaceType;
028: import org.openharmonise.dav.server.property.domains.DAVDomain;
029: import org.openharmonise.dav.server.property.ranges.DAVRange;
030: import org.openharmonise.dav.server.utils.*;
031: import org.openharmonise.rm.DataAccessException;
032: import org.openharmonise.rm.resources.*;
033: import org.openharmonise.rm.resources.metadata.properties.Property;
034: import org.w3c.dom.*;
035:
036: import com.ibm.webdav.*;
037: import com.ibm.webdav.impl.*;
038:
039: /**
040: * Implementation of the <code>VersionedPropertiesManager</code> interface
041: * providing the Delta-V functionality on top of <code>PropertiesManager</code>.
042: *
043: * @author Michael Bell
044: * @version $Revision: 1.2 $
045: * @since May 21, 2004
046: */
047: public class VersionedPropertiesManager extends
048: HarmonisePropertiesManager implements
049: com.ibm.webdav.impl.VersionedPropertiesManager {
050:
051: public static final String TAG_SUCCESSOR_SET = "successor-set";
052: public static final String TAG_AUTO_VERSION = "auto-version";
053: public static final String TAG_LOCKED_CHECKOUT = "locked-checkout";
054: public static final String TAG_PREDECESSOR_SET = "predecessor-set";
055: public static final String TAG_CHECKED_OUT = "checked-out";
056: public static final String TAG_CHECKED_IN = "checked-in";
057: public static final String TAG_CHECKOUT_SET = "checkout-set";
058: public static final String TAG_VERSION_NAME = "version-name";
059: public static final String TAG_COMMENT = "comment";
060: public static final String TAG_CREATOR_DISPLAYNAME = "creator-displayname";
061: public static final String TAG_SUPPORTED_METHOD_SET = "supported-method-set";
062: public static final String TAG_SUPPORTED_LIVE_PROPERTY_SET = "supported-live-property-set";
063: public static final String TAG_SUPPORTED_REPORT_SET = "supported-report-set";
064: public static final String TAG_SUPPORTED_REPORT = "supported-report";
065: public static final String TAG_REPORT = "report";
066: public static final String TAG_VERSION_TREE = "version-tree";
067:
068: private static List VERSION_PROPS = new Vector();
069:
070: /**
071: * Logger for this class
072: */
073: private static final Logger m_logger = Logger
074: .getLogger(VersionedPropertiesManager.class.getName());
075:
076: static {
077: VERSION_PROPS.add(TAG_SUCCESSOR_SET);
078: VERSION_PROPS.add(TAG_PREDECESSOR_SET);
079: VERSION_PROPS.add(TAG_CHECKED_OUT);
080: VERSION_PROPS.add(TAG_CHECKED_IN);
081: VERSION_PROPS.add(TAG_VERSION_NAME);
082: VERSION_PROPS.add(TAG_COMMENT);
083: VERSION_PROPS.add(TAG_CREATOR_DISPLAYNAME);
084: VERSION_PROPS.add(TAG_SUPPORTED_METHOD_SET);
085: VERSION_PROPS.add(TAG_SUPPORTED_LIVE_PROPERTY_SET);
086: VERSION_PROPS.add(TAG_SUPPORTED_REPORT_SET);
087: VERSION_PROPS.add(TAG_CHECKOUT_SET);
088: VERSION_PROPS.add(TAG_AUTO_VERSION);
089: }
090:
091: /**
092: *
093: */
094: public VersionedPropertiesManager() {
095: super ();
096: }
097:
098: /**
099: * @param resource
100: * @param namespaceManager
101: */
102: public VersionedPropertiesManager(ResourceImpl resource,
103: NamespaceManager namespaceManager) {
104: super (resource, namespaceManager);
105: }
106:
107: protected Element getAutoVersion(Document document) {
108: Element autoversionEl = document.createElementNS(
109: NamespaceType.DAV.getURI(), TAG_AUTO_VERSION);
110: autoversionEl.setPrefix(NamespaceType.DAV.getPrefix());
111: Element lockedCheckoutEl = document.createElementNS(
112: NamespaceType.DAV.getURI(), TAG_LOCKED_CHECKOUT);
113: lockedCheckoutEl.setPrefix(NamespaceType.DAV.getPrefix());
114: autoversionEl.appendChild(lockedCheckoutEl);
115: return autoversionEl;
116: }
117:
118: private Element getSupportedReportSet(Document document) {
119: Element supReportsEl = document.createElementNS(
120: NamespaceType.DAV.getURI(), TAG_SUPPORTED_REPORT_SET);
121:
122: supReportsEl.setPrefix(NamespaceType.DAV.getPrefix());
123: Element supRepEl = document.createElementNS(NamespaceType.DAV
124: .getURI(), TAG_SUPPORTED_REPORT);
125:
126: supRepEl.setPrefix(NamespaceType.DAV.getPrefix());
127: Element reportEl = document.createElementNS(NamespaceType.DAV
128: .getURI(), TAG_REPORT);
129: reportEl.setPrefix(NamespaceType.DAV.getPrefix());
130:
131: reportEl.appendChild(document.createElementNS(NamespaceType.DAV
132: .getURI(), TAG_VERSION_TREE));
133: supRepEl.appendChild(reportEl);
134: supReportsEl.appendChild(supRepEl);
135: return supReportsEl;
136: }
137:
138: protected Element getSupportedLivePropertySet(Document document) {
139: Element supLivePropsEl = document.createElementNS(
140: NamespaceType.DAV.getURI(),
141: TAG_SUPPORTED_LIVE_PROPERTY_SET);
142:
143: supLivePropsEl.setPrefix(NamespaceType.DAV.getPrefix());
144: return supLivePropsEl;
145: }
146:
147: protected Element getVersionName(Document document)
148: throws DataAccessException {
149: Element versionNameEl = document.createElementNS(
150: NamespaceType.DAV.getURI(), TAG_VERSION_NAME);
151: versionNameEl.setPrefix(NamespaceType.DAV.getPrefix());
152:
153: versionNameEl.appendChild(document.createTextNode("Version "
154: + String.valueOf(m_child.getVersionNumber())));
155: return versionNameEl;
156: }
157:
158: protected Element getCheckedIn(Document document)
159: throws NameResolverException {
160: Element checkedInEl = document.createElementNS(
161: NamespaceType.DAV.getURI(), NamespaceType.DAV
162: .getPrefix()
163: + ":" + TAG_CHECKED_IN);
164:
165: Element hrefEl = document.createElementNS(NamespaceType.DAV
166: .getURI(), NamespaceType.DAV.getPrefix() + ":"
167: + HarmonisePropertiesManager.TAG_HREF);
168: hrefEl.appendChild(document
169: .createTextNode(HarmoniseNameResolver
170: .getVersionPath(m_child)));
171: checkedInEl.appendChild(hrefEl);
172: return checkedInEl;
173: }
174:
175: protected Element getCheckedOut(Document document)
176: throws NameResolverException, DataAccessException {
177: Element checkedOutEl = document.createElementNS(
178: NamespaceType.DAV.getURI(), NamespaceType.DAV
179: .getPrefix()
180: + ":" + TAG_CHECKED_OUT);
181:
182: Element hrefEl = document.createElementNS(NamespaceType.DAV
183: .getURI(), NamespaceType.DAV.getPrefix() + ":"
184: + HarmonisePropertiesManager.TAG_HREF);
185: hrefEl.appendChild(document
186: .createTextNode(HarmoniseNameResolver
187: .getVersionPath((AbstractChildObject) m_child
188: .getLiveVersion())));
189: checkedOutEl.appendChild(hrefEl);
190: return checkedOutEl;
191: }
192:
193: protected Element getVersionProperty(Document doc, String sPropName)
194: throws WebDAVException, DOMException, DataAccessException,
195: NameResolverException {
196: Element propEl = null;
197:
198: if (sPropName.equals(TAG_AUTO_VERSION) && isVersioned() == true) {
199: propEl = getAutoVersion(doc);
200: } else if (sPropName.equals(TAG_CHECKED_IN)
201: && m_child.isPendingVersion() == false) {
202: propEl = getCheckedIn(doc);
203: } else if (sPropName.equals(TAG_CHECKED_OUT)
204: && m_child.isPendingVersion() == true) {
205: propEl = getCheckedOut(doc);
206: } else if (sPropName.equals(TAG_CHECKOUT_SET)) {
207: propEl = getCheckedOutSet(doc);
208: } else if (sPropName.equals(TAG_PREDECESSOR_SET)) {
209: propEl = getPredecessors(doc);
210: } else if (sPropName.equals(TAG_SUCCESSOR_SET)) {
211: propEl = getSuccessors(doc);
212: } else if (sPropName.equals(TAG_SUPPORTED_LIVE_PROPERTY_SET)) {
213: propEl = getSupportedLivePropertySet(doc);
214: } else if (sPropName.equals(TAG_SUPPORTED_METHOD_SET)) {
215: propEl = getSupportedMethods(doc);
216: } else if (sPropName.equals(TAG_SUPPORTED_REPORT_SET)) {
217: propEl = getSupportedReportSet(doc);
218: } else if (sPropName.equals(TAG_VERSION_NAME)) {
219: propEl = getVersionName(doc);
220: }
221:
222: return propEl;
223: }
224:
225: public boolean isVersionProperty(String sPropName) {
226: boolean bIsVerProp = false;
227:
228: int nIndex = sPropName.indexOf(":");
229: if (nIndex >= 0) {
230: sPropName = sPropName.substring(nIndex + 1);
231: }
232:
233: bIsVerProp = VERSION_PROPS.contains(sPropName);
234:
235: return bIsVerProp;
236: }
237:
238: /**
239: * Removes all live version properties from <code>propertiesDocument</code>.
240: * They don't need to be saved.
241: *
242: * @param propertiesDocument
243: */
244: public void removeVersionProperties(
245: org.w3c.dom.Document propertiesDocument) {
246: Element properties = propertiesDocument.getDocumentElement();
247:
248: Iterator iter = VERSION_PROPS.iterator();
249:
250: while (iter.hasNext()) {
251: String sPropName = (String) iter.next();
252:
253: Element p = (Element) ((Element) properties)
254: .getElementsByTagNameNS(NamespaceType.DAV.getURI(),
255: sPropName).item(0);
256:
257: if (p != null) {
258: properties.removeChild(p);
259: }
260:
261: }
262:
263: }
264:
265: /**
266: * Adds a populated 'successors-set' element to <code>properties</code>.
267: *
268: * @param document
269: * @param properties
270: * @throws WebDAVException
271: */
272: protected Element getSuccessors(Document document)
273: throws WebDAVException {
274: Element successorSetEl = document.createElementNS(
275: NamespaceType.DAV.getURI(), NamespaceType.DAV
276: .getPrefix()
277: + ":" + TAG_SUCCESSOR_SET);
278:
279: try {
280:
281: Vector successors = new Vector();
282: AbstractChildObject liveChild = m_child;
283:
284: if (m_child.isLiveVersion() == false) {
285: liveChild = (AbstractChildObject) m_child
286: .getLiveVersion();
287: }
288:
289: if (m_child.isHistorical() == true) {
290:
291: List history = m_child.getAllVersions();
292:
293: Iterator histIter = history.iterator();
294:
295: //loop through the whole set in case they're not ordered properly
296: while (histIter.hasNext()) {
297: AbstractChildObject tmpChild = (AbstractChildObject) histIter
298: .next();
299:
300: if (tmpChild.getVersionNumber() > m_child
301: .getVersionNumber()) {
302: successors.add(tmpChild);
303: }
304: }
305: }
306:
307: Iterator successorIter = successors.iterator();
308:
309: while (successorIter.hasNext()) {
310: AbstractChildObject tmpChild = (AbstractChildObject) successorIter
311: .next();
312: Element hrefEl = document.createElementNS(
313: NamespaceType.DAV.getURI(), NamespaceType.DAV
314: .getPrefix()
315: + ":"
316: + HarmonisePropertiesManager.TAG_HREF);
317: hrefEl.appendChild(document
318: .createTextNode(HarmoniseNameResolver
319: .getVersionPath(tmpChild)));
320: successorSetEl.appendChild(hrefEl);
321: }
322:
323: } catch (DataAccessException e) {
324: throw new WebDAVException(
325: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
326: .getLocalizedMessage());
327: } catch (NameResolverException e) {
328: throw new WebDAVException(
329: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
330: .getLocalizedMessage());
331: }
332: return successorSetEl;
333: }
334:
335: /**
336: * Adds a populated 'predecessors-set' element to <code>properties</code>.
337: *
338: * @param document
339: * @param properties
340: * @throws WebDAVException
341: * @throws DOMException
342: * @throws NameResolverException
343: * @throws DataAccessException
344: */
345: private Element getPredecessors(Document document)
346: throws WebDAVException, DOMException,
347: NameResolverException, DataAccessException {
348: Element predecessorSetEl = document.createElementNS(
349: NamespaceType.DAV.getURI(), NamespaceType.DAV
350: .getPrefix()
351: + ":" + TAG_PREDECESSOR_SET);
352: ArrayList preds = new ArrayList();
353:
354: if (m_child.isHistorical() == false
355: && m_child.isLiveVersion() == false) {
356: preds.add(m_child.getLiveVersion());
357: }
358:
359: List hists = m_child.getHistoricalVersions();
360:
361: Iterator histIter = hists.iterator();
362:
363: while (histIter.hasNext()) {
364: AbstractChildObject tmpChild = (AbstractChildObject) histIter
365: .next();
366:
367: if (tmpChild.getVersionNumber() < m_child
368: .getVersionNumber()) {
369: preds.add(tmpChild);
370: }
371: }
372:
373: Iterator predIter = preds.iterator();
374:
375: while (predIter.hasNext()) {
376: AbstractChildObject tmpChild = (AbstractChildObject) predIter
377: .next();
378: Element hrefEl = document.createElementNS(NamespaceType.DAV
379: .getURI(), NamespaceType.DAV.getPrefix() + ":"
380: + HarmonisePropertiesManager.TAG_HREF);
381: hrefEl.appendChild(document
382: .createTextNode(HarmoniseNameResolver
383: .getVersionPath(tmpChild)));
384: predecessorSetEl.appendChild(hrefEl);
385: }
386:
387: return predecessorSetEl;
388: }
389:
390: /**
391: * Adds a populated 'checkedout-set' element to <code>properties</code>.
392: *
393: * @param document
394: * @param properties
395: * @throws DataAccessException
396: * @throws DOMException
397: * @throws NameResolverException
398: */
399: private Element getCheckedOutSet(Document document)
400: throws DataAccessException, DOMException,
401: NameResolverException {
402: List pends = m_child.getPendingVersions();
403:
404: Iterator iter = pends.iterator();
405: Element checkoutSetEl = document.createElementNS(
406: NamespaceType.DAV.getURI(), TAG_CHECKOUT_SET);
407: checkoutSetEl.setPrefix(NamespaceType.DAV.getPrefix());
408: while (iter.hasNext()) {
409: AbstractChildObject tmpChild = (AbstractChildObject) iter
410: .next();
411: Element hrefEl = document.createElementNS(NamespaceType.DAV
412: .getURI(), NamespaceType.DAV.getPrefix() + ":"
413: + HarmonisePropertiesManager.TAG_HREF);
414: hrefEl.appendChild(document
415: .createTextNode(HarmoniseNameResolver
416: .getVersionPath(tmpChild)));
417: checkoutSetEl.appendChild(hrefEl);
418: }
419:
420: return checkoutSetEl;
421: }
422:
423: /**
424: * Update the version properties that are unique to the
425: * repository implementation.
426: *
427: * @param document
428: * @throws WebDAVException
429: */
430: public void updateVersionProperties(Document document)
431: throws WebDAVException {
432:
433: if (m_child == null) {
434: throw new WebDAVException(WebDAVStatus.SC_NOT_FOUND,
435: "Could not find resource at this location");
436: }
437:
438: try {
439: Element properties = document.getDocumentElement();
440:
441: properties.appendChild(getSuccessors(document));
442:
443: properties.appendChild(getPredecessors(document));
444:
445: if (m_child.isPendingVersion() == true) {
446: Element checkedOutEl = getCheckedOut(document);
447: properties.appendChild(checkedOutEl);
448:
449: } else if (m_child.isLiveVersion() == true) {
450:
451: Element checkedInEl = getCheckedIn(document);
452: properties.appendChild(checkedInEl);
453:
454: properties.appendChild(getCheckedOutSet(document));
455:
456: } else if (m_child.isHistorical() == true
457: && m_child.getLiveVersion() == null) {
458: AbstractParentObject parent = m_child.getRealParent();
459: if (parent != null) {
460: List archived = parent.getArchivedChildren();
461:
462: if (archived.contains(m_child) == true) {
463: Element checkedInEl = getCheckedIn(document);
464: properties.appendChild(checkedInEl);
465: }
466: }
467:
468: }
469:
470: // version name
471: Element versionNameEl = getVersionName(document);
472: properties.appendChild(versionNameEl);
473:
474: //supported methods
475: Element supMethodsEl = getSupportedMethods(document);
476:
477: properties.appendChild(supMethodsEl);
478:
479: //supported live props
480: Element supLivePropsEl = getSupportedLivePropertySet(document);
481:
482: properties.appendChild(supLivePropsEl);
483:
484: //supported report set
485: Element supReportsEl = getSupportedReportSet(document);
486: properties.appendChild(supReportsEl);
487:
488: if (isVersioned() == true) {
489: Element autoversionEl = getAutoVersion(document);
490:
491: properties.appendChild(autoversionEl);
492: }
493:
494: } catch (DataAccessException e) {
495: m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
496: throw new WebDAVException(
497: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
498: .getLocalizedMessage());
499: } catch (NameResolverException e) {
500: throw new WebDAVException(
501: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
502: .getLocalizedMessage());
503: }
504:
505: }
506:
507: /**
508: * Returns a 'supported-method-set' element, correct for this resource.
509: *
510: * @param document
511: * @return
512: */
513: private Element getSupportedMethods(Document document) {
514: Element supMethodsEl = document.createElementNS(
515: NamespaceType.DAV.getURI(), TAG_SUPPORTED_METHOD_SET);
516:
517: supMethodsEl.setPrefix(NamespaceType.DAV.getPrefix());
518:
519: //TODO implement - client doesn't support this yet anyway
520:
521: return supMethodsEl;
522: }
523:
524: /**
525: * Returns <code>true</code> if this resource is under version control in the
526: * DAV sense, i.e. it has a live Harmonise version.
527: *
528: * @return
529: */
530: public boolean isVersioned() throws WebDAVException {
531: boolean bIsVersioned = false;
532:
533: if (m_child != null) {
534: try {
535: bIsVersioned = (m_child.isHistorical() == true || m_child
536: .getLiveVersion() != null);
537: } catch (DataAccessException e) {
538: throw new WebDAVException(
539: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
540: .getLocalizedMessage());
541: }
542: }
543:
544: return bIsVersioned;
545: }
546:
547: /**
548: * @param names
549: * @return
550: */
551: protected boolean isAllNonPropertyInstanceProperties(
552: PropertyName[] names) {
553: boolean bIsAllLive = true;
554:
555: int i = 0;
556:
557: while (bIsAllLive == true && i < names.length) {
558: String sLocalPropName = names[i].getLocal();
559:
560: bIsAllLive = false;
561:
562: bIsAllLive = isLive(sLocalPropName);
563:
564: if (bIsAllLive == false) {
565: bIsAllLive = isVersionProperty(sLocalPropName);
566: }
567:
568: if (bIsAllLive == false) {
569: bIsAllLive = sLocalPropName.equals(TAG_TITLE)
570: || sLocalPropName.equals(DAVRange.TAG_RANGE)
571: || sLocalPropName.equals(DAVDomain.TAG_DOMAIN)
572: || sLocalPropName.equals(TAG_LOCKDISCOVERY);
573: }
574:
575: i++;
576: }
577:
578: return bIsAllLive;
579: }
580:
581: /* (non-Javadoc)
582: * @see com.ibm.webdav.impl.PropertiesManager#getProperties(com.ibm.webdav.PropertyName[])
583: */
584: public MultiStatus getProperties(PropertyName[] names)
585: throws WebDAVException {
586: //assuming a partial PROPFIND will only be looking
587: //for non PropertyInstance properties and thus only optimising for
588: //that case
589:
590: MultiStatus result = null;
591: if (isAllNonPropertyInstanceProperties(names) == true) {
592: try {
593: result = new MultiStatus();
594:
595: DocumentBuilderFactory factory = DocumentBuilderFactory
596: .newInstance();
597: factory.setNamespaceAware(true);
598:
599: org.w3c.dom.Document propsDoc = factory
600: .newDocumentBuilder().newDocument();
601:
602: Element properties = (Element) propsDoc
603: .createElement("properties");
604: properties.setAttribute("xmlns:D", NamespaceType.DAV
605: .getURI());
606: propsDoc.appendChild(properties);
607:
608: //fill the document with the live props
609: this .updateLiveProperties(propsDoc);
610:
611: PropertyResponse newResponse = new PropertyResponse(
612: resource.getURL().getFile());
613:
614: //loop through names and find property values
615: for (int i = 0; i < names.length; i++) {
616: PropertyName tempName = names[i];
617:
618: String propName = tempName.getLocal();
619:
620: if (propName.equals(TAG_TITLE) && m_child != null) {
621: Element elTm = propsDoc.createElementNS(
622: names[i].getNamespace(), "X:"
623: + names[i].getLocal());
624:
625: elTm.setAttribute("xmlns:X", names[i]
626: .getNamespace());
627:
628: elTm.appendChild(propsDoc
629: .createTextNode(m_child
630: .getDisplayName()));
631:
632: newResponse.addProperty(names[i], elTm,
633: WebDAVStatus.SC_OK);
634: } else if (propName.equals(TAG_HARMONISE_ID)
635: && m_child != null) {
636: Element elTm = propsDoc.createElementNS(
637: names[i].getNamespace(), "X:"
638: + names[i].getLocal());
639:
640: elTm.setAttribute("xmlns:X", names[i]
641: .getNamespace());
642:
643: elTm.appendChild(propsDoc.createTextNode(String
644: .valueOf(m_child.getId())));
645:
646: newResponse.addProperty(names[i], elTm,
647: WebDAVStatus.SC_OK);
648: } else if (propName.equals(TAG_DESCRIPTION)
649: && m_child != null) {
650: Element elTm = propsDoc.createElementNS(
651: names[i].getNamespace(), "X:"
652: + names[i].getLocal());
653:
654: elTm.setAttribute("xmlns:X", names[i]
655: .getNamespace());
656:
657: elTm.appendChild(propsDoc
658: .createTextNode(m_child.getSummary()));
659:
660: newResponse.addProperty(names[i], elTm,
661: WebDAVStatus.SC_OK);
662: } else if (propName.equals(TAG_LOCKDISCOVERY)
663: && m_child != null
664: && m_child.isLocked() == true) {
665: Element elTm = propsDoc.createElementNS(
666: names[i].getNamespace(), "X:"
667: + names[i].getLocal());
668:
669: elTm.setAttribute("xmlns:X", names[i]
670: .getNamespace());
671:
672: addLockData(elTm);
673:
674: newResponse.addProperty(names[i], elTm,
675: WebDAVStatus.SC_OK);
676: } else if (propName.equals(DAVRange.TAG_RANGE)
677: && m_child != null
678: && m_child instanceof Property) {
679:
680: newResponse.addProperty(names[i],
681: getRangeElement(propsDoc,
682: (Property) m_child),
683: WebDAVStatus.SC_OK);
684: } else if (propName.equals(DAVDomain.TAG_DOMAIN)
685: && m_child != null
686: && m_child instanceof Property) {
687: DAVDomain davDomain = new DAVDomain(m_dsi,
688: ((Property) m_child).getDomains());
689:
690: Element domainEl = davDomain.asXML(propsDoc);
691:
692: newResponse.addProperty(names[i],
693: getRangeElement(propsDoc,
694: (Property) m_child),
695: WebDAVStatus.SC_OK);
696: } else if (isVersioned()
697: && isVersionProperty(propName)) {
698: Element propEl = getVersionProperty(propsDoc,
699: propName);
700:
701: if (propEl == null) {
702: Element elTm = propsDoc.createElementNS(
703: names[i].getNamespace(), "X:"
704: + names[i].getLocal());
705:
706: elTm.setAttribute("xmlns:X", names[i]
707: .getNamespace());
708:
709: newResponse.addProperty(names[i], elTm,
710: WebDAVStatus.SC_NOT_FOUND);
711: } else {
712: newResponse.addProperty(names[i], propEl,
713: WebDAVStatus.SC_OK);
714: }
715:
716: } else {
717: NodeList nodes = properties
718: .getElementsByTagNameNS(
719: NamespaceType.DAV.getURI(),
720: propName);
721:
722: if (nodes.getLength() > 0) {
723: Element propEl = (Element) nodes.item(0);
724:
725: newResponse.addProperty(tempName, propEl,
726: WebDAVStatus.SC_OK);
727: } else {
728: Element elTm = propsDoc.createElementNS(
729: names[i].getNamespace(), "X:"
730: + names[i].getLocal());
731:
732: elTm.setAttribute("xmlns:X", names[i]
733: .getNamespace());
734:
735: newResponse.addProperty(names[i], elTm,
736: WebDAVStatus.SC_NOT_FOUND);
737: }
738: }
739:
740: }
741:
742: result.addResponse(newResponse);
743: } catch (ServerException e) {
744: m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
745: throw new WebDAVException(
746: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
747: .getLocalizedMessage());
748: } catch (DOMException e) {
749: m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
750: throw new WebDAVException(
751: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
752: .getLocalizedMessage());
753: } catch (ParserConfigurationException e) {
754: m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
755: throw new WebDAVException(
756: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
757: .getLocalizedMessage());
758: } catch (FactoryConfigurationError e) {
759: m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
760: throw new WebDAVException(
761: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
762: .getLocalizedMessage());
763: } catch (DataAccessException e) {
764: m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
765: throw new WebDAVException(
766: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
767: .getLocalizedMessage());
768: } catch (WebDAVException e) {
769: m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
770: throw new WebDAVException(
771: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
772: .getLocalizedMessage());
773: } catch (NameResolverException e) {
774: m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
775: throw new WebDAVException(
776: WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e
777: .getLocalizedMessage());
778: }
779: } else {
780: result = super.getProperties(names);
781: }
782:
783: return result;
784: }
785:
786: }
|