lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r430568 [4/8] - in /lucene/java/trunk/contrib/gdata-server: ./ lib/ src/java/org/apache/lucene/gdata/data/ src/java/org/apache/lucene/gdata/search/ src/java/org/apache/lucene/gdata/search/analysis/ src/java/org/apache/lucene/gdata/search/co...
Date Thu, 10 Aug 2006 22:32:47 GMT
Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataService.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataService.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataService.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataService.java Thu Aug 10 15:32:40 2006
@@ -19,13 +19,12 @@
 import java.util.Date;
 import java.util.List;
 
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.gdata.data.ServerBaseEntry;
 import org.apache.lucene.gdata.data.ServerBaseFeed;
 import org.apache.lucene.gdata.server.registry.ComponentType;
+import org.apache.lucene.gdata.server.registry.EntryEventMediator;
 import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
 import org.apache.lucene.gdata.storage.ModificationConflictException;
 import org.apache.lucene.gdata.storage.ResourceNotFoundException;
@@ -48,7 +47,7 @@
  * 
  */
 public class GDataService implements Service {
-    private static final Log LOGGER = LogFactory.getLog(GDataService.class);
+    private static final Log LOG = LogFactory.getLog(GDataService.class);
 
     protected Storage storage;
 
@@ -61,6 +60,8 @@
     private static final String generatorURI = "http://lucene.apache.org";
 
     private static final String XMLMIME = "application/atom+xml";
+    
+    private final EntryEventMediator entryEventMediator;
     static {
         generator = new Generator();
         generator.setName(generatorName);
@@ -77,14 +78,14 @@
                 throw new StorageException(
                         "StorageController is not registered");
             this.storage = controller.getStorage();
-
+            this.entryEventMediator = GDataServerRegistry.getRegistry().getEntryEventMediator();
         } catch (StorageException e) {
-            LOGGER
+            LOG
                     .fatal(
                             "Can't get Storage Instance -- can't serve any requests",
                             e);
             ServiceException ex = new ServiceException(
-                    "Can't get Storage instance" + e.getMessage(), e);
+                    "Can't get Storage instance" + e.getMessage(), e,GDataResponse.SERVER_ERROR);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }
@@ -98,8 +99,8 @@
     public BaseEntry createEntry(GDataRequest request, GDataResponse response)
             throws ServiceException {
 
-        if (LOGGER.isInfoEnabled())
-            LOGGER.info("create Entry for feedId: " + request.getFeedId());
+        if (LOG.isInfoEnabled())
+            LOG.info("create Entry for feedId: " + request.getFeedId());
 
         ServerBaseEntry entry = buildEntry(request, response);
         entry.setFeedId(request.getFeedId());
@@ -108,15 +109,17 @@
         tempEntry.setPublished(getCurrentDateTime());
         tempEntry.setUpdated(getCurrentDateTime());
         BaseEntry retVal = null;
+        removeDynamicElements(entry.getEntry());
         try {
             retVal = this.storage.storeEntry(entry);
         } catch (Exception e) {
-            response.setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            
             ServiceException ex = new ServiceException("Could not store entry",
-                    e);
+                    e,GDataResponse.SERVER_ERROR);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }
+        this.entryEventMediator.entryAdded(entry);
         return retVal;
     }
 
@@ -135,28 +138,31 @@
         setVersionId(entry,request,response);
         if (entry.getId() == null)
             throw new ServiceException(
-                    "entry id is null -- can not delete null entry");
+                    "entry id is null -- can not delete null entry",GDataResponse.SERVER_ERROR);
         try {
             this.storage.deleteEntry(entry);
+            
         } catch (ResourceNotFoundException e) {
-            response.setError(HttpServletResponse.SC_BAD_REQUEST);
+            
             ServiceException ex = new ServiceException(
-                    "Could not delete entry", e);
+                    "Could not delete entry", e,GDataResponse.BAD_REQUEST);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }catch (ModificationConflictException e) {
-            response.setError(HttpServletResponse.SC_CONFLICT);
+            
             ServiceException ex = new ServiceException(
-                    "Could not delete entry - version confilict", e);
+                    "Could not delete entry - version conflict",e, GDataResponse.CONFLICT);
             ex.setStackTrace(e.getStackTrace());
             throw ex;  
         }catch (StorageException e) {
-            response.setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            
             ServiceException ex = new ServiceException(
-                    "Could not delete entry", e);
+                    "Could not delete entry", e,GDataResponse.SERVER_ERROR);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }
+        this.entryEventMediator.entryDeleted(entry);
+        //TODO change ret value
         return null;
     }
 
@@ -172,51 +178,50 @@
         entry.setFeedId(request.getFeedId());
         setVersionId(entry,request,response);
         entry.setServiceConfig(request.getConfigurator());
-        if (LOGGER.isInfoEnabled())
-            LOGGER.info("update Entry" + entry.getId() + " for feedId: "
+        if (LOG.isInfoEnabled())
+            LOG.info("update Entry" + entry.getId() + " for feedId: "
                     + request.getFeedId());
         if (entry.getId() == null) {
-            response.setError(HttpServletResponse.SC_BAD_REQUEST);
-            throw new ServiceException("Entry id is null can not update entry");
+            throw new ServiceException("Entry id is null can not update entry",GDataResponse.BAD_REQUEST);
         }
         if (!entry.getId().equals(request.getEntryId())) {
-            if (LOGGER.isInfoEnabled())
-                LOGGER
+            if (LOG.isInfoEnabled())
+                LOG
                         .info("Entry id in the entry xml does not match the requested resource -- XML-ID:"
                                 + entry.getId()
                                 + "; Requested resource: "
                                 + request.getEntryId());
-            response.setError(HttpServletResponse.SC_BAD_REQUEST);
+
             throw new ServiceException(
-                    "Entry id in the entry xml does not match the requested resource");
+                    "Entry id in the entry xml does not match the requested resource",GDataResponse.BAD_REQUEST);
         }
         BaseEntry tempEntry = entry.getEntry();
         tempEntry.setUpdated(getCurrentDateTime());
-        Link selfLink = entry.getSelfLink();
-        if(selfLink != null)
-            entry.getLinks().remove(selfLink);
+        removeDynamicElements(entry.getEntry());
+        
         BaseEntry retVal = null;
+     
         try {
             retVal = this.storage.updateEntry(entry);
         } catch (ResourceNotFoundException e) {
-            response.setError(HttpServletResponse.SC_BAD_REQUEST);
+            
             ServiceException ex = new ServiceException(
-                    "Could not update entry", e);
+                    "Could not update entry", e,GDataResponse.BAD_REQUEST);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }catch (ModificationConflictException e) {
-            response.setError(HttpServletResponse.SC_CONFLICT);
             ServiceException ex = new ServiceException(
-                    "Could not update entry - version confilict", e);
+                    "Could not update entry - version conflict", e,GDataResponse.CONFLICT);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }catch (StorageException e) {
-            response.setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
             ServiceException ex = new ServiceException(
-                    "Could not update entry", e);
+                    "Could not update entry", e,GDataResponse.SERVER_ERROR);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }
+        this.entryEventMediator.entryUpdated(entry);
         return retVal;
     }
 
@@ -234,17 +239,19 @@
         feed.setItemsPerPage(request.getItemsPerPage());
         feed.setServiceConfig(request.getConfigurator());
         try {
+            /*
+             * the strategy executes either a search or a direct access.
+             */
             BaseFeed retVal = this.storage.getFeed(feed);
             dynamicElementFeedStragey(retVal, request);
 
             return retVal;
             /*
-             * resouce not found will be detected in Gdata request.
-             * the request queries the storage for the feed to get the serivce for the feed
+             * Resource not found will be detected in Gdata request.
+             * the request queries the storage for the feed to get the service for the feed
              */
         } catch (StorageException e) {
-            response.setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-            ServiceException ex = new ServiceException("Could not get feed", e);
+            ServiceException ex = new ServiceException("Could not get feed", e,GDataResponse.NOT_FOUND);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }
@@ -267,15 +274,13 @@
             return entry;
 
         } catch (ParseException e) {
-            response.setError(HttpServletResponse.SC_BAD_REQUEST);
             ServiceException ex = new ServiceException(
-                    "Could not parse entry from incoming request", e);
+                    "Could not parse entry from incoming request", e, GDataResponse.BAD_REQUEST);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         } catch (IOException e) {
-            response.setError(HttpServletResponse.SC_BAD_REQUEST);
             ServiceException ex = new ServiceException(
-                    "Could not read or open input stream", e);
+                    "Could not read or open input stream", e, GDataResponse.BAD_REQUEST);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }
@@ -298,8 +303,7 @@
 
             
             if(entry.getId() == null){
-                response.setError(HttpServletResponse.SC_BAD_REQUEST);
-                throw new ServiceException("entry is null can't get entry");
+                throw new ServiceException("entry is null can't get entry", GDataResponse.BAD_REQUEST);
             }
                 
             BaseEntry retVal = null;
