[Mulgara-svn] r2009 - in trunk/src/jar: resolver/java/org/mulgara/resolver resolver-spi/java/org/mulgara/content

alexhall at mulgara.org alexhall at mulgara.org
Tue Jul 19 18:22:42 UTC 2011


Author: alexhall
Date: 2011-07-19 18:22:41 +0000 (Tue, 19 Jul 2011)
New Revision: 2009

Removed:
   trunk/src/jar/resolver-spi/java/org/mulgara/content/ContentLoader.java
Modified:
   trunk/src/jar/resolver-spi/java/org/mulgara/content/ContentHandlerManager.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/ContentHandlerManagerImpl.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java
Log:
Removing un-implemented ContentLoader interface and associated SetGraphOperation.preExecute hack

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/ContentHandlerManagerImpl.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/ContentHandlerManagerImpl.java	2011-07-19 18:15:40 UTC (rev 2008)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/ContentHandlerManagerImpl.java	2011-07-19 18:22:41 UTC (rev 2009)
@@ -28,21 +28,17 @@
 package org.mulgara.resolver;
 
 // Java 2 standard packages
-import java.lang.reflect.*;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
 
-// Third party packages
-import org.apache.log4j.Logger;  // Apache Log4J
-
-// Local packages
-
+import org.apache.log4j.Logger;
 import org.mulgara.content.Content;
 import org.mulgara.content.ContentHandler;
 import org.mulgara.content.ContentHandlerException;
 import org.mulgara.content.ContentHandlerManager;
-import org.mulgara.content.ContentLoader;
 import org.mulgara.content.NotModifiedException;
+import org.mulgara.query.QueryException;
 import org.mulgara.resolver.spi.ResolverSession;
 import org.mulgara.resolver.spi.Statements;
 import org.mulgara.util.StackTrace;
@@ -68,7 +64,6 @@
 
 
   protected List<ContentHandler> contentHandlerList;
-  protected List<ContentLoader> contentLoaderList;
   protected ContentHandler defaultHandler;
 
   /**
@@ -80,7 +75,6 @@
     throws ContentHandlerException
   {
     contentHandlerList  = new ArrayList<ContentHandler>();
-    contentLoaderList   = new ArrayList<ContentLoader>();
     this.defaultHandler = defaultContentHandler;
 
     contentHandlerList.add(defaultContentHandler);
@@ -192,10 +186,6 @@
       ContentHandler handler = (ContentHandler)contentHandlerClass.getConstructor(new Class[] {})
                                                  .newInstance(new Object[] {});
       contentHandlerList.add(handler);
-
-      if (handler instanceof ContentLoader) {
-        contentLoaderList.add((ContentLoader)handler);
-      }
     } catch (IllegalAccessException e) {
       logger.warn("Error generating content handler", e);
       IllegalArgumentException illegalArgumentException =
@@ -223,14 +213,4 @@
     }
   }
 
-  /**
-   * @return head(filter(\x:x.canLoad(uri), contentLoaders)) or null if filter is empty.
-   */
-  public ContentLoader getContentLoader(Content content) throws ContentHandlerException, NotModifiedException {
-    for (ContentLoader loader: contentLoaderList) {
-      if (loader.canParse(content)) return loader;
-    }
-
-    return null;
-  }
 }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java	2011-07-19 18:15:40 UTC (rev 2008)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java	2011-07-19 18:22:41 UTC (rev 2009)
@@ -576,11 +576,8 @@
 
     // Perform the operation
     SetGraphOperation op = new SetGraphOperation(sourceUri, destinationUri,
-                                  inputStream, contentType, contentHandlers, this);
-    // preExcecute is a rather ugly hack, get rid of it once we support re-entrant transactions.
-    if (op.preExecute()) {
-      execute(op, "Unable to load " + sourceUri + " into " + destinationUri);
-    }
+                                  inputStream, contentType, contentHandlers);
+    execute(op, "Unable to load " + sourceUri + " into " + destinationUri);
 
     return op.getStatementCount();
   }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java	2011-07-19 18:15:40 UTC (rev 2008)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java	2011-07-19 18:22:41 UTC (rev 2009)
@@ -28,24 +28,22 @@
 package org.mulgara.resolver;
 
 // Java 2 standard packages
-import java.io.*;
+import java.io.InputStream;
 import java.net.URI;
 
 import javax.activation.MimeType;
 
-// Third party packages
 import org.apache.log4j.Logger;
-
-// Local packages
 import org.mulgara.content.Content;
 import org.mulgara.content.ContentHandler;
 import org.mulgara.content.ContentHandlerException;
 import org.mulgara.content.ContentHandlerManager;
