This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.jcr.contentloader-2.0.6 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git
commit d292bfb095039b1899695e466009c207819bf5de Author: Carsten Ziegeler <cziege...@apache.org> AuthorDate: Tue Nov 3 23:39:09 2009 +0000 Clean up code git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentloader@832608 13f79535-47bb-0310-9956-ffa450edef68 --- .../internal/DefaultContentCreator.java | 36 ++++++++++------------ .../sling/jcr/contentloader/internal/Loader.java | 8 ----- .../contentloader/internal/readers/XmlReader.java | 11 +++---- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java index c6f8785..c28e833 100644 --- a/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java +++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java @@ -98,12 +98,12 @@ public class DefaultContentCreator implements ContentCreator { * A one time use seed to randomize the user location. */ private static final long INSTANCE_SEED = System.currentTimeMillis(); - + /** * The number of levels folder used to store a user, could be a configuration option. */ private static final int STORAGE_LEVELS = 3; - + /** * Constructor. * @param jcrContentHelper Helper class to get the mime type of a file @@ -642,7 +642,7 @@ public class DefaultContentCreator implements ContentCreator { final Node parentNode = this.parentNodeStack.peek(); Session session = parentNode.getSession(); - + UserManager userManager = AccessControlUtil.getUserManager(session); Authorizable authorizable = userManager.getAuthorizable(name); if (authorizable == null) { @@ -660,9 +660,8 @@ public class DefaultContentCreator implements ContentCreator { throw new RepositoryException( "A user already exists with the requested name: " + name); - } else { - //group already exists so just update it below - } + } + //group already exists so just update it below } //update the group members if (members != null) { @@ -691,7 +690,7 @@ public class DefaultContentCreator implements ContentCreator { Map<String, Object> extraProperties) throws RepositoryException { final Node parentNode = this.parentNodeStack.peek(); Session session = parentNode.getSession(); - + UserManager userManager = AccessControlUtil.getUserManager(session); Authorizable authorizable = userManager.getAuthorizable(name); if (authorizable == null) { @@ -712,9 +711,8 @@ public class DefaultContentCreator implements ContentCreator { throw new RepositoryException( "A group already exists with the requested name: " + name); - } else { - //user already exists so just update it below - } + } + //user already exists so just update it below } if (extraProperties != null) { ValueFactory valueFactory = session.getValueFactory(); @@ -725,7 +723,7 @@ public class DefaultContentCreator implements ContentCreator { } } } - + /** * @param item * @return a parent path fragment for the item. @@ -744,7 +742,7 @@ public class DefaultContentCreator implements ContentCreator { throw new RepositoryException("Unable to hash the path.", e); } } - + /* (non-Javadoc) * @see org.apache.sling.jcr.contentloader.internal.ContentCreator#createAce(java.lang.String, java.lang.String, java.lang.String[], java.lang.String[]) @@ -754,7 +752,7 @@ public class DefaultContentCreator implements ContentCreator { throws RepositoryException { final Node parentNode = this.parentNodeStack.peek(); Session session = parentNode.getSession(); - + UserManager userManager = AccessControlUtil.getUserManager(session); Authorizable authorizable = userManager.getAuthorizable(principalId); if (authorizable == null) { @@ -762,7 +760,7 @@ public class DefaultContentCreator implements ContentCreator { } String resourcePath = parentNode.getPath(); - + AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session); AccessControlList updatedAcl = null; AccessControlPolicyIterator applicablePolicies = accessControlManager.getApplicablePolicies(resourcePath); @@ -784,10 +782,10 @@ public class DefaultContentCreator implements ContentCreator { if (deniedPrivilegeNames != null) { postedPrivilegeNames.addAll(Arrays.asList(deniedPrivilegeNames)); } - + List<Privilege> preserveGrantedPrivileges = new ArrayList<Privilege>(); List<Privilege> preserveDeniedPrivileges = new ArrayList<Privilege>(); - + //keep track of the existing Aces for the target principal AccessControlEntry[] accessControlEntries = updatedAcl.getAccessControlEntries(); List<AccessControlEntry> oldAces = new ArrayList<AccessControlEntry>(); @@ -818,7 +816,7 @@ public class DefaultContentCreator implements ContentCreator { updatedAcl.removeAccessControlEntry(ace); } } - + //add a fresh ACE with the granted privileges List<Privilege> grantedPrivilegeList = new ArrayList<Privilege>(); for (String name : grantedPrivilegeNames) { @@ -830,7 +828,7 @@ public class DefaultContentCreator implements ContentCreator { } //add the privileges that should be preserved grantedPrivilegeList.addAll(preserveGrantedPrivileges); - + if (grantedPrivilegeList.size() > 0) { Principal principal = authorizable.getPrincipal(); updatedAcl.addAccessControlEntry(principal, grantedPrivilegeList.toArray(new Privilege[grantedPrivilegeList.size()])); @@ -857,5 +855,5 @@ public class DefaultContentCreator implements ContentCreator { } accessControlManager.setPolicy(resourcePath, updatedAcl); - } + } } diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java index ef134f6..ef41c58 100644 --- a/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java +++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java @@ -462,7 +462,6 @@ public class Loader { PathEntry configuration) throws RepositoryException { final String resourcePath = resourceUrl.getPath().toLowerCase(); - InputStream ins = null; try { // special treatment for system view imports if (resourcePath.endsWith(EXT_JCR_XML)) { @@ -489,13 +488,6 @@ public class Loader { throw re; } catch (Throwable t) { throw new RepositoryException(t.getMessage(), t); - } finally { - if (ins != null) { - try { - ins.close(); - } catch (IOException ignore) { - } - } } } diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java index 7047685..4f16bd6 100644 --- a/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java +++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java @@ -20,14 +20,16 @@ package org.apache.sling.jcr.contentloader.internal.readers; import java.io.BufferedInputStream; import java.io.Closeable; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; -import java.io.File; -import java.net.URL; import java.net.MalformedURLException; -import java.net.URISyntaxException; +import java.net.URL; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; @@ -36,9 +38,6 @@ import java.util.Map; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.text.DateFormat; import javax.jcr.PropertyType; import javax.jcr.RepositoryException; -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" <commits@sling.apache.org>.