@@ -307,13 +311,12 @@
             dynamicElementEntryStragey(retVal, request);
             return retVal;
         } catch (ResourceNotFoundException e) {
-            response.setError(HttpServletResponse.SC_BAD_REQUEST);
             ServiceException ex = new ServiceException(
-                    "Could not get entry", e);
+                    "Could not get entry", e, GDataResponse.BAD_REQUEST);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         } catch (StorageException e) {
-            ServiceException ex = new ServiceException("Could not get feed", e);
+            ServiceException ex = new ServiceException("Could not get entry", e, GDataResponse.SERVER_ERROR);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }
@@ -331,7 +334,7 @@
      * adds all dynamic element to the feed entries
      */
     @SuppressWarnings("unchecked")
-    private void dynamicElementFeedStragey(final BaseFeed feed,
+    protected void dynamicElementFeedStragey(final BaseFeed feed,
             final GDataRequest request) {
          buildDynamicFeedElements(request, feed);
         List<BaseEntry> entryList = feed.getEntries();
@@ -372,6 +375,9 @@
                 buildLink(Link.Rel.SELF, Link.Type.ATOM, request.getSelfId()));
         links.add(
                 buildLink(Link.Rel.NEXT, XMLMIME, request.getNextId()));
+        String prevLink = request.getPreviousId();
+        if(prevLink != null)
+            links.add(buildLink(Link.Rel.PREVIOUS,XMLMIME,prevLink));
         
 
     }
@@ -392,7 +398,7 @@
            
         } catch (StorageException e) {
             ServiceException ex = new ServiceException(
-                    "Could not get Last update for feed -- "+feedId, e);
+                    "Could not get Last update for feed -- "+feedId, e, GDataResponse.SERVER_ERROR);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
         }
@@ -405,12 +411,9 @@
     public Date getEntryLastModified(final String entryId,final String feedId) throws ServiceException {
             try {
                 return new Date(this.storage.getEntryLastModified(entryId, feedId));
-                
-               
-                
             } catch (StorageException e) {
                 ServiceException ex = new ServiceException(
-                        "Could not get Last update for entry  -- "+entryId, e);
+                        "Could not get Last update for entry  -- "+entryId, e, GDataResponse.SERVER_ERROR);
                 ex.setStackTrace(e.getStackTrace());
                 throw ex;
             }
@@ -421,9 +424,8 @@
             entry.setVersion(Integer.parseInt(request.getEntryVersion()));
             return entry;
         }catch (Exception e) {
-            LOGGER.error("Can not parse entry version -- version is not an integer -- versionid: "+request.getEntryVersion(),e);
-            response.setError(HttpServletResponse.SC_BAD_REQUEST);
-            throw new ServiceException("Can not parse entry version -- version is not an integer -- versionid: "+request.getEntryVersion(),e);
+            LOG.error("Can not parse entry version -- version is not an integer -- versionid: "+request.getEntryVersion(),e);
+            throw new ServiceException("Can not parse entry version -- version is not an integer -- versionid: "+request.getEntryVersion(),e, GDataResponse.BAD_REQUEST);
            
         }
     }
@@ -434,5 +436,14 @@
      */
     protected DateTime getCurrentDateTime(){
         return new DateTime(System.currentTimeMillis(),0);
+    }
+    
+    private void removeDynamicElements(BaseEntry entry){
+        Link selfLink = entry.getSelfLink();
+        if(selfLink != null)
+            entry.getLinks().remove(selfLink);
+        Link editLink = entry.getEditLink();
+        if(editLink != null)
+            entry.getLinks().remove(editLink);
     }
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ServiceException.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ServiceException.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ServiceException.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ServiceException.java Thu Aug 10 15:32:40 2006
@@ -16,16 +16,18 @@
 
 package org.apache.lucene.gdata.server;
 
