You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by it...@apache.org on 2011/01/24 18:27:42 UTC

svn commit: r1062890 - /incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/RdfList.java

Author: ito
Date: Mon Jan 24 17:27:42 2011
New Revision: 1062890

URL: http://svn.apache.org/viewvc?rev=1062890&view=rev
Log:
CLEREZZA-407: invoke create broken-list.nt as doPrivileged block

Modified:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/RdfList.java

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/RdfList.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/RdfList.java?rev=1062890&r1=1062889&r2=1062890&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/RdfList.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/RdfList.java Mon Jan 24 17:27:42 2011
@@ -18,8 +18,9 @@
  */
 package org.apache.clerezza.rdf.utils;
 
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.AbstractList;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -247,28 +248,31 @@ public class RdfList extends AbstractLis
 		return (NonLiteral) tc.filter(list, RDF.rest, null).next().getObject();
 	}
 
-	private Resource getFirstEntry(NonLiteral listResource) {
+	private Resource getFirstEntry(final NonLiteral listResource) {
 		try {
 			return tc.filter(listResource, RDF.first, null).next().getObject();
-		} catch (NullPointerException e) {
-			try {
-				final FileOutputStream fileOutputStream = new FileOutputStream("/tmp/broken-list.nt");
-				final GraphNode graphNode = new GraphNode(listResource, tc);
-				Serializer.getInstance().serialize(
-						fileOutputStream,
-						graphNode.getNodeContext(),
-						SupportedFormat.N_TRIPLE);
-				fileOutputStream.flush();
-				logger.warn("GraphNode: "+graphNode);
-				final Iterator<UriRef> properties = graphNode.getProperties();
-				while (properties.hasNext()) {
-					logger.warn("available: "+properties.next());
-				}
+		} catch (final NullPointerException e) {
+			RuntimeException runtimeEx = AccessController.doPrivileged(new PrivilegedAction<RuntimeException>() {
+				@Override
+				public RuntimeException run(){
+					try {
+						final FileOutputStream fileOutputStream = new FileOutputStream("/tmp/broken-list.nt");
+						final GraphNode graphNode = new GraphNode(listResource, tc);
+						Serializer.getInstance().serialize(fileOutputStream, graphNode.getNodeContext(), SupportedFormat.N_TRIPLE);
+						fileOutputStream.flush();
+						logger.warn("GraphNode: " + graphNode);
+						final Iterator<UriRef> properties = graphNode.getProperties();
+						while (properties.hasNext()) {
+							logger.warn("available: " + properties.next());
+						}
+						return new RuntimeException("broken list " + listResource, e);
+					} catch (Exception ex) {
+						return new RuntimeException(ex);
+					}
 
-				throw new RuntimeException("broken list "+listResource, e);
-			} catch (Exception ex) {
-				throw new RuntimeException(ex);
-			}
+				}
+			});
+			throw runtimeEx;
 		}
 	}