jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r891242 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: persistence/bundle/ persistence/pool/ security/authorization/ security/principal/ state/
Date Wed, 16 Dec 2009 14:06:41 GMT
Author: jukka
Date: Wed Dec 16 14:06:40 2009
New Revision: 891242

URL: http://svn.apache.org/viewvc?rev=891242&view=rev
Log:
JCR-2435: [patch] Fix overly specific casting in core

Patch by Dave Brosius, plus some Java 5 cleanups to ChildNodeEntries

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=891242&r1=891241&r2=891242&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
Wed Dec 16 14:06:40 2009
@@ -251,7 +251,7 @@
                 if (nsFile.exists()) {
                     nsIndex = new HashMapIndex(nsFile);
                 } else {
-                    nsIndex = (NamespaceRegistryImpl) context.getNamespaceRegistry();
+                    nsIndex = (StringIndex) context.getNamespaceRegistry();
                 }
             }
             return nsIndex;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java?rev=891242&r1=891241&r2=891242&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
Wed Dec 16 14:06:40 2009
@@ -251,7 +251,7 @@
                 if (nsFile.exists()) {
                     nsIndex = new HashMapIndex(nsFile);
                 } else {
-                    nsIndex = (NamespaceRegistryImpl) context.getNamespaceRegistry();
+                    nsIndex = (StringIndex) context.getNamespaceRegistry();
                 }
             }
             return nsIndex;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java?rev=891242&r1=891241&r2=891242&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java
Wed Dec 16 14:06:40 2009
@@ -174,7 +174,7 @@
         }
         session = (SessionImpl) systemSession;
         observationMgr = systemSession.getWorkspace().getObservationManager();
-        resolver = (SessionImpl) systemSession;
+        resolver = (NamePathResolver) systemSession;
 
         privAll = PrivilegeRegistry.getBits(new Privilege[] {session.getAccessControlManager().privilegeFromName(Privilege.JCR_ALL)});
         privRead = PrivilegeRegistry.getBits(new Privilege[] {session.getAccessControlManager().privilegeFromName(Privilege.JCR_READ)});
