jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1232035 - in /jackrabbit/trunk: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/ jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/...
Date Mon, 16 Jan 2012 15:43:12 GMT
Author: reschke
Date: Mon Jan 16 15:43:12 2012
New Revision: 1232035

URL: http://svn.apache.org/viewvc?rev=1232035&view=rev
Log:
Code cleanup (use QNames in more places, and avoid putting an XML attribute in observation
into a namespace); remove unused imports.

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/xml/DomUtil.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java?rev=1232035&r1=1232034&r2=1232035&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
Mon Jan 16 15:43:12 2012
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.webdav.jcr.observation;
 
 import org.apache.jackrabbit.commons.webdav.EventUtil;
-import org.apache.jackrabbit.commons.webdav.JcrRemotingConstants;
 import org.apache.jackrabbit.server.SessionProviderImpl;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.AdditionalEventInfo;
@@ -45,12 +44,9 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import com.sun.org.apache.xalan.internal.xsltc.dom.ExtendedSAX;
-
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.Value;
 import javax.jcr.observation.Event;
 import javax.jcr.observation.EventIterator;
 import javax.jcr.observation.EventListener;
@@ -476,8 +472,7 @@ public class SubscriptionImpl implements
                                     .getSessionAttribute(SessionProviderImpl.ATTRIBUTE_SESSION_ID);
                             boolean isLocal = forSessionId
                                     .equals(eventforSessionId);
-                            DomUtil.setAttribute(bundle, XML_EVENT_LOCAL,
-                                    NAMESPACE, Boolean.toString(isLocal));
+                            DomUtil.setAttribute(bundle, XML_EVENT_LOCAL, null, Boolean.toString(isLocal));
                         } catch (UnsupportedRepositoryOperationException ex) {
                             // optional feature
                         }

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java?rev=1232035&r1=1232034&r2=1232035&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
Mon Jan 16 15:43:12 2012
@@ -61,11 +61,10 @@ public class EventImpl
             Element eventElement, NamePathResolver resolver, QValueFactory qvFactory) throws