+
 /**
  * The ServiceException is used to encapsulate all {@link java.lang.Exception}
- * throw by underlaying layers of the
+ * throw by underlying layers of the
  * {@link org.apache.lucene.gdata.server.Service} layer.
  * 
  * @author Simon Willnauer
  * 
  */
 public class ServiceException extends Exception {
-
+    
+    private int errorCode;
     /**
      * 
      */
@@ -33,38 +35,51 @@
 
     /**
      * Constructs a new ServiceException
+     * @param errorCode - gdata request error code
      */
-    public ServiceException() {
+    public ServiceException(int errorCode) {
         super();
+        this.errorCode = errorCode;
 
     }
 
     /**
      * Constructs a new ServiceException
      * @param arg0 - the exception message
+     * @param errorCode - gdata request error code
      */
-    public ServiceException(String arg0) {
+    public ServiceException(String arg0,int errorCode) {
         super(arg0);
-
+        this.errorCode = errorCode;
     }
 
     /**
      * Constructs a new ServiceException
-     * @param arg0 - the exceptin message
+     * @param arg0 - the exception message
      * @param arg1 - the exception cause
+     * @param errorCode - gdata request error code
      */
-    public ServiceException(String arg0, Throwable arg1) {
+    public ServiceException(String arg0, Throwable arg1,int errorCode) {
         super(arg0, arg1);
-
+        this.errorCode = errorCode;
+        
     }
 
     /**
      * Constructs a new ServiceException
      * @param arg0 - the exception cause
+     * @param errorCode - gdata request error code
      */
-    public ServiceException(Throwable arg0) {
+    public ServiceException(Throwable arg0,int errorCode) {
         super(arg0);
+        this.errorCode = errorCode;
+    }
 
+    /**
+     * @return Returns the errorCode.
+     */
+    public int getErrorCode() {
+        return this.errorCode;
     }
 
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ServiceFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ServiceFactory.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ServiceFactory.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ServiceFactory.java Thu Aug 10 15:32:40 2006
@@ -51,11 +51,14 @@
 
 	/**
 	 * Creates a {@link Service} instance.
+	 * @param request - the request for this service
 	 * 
 	 * @return a Service instance
 	 */
-	public Service getService() {
+	public Service getService(GDataRequest request) {
 		try{
+            if(request.isSearchRequested())
+                return new GDataSearchService();
 		return new GDataService();
         }catch (Exception e) {
             //

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/AccountBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/AccountBuilder.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/AccountBuilder.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/AccountBuilder.java Thu Aug 10 15:32:40 2006
@@ -17,14 +17,18 @@
 
 import java.io.IOException;
 import java.io.Reader;
+import java.net.URL;
+
+
 
 import org.apache.commons.digester.Digester;
 import org.apache.lucene.gdata.data.GDataAccount;
 import org.apache.lucene.gdata.utils.SimpleSaxErrorHandler;
+import org.apache.xerces.parsers.SAXParser;
 import org.xml.sax.SAXException;
 
 /**
- * Helperclass to create {@link org.apache.lucene.gdata.data.GDataAccount}
+ * Helper class to create {@link org.apache.lucene.gdata.data.GDataAccount}
  * instances from a xml stream provided via a {@link Reader} instance.
  * 
  * @author Simon Willnauer
@@ -36,16 +40,27 @@
      * Reads the xml from the provided reader and binds the values to the 
      * @param reader - the reader to read the xml from
      * @return - the GDataAccount 
-     * @throws IOException - if an IOException occures
+     * @throws IOException - if an IOException occurs
      * @throws SAXException - if the xml can not be parsed by the sax reader
      */
     public static GDataAccount buildAccount(final Reader reader) throws IOException,
             SAXException {
         if (reader == null)
             throw new IllegalArgumentException("Reader must not be null");
-        String schemaFile = AccountBuilder.class.getResource("/gdata-account.xsd").getFile();
+        URL resource = AccountBuilder.class.getResource("/gdata-account.xsd");
+        if(resource == null)
+            throw new RuntimeException("can not find xml schema file 'gdata-account.xsd' -- file must be present on the classpath");
+        String schemaFile = resource.getFile();
         GDataAccount account = null;
-        Digester digester = new Digester();
+        /*
+         * Force using apache xerces parser for digester
+         */
+        SAXParser parser = new SAXParser();
+        parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
+        parser.setFeature("http://apache.org/xml/features/validation/schema",true);
+        parser.setFeature("http://xml.org/sax/features/validation",true); 
+        parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",schemaFile);
+        Digester digester = new Digester(parser);
         digester.setValidating(true);
         digester.setErrorHandler(new SimpleSaxErrorHandler());
         digester.setSchema(schemaFile);
@@ -61,7 +76,6 @@
                 "authorLink");
 
         account = (GDataAccount) digester.parse(reader);
-
         return account;
     }
     

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/GDataAdminService.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/GDataAdminService.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/GDataAdminService.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/GDataAdminService.java Thu Aug 10 15:32:40 2006
@@ -19,6 +19,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.gdata.data.GDataAccount;
 import org.apache.lucene.gdata.data.ServerBaseFeed;
+import org.apache.lucene.gdata.server.GDataResponse;
 import org.apache.lucene.gdata.server.GDataService;
 import org.apache.lucene.gdata.server.ServiceException;
 import org.apache.lucene.gdata.storage.StorageException;
@@ -47,13 +48,13 @@
      */
     public void createFeed(final ServerBaseFeed feed,final GDataAccount account) throws ServiceException {
         if(feed == null)
-            throw new ServiceException("Can not create feed -- feed is null");
+            throw new ServiceException("Can not create feed -- feed is null", GDataResponse.BAD_REQUEST);
         if(account == null)
-            throw new ServiceException("Can not create feed -- account is null");
+            throw new ServiceException("Can not create feed -- account is null", GDataResponse.UNAUTHORIZED);
         if(feed.getId() == null)
-            throw new ServiceException("Feed ID is null can not create feed");
+            throw new ServiceException("Feed ID is null can not create feed", GDataResponse.BAD_REQUEST);
         if(account.getName() == null)
-            throw new ServiceException("Account name is null -- can't create feed");
+            throw new ServiceException("Account name is null -- can't create feed", GDataResponse.UNAUTHORIZED);
     try {
         feed.setUpdated(getCurrentDateTime());
         feed.setAccount(account);
@@ -61,7 +62,7 @@
     } catch (StorageException e) {
         if(LOG.isInfoEnabled())
             LOG.info("Can not save feed -- "+e.getMessage(),e);
-        throw new ServiceException("Can not save feed",e);
+        throw new ServiceException("Can not save feed",e, GDataResponse.SERVER_ERROR);
     }
  
     }
@@ -73,13 +74,13 @@
      */
     public void updateFeed(ServerBaseFeed feed, GDataAccount account) throws ServiceException {
         if(feed == null)
-            throw new ServiceException("Can not update null feed");
+            throw new ServiceException("Can not update null feed", GDataResponse.BAD_REQUEST);
         if(account == null)
-            throw new ServiceException("Can not update feed -- account is null");
+            throw new ServiceException("Can not update feed -- account is null", GDataResponse.UNAUTHORIZED);
         if(feed.getId() == null)
-            throw new ServiceException("Feed ID is null can not update feed");
+            throw new ServiceException("Feed ID is null can not update feed", GDataResponse.BAD_REQUEST);
         if(account.getName() == null)
-            throw new ServiceException("Account name is null -- can't update feed");
+            throw new ServiceException("Account name is null -- can't update feed", GDataResponse.UNAUTHORIZED);
     try {
         feed.setAccount(account);
         feed.setUpdated(getCurrentDateTime());
@@ -87,7 +88,7 @@
     } catch (StorageException e) {
         if(LOG.isInfoEnabled())
             LOG.info("Can not update feed -- "+e.getMessage(),e);
-        throw new ServiceException("Can not update feed",e);
+        throw new ServiceException("Can not update feed",e, GDataResponse.SERVER_ERROR);
     }
 
     }
@@ -99,15 +100,15 @@
      */
     public void deleteFeed(ServerBaseFeed feed) throws ServiceException {
         if(feed == null)
-            throw new ServiceException("Can not delete null feed");
+            throw new ServiceException("Can not delete null feed", GDataResponse.BAD_REQUEST);
         if(feed.getId() == null)
-            throw new ServiceException("Feed ID is null can not delete feed");
+            throw new ServiceException("Feed ID is null can not delete feed", GDataResponse.BAD_REQUEST);
     try {
         this.storage.deleteFeed(feed.getId());
     } catch (StorageException e) {
         if(LOG.isInfoEnabled())
             LOG.info("Can not delete feed -- "+e.getMessage(),e);
-        throw new ServiceException("Can not delete feed",e);
+        throw new ServiceException("Can not delete feed",e, GDataResponse.SERVER_ERROR);
     }
 
     }
@@ -117,13 +118,13 @@
      */
     public void createAccount(GDataAccount account) throws ServiceException {
         if(account == null)
-            throw new ServiceException("Can not save null account");
+            throw new ServiceException("Can not save null account", GDataResponse.BAD_REQUEST);
         try {
             this.storage.storeAccount(account);
         } catch (StorageException e) {
             if(LOG.isInfoEnabled())
                 LOG.info("Can not save account -- "+e.getMessage(),e);
-            throw new ServiceException("Can not save account",e);
+            throw new ServiceException("Can not save account",e, GDataResponse.SERVER_ERROR);
         }
     }
 
@@ -132,13 +133,13 @@
      */
     public void deleteAccount(GDataAccount account) throws ServiceException {
         if(account == null)
-            throw new ServiceException("Can not delete null account");
+            throw new ServiceException("Can not delete null account", GDataResponse.BAD_REQUEST);
         try {
             this.storage.deleteAccount(account.getName());
         } catch (StorageException e) {
             if(LOG.isInfoEnabled())
                 LOG.info("Can not save account -- "+e.getMessage(),e);
-            throw new ServiceException("Can not save account",e);
+            throw new ServiceException("Can not save account",e, GDataResponse.SERVER_ERROR);
         }
     }
 
@@ -147,13 +148,13 @@
      */
     public void updateAccount(GDataAccount account) throws ServiceException {
         if(account == null)
-            throw new ServiceException("Can not update null account");
+            throw new ServiceException("Can not update null account", GDataResponse.BAD_REQUEST);
         try {
             this.storage.updateAccount(account);
         } catch (StorageException e) {
             if(LOG.isInfoEnabled())
                 LOG.info("Can not save account -- "+e.getMessage(),e);
-            throw new ServiceException("Can not save account",e);
+            throw new ServiceException("Can not save account",e, GDataResponse.SERVER_ERROR);
         }
     }
     
@@ -162,13 +163,13 @@
      */
     public GDataAccount getAccount(String accountName)throws ServiceException{
         if(accountName == null)
-            throw new ServiceException("Can not get null account");
+            throw new ServiceException("Can not get null account", GDataResponse.BAD_REQUEST);
         try {
             return this.storage.getAccount(accountName);
         } catch (StorageException e) {
             if(LOG.isInfoEnabled())
                 LOG.info("Can not get account -- "+e.getMessage(),e);
-            throw new ServiceException("Can not get account",e);
+            throw new ServiceException("Can not get account",e, GDataResponse.SERVER_ERROR);
         }
        
     }
@@ -180,7 +181,7 @@
      */
     public GDataAccount getFeedOwningAccount(String feedId) throws ServiceException {
         if(feedId == null)
-            throw new ServiceException("Can not get account - feed id must not be null");
+            throw new ServiceException("Can not get account - feed id must not be null", GDataResponse.BAD_REQUEST);
         try {
             String accountName =  this.storage.getAccountNameForFeedId(feedId);
            return this.storage.getAccount(accountName);
@@ -188,7 +189,7 @@
         } catch (StorageException e) {
             if(LOG.isInfoEnabled())
                 LOG.info("Can not get account for feed Id -- "+e.getMessage(),e);
-            throw new ServiceException("Can not get account for the given feed id",e);
+            throw new ServiceException("Can not get account for the given feed id",e, GDataResponse.SERVER_ERROR);
         }
     }
 

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ComponentType.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ComponentType.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ComponentType.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ComponentType.java Thu Aug 10 15:32:40 2006
@@ -1,12 +1,13 @@
 package org.apache.lucene.gdata.server.registry;
 
+import org.apache.lucene.gdata.search.SearchComponent;
 import org.apache.lucene.gdata.server.ServiceFactory;
 import org.apache.lucene.gdata.server.authentication.AuthenticationController;
 import org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory;
 import org.apache.lucene.gdata.storage.StorageController;
 
 /**
- * The enmueration {@link ComponentType} defines the GDATA-Server Components 
+ * The enumeration {@link ComponentType} defines the GDATA-Server Components 
  * available via {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry#lookup(Class, ComponentType)} 
  * method.
  * @see org.apache.lucene.gdata.server.registry.Component
@@ -30,12 +31,11 @@
     @SuperType(superType = RequestHandlerFactory.class)
     REQUESTHANDLERFACTORY,
     /**
-     * INDEXER TYPE
-     * 
+     * SearchComponent Type
+     * @see SearchComponent
      */
-    // TODO not available yet
-    @SuperType(superType = Object.class)
-    INDEXER,
+    @SuperType(superType = SearchComponent.class)
+    SEARCHCONTROLLER,
     /**
      * ServiceFactory Type
      * 
@@ -44,7 +44,7 @@
     @SuperType(superType = ServiceFactory.class)
     SERVICEFACTORY,
     /**
-     * Supertype for AuthenticationController implementations
+     * Super type for AuthenticationController implementations
      * @see AuthenticationController
      */
     @SuperType(superType = AuthenticationController.class)

Added: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventListener.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventListener.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventListener.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventListener.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.gdata.server.registry;
+
+import org.apache.lucene.gdata.data.ServerBaseEntry;
+
+/**
+ * The EntryEventListener interface should be implemented by any class needs to be informed about any changes on entries.
+ * To register a class as a EntryEventListener use:
+ * <p>
+ * <tt>
+ * GdataServerRegistry.registerEntryEventListener(EntryEventListener);
+ * <tt>
+ * </p>
+ * @author Simon Willnauer
+ *
+ */
+public interface EntryEventListener {
+    /**
+     * will be invoked on every successful update on every entry
+     * @param entry the updated entry
+     */
+    public abstract void fireUpdateEvent(ServerBaseEntry entry);
+    /**
+     * will be invoked on every successful entry insert
+     * @param entry
+     */
+    public abstract void fireInsertEvent(ServerBaseEntry entry);
+    /**
+     * will be invoked on every successful entry delete
+     * @param entry
+     */
+    public abstract void fireDeleteEvent(ServerBaseEntry entry);
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventListener.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventMediator.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventMediator.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventMediator.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventMediator.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,89 @@
+/**
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.gdata.server.registry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.gdata.data.ServerBaseEntry;
+
+/**
+ * This class will be informed about every successful entry event and
+ * distributes all event to all registered
+ * {@link org.apache.lucene.gdata.server.registry.EntryEventListener}
+ * 
+ * @author Simon Willnauer
+ * 
+ */
+public abstract class EntryEventMediator {
+
+    private final List<EntryEventListener> entryEventListener = new ArrayList<EntryEventListener>(
+            5);
+
+    /**
+     * @return - a entry event mediator instance
+     */
+    public abstract EntryEventMediator getEntryEventMediator();
+
+    /**
+     * Registers a {@link EntryEventListener}. This listner will be fired if an
+     * entry update, insert or delete occures
+     * 
+     * @param listener -
+     *            listener to register
+     */
+    public void registerEntryEventListener(final EntryEventListener listener) {
+        if (listener == null || this.entryEventListener.contains(listener))
+            return;
+        this.entryEventListener.add(listener);
+    }
+
+    /**
+     * @param entry -
+     *            the updated entry
+     */
+    public void entryUpdated(final ServerBaseEntry entry) {
+        for (EntryEventListener listener : this.entryEventListener) {
+            listener.fireUpdateEvent(entry);
+        }
+    }
+
+    /**
+     * @param entry -
+     *            the added entry
+     */
+    public void entryAdded(final ServerBaseEntry entry) {
+        for (EntryEventListener listener : this.entryEventListener) {
+            listener.fireInsertEvent(entry);
+        }
+    }
+
+    /**
+     * @param entry -
+     *            the deleted entry
+     */
+    public void entryDeleted(final ServerBaseEntry entry) {
+        for (EntryEventListener listener : this.entryEventListener) {
+            listener.fireDeleteEvent(entry);
+        }
+    }
+    
+    public boolean isListenerRegistered(final EntryEventListener listner){
+        return listner!=null&&this.entryEventListener.contains(listner);
+    }
+
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventMediator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/EntryEventMediator.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataServerRegistry.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataServerRegistry.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataServerRegistry.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataServerRegistry.java Thu Aug 10 15:32:40 2006
@@ -25,12 +25,13 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.gdata.server.registry.configuration.ComponentConfiguration;
 import org.apache.lucene.gdata.server.registry.configuration.PropertyInjector;
+import org.apache.lucene.gdata.utils.ReflectionUtils;
 
 /**
  * 
  * The GDataServerRegistry represents the registry component of the GData
  * Server. All provided services and server components will be registered here.
- * The Gdata Server serves RSS / ATOM feeds for defined services. Each service
+ * The GData Server serves RSS / ATOM feeds for defined services. Each service
  * provides <i>n</i> feeds of a defined subclass of
  * {@link com.google.gdata.data.BaseFeed}. Each feed contains <i>m</i> entries
  * of a defined subclass of {@link com.google.gdata.data.BaseEntry}. To
@@ -42,9 +43,9 @@
  * </p>
  * <p>
  * The components defined in the gdata-config.xml will also be loaded and
- * instanciated at startup. If a component can not be loaded or an Exception
- * occures the server will not start up. To cause of the exception or error will
- * be logged to the standart server output.
+ * instantiated at startup. If a component can not be loaded or an Exception
+ * occurs the server will not start up. To cause of the exception or error will
+ * be logged to the standard server output.
  * </p>
  * <p>
  * The GDataServerRegistry is a Singleton
@@ -54,16 +55,17 @@
  * @author Simon Willnauer
  * 
  */
-public class GDataServerRegistry {
+public class GDataServerRegistry extends EntryEventMediator{
     private static GDataServerRegistry INSTANCE;
 
-    private static final Log LOGGER = LogFactory
+    private static final Log LOG = LogFactory
             .getLog(GDataServerRegistry.class);
 
     private ScopeVisitable requestVisitable;
 
     private ScopeVisitable sessionVisitable;
-    //not available yet
+
+    // not available yet
     private ScopeVisitable contextVisitable;
 
     private List<ScopeVisitor> visitorBuffer = new ArrayList<ScopeVisitor>(5);
@@ -78,7 +80,7 @@
     }
 
     /**
-     * @return a Sinleton registry instance
+     * @return a Singleton registry instance
      */
     public static synchronized GDataServerRegistry getRegistry() {
         if (INSTANCE == null)
@@ -94,7 +96,7 @@
      */
     public void registerService(ProvidedService configurator) {
         if (configurator == null) {
-            LOGGER.warn("Feedconfigurator is null -- skip registration");
+            LOG.warn("Feed configurator is null -- skip registration");
             return;
         }
         this.serviceTypeMap.put(configurator.getName(), configurator);
@@ -112,8 +114,8 @@
         Scope scope = visitor.getClass().getAnnotation(Scope.class);
         if (scope == null)
             throw new RegistryException("Visitor has not Scope");
-        if (LOGGER.isInfoEnabled())
-            LOGGER.info("Register scope visitor -- " + visitor.getClass());
+        if (LOG.isInfoEnabled())
+            LOG.info("Register scope visitor -- " + visitor.getClass());
         if (scope.scope().equals(Scope.ScopeType.REQUEST)
                 && this.requestVisitable != null)
             this.requestVisitable.accept(visitor);
@@ -141,8 +143,8 @@
         Scope scope = visitable.getClass().getAnnotation(Scope.class);
         if (scope == null)
             throw new RegistryException("Visitable has not Scope");
-        if (LOGGER.isInfoEnabled())
-            LOGGER.info("Register scope visitable -- " + visitable.getClass());
+        if (LOG.isInfoEnabled())
+            LOG.info("Register scope visitable -- " + visitable.getClass());
         if (scope.scope() == Scope.ScopeType.REQUEST
                 && this.requestVisitable == null)
             this.requestVisitable = visitable;
@@ -176,7 +178,7 @@
     public ProvidedService getProvidedService(String service) {
         if (service == null)
             throw new IllegalArgumentException(
-                    "Service is null - must not be null to get registered feedtype");
+                    "Service is null - must not be null to get registered feed type");
         return this.serviceTypeMap.get(service);
     }
 
@@ -267,7 +269,7 @@
      *             annotations not visible at runtime or not set, if the super
      *             type provided by the {@link ComponentType} for the class to
      *             register is not a super type of the class or if the
-     *             invokation of the {@link ServerComponent#initialize()} method
+     *             invocation of the {@link ServerComponent#initialize()} method
      *             throws an exception.
      */
     @SuppressWarnings("unchecked")
@@ -280,7 +282,8 @@
             throw new IllegalArgumentException(
                     "component class must not be null");
 
-        if (!checkSuperType(componentClass, ServerComponent.class))
+        if (!ReflectionUtils.implementsType(componentClass,
+                ServerComponent.class))
             throw new RegistryException(
                     "can not register component. the given class does not implement ServerComponent interface -- "
                             + componentClass.getName());
@@ -298,14 +301,14 @@
                         + type.name());
             Class superType = type.getClass().getField(type.name())
                     .getAnnotation(SuperType.class).superType();
-            if (!checkSuperType(componentClass, superType))
-                throw new RegistryException("Considered Supertype <"
+            if (!ReflectionUtils.isTypeOf(componentClass, superType))
+                throw new RegistryException("Considered super type <"
                         + superType.getName() + "> is not a super type of <"
                         + componentClass + ">");
             ServerComponent comp = componentClass.newInstance();
             if (configuration == null) {
-                if (LOGGER.isInfoEnabled())
-                    LOGGER.info("no configuration for ComponentType: "
+                if (LOG.isInfoEnabled())
+                    LOG.info("no configuration for ComponentType: "
                             + type.name());
             } else
                 configureComponent(comp, type, configuration);
@@ -313,7 +316,8 @@
             ComponentBean bean = new ComponentBean(comp, superType);
 
             this.componentMap.put(type, bean);
-            if (checkSuperType(componentClass, ScopeVisitor.class))
+            if (ReflectionUtils.implementsType(componentClass,
+                    ScopeVisitor.class))
                 this.registerScopeVisitor((ScopeVisitor) comp);
         } catch (Exception e) {
             e.printStackTrace();
@@ -334,21 +338,6 @@
         injector.injectProperties(configuration);
     }
 
-    private static boolean checkSuperType(Class type, Class consideredSuperType) {
-        if (type == null)
-            return false;
-        if (type.equals(Object.class))
-            return false;
-        if (type.equals(consideredSuperType))
-            return true;
-        Class[] interfaces = type.getInterfaces();
-        for (int i = 0; i < interfaces.length; i++) {
-            if (checkSuperType(interfaces[i], consideredSuperType))
-                return true;
-        }
-        return checkSuperType(type.getSuperclass(), consideredSuperType);
-    }
-
     private static class ComponentBean {
         private final Class superType;
 
@@ -367,6 +356,23 @@
             return this.superType;
         }
 
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.server.registry.EntryEventMediator#getEntryEventMediator()
+     */
+    @Override
+    public EntryEventMediator getEntryEventMediator() {
+        
+        return this;
+    }
+
+    /**
+     * @return - all registered services
+     */
+    public Collection<ProvidedService> getServices() {
+        
+        return this.serviceTypeMap.values();
     }
 
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedService.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedService.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedService.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedService.java Thu Aug 10 15:32:40 2006
@@ -15,6 +15,8 @@
  */ 
 package org.apache.lucene.gdata.server.registry;
 
+import org.apache.lucene.gdata.search.config.IndexSchema;
+
 import com.google.gdata.data.ExtensionProfile;
 
 /**
@@ -41,7 +43,7 @@
     public abstract Class getEntryType();
 
     /**
-     * @return - the servicename
+     * @return - the service name
      */
     public abstract String getName();
 
@@ -49,5 +51,8 @@
      * releases all dependencies and resources
      */
     public abstract void destroy();
-
+    /**
+     * @return the index schema configuration for this service
+     */
+    public abstract IndexSchema getIndexSchema();
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedServiceConfig.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedServiceConfig.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedServiceConfig.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedServiceConfig.java Thu Aug 10 15:32:40 2006
@@ -19,20 +19,25 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.gdata.search.config.IndexSchema;
 import org.apache.lucene.gdata.utils.Pool;
 import org.apache.lucene.gdata.utils.PoolObjectFactory;
 import org.apache.lucene.gdata.utils.SimpleObjectPool;
 
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.BaseFeed;
+import com.google.gdata.data.Entry;
 import com.google.gdata.data.ExtensionProfile;
+import com.google.gdata.data.Feed;
 
 /**
- * Standart implementation of
+ * Standard implementation of
  * {@link org.apache.lucene.gdata.server.registry.ProvidedService} to be used
  * inside the
  * {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry}
  * <p>
  * ExtensionProfiles are used to generate and parse xml by the gdata api. For
- * that case all methodes are synchronized. This will slow down the application
+ * that case all methods are synchronized. This will slow down the application
  * when performing lots of xml generation concurrently. For that case the
  * extensionProfile for a specific service will be pooled and reused.
  * </p>
@@ -47,13 +52,13 @@
             .getLog(ProvidedServiceConfig.class);
 
     private static final int DEFAULT_POOL_SIZE = 5;
-
+    private IndexSchema indexSchema;
     /*
-     * To ensure a extensionprofile instance will not be shared within multiple
+     * To ensure a extension profile instance will not be shared within multiple
      * threads each thread requesting a config will have one instance for the
      * entire request.
      */
-    private final ThreadLocal<ExtensionProfile> extProfThreadLocal = new ThreadLocal<ExtensionProfile>();
+    protected final ThreadLocal<ExtensionProfile> extProfThreadLocal = new ThreadLocal<ExtensionProfile>();
 
     /*
      * ExtensionProfiles are used to generate and parse xml by the gdata api.
@@ -66,9 +71,9 @@
 
     private String serviceName;
 
-    private Class entryType;
+    private Class<? extends BaseEntry> entryType;
 
-    private Class feedType;
+    private Class<? extends BaseFeed> feedType;
 
     private ExtensionProfile extensionProfile;
 
@@ -92,7 +97,7 @@
     }
 
     /**
-     * Default constructor to instanciate via reflection
+     * Default constructor to instantiate via reflection
      */
     public ProvidedServiceConfig() {
         try {
@@ -126,6 +131,8 @@
         if (ext != null) {
             return ext;
         }
+        if(this.extensionProfile == null)
+            return null;
         if (this.profilPool == null)
             createProfilePool();
         ext = this.profilPool.aquire();
@@ -135,7 +142,7 @@
 
     /**
      * @param extensionProfil -
-     *            the extensionprofile for this feed configuration
+     *            the extension profile for this feed configuration
      */
     @SuppressWarnings("unchecked")
     public void setExtensionProfile(ExtensionProfile extensionProfil) {
@@ -150,11 +157,11 @@
 
     private void createProfilePool() {
         if (LOG.isInfoEnabled())
-            LOG.info("Create ExtensionProfile pool with poolsize:"
+            LOG.info("Create ExtensionProfile pool with pool size:"
                     + this.poolSize + " for service " + this.serviceName);
         this.profilPool = new SimpleObjectPool<ExtensionProfile>(this.poolSize,
                 new ExtensionProfileFactory<ExtensionProfile>(
-                        this.extensionProfile.getClass()));
+                        this.extensionProfile.getClass(),this.entryType,this.feedType));
     }
 
     /**
@@ -225,14 +232,19 @@
         private final Constructor<? extends ExtensionProfile> constructor;
 
         private static final Object[] constArray = new Object[0];
+        
+        private BaseEntry entry;
+        private BaseFeed feed;
 
-        ExtensionProfileFactory(Class<? extends ExtensionProfile> clazz) {
+        ExtensionProfileFactory(Class<? extends ExtensionProfile> clazz, Class<? extends BaseEntry> entryClass, Class<? extends BaseFeed> feedClass) {
             this.clazz = clazz;
             try {
                 this.constructor = clazz.getConstructor(new Class[0]);
+                this.entry = entryClass.newInstance();
+                this.feed = feedClass.newInstance();
             } catch (Exception e) {
                 throw new IllegalArgumentException(
-                        "The given class has no defaul constructor -- can not use as a ExtensionProfile -- "
+                        "The given class has no default constructor -- can not use as a ExtensionProfile -- "
                                 + this.clazz.getName(), e);
             }
         }
@@ -244,10 +256,13 @@
         public Type getInstance() {
 
             try {
-                return (Type) this.constructor.newInstance(constArray);
+                Type retValue = (Type) this.constructor.newInstance(constArray);
+                this.entry.declareExtensions(retValue);
+                this.feed.declareExtensions(retValue);
+                return retValue; 
             } catch (Exception e) {
                 throw new RuntimeException(
-                        "Can not instanciate new ExtensionProfile -- ", e);
+                        "Can not instantiate new ExtensionProfile -- ", e);
 
             }
         }
@@ -271,7 +286,7 @@
             createProfilePool();
         /*
          * don't set a extension profile for each thread. The current thread
-         * might use another service and does not need the extensionprofile of
+         * might use another service and does not need the extension profile of
          * this service
          */
     }
@@ -293,6 +308,22 @@
         }
         this.extProfThreadLocal.set(null);
         this.profilPool.release(ext);
+    }
+
+    /**
+     * @return Returns the indexSchema.
+     */
+    public IndexSchema getIndexSchema() {
+        return this.indexSchema;
+    }
+
+    /**
+     * @param indexSchema The indexSchema to set.
+     */
+    public void setIndexSchema(IndexSchema indexSchema) {
+        this.indexSchema = indexSchema;
+        if(this.indexSchema != null)
+            this.indexSchema.setName(this.serviceName);
     }
 
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryBuilder.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryBuilder.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryBuilder.java Thu Aug 10 15:32:40 2006
@@ -18,14 +18,17 @@
 import java.io.IOException;
 
 import org.apache.commons.digester.Digester;
+import org.apache.lucene.gdata.search.config.IndexSchema;
+import org.apache.lucene.gdata.search.config.IndexSchemaField;
 import org.apache.lucene.gdata.server.registry.configuration.ComponentConfiguration;
 import org.apache.lucene.gdata.utils.SimpleSaxErrorHandler;
+import org.apache.xerces.parsers.SAXParser;
 import org.xml.sax.SAXException;
 
 /**
  * Reads the configuration file and creates the
  * {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry} singleton
- * instance. All services and components will be instanciated and registered in
+ * instance. All services and components will be instantiated and registered in
  * the registry.
  * 
  * @author Simon Willnauer
@@ -38,22 +41,30 @@
      * {@link GDataServerRegistry#getRegistry()} method
      * 
      * @throws IOException -
-     *             if an IOException occures while reading the config file
+     *             if an IOException occurs while reading the config file
      * @throws SAXException -
      *             if the config file can not be parsed
      */
     static void buildRegistry() throws IOException, SAXException {
-
-        buildFromConfiguration(new Digester(), GDataServerRegistry
-                .getRegistry());
+        String schemaFile = RegistryBuilder.class.getResource("/gdata-config.xsd").getFile();
+        /*
+         * Force using apache xerces parser for digester
+         */
+        SAXParser parser = new SAXParser();
+        parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
+        parser.setFeature("http://apache.org/xml/features/validation/schema",true);
+        parser.setFeature("http://xml.org/sax/features/validation",true); 
+        parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",schemaFile);
+        Digester digester = new Digester(parser);
+        buildFromConfiguration(digester, GDataServerRegistry
+                .getRegistry(),schemaFile);
 
     }
 
     private static void buildFromConfiguration(Digester digester,
-            GDataServerRegistry registry) throws IOException, SAXException {
-        String schemaFile = RegistryBuilder.class.getResource("/gdata-config.xsd").getFile();
+            GDataServerRegistry registry, String schemaURL) throws IOException, SAXException {
         digester.setValidating(true);
-        digester.setSchema(schemaFile);
+        digester.setSchema(schemaURL);
         digester.setErrorHandler(new SimpleSaxErrorHandler());
         digester.push(registry);
         /*
@@ -66,7 +77,7 @@
         digester.addBeanPropertySetter("gdata/service/entry-class", "entryType");
         digester.addBeanPropertySetter("gdata/service/extension-profile",
                 "extensionProfileClass");
-      
+        addIndexRule(digester);
         /*
          * load components and configurations
          */
@@ -77,9 +88,64 @@
             digester.addCallMethod("gdata/server-components/component/configuration/property","set",2,new Class[]{String.class,String.class});
             digester.addCallParam("gdata/server-components/component/configuration/property",0,"name");
             digester.addCallParam("gdata/server-components/component/configuration/property",1);
+        //second parameter on registerComponent -- top of the stack (Component configuration)
         digester.addCallParam("gdata/server-components/component/configuration",1,0);    
         digester.parse(RegistryBuilder.class
                 .getResourceAsStream("/gdata-config.xml"));
+        
+    }
+    
+    
+    private static void addIndexRule(Digester digester){
+        digester.addObjectCreate("gdata/service/index-schema", IndexSchema.class);
+        digester.addSetNext("gdata/service/index-schema", "setIndexSchema");
+        digester.addSetProperties("gdata/service/index-schema");
+        digester.addSetProperties("gdata/service/index-schema/index");
+        digester.addBeanPropertySetter("gdata/service/index-schema/index/maxMergeDocs");
+        digester.addBeanPropertySetter("gdata/service/index-schema/index/maxBufferedDocs");
+        digester.addBeanPropertySetter("gdata/service/index-schema/index/maxFieldLength");
+        digester.addBeanPropertySetter("gdata/service/index-schema/index/mergeFactor");
+        digester.addBeanPropertySetter("gdata/service/index-schema/index/indexLocation");
+        digester.addBeanPropertySetter("gdata/service/index-schema/index/useCompoundFile");
+        digester.addCallMethod("gdata/service/index-schema/index/defaultAnalyzer", "serviceAnalyzer",1,new Class[]{Class.class});
+        
+        //call method on top of the stack addSchemaField
+        digester.addCallMethod("gdata/service/index-schema/field","addSchemaField",1,new Class[]{IndexSchemaField.class});
+        digester.addObjectCreate("gdata/service/index-schema/field",IndexSchemaField.class);
+        //set parameter for method call -- parameter is IndexSchemaField
+        digester.addCallParam("gdata/service/index-schema/field",0,0);
+        digester.addSetProperties("gdata/service/index-schema/field");
+        digester.addBeanPropertySetter("gdata/service/index-schema/field/path");
+        digester.addBeanPropertySetter("gdata/service/index-schema/field/store","storeByName");
+        digester.addBeanPropertySetter("gdata/service/index-schema/field/index","indexByName");
+        digester.addBeanPropertySetter("gdata/service/index-schema/field/analyzer","analyzerClass");
+        
+//      call method on top of the stack addSchemaField
+        digester.addCallMethod("gdata/service/index-schema/custom","addSchemaField",1,new Class[]{IndexSchemaField.class});
+        digester.addObjectCreate("gdata/service/index-schema/custom",IndexSchemaField.class);
+        //set parameter for method call -- parameter is IndexSchemaField
+        digester.addCallParam("gdata/service/index-schema/custom",0,0);
+        digester.addSetProperties("gdata/service/index-schema/custom");
+        digester.addBeanPropertySetter("gdata/service/index-schema/custom/path");
+        digester.addBeanPropertySetter("gdata/service/index-schema/custom/store","storeByName");
+        digester.addBeanPropertySetter("gdata/service/index-schema/custom/index","indexByName");
+        digester.addBeanPropertySetter("gdata/service/index-schema/custom/analyzer","analyzerClass");
+        digester.addBeanPropertySetter("gdata/service/index-schema/custom/field-class","fieldClass");
+//        digester.addCallMethod("gdata/service/index-schema/custom/field-class","fieldClass",1,new Class[]{Class.class});
+     
+     
+//      call method on top of the stack addSchemaField
+        digester.addCallMethod("gdata/service/index-schema/mixed","addSchemaField",1,new Class[]{IndexSchemaField.class});
+        digester.addObjectCreate("gdata/service/index-schema/mixed",IndexSchemaField.class);
+        //set parameter for method call -- parameter is IndexSchemaField
+        digester.addCallParam("gdata/service/index-schema/mixed",0,0);
+        digester.addSetProperties("gdata/service/index-schema/mixed");
+        digester.addBeanPropertySetter("gdata/service/index-schema/mixed","type");
+        digester.addBeanPropertySetter("gdata/service/index-schema/mixed/path");
+        digester.addBeanPropertySetter("gdata/service/index-schema/mixed/store","storeByName");
+        digester.addBeanPropertySetter("gdata/service/index-schema/mixed/index","indexByName");
+        digester.addBeanPropertySetter("gdata/service/index-schema/mixed/contenttype","typePath");
+        digester.addBeanPropertySetter("gdata/service/index-schema/mixed/analyzer","analyzerClass");
         
     }
 

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryContextListener.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryContextListener.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryContextListener.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryContextListener.java Thu Aug 10 15:32:40 2006
@@ -27,7 +27,7 @@
  * {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry} when the
  * context is loaded. The registry will be loaded before the
  * {@link org.apache.lucene.gdata.servlet.RequestControllerServlet} is loaded.
- * The Registry will be loaded and set up befor the REST interface is available.
+ * The Registry will be loaded and set up before the REST interface is available.
  * <p>
  * This ContextListener has to be configured in the <code>web.xml</code>
  * deployment descriptor.
@@ -58,9 +58,13 @@
         try {
             RegistryBuilder.buildRegistry();
             this.serverRegistry = GDataServerRegistry.getRegistry();
-        } catch (Exception e) {
-            this.serverRegistry.destroy();
-            LOG.error("can not register requiered components", e);
+            /*
+             * catch all exceptions and destroy the registry to release all resources.
+             * some components start lots of threads, the will remain running if the registry is not destroyed
+             */
+        } catch (Throwable e) {
+            GDataServerRegistry.getRegistry().destroy();
+            LOG.error("can not register required components", e);
             throw new RuntimeException("Can not register required components",
                     e);
         }
@@ -73,7 +77,12 @@
      */
     public void contextDestroyed(ServletContextEvent arg0) {
         LOG.info("Destroying context");
-        this.serverRegistry.destroy();
+        /*
+         * this might be null if startup fails
+         * --> prevent null pointer exception
+         */
+        if(this.serverRegistry != null)
+            this.serverRegistry.destroy();
 
     }
 

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ServerComponent.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ServerComponent.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ServerComponent.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ServerComponent.java Thu Aug 10 15:32:40 2006
@@ -32,6 +32,7 @@
 public interface ServerComponent {
     /**
      * will be call when the component is registered.
+     * if this fails the server must not startup.
      */
     public abstract void initialize();
 

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/configuration/ComponentConfiguration.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/configuration/ComponentConfiguration.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/configuration/ComponentConfiguration.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/configuration/ComponentConfiguration.java Thu Aug 10 15:32:40 2006
@@ -21,7 +21,7 @@
 
 /**
  * Simple configuration class storing properties as key with defined property
- * values as values in a <code>Map<String,String></code>. As amap cannot
+ * values as values in a <code>Map<String,String></code>. As a map cannot
  * contain duplicate keys the first use of a key can not be replaced. If a key
  * is used twice a {@link java.lang.IllegalArgumentException} will be thrown.
  * @see Map

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/configuration/PropertyInjector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/configuration/PropertyInjector.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/configuration/PropertyInjector.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/configuration/PropertyInjector.java Thu Aug 10 15:32:40 2006
@@ -19,14 +19,15 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.util.HashMap;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.Map.Entry;
 
+import org.apache.lucene.gdata.utils.ReflectionUtils;
+
 /**
  * PropertyInjector is used to set member variables / properties of classes via
- * <i>setter</i> methodes using the
+ * <i>setter</i> methods using the
  * {@link org.apache.lucene.gdata.server.registry.configuration.ComponentConfiguration}
  * class.
  * <p>
@@ -34,8 +35,8 @@
  * the class or a superclass of the object to populate has to provide at least
  * one setter method with a single parameter. The object to populate is set via
  * the {@link PropertyInjector#setTargetObject} method. The class of the object
- * will be analyzed for setter methodes having a "set" prefix in their method
- * name. If one of the found setter methodes is annotated with
+ * will be analyzed for setter methods having a "set" prefix in their method
+ * name. If one of the found setter methods is annotated with
  * {@link org.apache.lucene.gdata.server.registry.configuration.Requiered} this
  * property is interpreted as a mandatory property. Mandatory properties must be
  * available in the provided ComponentConfiguration, if not the injection will
@@ -46,14 +47,14 @@
  * setter method without the 'set' prefix and must begin with a lower case
  * character. <span>Key<code>bufferSize</code> does match a method signature
  * of <code>setBufferSize</code></span> The type of the parameter will be
- * reflected via the Reflection API and instanciated with the given value if
+ * reflected via the Reflection API and instantiated with the given value if
  * possible.
  * </p>
  * <p>
- * Setter methodes without a <code>Requiered</code> anntoation will be set if
+ * Setter methods without a <code>Required</code> annotation will be set if
  * the property is present in the ComponentConfiguration
  * </p>
- * <p>This class does not support overloaded setter methodes.</p>
+ * <p>This class does not support overloaded setter methods.</p>
  * @author Simon Willnauer
  * @see org.apache.lucene.gdata.server.registry.configuration.Requiered
  * @see org.apache.lucene.gdata.server.registry.configuration.ComponentConfiguration
@@ -88,7 +89,7 @@
         if (this.requieredProperties.isEmpty()
                 && this.optionalProperties.isEmpty())
             throw new InjectionException(
-                    "Given type has no public setter methodes -- "
+                    "Given type has no public setter methods -- "
                             + o.getClass().getName());
 
     }
@@ -132,7 +133,7 @@
 
     /**
      * Injects the properties stored in the <code>ComponentConfiguration</code>
-     * to the corresponding methodes of the target object
+     * to the corresponding methods of the target object
      * @param bean - configuration bean containing all properties to set.
      * 
      */
@@ -143,11 +144,11 @@
             throw new IllegalStateException("target is not set -- null");
         Set<Entry<String, Method>> requiered = this.requieredProperties
                 .entrySet();
-        // set requiered properties
+        // set required properties
         for (Entry<String, Method> entry : requiered) {
             if (!bean.contains(entry.getKey()))
                 throw new InjectionException(
-                        "requiered property can not be set -- value not in configuration bean; Property: "
+                        "Required property can not be set -- value not in configuration bean; Property: "
                                 + entry.getKey()
                                 + "for class "
                                 + this.targetClass.getName());
@@ -196,12 +197,12 @@
     private Object createObject(String s, Class<?> clazz) {
 
         try {
-            // if class is requested use s as fully qualified classname
+            // if class is requested use s as fully qualified class name
             if (clazz == Class.class)
                 return Class.forName(s);
             // check for primitive type
             if (clazz.isPrimitive())
-                clazz = getPrimitiveWrapper(clazz);
+                clazz = ReflectionUtils.getPrimitiveWrapper(clazz);
             boolean defaultConst = false;
             boolean stringConst = false;
             Constructor[] constructors = clazz.getConstructors();
@@ -226,8 +227,8 @@
                 return constructor.newInstance(new Object[] { s });
             }
             /*
-             * if no string const. but a default const -- use the string as a
-             * classname
+             * if no string const. but a default const. -- use the string as a
+             * class name
              */
             if (defaultConst)
                 return Class.forName(s).newInstance();
@@ -255,28 +256,6 @@
         this.requieredProperties.clear();
     }
 
-    /*
-     * return the wrappertype for the given primitive type. Wrappers can be
-     * easily instanciated via reflection and will be boxed by the vm
-     */
-    private static final Class getPrimitiveWrapper(Class primitive) {
-
-        if (primitive == Integer.TYPE)
-            return Integer.class;
-        if (primitive == Float.TYPE)
-            return Float.class;
-        if (primitive == Long.TYPE)
-            return Long.class;
-        if (primitive == Short.TYPE)
-            return Short.class;
-        if (primitive == Byte.TYPE)
-            return Byte.class;
-        if (primitive == Double.TYPE)
-            return Double.class;
-        if (primitive == Boolean.TYPE)
-            return Boolean.class;
-
-        return primitive;
-    }
+    
 
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractAccountHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractAccountHandler.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractAccountHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractAccountHandler.java Thu Aug 10 15:32:40 2006
@@ -26,6 +26,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.gdata.data.GDataAccount;
 import org.apache.lucene.gdata.data.GDataAccount.AccountRole;
+import org.apache.lucene.gdata.server.GDataResponse;
 import org.apache.lucene.gdata.server.ServiceException;
 import org.apache.lucene.gdata.server.ServiceFactory;
 import org.apache.lucene.gdata.server.administration.AccountBuilder;
@@ -72,10 +73,10 @@
 
                 GDataAccount account = getAccountFromRequest(request);
                 if (!account.requiredValuesSet()) {
-                    setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
-                            "requiered server component not available");
+                    setError(GDataResponse.SERVER_ERROR,
+                            "Required server component not available");
                     throw new AccountHandlerException(
-                            "requiered values are not set -- account can not be saved -- "
+                            "Required values are not set -- account can not be saved -- "
                                     + account);
                 }
                 this.service = factory.getAdminService();
@@ -83,13 +84,14 @@
             } catch (ServiceException e) {
                 LOG.error("Can't process account action -- " + e.getMessage(),
                         e);
-                setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "");
-            } catch (Exception e) {
+                setError(e.getErrorCode(), "");
+            } 
+            catch (AccountHandlerException e) {
                 LOG.error("Can't process account action -- " + e.getMessage(),
                         e);
             }
         }else{
-            setError(HttpServletResponse.SC_UNAUTHORIZED,"Authorization failed");
+            setError(GDataResponse.UNAUTHORIZED,"Authorization failed");
         }
         sendResponse(response);
       }finally{

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractFeedHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractFeedHandler.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractFeedHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractFeedHandler.java Thu Aug 10 15:32:40 2006
@@ -28,6 +28,7 @@
 import org.apache.lucene.gdata.data.ServerBaseFeed;
 import org.apache.lucene.gdata.data.GDataAccount.AccountRole;
 import org.apache.lucene.gdata.server.GDataEntityBuilder;
+import org.apache.lucene.gdata.server.GDataResponse;
 import org.apache.lucene.gdata.server.ServiceException;
 import org.apache.lucene.gdata.server.ServiceFactory;
 import org.apache.lucene.gdata.server.administration.AdminService;
@@ -62,7 +63,7 @@
             HttpServletResponse response) throws ServletException, IOException {
             this.authenticated = authenticateAccount(request,AccountRole.FEEDAMINISTRATOR);
             if(!this.authenticated)
-                setError(HttpServletResponse.SC_UNAUTHORIZED,"Authorization failed");
+                setError(GDataResponse.UNAUTHORIZED,"Authorization failed");
         
     }
     
@@ -70,12 +71,12 @@
         GDataServerRegistry registry = GDataServerRegistry.getRegistry();
         String providedService = request.getParameter(PARAMETER_SERVICE);
         if(!registry.isServiceRegistered(providedService)){
-            setError(HttpServletResponse.SC_NOT_FOUND,"no such service");
+            setError(GDataResponse.NOT_FOUND,"no such service");
             throw new FeedHandlerException("ProvicdedService is not registered -- Name: "+providedService);
          }
         ProvidedService provServiceInstance = registry.getProvidedService(providedService);  
         if(providedService == null){
-            setError(HttpServletResponse.SC_BAD_REQUEST,"no such service");
+            setError(GDataResponse.BAD_REQUEST,"no such service");
             throw new FeedHandlerException("no such service registered -- "+providedService);
         }
         try{
@@ -85,12 +86,12 @@
         }catch (IOException e) {
             if(LOG.isInfoEnabled())
                 LOG.info("Can not read from input stream - ",e);
-            setError(HttpServletResponse.SC_BAD_REQUEST,"Can not read from input stream");
+            setError(GDataResponse.BAD_REQUEST,"Can not read from input stream");
             throw e;
         }catch (ParseException e) {
             if(LOG.isInfoEnabled())
                 LOG.info("feed can not be parsed - ",e);
-            setError(HttpServletResponse.SC_BAD_REQUEST,"incoming feed can not be parsed");
+            setError(GDataResponse.BAD_REQUEST,"incoming feed can not be parsed");
             throw e;
         }
         
@@ -102,7 +103,7 @@
            ServiceFactory serviceFactory = registry.lookup(ServiceFactory.class,ComponentType.SERVICEFACTORY);
         
         if(serviceFactory == null){
-            setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Required server component not available");
+            setError(GDataResponse.SERVER_ERROR, "Required server component not available");
             throw new FeedHandlerException("Required server component not available -- "+ServiceFactory.class.getName());
         }
         AdminService service = serviceFactory.getAdminService();

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractGdataRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractGdataRequestHandler.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractGdataRequestHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractGdataRequestHandler.java Thu Aug 10 15:32:40 2006
@@ -61,14 +61,15 @@
         this.feedRequest = new GDataRequest(request, type);
         this.feedResponse = new GDataResponse(response);
         this.feedResponse.setEncoding(ENCODING);
-        getService();
+        
         try {       
             this.feedRequest.initializeRequest();
         } catch (GDataRequestException e) {
-            this.feedResponse.setError(HttpServletResponse.SC_NOT_FOUND);
+            setError(e.getErrorCode());
             LOG.warn("Couldn't initialize FeedRequest - " + e.getMessage(), e);
             throw e;
         }
+        getService(this.feedRequest);
     }
 
     
@@ -90,10 +91,10 @@
 		this.feedResponse.setError(error);
 	}
 
-    private void getService() throws ServletException {
+    private void getService(GDataRequest request) throws ServletException {
         GDataServerRegistry registry = GDataServerRegistry.getRegistry();
         ServiceFactory serviceFactory = registry.lookup(ServiceFactory.class,ComponentType.SERVICEFACTORY);
-        this.service = serviceFactory.getService();
+        this.service = serviceFactory.getService(request);
         if(this.service == null)
             throw new ServletException("Service not available"); 
         

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AuthenticationHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AuthenticationHandler.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AuthenticationHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AuthenticationHandler.java Thu Aug 10 15:32:40 2006
@@ -27,6 +27,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.gdata.data.GDataAccount;
+import org.apache.lucene.gdata.server.GDataResponse;
 import org.apache.lucene.gdata.server.ServiceException;
 import org.apache.lucene.gdata.server.ServiceFactory;
 import org.apache.lucene.gdata.server.administration.AdminService;
@@ -91,10 +92,10 @@
         }
         } catch (AuthenticationException e){
             LOG.error("BadAuthentication -- "+e.getMessage(),e);
-            sendError(response, HttpServletResponse.SC_FORBIDDEN,"BadAuthentication");
+            sendError(response, GDataResponse.FORBIDDEN,"BadAuthentication");
         }catch (Exception e) {
             LOG.error("Unexpected Exception -- SERVERERROR -- "+e.getMessage(),e);
-            sendError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Service not available");
+            sendError(response,GDataResponse.SERVER_ERROR, "Service not available");
         }
     }
     

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultDeleteHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultDeleteHandler.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultDeleteHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultDeleteHandler.java Thu Aug 10 15:32:40 2006
@@ -25,6 +25,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.gdata.data.GDataAccount.AccountRole;
 import org.apache.lucene.gdata.server.GDataRequestException;
+import org.apache.lucene.gdata.server.GDataResponse;
 import org.apache.lucene.gdata.server.ServiceException;
 import org.apache.lucene.gdata.server.GDataRequest.GDataRequestType;
 
@@ -37,7 +38,7 @@
  * </p>
  * <ol>
  * <li>if the entry could be deleted - HTTP status code <i>200 OK</i></li>
- * <li>if an error occures - HTTP status code <i>500 INTERNAL SERVER ERROR</i></li>
+ * <li>if an error occurs - HTTP status code <i>500 INTERNAL SERVER ERROR</i></li>
  * <li>if the resource could not found - HTTP status code <i>404 NOT FOUND</i></li>
  * </ol>
  *  
@@ -63,7 +64,7 @@
 			return;
 		}
         if(!authenticateAccount(request,AccountRole.ENTRYAMINISTRATOR)){
-            setError(HttpServletResponse.SC_UNAUTHORIZED);
+            setError(GDataResponse.UNAUTHORIZED);
             sendError();
             return;
         }
@@ -74,6 +75,7 @@
 		} catch (ServiceException e) {
 			LOG.error("Could not process DeleteFeed request - "
 					+ e.getMessage(), e);
+            setError(e.getErrorCode());
 			sendError();
 		}finally{
         closeService();

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultGetHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultGetHandler.java?rev=430568&r1=430567&r2=430568&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultGetHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultGetHandler.java Thu Aug 10 15:32:40 2006
@@ -37,10 +37,10 @@
 /**
  * Default Handler implementation. This handler processes the incoming
  * {@link org.apache.lucene.gdata.server.GDataRequest} and retrieves the
- * requested feed from the underlaying storage.
+ * requested feed from the underlying storage.
  * <p>
- * This hander also processes search queries and retrives the search hits from
- * the underlaying search component. The user query will be accessed via the
+ * This hander also processes search queries and retrieves the search hits from
+ * the underlying search component. The user query will be accessed via the
  * {@link org.apache.lucene.gdata.server.GDataRequest} instance passed to the
  * {@link Service} class.
  * </p>
@@ -101,6 +101,7 @@
         } catch (ServiceException e) {
             LOG.error("Could not process GetFeed request - " + e.getMessage(),
                     e);
+            setError(e.getErrorCode());
             sendError();
         }finally{
         closeService();
@@ -110,9 +111,9 @@
     /**
      * 
      * returns true if the resource has been modified since the specified
-     * reqeust header value
+     * request header value
      */
-    private boolean checkIsModified(String lastModified)
+    protected boolean checkIsModified(String lastModified)
             throws ServiceException {
         if (lastModified == null)
             return true;
@@ -126,7 +127,7 @@
                 entityDate = this.service.getEntryLastModified(this.feedRequest
                         .getEntryId(),this.feedRequest.getFeedId());
             if(LOG.isInfoEnabled())
-                LOG.info("comparing date clientDate: "+clientDate+"; lastmodified: "+entityDate);
+                LOG.info("comparing date clientDate: "+clientDate+"; last modified: "+entityDate);
             return (entityDate.getTime()-clientDate.getTime() > 1000);
         } catch (java.text.ParseException e) {
             LOG.info("Couldn't parse Last-Modified header -- "+lastModified,e);



Mime
View raw message