@@ -196,4 +196,4 @@
     public boolean isLive() {
         return initialized && session.isLive();
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java?rev=891242&r1=891241&r2=891242&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java
Wed Dec 16 14:06:40 2009
@@ -93,7 +93,7 @@
         // listen to modifications of group-membership
         String[] ntNames = new String[1];
         if (securitySession instanceof SessionImpl) {
-            NameResolver resolver = (SessionImpl) securitySession;
+            NameResolver resolver = (NameResolver) securitySession;
             ntNames[0] = resolver.getJCRName(UserManagerImpl.NT_REP_GROUP);
             pMembers = resolver.getJCRName(UserManagerImpl.P_MEMBERS);
             pPrincipalName = resolver.getJCRName(UserManagerImpl.P_PRINCIPAL_NAME);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java?rev=891242&r1=891241&r2=891242&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java
Wed Dec 16 14:06:40 2009
@@ -68,20 +68,22 @@
         return (ChildNodeEntry) entries.get(id);
     }
 
+    @SuppressWarnings("unchecked")
     List<ChildNodeEntry> get(Name nodeName) {
         Object obj = nameMap.get(nodeName);
         if (obj == null) {
             return Collections.emptyList();
         }
-        if (obj instanceof ArrayList<?>) {
+        if (obj instanceof List<?>) {
             // map entry is a list of siblings
-            return Collections.unmodifiableList((ArrayList<ChildNodeEntry>) obj);
+            return Collections.unmodifiableList((List<ChildNodeEntry>) obj);
         } else {
             // map entry is a single child node entry
             return Collections.singletonList((ChildNodeEntry) obj);
         }
     }
 
+    @SuppressWarnings("unchecked")
     ChildNodeEntry get(Name nodeName, int index) {
         if (index < 1) {
             throw new IllegalArgumentException("index is 1-based");
@@ -91,9 +93,9 @@
         if (obj == null) {
             return null;
         }
-        if (obj instanceof ArrayList<?>) {
+        if (obj instanceof List<?>) {
             // map entry is a list of siblings
-            ArrayList<ChildNodeEntry> siblings = (ArrayList<ChildNodeEntry>)
obj;
+            List<ChildNodeEntry> siblings = (List<ChildNodeEntry>) obj;
             if (index <= siblings.size()) {
                 return siblings.get(index - 1);
             }
@@ -106,25 +108,26 @@
         return null;
     }
 
+    @SuppressWarnings("unchecked")
     ChildNodeEntry add(Name nodeName, NodeId id) {
         ensureModifiable();
-        List<Object> siblings = null;
+        List<ChildNodeEntry> siblings = null;
         int index = 0;
         Object obj = nameMap.get(nodeName);
         if (obj != null) {
-            if (obj instanceof ArrayList<?>) {
+            if (obj instanceof List<?>) {
                 // map entry is a list of siblings
-                siblings = (ArrayList<Object>) obj;
+                siblings = (List<ChildNodeEntry>) obj;
                 if (siblings.size() > 0) {
                     // reuse immutable Name instance from 1st same name sibling
                     // in order to help gc conserving memory
-                    nodeName = ((ChildNodeEntry) siblings.get(0)).getName();
+                    nodeName = siblings.get(0).getName();
                 }
             } else {
                 // map entry is a single child node entry,
                 // convert to siblings list
-                siblings = new ArrayList<Object>();
-                siblings.add(obj);
+                siblings = new ArrayList<ChildNodeEntry>();
+                siblings.add((ChildNodeEntry) obj);
                 nameMap.put(nodeName, siblings);
             }
             index = siblings.size();
@@ -150,6 +153,7 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     public ChildNodeEntry remove(Name nodeName, int index) {
         if (index < 1) {
             throw new IllegalArgumentException("index is 1-based");
@@ -173,7 +177,7 @@
         }
 
         // map entry is a list of siblings
-        List<ChildNodeEntry> siblings = (ArrayList<ChildNodeEntry>) obj;
+        List<ChildNodeEntry> siblings = (List<ChildNodeEntry>) obj;
         if (index > siblings.size()) {
             return null;
         }
@@ -315,10 +319,9 @@
         }
     }
 
-    public boolean containsAll(Collection c) {
-        Iterator iter = c.iterator();
-        while (iter.hasNext()) {
-            if (!contains(iter.next())) {
+    public boolean containsAll(Collection<?> c) {
+        for (Object entry : c) {
+            if (!contains(entry)) {
                 return false;
             }
         }
@@ -379,6 +382,7 @@
         return toArray(array);
     }
 
+    @SuppressWarnings("unchecked")
     public Object[] toArray(Object[] a) {
         if (!a.getClass().getComponentType().isAssignableFrom(ChildNodeEntry.class)) {
             throw new ArrayStoreException();
@@ -407,11 +411,11 @@
         throw new UnsupportedOperationException();
     }
 
-    public boolean addAll(Collection c) {
+    public boolean addAll(Collection<? extends ChildNodeEntry> c) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean addAll(int index, Collection c) {
+    public boolean addAll(int index, Collection<? extends ChildNodeEntry> c) {
         throw new UnsupportedOperationException();
     }
 
@@ -427,11 +431,11 @@
         throw new UnsupportedOperationException();
     }
 
-    public boolean removeAll(Collection c) {
+    public boolean removeAll(Collection<?> c) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean retainAll(Collection c) {
+    public boolean retainAll(Collection<?> c) {
         throw new UnsupportedOperationException();
     }
 
@@ -492,7 +496,7 @@
      * Initializes the name and entries map with unmodifiable empty instances.
      */
     private void init() {
-        nameMap = Collections.EMPTY_MAP;
+        nameMap = Collections.emptyMap();
         entries = EmptyLinkedMap.INSTANCE;
         shared = false;
     }
@@ -501,18 +505,19 @@
      * Ensures that the {@link #nameMap} and {@link #entries} map are
      * modifiable.
      */
+    @SuppressWarnings("unchecked")
     private void ensureModifiable() {
         if (nameMap == Collections.EMPTY_MAP) {
             nameMap = new HashMap<Name, Object>();
             entries = new LinkedMap();
         } else if (shared) {
             entries = (LinkedMap) entries.clone();
-            nameMap = (Map<Name, Object>) ((HashMap<Name, Object>) nameMap).clone();
-            for (Iterator it = nameMap.entrySet().iterator(); it.hasNext(); ) {
-                Map.Entry entry = (Map.Entry) it.next();
+            nameMap = new HashMap<Name, Object>(nameMap);
+            for (Map.Entry<Name, Object> entry : nameMap.entrySet()) {
                 Object value = entry.getValue();
-                if (value instanceof ArrayList) {
-                    entry.setValue(((ArrayList) value).clone());
+                if (value instanceof List<?>) {
+                    entry.setValue(new ArrayList<ChildNodeEntry>(
+                            (List<ChildNodeEntry>) value));
                 }
             }
             shared = false;



Mime
View raw message