-import org.mulgara.content.ContentLoader;
-import org.mulgara.content.NotModifiedException;
-import org.mulgara.query.*;
-import org.mulgara.query.rdf.*;
-import org.mulgara.resolver.spi.*;
+import org.mulgara.query.QueryException;
+import org.mulgara.query.rdf.URIReferenceImpl;
+import org.mulgara.resolver.spi.DatabaseMetadata;
+import org.mulgara.resolver.spi.Resolver;
+import org.mulgara.resolver.spi.Statements;
+import org.mulgara.resolver.spi.SystemResolver;
 
 /**
  * An {@link Operation} that implements the
@@ -79,7 +77,6 @@
 
   private Content               content;
   private final ContentHandlerManager contentHandlers;
-  private final DatabaseSession databaseSession;
 
   /**
    * Number of statements loaded, or -1 if the {@link #execute} method hasn't yet been
@@ -103,15 +100,13 @@
                     URI         destModelURI,
                     InputStream inputStream,
                     MimeType    contentType,
-                    ContentHandlerManager contentHandlers,
-                    DatabaseSession databaseSession)
+                    ContentHandlerManager contentHandlers)
   {
     this.srcModelURI      = srcModelURI;
     this.destModelURI     = destModelURI;
     this.inputStream      = inputStream;
     this.contentType      = contentType;
     this.contentHandlers  = contentHandlers;
-    this.databaseSession  = databaseSession;
   }
 
   //
@@ -127,6 +122,24 @@
       throw new IllegalStateException("SetGraphOperation already executed.  Cannot reexecute.");
     }
 
+    // create a StreamContent if an inputStream has been supplied
+    if (inputStream != null) {
+      if (logger.isDebugEnabled()) {
+        logger.debug("Detected inputstream associated with " + srcModelURI );
+      }
+      if (srcModelURI == null) {
+        content = new StreamContent(inputStream, contentType);
+      } else {
+        content = new StreamContent(inputStream, srcModelURI);
+      }
+    } else {
+      try {
+        content = ContentFactory.getContent(srcModelURI);
+      } catch (ContentHandlerException ec) {
+        throw new QueryException("Failed to find Content for uri", ec);
+      }
+    }
+    
     long destinationModel = systemResolver.localize(new URIReferenceImpl(destModelURI));
     try {
       long sourceModel = systemResolver.localize(new URIReferenceImpl(srcModelURI, false));
@@ -185,53 +198,4 @@
     return statementCount;
   }
 
-
-  /**
-   * This method is a refactoring hack, purely to get all the code which
-   * depends on content handler and resolver components out of the core
-   * <code>resolver</code> component.
-   *
-   * @return whether {@link #execute} should be called next
-   */
-  boolean preExecute() throws QueryException
-  {
-    // create a StreamContent if an inputStream has been supplied
-    if (inputStream != null) {
-      if (logger.isDebugEnabled()) {
-        logger.debug("Detected inputstream associated with " + srcModelURI );
-      }
-      if (srcModelURI == null) {
-        content = new StreamContent(inputStream, contentType);
-      } else {
-        content = new StreamContent(inputStream, srcModelURI);
-      }
-    } else {
-      try {
-        content = ContentFactory.getContent(srcModelURI);
-      } catch (ContentHandlerException ec) {
-        throw new QueryException("Failed to find Content for uri", ec);
-      }
-    }
-
-    ContentLoader loader;
-    try {
-      loader = contentHandlers.getContentLoader(content);
-    } catch (NotModifiedException e) {
-      throw new QueryException("Content is already cached", e);
-    } catch (ContentHandlerException ec) {
-      throw new QueryException("Failure finding contentLoader");
-    }
-
-    if (loader != null) {
-      try {
-        statementCount = loader.load(content, new GraphResource(destModelURI), databaseSession);
-
-        return false; // notifies caller that a call to execute will fail.
-      } catch (ContentHandlerException handlerException) {
-        throw new QueryException("Failed to setModel.", handlerException);
-      }
-    }
-
-    return true;
-  }
 }

Modified: trunk/src/jar/resolver-spi/java/org/mulgara/content/ContentHandlerManager.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/content/ContentHandlerManager.java	2011-07-19 18:15:40 UTC (rev 2008)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/content/ContentHandlerManager.java	2011-07-19 18:22:41 UTC (rev 2009)
@@ -77,17 +77,4 @@
   public Statements blindParse(Content content, ResolverSession resolverSession)
     throws ContentHandlerException, NotModifiedException;
 
-  /**
-   * Obtains a ContentHandler suitable for preempting a load operation.
-   *
-   * Note: This is a temporary measure required until we can implement
-   * reentrant transactional support.
-   * 
-   * @param content  the content to load, never <code>null</code>
-   * @return preempting content handler or <code>null</code> if none available.
-   * @throws IllegalArgumentException if <var>content</var> is <code>null</code>
-   * @throws NotModifiedException if the <var>content</var> is already cached
-   */
-  public ContentLoader getContentLoader(Content content)
-    throws ContentHandlerException, NotModifiedException;
 }

Deleted: trunk/src/jar/resolver-spi/java/org/mulgara/content/ContentLoader.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/content/ContentLoader.java	2011-07-19 18:15:40 UTC (rev 2008)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/content/ContentLoader.java	2011-07-19 18:22:41 UTC (rev 2009)
@@ -1,75 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.content;
-
-// Local packages
-import org.mulgara.content.Content;
-import org.mulgara.content.ContentHandler;
-import org.mulgara.content.ContentHandlerException;
-import org.mulgara.query.GraphResource;
-import org.mulgara.server.Session;
-
-/**
- * Interface for loading Content into a Graph (GraphExpression). Similar to a
- * {@link ContentHandler} but is reponsible for inserting global statements
- * directly into the destination.
- *
- * Note: This is a temporary measure until we can support reenterant transactions.
- *
- * @created 2004-10-29
- *
- * @author <a href="mailto:robert.turner at tucanatech.com">Robert Turner</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:50 $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright ©2001 <a href="http://www.pisoftware.com/">Plugged In
- *   Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public interface ContentLoader extends ContentHandler {
-  /**
-   * Processes and Loads the content and inserts the statements into the
-   * GraphResource.
-   *
-   * @param content Content
-   * @param destination GraphResource
-   * @param session Session
-   * @throws ContentHandlerException
-   * @return long The number of statements loaded
-   */
-  public long load(Content content, GraphResource destination,
-      Session session) throws ContentHandlerException;
-
-}



More information about the Mulgara-svn mailing list