NamespaceException,
             IllegalNameException {
         super(getSpiEventType(eventType), eventPath, eventId, parentId, getNameSafe(
-                DomUtil.getChildTextTrim(eventElement, XML_EVENTPRIMARNODETYPE, NAMESPACE),
resolver), getNames(
-                DomUtil.getChildren(eventElement, XML_EVENTMIXINNODETYPE, NAMESPACE), resolver),
userId, DomUtil
-                .getChildTextTrim(eventElement, XML_EVENTUSERDATA, NAMESPACE), Long.parseLong(DomUtil.getChildTextTrim(
-                eventElement, XML_EVENTDATE, NAMESPACE)), getEventInfo(
-                DomUtil.getChildElement(eventElement, XML_EVENTINFO, NAMESPACE), resolver,
qvFactory));
+                DomUtil.getChildTextTrim(eventElement, N_EVENTPRIMARYNODETYPE), resolver),
getNames(
+                DomUtil.getChildren(eventElement, N_EVENTMIXINNODETYPE), resolver), userId,
DomUtil.getChildTextTrim(
+                eventElement, N_EVENTUSERDATA), Long.parseLong(DomUtil.getChildTextTrim(eventElement,
N_EVENTDATE)),
+                getEventInfo(DomUtil.getChildElement(eventElement, N_EVENTINFO), resolver,
qvFactory));
     }
 
     //--------------------------------------------------------------------------

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1232035&r1=1232034&r2=1232035&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Mon Jan 16 15:43:12 2012
@@ -2235,14 +2235,12 @@ public class RepositoryServiceImpl imple
             } else {
                 Element discEl = disc.toXml(DomUtil.createDocument());
                 ElementIterator it = DomUtil.getChildren(discEl,
-                        ObservationConstants.XML_EVENTBUNDLE,
-                        ObservationConstants.NAMESPACE);
+                        ObservationConstants.N_EVENTBUNDLE);
                 List<EventBundle> bundles = new ArrayList<EventBundle>();
                 while (it.hasNext()) {
                     Element bundleElement = it.nextElement();
                     String value = DomUtil.getAttribute(bundleElement,
-                            ObservationConstants.XML_EVENT_LOCAL,
-                            ObservationConstants.NAMESPACE);
+                            ObservationConstants.XML_EVENT_LOCAL, null);
                     // check if it matches a batch id recently submitted
                     boolean isLocal = false;
                     if (value != null) {
@@ -2270,7 +2268,7 @@ public class RepositoryServiceImpl imple
 
     private List<Event> buildEventList(Element bundleElement, SessionInfoImpl sessionInfo)
throws IllegalNameException, NamespaceException {
         List<Event> events = new ArrayList<Event>();
-        ElementIterator eventElementIterator = DomUtil.getChildren(bundleElement, ObservationConstants.XML_EVENT,
ObservationConstants.NAMESPACE);
+        ElementIterator eventElementIterator = DomUtil.getChildren(bundleElement, ObservationConstants.N_EVENT);
 
         String userId = null;
 
@@ -2285,7 +2283,7 @@ public class RepositoryServiceImpl imple
 
         while (eventElementIterator.hasNext()) {
             Element evElem = eventElementIterator.nextElement();
-            Element typeEl = DomUtil.getChildElement(evElem, ObservationConstants.XML_EVENTTYPE,
ObservationConstants.NAMESPACE);
+            Element typeEl = DomUtil.getChildElement(evElem, ObservationConstants.N_EVENTTYPE);
             EventType[] et = DefaultEventType.createFromXml(typeEl);
             if (et.length == 0 || et.length > 1) {
                 // should not occur.
@@ -2346,7 +2344,7 @@ public class RepositoryServiceImpl imple
 
             if (userId == null) {
                 // user id not retrieved from container
-                userId = DomUtil.getChildTextTrim(evElem, ObservationConstants.XML_EVENTUSERID,
ObservationConstants.NAMESPACE);
+                userId = DomUtil.getChildTextTrim(evElem, ObservationConstants.N_EVENTUSERID);
             }
 
             events.add(new EventImpl(eventId, eventPath, parentId, type, userId, evElem,

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java?rev=1232035&r1=1232034&r2=1232035&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
Mon Jan 16 15:43:12 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.webdav.observation;
 
+import javax.xml.namespace.QName;
+
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.xml.Namespace;
 
@@ -78,7 +80,18 @@ public interface ObservationConstants {
     public static final String XML_EVENTINFO = "eventinfo";
     public static final String XML_EVENTPRIMARNODETYPE = "eventprimarynodetype";
     public static final String XML_EVENTMIXINNODETYPE = "eventmixinnodetype";
-    
+
+    public static final QName N_EVENT = new QName(NAMESPACE.getURI(), XML_EVENT);
+    public static final QName N_EVENTBUNDLE = new QName(NAMESPACE.getURI(), XML_EVENTBUNDLE);
+    public static final QName N_EVENTDATE = new QName(NAMESPACE.getURI(), XML_EVENTDATE);
+    public static final QName N_EVENTDISCOVERY = new QName(NAMESPACE.getURI(), XML_EVENTDISCOVERY);
+    public static final QName N_EVENTINFO = new QName(NAMESPACE.getURI(), XML_EVENTINFO);
+    public static final QName N_EVENTMIXINNODETYPE = new QName(NAMESPACE.getURI(), XML_EVENTMIXINNODETYPE);
+    public static final QName N_EVENTPRIMARYNODETYPE = new QName(NAMESPACE.getURI(), XML_EVENTPRIMARNODETYPE);
+    public static final QName N_EVENTTYPE = new QName(NAMESPACE.getURI(), XML_EVENTTYPE);
+    public static final QName N_EVENTUSERDATA = new QName(NAMESPACE.getURI(), XML_EVENTUSERDATA);
+    public static final QName N_EVENTUSERID = new QName(NAMESPACE.getURI(), XML_EVENTUSERID);
+
     //---< Property Names >-----------------------------------------------------
     /**
      * The protected subscription discovery property is used to find out about

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/xml/DomUtil.java?rev=1232035&r1=1232034&r2=1232035&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
Mon Jan 16 15:43:12 2012
@@ -253,6 +253,22 @@ public class DomUtil {
     }
 
     /**
+     * Calls {@link #getTextTrim(Element)} on the first child element that matches
+     * the given name.
+     *
+     * @param parent
+     * @param childName
+     * @return text contained in the first child that matches the given name
+     * or <code>null</code>. Note, that leading and trailing whitespace
+     * is removed from the text.
+     * @see #getTextTrim(Element)
+     */
+    public static String getChildTextTrim(Element parent, QName childName) {
+        Element child = getChildElement(parent, childName);
+        return (child == null) ? null : getTextTrim(child);
+    }
+
+    /**
      * Returns true if the given parent node has a child element that matches
      * the specified local name and namespace.
      *



Mime
View raw message