lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r417265 [3/6] - in /lucene/java/trunk/contrib/gdata-server: ./ lib/ src/java/ src/java/org/apache/lucene/gdata/server/ src/java/org/apache/lucene/gdata/server/registry/ src/java/org/apache/lucene/gdata/servlet/ src/java/org/apache/lucene/gd...
Date Mon, 26 Jun 2006 18:14:55 GMT
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=417265&r1=417264&r2=417265&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 Mon Jun 26 11:14:53 2006
@@ -1,84 +1,83 @@
-/** 
- * 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.servlet.handler; 
- 
-import java.io.IOException; 
- 
-import javax.servlet.ServletException; 
-import javax.servlet.http.HttpServletRequest; 
-import javax.servlet.http.HttpServletResponse; 
- 
-import org.apache.commons.logging.Log; 
-import org.apache.commons.logging.LogFactory; 
-import org.apache.lucene.gdata.server.FeedNotFoundException; 
-import org.apache.lucene.gdata.server.GDataRequestException; 
-import org.apache.lucene.gdata.server.Service; 
-import org.apache.lucene.gdata.server.ServiceException; 
-import org.apache.lucene.gdata.server.GDataRequest.GDataRequestType; 
- 
-/** 
- * Default Handler implementation. This handler processes the incoming 
- * {@link org.apache.lucene.gdata.server.GDataRequest} and deletes the requested 
- * feed entry from the storage and the search component. 
- * <p> 
- * The handler sends following response to the client: 
- * </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 the resource could not found - HTTP status code <i>404 NOT FOUND</i></li> 
- * </ol> 
+/**
+ * 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.servlet.handler;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+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.ServiceException;
+import org.apache.lucene.gdata.server.GDataRequest.GDataRequestType;
+
+/**
+ * Default Handler implementation. This handler processes the incoming
+ * {@link org.apache.lucene.gdata.server.GDataRequest} and deletes the requested
+ * feed entry from the storage and the search component.
+ * <p>
+ * The handler sends following response to the client:
+ * </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 the resource could not found - HTTP status code <i>404 NOT FOUND</i></li>
+ * </ol>
  *  
- * @author Simon Willnauer 
- *  
- */ 
-public class DefaultDeleteHandler extends AbstractGdataRequestHandler { 
-    private static final Log LOG = LogFactory 
-            .getLog(DefaultDeleteHandler.class); 
- 
-    /** 
-     * @throws ServletException  
-     * @see org.apache.lucene.gdata.servlet.handler.AbstractGdataRequestHandler#processRequest(javax.servlet.http.HttpServletRequest, 
-     *      javax.servlet.http.HttpServletResponse) 
-     */ 
-    @Override 
-    public void processRequest(HttpServletRequest request, 
-            HttpServletResponse response) throws IOException, ServletException { 
-        try { 
-            initializeRequestHandler(request, response,GDataRequestType.DELETE); 
-        } catch (GDataRequestException e) { 
-            sendError(); 
-            return; 
-        } 
-         
-        Service service = getService(); 
-        try { 
-            service.deleteEntry(this.feedRequest, this.feedResponse); 
-        } catch (FeedNotFoundException e) { 
-            LOG.error("Could not process DeleteFeed request Feed Not Found- " 
-                    + e.getMessage(), e); 
-            setError(HttpServletResponse.SC_NOT_FOUND); 
-            sendError(); 
-        } catch (ServiceException e) { 
-            LOG.error("Could not process DeleteFeed request - " 
-                    + e.getMessage(), e); 
-            setError(HttpServletResponse.SC_BAD_REQUEST); 
-            sendError(); 
-        } 
- 
-    } 
- 
-} 
+ * @author Simon Willnauer
+ * 
+ */
+public class DefaultDeleteHandler extends AbstractGdataRequestHandler {
+	private static final Log LOG = LogFactory
+			.getLog(DefaultDeleteHandler.class);
+
+	/**
+	 * @throws ServletException 
+	 * @see org.apache.lucene.gdata.servlet.handler.AbstractGdataRequestHandler#processRequest(javax.servlet.http.HttpServletRequest,
+	 *      javax.servlet.http.HttpServletResponse)
+	 */
+	@Override
+	public void processRequest(HttpServletRequest request,
+			HttpServletResponse response) throws IOException, ServletException {
+		try {
+			initializeRequestHandler(request, response,GDataRequestType.DELETE);
+		} catch (GDataRequestException e) {
+			sendError();
+			return;
+		}
+        if(!authenticateAccount(request,AccountRole.ENTRYAMINISTRATOR)){
+            setError(HttpServletResponse.SC_UNAUTHORIZED);
+            sendError();
+            return;
+        }
+		
+		try {
+			this.service.deleteEntry(this.feedRequest, this.feedResponse);
+		
+		} catch (ServiceException e) {
+			LOG.error("Could not process DeleteFeed request - "
+					+ e.getMessage(), e);
+			sendError();
+		}
+        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=417265&r1=417264&r2=417265&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 Mon Jun 26 11:14:53 2006
@@ -1,104 +1,138 @@
-/** 
- * Copyright 2004 The Apache Software Foundation 
+/**
+ * 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.servlet.handler;
+
+import java.io.IOException;
+import java.util.Date;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.gdata.server.GDataRequestException;
+import org.apache.lucene.gdata.server.Service;
+import org.apache.lucene.gdata.server.ServiceException;
+import org.apache.lucene.gdata.server.GDataRequest.GDataRequestType;
+import org.apache.lucene.gdata.utils.DateFormater;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.BaseFeed;
+
+/**
+ * Default Handler implementation. This handler processes the incoming
+ * {@link org.apache.lucene.gdata.server.GDataRequest} and retrieves the
+ * requested feed from the underlaying 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
+ * {@link org.apache.lucene.gdata.server.GDataRequest} instance passed to the
+ * {@link Service} class.
+ * </p>
+ * <p>
+ * The DefaultGetHandler supports HTTP Conditional GET. It set the Last-Modified
+ * response header based upon the value of the <atom:updated> element in the
+ * returned feed or entry. A client can send this value back as the value of the
+ * If-Modified-Since request header to avoid retrieving the content again if it
+ * hasn't changed. If the content hasn't changed since the If-Modified-Since
+ * time, then the GData service returns a 304 (Not Modified) HTTP response.</p>
  * 
- * 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 
+ * @author Simon Willnauer
  * 
- * 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.servlet.handler; 
- 
-import java.io.IOException; 
- 
-import javax.servlet.ServletException; 
-import javax.servlet.http.HttpServletRequest; 
-import javax.servlet.http.HttpServletResponse; 
- 
-import org.apache.commons.logging.Log; 
-import org.apache.commons.logging.LogFactory; 
-import org.apache.lucene.gdata.server.GDataRequestException; 
-import org.apache.lucene.gdata.server.Service; 
-import org.apache.lucene.gdata.server.ServiceException; 
-import org.apache.lucene.gdata.server.GDataRequest.GDataRequestType; 
- 
-import com.google.gdata.data.BaseEntry; 
-import com.google.gdata.data.BaseFeed; 
- 
-/** 
- * Default Handler implementation. This handler processes the incoming 
- * {@link org.apache.lucene.gdata.server.GDataRequest} and retrieves the 
- * requested feed from the underlaying 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 
- * {@link org.apache.lucene.gdata.server.GDataRequest} instance passed to the 
- * {@link Service} class. 
- * </p> 
- *  
- *  
- * @author Simon Willnauer 
- *  
- */ 
-public class DefaultGetHandler extends AbstractGdataRequestHandler { 
-    private static final Log LOG = LogFactory.getLog(DefaultGetHandler.class); 
- 
-    /** 
-     * @see org.apache.lucene.gdata.servlet.handler.AbstractGdataRequestHandler#processRequest(javax.servlet.http.HttpServletRequest, 
-     *      javax.servlet.http.HttpServletResponse) 
-     */ 
-    @Override 
-    public void processRequest(HttpServletRequest request, 
-            HttpServletResponse response) throws IOException, ServletException { 
-        try { 
-            initializeRequestHandler(request, response, GDataRequestType.GET); 
-        } catch (GDataRequestException e) { 
-            sendError(); 
-            return; 
-        } 
-        Service service = getService(); 
-        try { 
-            if (LOG.isInfoEnabled()) 
-                LOG.info("Requested output formate: " 
-                        + this.feedRequest.getRequestedResponseFormat()); 
-            this.feedResponse.setOutputFormat(this.feedRequest 
-                    .getRequestedResponseFormat()); 
-            if(this.feedRequest.isFeedRequested()){ 
-            BaseFeed feed = service 
-                    .getFeed(this.feedRequest, this.feedResponse); 
-         
-            this.feedResponse.sendResponse(feed, this.feedRequest.getExtensionProfile()); 
-            }else{ 
-             BaseEntry entry = service.getSingleEntry(this.feedRequest,this.feedResponse); 
-             if(entry == null){ 
-                 this.feedResponse.setError(HttpServletResponse.SC_NOT_FOUND); 
-                 sendError(); 
-             } 
-             this.feedResponse.sendResponse(entry, this.feedRequest.getExtensionProfile()); 
-            } 
-             
-             
-        } catch (ServiceException e) { // TODO handle exceptions to send exact 
-            // response 
-            LOG.error("Could not process GetFeed request - " + e.getMessage(), 
-                    e); 
-            this.feedResponse.setError(HttpServletResponse.SC_BAD_REQUEST); // TODO 
-            // change 
-            // this 
-            sendError(); 
-        } 
-         
-         
- 
-    } 
-     
-     
- 
-} 
+ */
+public class DefaultGetHandler extends AbstractGdataRequestHandler {
+    private static final Log LOG = LogFactory.getLog(DefaultGetHandler.class);
+
+    /**
+     * @see org.apache.lucene.gdata.servlet.handler.AbstractGdataRequestHandler#processRequest(javax.servlet.http.HttpServletRequest,
+     *      javax.servlet.http.HttpServletResponse)
+     */
+    @Override
+    public void processRequest(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException {
+        try {
+            initializeRequestHandler(request, response, GDataRequestType.GET);
+        } catch (GDataRequestException e) {
+            sendError();
+            return;
+        }
+
+        try {
+            String modifiedSince = this.feedRequest.getModifiedSince();
+            if (!checkIsModified(modifiedSince)) {
+                this.feedResponse
+                        .setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+                return;
+            }
+            if (LOG.isInfoEnabled())
+                LOG.info("Requested output formate: "
+                        + this.feedRequest.getRequestedResponseFormat());
+            this.feedResponse.setOutputFormat(this.feedRequest
+                    .getRequestedResponseFormat());
+            if (this.feedRequest.isFeedRequested()) {
+                BaseFeed feed = this.service.getFeed(this.feedRequest,
+                        this.feedResponse);
+
+                this.feedResponse.sendResponse(feed, this.feedRequest
+                        .getConfigurator().getExtensionProfile());
+            } else {
+                BaseEntry entry = this.service.getSingleEntry(this.feedRequest,
+                        this.feedResponse);
+                this.feedResponse.sendResponse(entry, this.feedRequest
+                        .getConfigurator().getExtensionProfile());
+            }
+
+        } catch (ServiceException e) {
+            LOG.error("Could not process GetFeed request - " + e.getMessage(),
+                    e);
+            sendError();
+        }
+        closeService();
+
+    }
+
+    /**
+     * 
+     * returns true if the resource has been modified since the specified
+     * reqeust header value
+     */
+    private boolean checkIsModified(String lastModified)
+            throws ServiceException {
+        if (lastModified == null)
+            return true;
+        try {
+            Date clientDate = DateFormater.parseDate(lastModified,DateFormater.HTTP_HEADER_DATE_FORMAT,DateFormater.HTTP_HEADER_DATE_FORMAT_TIME_OFFSET);
+            Date entityDate;
+            if (this.feedRequest.isFeedRequested())
+                entityDate = this.service.getFeedLastModified(this.feedRequest
+                        .getFeedId());
+            else
+                entityDate = this.service.getEntryLastModified(this.feedRequest
+                        .getEntryId(),this.feedRequest.getFeedId());
+            if(LOG.isInfoEnabled())
+                LOG.info("comparing date clientDate: "+clientDate+"; lastmodified: "+entityDate);
+            return (entityDate.getTime()-clientDate.getTime() > 1000);
+        } catch (java.text.ParseException e) {
+            LOG.info("Couldn't parse Last-Modified header -- "+lastModified,e);
+
+        }
+        return true;
+    }
+
+}

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultInsertHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultInsertHandler.java?rev=417265&r1=417264&r2=417265&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultInsertHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultInsertHandler.java Mon Jun 26 11:14:53 2006
@@ -1,83 +1,86 @@
-/** 
- * Copyright 2004 The Apache Software Foundation 
+/**
+ * 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.servlet.handler;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+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.ServiceException;
+import org.apache.lucene.gdata.server.GDataRequest.GDataRequestType;
+
+import com.google.gdata.data.BaseEntry;
+
+/**
+ * Default Handler implementation. This handler processes the incoming
+ * {@link org.apache.lucene.gdata.server.GDataRequest} and inserts the requested
+ * feed entry into the storage and the search component.
+ * <p>
+ * The handler sends following response to the client:
+ * </p>
+ * <ol>
+ * <li>if the entry was added - 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 the resource could not found - HTTP status code <i>404 NOT FOUND</i></li>
+ * </ol>
+ * <p>The added entry will be send back to the client if the insert request was successful.</p>
  * 
- * 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.servlet.handler; 
- 
-import java.io.IOException; 
- 
-import javax.servlet.ServletException; 
-import javax.servlet.http.HttpServletRequest; 
-import javax.servlet.http.HttpServletResponse; 
- 
-import org.apache.commons.logging.Log; 
-import org.apache.commons.logging.LogFactory; 
-import org.apache.lucene.gdata.server.GDataRequestException; 
-import org.apache.lucene.gdata.server.Service; 
-import org.apache.lucene.gdata.server.ServiceException; 
-import org.apache.lucene.gdata.server.GDataRequest.GDataRequestType; 
- 
-import com.google.gdata.data.BaseEntry; 
- 
-/** 
- * Default Handler implementation. This handler processes the incoming 
- * {@link org.apache.lucene.gdata.server.GDataRequest} and inserts the requested 
- * feed entry into the storage and the search component. 
- * <p> 
- * The handler sends following response to the client: 
- * </p> 
- * <ol> 
- * <li>if the entry was added - 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 the resource could not found - HTTP status code <i>404 NOT FOUND</i></li> 
- * </ol> 
- * <p>The added entry will be send back to the client if the insert request was successful.</p> 
- *  
- * @author Simon Willnauer 
- * 
- */ 
-public class DefaultInsertHandler extends AbstractGdataRequestHandler { 
-    private static final Log LOG = LogFactory.getLog(DefaultInsertHandler.class); 
-    /** 
-     * @throws ServletException  
-     * @see org.apache.lucene.gdata.servlet.handler.GDataRequestHandler#processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 
-     */ 
-    @Override 
-    public void processRequest(HttpServletRequest request, 
-            HttpServletResponse response) throws IOException, ServletException { 
-        try { 
-            initializeRequestHandler(request,response,GDataRequestType.INSERT);             
-        } catch (GDataRequestException e) { 
-            sendError(); 
-            return; 
-        } 
-         
-        Service service = getService(); 
-        try{         
-        BaseEntry entry = service.createEntry(this.feedRequest,this.feedResponse); 
-        setFeedResponseFormat(); 
-        setFeedResponseStatus(HttpServletResponse.SC_CREATED);         
-        this.feedResponse.sendResponse(entry, this.feedRequest.getExtensionProfile()); 
-         
-        }catch (ServiceException e) { 
-           LOG.error("Could not process GetFeed request - "+e.getMessage(),e); 
-           setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); 
-           this.feedResponse.sendError(); 
-        } 
-         
-         
-    } 
- 
-} 
+ * @author Simon Willnauer
+ *
+ */
+public class DefaultInsertHandler extends AbstractGdataRequestHandler {
+    private static final Log LOG = LogFactory.getLog(DefaultInsertHandler.class);
+    /**
+     * @throws ServletException 
+     * @see org.apache.lucene.gdata.servlet.handler.GDataRequestHandler#processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+     */
+    @Override
+	public void processRequest(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException {
+        try {
+            initializeRequestHandler(request,response,GDataRequestType.INSERT);            
+        } catch (GDataRequestException e) {
+            sendError();
+            return;
+        }
+        if(!authenticateAccount(this.feedRequest,AccountRole.ENTRYAMINISTRATOR)){
+            setError(HttpServletResponse.SC_UNAUTHORIZED);
+            sendError();
+            return;
+        }
+       
+        try{        
+        BaseEntry entry = this.service.createEntry(this.feedRequest,this.feedResponse);
+        setFeedResponseFormat();
+        setFeedResponseStatus(HttpServletResponse.SC_CREATED);        
+        this.feedResponse.sendResponse(entry, this.feedRequest.getConfigurator().getExtensionProfile());
+        
+        }catch (ServiceException e) {
+           LOG.error("Could not process GetFeed request - "+e.getMessage(),e);
+           this.feedResponse.sendError();
+        }
+        closeService();
+        
+    }
+
+}

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultRequestHandlerFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultRequestHandlerFactory.java?rev=417265&r1=417264&r2=417265&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultRequestHandlerFactory.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultRequestHandlerFactory.java Mon Jun 26 11:14:53 2006
@@ -1,69 +1,149 @@
-/** 
- * Copyright 2004 The Apache Software Foundation 
+/**
+ * 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.servlet.handler;
+
+import org.apache.lucene.gdata.server.registry.Component;
+import org.apache.lucene.gdata.server.registry.ComponentType;
+
+/**
+ * Default implementation for RequestHandlerFactory Builds the
+ * {@link org.apache.lucene.gdata.servlet.handler.GDataRequestHandler}
+ * instances.
+ * This class should not be access directy. The class will be registered in the {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry}.
+ * Use {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry#lookup(Class, ComponentType)}
  * 
- * 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 
+ * @author Simon Willnauer
  * 
- *     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.servlet.handler; 
- 
-/** 
- * Default implementation for RequestHandlerFactory Builds the 
- * {@link org.apache.lucene.gdata.servlet.handler.GDataRequestHandler} 
- * instances. 
- *  
- * @author Simon Willnauer 
- *  
- */ 
-public class DefaultRequestHandlerFactory extends RequestHandlerFactory { 
- 
-    DefaultRequestHandlerFactory() { 
-        // 
-    } 
- 
-    /** 
-     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getUpdateHandler() 
-     */ 
-    @Override 
-    public GDataRequestHandler getUpdateHandler() { 
- 
-        return new DefaultUpdateHandler(); 
-    } 
- 
-    /** 
-     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getDeleteHandler() 
-     */ 
-    @Override 
-    public GDataRequestHandler getDeleteHandler() { 
- 
-        return new DefaultDeleteHandler(); 
-    } 
- 
-    /** 
-     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getQueryHandler() 
-     */ 
-    @Override 
-    public GDataRequestHandler getQueryHandler() { 
- 
-        return new DefaultGetHandler(); 
-    } 
- 
-    /** 
-     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getInsertHandler() 
-     */ 
-    @Override 
-    public GDataRequestHandler getInsertHandler() { 
- 
-        return new DefaultInsertHandler(); 
-    } 
- 
-} 
+ */
+@Component(componentType=ComponentType.REQUESTHANDLERFACTORY)
+public class DefaultRequestHandlerFactory extends RequestHandlerFactory {
+
+
+    /**
+     * public constructor to enable loading via the registry
+     * @see org.apache.lucene.gdata.server.registry.Component
+     * @see org.apache.lucene.gdata.server.registry.GDataServerRegistry
+     */
+	public DefaultRequestHandlerFactory() {
+		//
+	}
+
+	/**
+	 * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getEntryUpdateHandler()
+	 */
+	@Override
+	public GDataRequestHandler getEntryUpdateHandler() {
+
+		return new DefaultUpdateHandler();
+	}
+
+	/**
+	 * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getEntryDeleteHandler()
+	 */
+	@Override
+	public GDataRequestHandler getEntryDeleteHandler() {
+
+		return new DefaultDeleteHandler();
+	}
+
+	/**
+	 * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getFeedQueryHandler()
+	 */
+	@Override
+	public GDataRequestHandler getFeedQueryHandler() {
+
+		return new DefaultGetHandler();
+	}
+
+	/**
+	 * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getEntryInsertHandler()
+	 */
+	@Override
+	public GDataRequestHandler getEntryInsertHandler() {
+
+		return new DefaultInsertHandler();
+	}
+
+    /**
+     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getInsertAccountHandler()
+     */
+    @Override
+    public GDataRequestHandler getInsertAccountHandler() {
+        
+        return new InsertAccountStrategy();
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getDeleteAccountHandler()
+     */
+    @Override
+    public GDataRequestHandler getDeleteAccountHandler() {
+        
+        return new DeleteAccountStrategy();
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getUpdateAccountHandler()
+     */
+    @Override
+    public GDataRequestHandler getUpdateAccountHandler() {
+        
+        return new UpdataAccountStrategy();
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getInsertFeedHandler()
+     */
+    @Override
+    public GDataRequestHandler getInsertFeedHandler() {
+        
+        return new InsertFeedHandler();
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getUpdateFeedHandler()
+     */
+    @Override
+    public GDataRequestHandler getUpdateFeedHandler() {
+        
+        return new UpdateFeedHandler();
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory#getDeleteFeedHandler()
+     */
+    @Override
+    public GDataRequestHandler getDeleteFeedHandler() {
+        
+        return new DeleteFeedHandler();
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.server.registry.ServerComponent#initialize()
+     */
+    public void initialize() {
+        //
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.server.registry.ServerComponent#destroy()
+     */
+    public void destroy() {
+        //
+    }
+
+}

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultUpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultUpdateHandler.java?rev=417265&r1=417264&r2=417265&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultUpdateHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultUpdateHandler.java Mon Jun 26 11:14:53 2006
@@ -1,94 +1,89 @@
-/** 
- * Copyright 2004 The Apache Software Foundation 
+/**
+ * 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.servlet.handler;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+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.ServiceException;
+import org.apache.lucene.gdata.server.GDataRequest.GDataRequestType;
+
+import com.google.gdata.data.BaseEntry;
+
+/**
+ * Default Handler implementation. This handler processes the incoming
+ * {@link org.apache.lucene.gdata.server.GDataRequest} and updates the requested
+ * feed entry in the storage and the search component.
+ * <p>
+ * The handler sends following response to the client:
+ * </p>
+ * <ol>
+ * <li>if the entry was successfully updated - 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 the resource could not found - HTTP status code <i>404 NOT FOUND</i></li>
+ * </ol>
  * 
- * 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.servlet.handler; 
- 
-import java.io.IOException; 
- 
-import javax.servlet.ServletException; 
-import javax.servlet.http.HttpServletRequest; 
-import javax.servlet.http.HttpServletResponse; 
- 
-import org.apache.commons.logging.Log; 
-import org.apache.commons.logging.LogFactory; 
-import org.apache.lucene.gdata.server.FeedNotFoundException; 
-import org.apache.lucene.gdata.server.GDataRequestException; 
-import org.apache.lucene.gdata.server.Service; 
-import org.apache.lucene.gdata.server.ServiceException; 
-import org.apache.lucene.gdata.server.GDataRequest.GDataRequestType; 
- 
-import com.google.gdata.data.BaseEntry; 
- 
-/** 
- * Default Handler implementation. This handler processes the incoming 
- * {@link org.apache.lucene.gdata.server.GDataRequest} and updates the requested 
- * feed entry in the storage and the search component. 
- * <p> 
- * The handler sends following response to the client: 
- * </p> 
- * <ol> 
- * <li>if the entry was successfully updated - 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 the resource could not found - HTTP status code <i>404 NOT FOUND</i></li> 
- * </ol> 
- *  
- * @author Simon Willnauer 
+ * @author Simon Willnauer
  *  
- */ 
-public class DefaultUpdateHandler extends AbstractGdataRequestHandler { 
-    private static final Log LOG = LogFactory 
-            .getLog(DefaultUpdateHandler.class); 
- 
-    /** 
-     * @throws ServletException  
-     * @see org.apache.lucene.gdata.servlet.handler.AbstractGdataRequestHandler#processRequest(javax.servlet.http.HttpServletRequest, 
-     *      javax.servlet.http.HttpServletResponse) 
-     */ 
-    @Override 
-    public void processRequest(HttpServletRequest request, 
-            HttpServletResponse response) throws  IOException, ServletException { 
-        try { 
-            initializeRequestHandler(request, response,GDataRequestType.UPDATE); 
-        } catch (GDataRequestException e) { 
-            sendError(); 
-            return; 
-        } 
-         
-        Service service = getService(); 
-        try { 
-            BaseEntry entry = service.updateEntry(this.feedRequest, 
-                    this.feedResponse); 
-            setFeedResponseFormat(); 
-            setFeedResponseStatus(HttpServletResponse.SC_OK); 
-            this.feedResponse.sendResponse(entry, this.feedRequest.getExtensionProfile()); 
-        }catch (FeedNotFoundException e) { 
-            LOG.error("Could not process UpdateFeed request - " 
-                    + e.getMessage(), e); 
-            setError(HttpServletResponse.SC_NOT_FOUND); 
-             
-            sendError(); 
-        } 
-        catch (ServiceException e) { 
-             
-            LOG.error("Could not process UpdateFeed request - " 
-                    + e.getMessage(), e); 
-            setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); 
-             
-            sendError(); 
-        } 
- 
-    } 
- 
-} 
+ */
+public class DefaultUpdateHandler extends AbstractGdataRequestHandler {
+	private static final Log LOG = LogFactory
+			.getLog(DefaultUpdateHandler.class);
+
+	/**
+	 * @throws ServletException 
+	 * @see org.apache.lucene.gdata.servlet.handler.AbstractGdataRequestHandler#processRequest(javax.servlet.http.HttpServletRequest,
+	 *      javax.servlet.http.HttpServletResponse)
+	 */
+	@Override
+	public void processRequest(HttpServletRequest request,
+			HttpServletResponse response) throws  IOException, ServletException {
+		try {
+			initializeRequestHandler(request, response,GDataRequestType.UPDATE);
+		} catch (GDataRequestException e) {
+            setError(HttpServletResponse.SC_UNAUTHORIZED);
+			sendError();
+			return;
+		}
+        if(!authenticateAccount(request,AccountRole.ENTRYAMINISTRATOR)){
+            sendError();
+            return;
+        }
+        
+		try {
+			BaseEntry entry = this.service.updateEntry(this.feedRequest,
+					this.feedResponse);
+			setFeedResponseFormat();
+			setFeedResponseStatus(HttpServletResponse.SC_OK);
+			this.feedResponse.sendResponse(entry, this.feedRequest.getConfigurator().getExtensionProfile());
+		
+		}
+		catch (ServiceException e) {
+			LOG.error("Could not process UpdateFeed request - "
+					+ e.getMessage(), e);
+			sendError();
+		}
+        closeService();
+	}
+
+}

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/RequestHandlerFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/RequestHandlerFactory.java?rev=417265&r1=417264&r2=417265&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/RequestHandlerFactory.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/RequestHandlerFactory.java Mon Jun 26 11:14:53 2006
@@ -1,122 +1,98 @@
-/** 
- * Copyright 2004 The Apache Software Foundation 
+/**
+ * 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.servlet.handler;
+
+import org.apache.lucene.gdata.server.registry.ServerComponent;
+
+/**
+ * Abstract Superclass for RequestHandlerFactories
+ * @author Simon Willnauer
  * 
- * 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.servlet.handler; 
- 
-/** 
- * @author Simon Willnauer 
- *  
- */ 
-public abstract class RequestHandlerFactory { 
-     
-    private static RequestHandlerFactory INSTANCE = null; 
- 
-    /** 
-     * This method creates a singleton instance of the given type. The fist call 
-     * will create an instance of the given class which will be returned in 
-     * every subsequent call. Any subsequent call to this method will ignore the 
-     * given class object.  
-     *  
-     * @param factoryImplementation - 
-     *            the factory implementation (must be a subtype of this Class) 
-     *  
-     * @return - a singleton instance of the given type 
-     *  
-     */ 
-    public static synchronized RequestHandlerFactory getInstance( 
-            Class factoryImplementation) { 
-        if (INSTANCE == null) { 
- 
-            INSTANCE = createInstance(factoryImplementation); 
-        } 
-        return INSTANCE; 
-    } 
- 
-    /** 
-     * Singleton - Pattern using private constructor 
-     *  
-     */ 
-    RequestHandlerFactory() { 
-        super(); 
- 
-    } 
- 
-    private static RequestHandlerFactory createInstance( 
-            final Class qualifiedClass) { 
-        if (qualifiedClass == null) 
-            throw new IllegalArgumentException( 
-                    "Factory class is null -- must be a implementation of org.apache.lucene.gdata.servlet.handler.RequestHandlerFactory"); 
-        try { 
-            return (RequestHandlerFactory) qualifiedClass.newInstance(); 
-        } catch (Exception e) { 
-            FactoryImplementationException ex = new FactoryImplementationException( 
-                    "Factory implementation could not be created", e.getCause()); 
-            ex.setStackTrace(e.getStackTrace()); 
-            throw ex; 
-        } 
-    } 
- 
-    /** 
-     * Creates a UpdateHandler which processes a GDATA UPDATE request. 
-     * @return - an RequestHandlerInstance 
-     */ 
-    public abstract GDataRequestHandler getUpdateHandler(); 
- 
-    /** 
-     * Creates a DeleteHandler which processes a GDATA DELETE request. 
-     * @return - an RequestHandlerInstance 
-     */ 
-    public abstract GDataRequestHandler getDeleteHandler(); 
- 
-    /** 
-     * Creates a QueryHandler which processes a GDATA Query / Get request. 
-     * @return - an RequestHandlerInstance 
-     */ 
-    public abstract GDataRequestHandler getQueryHandler(); 
- 
-    /** 
-     * Creates a InsertHandler which processes a GDATA Insert request. 
-     * @return - an RequestHandlerInstance 
-     */ 
-    public abstract GDataRequestHandler getInsertHandler(); 
-     
- 
- 
-    private static class FactoryImplementationException extends 
-            RuntimeException { 
- 
-        /** 
-         *  
-         */ 
-        private static final long serialVersionUID = 3166033278825112569L; 
- 
-        /** 
-         * Constructs a new FactoryImplementationException with the specified 
-         * cause and message 
-         *  
-         * @param arg0 - 
-         *            the detail message 
-         * @param arg1 - 
-         *            the throw cause 
-         */ 
-        public FactoryImplementationException(String arg0, Throwable arg1) { 
-            super(arg0, arg1); 
- 
-        } 
- 
-    } 
- 
-} 
+ */
+public abstract class RequestHandlerFactory implements ServerComponent {
+    
+
+
+
+    /**
+     * public constructor to enable loading via the registry
+     * @see org.apache.lucene.gdata.server.registry.Component
+     * @see org.apache.lucene.gdata.server.registry.GDataServerRegistry
+     */
+    public RequestHandlerFactory() {
+        super();
+
+    }
+
+
+    /**
+     * Creates a EntryUpdateHandler which processes a GDATA UPDATE request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getEntryUpdateHandler();
+
+    /**
+     * Creates a EntryDeleteHandler which processes a GDATA DELETE request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getEntryDeleteHandler();
+
+    /**
+     * Creates a FeedQueryHandler which processes a GDATA Query / Get request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getFeedQueryHandler();
+
+    /**
+     * Creates a EntryInsertHandler which processes a GDATA Insert request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getEntryInsertHandler();
+    /**
+     * Creates a InsertAccountHandler which processes a Account Insert request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getInsertAccountHandler();
+    /**
+     * Creates a DeleteAccountHandler which processes a Account Delete request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getDeleteAccountHandler();
+    /**
+     * Creates a UpdateAccountHandler which processes a Account Update request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getUpdateAccountHandler();
+    /**
+     * Creates a InsertFeedHandler which processes a Feed Insert request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getInsertFeedHandler();
+    /**
+     * Creates a UpdateFeedHandler which processes a Feed Insert request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getUpdateFeedHandler();
+    /**
+     * Creates a DeleteFeedHandler which processes a Feed Insert request.
+     * @return - a RequestHandlerInstance
+     */
+    public abstract GDataRequestHandler getDeleteFeedHandler();
+    
+
+    
+}

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/IDGenerator.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/IDGenerator.java?rev=417265&r1=417264&r2=417265&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/IDGenerator.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/IDGenerator.java Mon Jun 26 11:14:53 2006
@@ -51,7 +51,9 @@
  
     private static final int DEFAULT_CAPACITY = 10; 
  
-    protected static final Log LOGGER = LogFactory.getLog(IDGenerator.class); 
+    protected static final Log LOGGER = LogFactory.getLog(IDGenerator.class);
+
+    private static final String RUNNER_THREAD_NAME = "GDATA-ID Generator"; 
  
     /** 
      * Constructs a new ID generator. with a fixed capacity of prebuild ids. The 
@@ -91,7 +93,9 @@
         if (this.runner == null) { 
             UIDProducer producer = new UIDProducer(this.blockingQueue, 
                     this.secureRandom, this.mdigest); 
-            this.runner = new Thread(producer); 
+            this.runner = new Thread(producer);
+            this.runner.setDaemon(true);
+            this.runner.setName(RUNNER_THREAD_NAME);
             this.runner.start(); 
         } 
     } 

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/Storage.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/Storage.java?rev=417265&r1=417264&r2=417265&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/Storage.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/Storage.java Mon Jun 26 11:14:53 2006
@@ -12,89 +12,263 @@
  * 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.storage; 
- 
-import java.util.List; 
- 
-import com.google.gdata.data.BaseEntry; 
-import com.google.gdata.data.BaseFeed; 
-import com.google.gdata.data.ExtensionProfile; 
- 
-/** 
- * This is the main storage interface. The Storage represents the internal 
- * server storage. It acts as a Database to persist the feed data. 
- * This inferface is not public yet!! 
- *  
- * @author Simon Willnauer 
- *  
- */ 
-public interface Storage { 
- 
-    /** 
-     * This stores an incoming entry for a later retrival. 
-     * The Entry will be associated with the feedid. 
-     * @param entry - the entry 
-     * @param feedId - the feedID 
-     * @return - the stored Entry 
-     * @throws StorageException 
-     */ 
-    public abstract BaseEntry storeEntry(BaseEntry entry, String feedId) 
-            throws StorageException; 
- 
-    /** 
-     * @param entryId 
-     * @param feedId 
-     * @throws StorageException 
-     */ 
-    public abstract void deleteEntry(String entryId, String feedId) 
-            throws StorageException; 
- 
-    /** 
-     * @param entry 
-     * @param feedId 
-     * @return  
-     * @throws StorageException 
-     */ 
-    public abstract BaseEntry updateEntry(BaseEntry entry, String feedId) 
-            throws StorageException; 
- 
-    /** 
-     * @param feedId 
-     * @param startIndex 
-     * @param resultCount 
-     * @return 
-     * @throws StorageException 
-     */ 
-    public abstract BaseFeed getFeed(String feedId, int startIndex, 
-            int resultCount) throws StorageException; 
- 
-    /** 
-     * @param entryId 
-     * @param feedId 
-     * @return 
-     * @throws StorageException 
-     */ 
-    public abstract BaseEntry getEntry(String entryId, String feedId) 
-            throws StorageException; 
- 
-    /** 
-     * @param entryIdList 
-     * @param feedId 
-     * @return 
-     * @throws StorageException 
-     */ 
-    public abstract List<BaseEntry> getEntries(List<String> entryIdList, 
-            String feedId) throws StorageException; 
- 
-    /** 
-     * @param profile 
-     */ 
-    public abstract void setExtensionProfile(final ExtensionProfile profile); 
- 
-    /** 
-     * close this storage instance 
-     */ 
-    public abstract void close(); 
- 
-} 
+ */
+package org.apache.lucene.gdata.storage;
+
+import org.apache.lucene.gdata.data.GDataAccount;
+import org.apache.lucene.gdata.data.ServerBaseEntry;
+import org.apache.lucene.gdata.data.ServerBaseFeed;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.BaseFeed;
+
+/**
+ * A interface every storage implementation must provide to access the
+ * <tt>Storage</tt>. It describes all access methodes needed to store,
+ * retrieve and look up data stored in the <tt>Storage</tt> component. This
+ * interface acts as a <tt>Facade</tt> to hide the storage implementation from
+ * the user.
+ * <p>
+ * This could also act as a proxy for a remote storage. It also removes any
+ * restrictions from custom storage implementations.
+ * </p>
+ * 
+ * 
+ * @author Simon Willnauer
+ * 
+ */
+/*
+ * not final yet
+ */
+public interface Storage {
+
+    /**
+     * 
+     * Stores the given entry. The ServerBaseEntry must provide a feed id and
+     * the service type. configuration for the entry.
+     * 
+     * @param entry -
+     *            the entry to store
+     * 
+     * @return - the stored Entry for the server response
+     * @throws StorageException -
+     *             if the entry can not be stored or required field are not set.
+     */
+    public abstract BaseEntry storeEntry(ServerBaseEntry entry)
+            throws StorageException;
+
+    /**
+     * Deletes the given entry. The ServerBaseEntry just hase to provide the
+     * entry id to be deleted.
+     * 
+     * @param entry -
+     *            the entry to delete from the storage
+     * @throws StorageException -
+     *             if the entry can not be deleted or the entry does not exist
+     *             or required field are not set.
+     */
+    public abstract void deleteEntry(ServerBaseEntry entry)
+            throws StorageException;
+
+    /**
+     * Updates the given entry. The ServerBaseEntry must provide a feed id,
+     * service id and the
+     * {@link org.apache.lucene.gdata.server.registry.ProvidedService}
+     * 
+     * @param entry -
+     *            the entry to update
+     * 
+     * @return - the updated entry for server response.
+     * @throws StorageException -
+     *             if the entry can not be updated or does not exist or required
+     *             field are not set.
+     */
+    public abstract BaseEntry updateEntry(ServerBaseEntry entry)
+            throws StorageException;
+
+    /**
+     * Retrieves the requested feed from the storage. The given ServerBaseFeed
+     * must provide information about the feed id, max-result count and the
+     * start index. To create feeds and entries also the service type must be
+     * provided.
+     * 
+     * @param feed -
+     *            the to retieve from the storage
+     * @return the requested feed
+     * @throws StorageException -
+     *             the feed does not exist or can not be retrieved or required
+     *             field are not set.
+     */
+    public abstract BaseFeed getFeed(ServerBaseFeed feed)
+            throws StorageException;
+
+    /**
+     * Retrieves the requested entry from the storage. The given entry must
+     * provide information about the entry id and service type.
+     * 
+     * @param entry -
+     *            the entry to retrieve
+     * @return - the requested entry
+     * @throws StorageException -
+     *             if the entry does not exist or can not be created or required
+     *             field are not set.
+     */
+    public abstract BaseEntry getEntry(ServerBaseEntry entry)
+            throws StorageException;
+
+    /**
+     * Saves a new account. Required attributes to set are <tt>password</tt>
+     * and <tt>accountname</tt>
+     * 
+     * @param account -
+     *            the account to save
+     * @throws StorageException -
+     *             if the account can not be stored or the account already
+     *             exists or required field are not set.
+     */
+    public abstract void storeAccount(final GDataAccount account)
+            throws StorageException;
+
+    /**
+     * Updates an existing account. Required attributes to set are
+     * <tt>password</tt> and <tt>accountname</tt>
+     * 
+     * @param account -
+     *            the account to update
+     * @throws StorageException -
+     *             if the account does not exist or required field are not set.
+     */
+    public abstract void updateAccount(final GDataAccount account)
+            throws StorageException;
+
+    /**
+     * Deletes the account for the given account name. All feeds and entries
+     * referencing this account will be deleted as well!
+     * 
+     * @param accountname -
+     *            the name of the account to delete
+     * @throws StorageException -
+     *             if the account does not exist
+     */
+    public abstract void deleteAccount(final String accountname)
+            throws StorageException;
+
+    /**
+     * Stores a new feed for a existing account. The Feed must provide
+     * information about the service type to store the feed for and the feed id
+     * used for accessing and retrieving the feed from the storage. Each feed is
+     * associated with a provided service. This method does check wheather a
+     * feed with the same feed id as the given feed does already exists.
+     * 
+     * @see org.apache.lucene.gdata.server.registry.ProvidedService
+     * @param feed -
+     *            the feed to create
+     * @param accountname -
+     *            the account name belongs to the feed
+     * @throws StorageException -
+     *             if the feed already exists or the feed can not be stored
+     */
+    public abstract void storeFeed(final ServerBaseFeed feed, String accountname)
+            throws StorageException;
+
+    /**
+     * Deletes the feed for the given feed id. All Entries referencing the given
+     * feed id will be deleted as well.
+     * 
+     * @param feedId -
+     *            the feed id for the feed to delete.
+     * @throws StorageException -
+     *             if the feed for the feed id does not exist or the feed can
+     *             not be deleted
+     */
+    public abstract void deleteFeed(final String feedId)
+            throws StorageException;
+
+    /**
+     * Updates a stored feed. The Feed must provide information about the
+     * service type to store the feed for and the feed id used for accessing and
+     * retrieving the feed from the storage.
+     * 
+     * @param feed -
+     *            the feed to update
+     * @param accountname -
+     *            the account name belongs to the feed
+     * @throws StorageException -
+     *             if the feed does not exist or the feed can not be updated
+     */
+    public abstract void updateFeed(final ServerBaseFeed feed,
+            String accountname) throws StorageException;
+
+    /**
+     * Retrieves the service name for a stored feed
+     * 
+     * @param feedId -
+     *            the feed id
+     * @return - the name of the service
+     * @throws StorageException -
+     *             if no feed for the provided id is stored
+     */
+    public abstract String getServiceForFeed(String feedId)
+            throws StorageException;
+
+    /**
+     * @param accountName -
+     *            the name of the requested account
+     * @return - a {@link GDataAccount} instance for the requested account name
+     * @throws StorageException -
+     *             if no account for the account name is stored
+     * 
+     */
+    public abstract GDataAccount getAccount(String accountName)
+            throws StorageException;
+
+    /**
+     * close this storage instance. This method will be called by clients after
+     * use.
+     */
+    public abstract void close();
+
+    /**
+     * Each feed belongs to one specific account. This method retrieves the
+     * account name for
+     * 
+     * @param feedId -
+     *            the id of the feed to retrieve the accountname
+     * @return - the name / id of the account associated with the feed for the
+     *         given feed id
+     * @throws StorageException -
+     *             if the feed is not stored or the storage can not be accessed
+     */
+    public String getAccountNameForFeedId(String feedId)
+            throws StorageException;
+
+    /**
+     * Retrieves the date of the last modification for the given id
+     * 
+     * @param entryId -
+     *            the entry Id
+     * @param feedId -
+     *            the feed which contains the entry
+     * @return - The date of the last modifiaction in milliseconds or
+     *         <code>new Long(0)</code> if the resource can not be found eg.
+     *         the time can not be accessed
+     * @throws StorageException -
+     *             if the storage can not be accessed
+     */
+    public Long getEntryLastModified(String entryId, String feedId)
+            throws StorageException;
+
+    /**
+     * Retrieves the date of the last modification for the given id
+     * 
+     * @param feedId -
+     *            the feed Id
+     * @return - The date of the last modifiaction in milliseconds or
+     *         <code>new Long(0)</code> if the resource can not be found eg.
+     *         the time can not be accessed
+     * @throws StorageException -
+     *             if the storage can not be accessed
+     */
+    public Long getFeedLastModified(String feedId) throws StorageException;
+
+}

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageController.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageController.java?rev=417265&r1=417264&r2=417265&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageController.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageController.java Mon Jun 26 11:14:53 2006
@@ -1,27 +1,61 @@
-/** 
- * Copyright 2004 The Apache Software Foundation 
+/**
+ * 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.storage;
+
+import org.apache.lucene.gdata.server.registry.ServerComponent;
+
+/**
+ * An interface to define a central storage controller acting as a
+ * <tt>Stroage</tt> Factory. The <tt>StroageController</tt> manages the
+ * storage logic. Subclasses of {@link StorageController} can be registered as
+ * {@link org.apache.lucene.gdata.server.registry.Component} in the
+ * {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry}. A
+ * single instance of the contorller will be loaded and passed to clients via
+ * the lookup service.
+ * <p>
+ * This instances, registered in the registry must be thread save as they are
+ * shared between several clients
+ * </p>
+ * <p>
+ * Each StroageController implementation must provide a super user
+ * {@link org.apache.lucene.gdata.data.GDataAccount} with all
+ * {@link org.apache.lucene.gdata.data.GDataAccount.AccountRole} set. This
+ * account must have the defined name <i>administrator</i> and a default
+ * password <i>password</i>. The password has to be updated by the server
+ * administrator before production use.
+ * To get the predefinded GDataAccount use {@link org.apache.lucene.gdata.data.GDataAccount#createAdminAccount()}
+ * </p>
+ *
  * 
- * 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 
+ * @author Simon Willnauer
  * 
- *     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.storage; 
- 
-/** 
- * @author Simon Willnauer 
- * 
- */ 
-public interface StorageController { 
-/** 
- * Destroys the controller 
- */ 
-public abstract void destroy(); 
-} 
+ */
+public interface StorageController extends ServerComponent {
+    /**
+     * Destroys the controller - this method is called by the registry when the
+     * context will be destroyed
+     */
+    public abstract void destroy();
+
+    /**
+     * Creates Storage instances to access the underlaying storage component
+     * 
+     * @return a storage instance
+     * @throws StorageException -
+     *             if the storage instance can not be created
+     */
+    public abstract Storage getStorage() throws StorageException;
+}

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageFactory.java?rev=417265&r1=417264&r2=417265&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageFactory.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageFactory.java Mon Jun 26 11:14:53 2006
@@ -1,44 +0,0 @@
-/** 
- * 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.storage; 
- 
-import java.io.IOException; 
- 
-import org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation; 
- 
-/** 
- *TODO document me 
- * @author Simon Willnauer 
- * 
- */ 
-public class StorageFactory { 
-    /** 
-     * Creates a {@link Storage} instance 
-     * @return - a storage instance 
-     * @throws StorageException  - if the storage can not be created 
-     */ 
-    public static Storage getStorage()throws StorageException{ 
-        try { 
-            return new StorageImplementation(); 
-        } catch (IOException e) { 
-            StorageException ex = new StorageException("Can't create Storage instance -- " 
-                    + e.getMessage(), e); 
-            ex.setStackTrace(e.getStackTrace()); 
-            throw ex;  
-             
-        }  
-    } 
-} 

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageBuffer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageBuffer.java?rev=417265&r1=417264&r2=417265&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageBuffer.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageBuffer.java Mon Jun 26 11:14:53 2006
@@ -16,19 +16,26 @@
  
 package org.apache.lucene.gdata.storage.lucenestorage; 
  
-import java.util.ArrayList; 
-import java.util.Collection; 
-import java.util.Collections; 
-import java.util.HashMap; 
-import java.util.List; 
-import java.util.Map; 
-import java.util.concurrent.locks.Lock; 
-import java.util.concurrent.locks.ReadWriteLock; 
-import java.util.concurrent.locks.ReentrantReadWriteLock; 
- 
-import org.apache.commons.logging.Log; 
-import org.apache.commons.logging.LogFactory; 
-import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper.StorageOperation; 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper.StorageOperation;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.ExtensionProfile;
+import com.google.gdata.data.Link;
  
 /** 
  * The StorageBuffer is used to buffer incoming updates, deletes and inserts to 
@@ -55,7 +62,9 @@
 public class StorageBuffer { 
     private static final Log LOG = LogFactory.getLog(StorageBuffer.class); 
  
-    private final Map<String, Map<String, StorageEntryWrapper>> bufferMap; 
+    private final Map<String, Map<String, StorageEntryWrapper>> bufferMap;
+    
+    private final Map<String, Long> modifiyMap;
  
     private final List<String> excludeList; 
  
@@ -86,6 +95,9 @@
         this.excludeList = new ArrayList<String>( 
                 expectedBufferCount < DEFAULT_BUFFER_COUNT ? DEFAULT_BUFFER_COUNT 
                         : expectedBufferCount); 
+        this.modifiyMap = new HashMap<String, Long>( 
+                expectedBufferCount < DEFAULT_BUFFER_COUNT ? DEFAULT_BUFFER_COUNT 
+                        : expectedBufferCount); 
     } 
  
     /** 
@@ -114,7 +126,9 @@
                         20); 
                 newFeedMap.put(wrapper.getEntryId(), wrapper); 
                 this.bufferMap.put(feedId, newFeedMap); 
+                
             } 
+            addLastModified(wrapper.getFeedId(),wrapper.getTimestamp());
         } finally { 
             /* 
              * add all to exclude from searches doc will be available via the 
@@ -124,6 +138,22 @@
             this.writeLock.unlock(); 
         } 
     } 
+    
+    private void addLastModified(final String feedId,Long timestamp){
+        if(this.modifiyMap.containsKey(feedId))
+            this.modifiyMap.remove(feedId);
+        this.modifiyMap.put(feedId,timestamp);
+        
+    }
+    
+    protected Long getFeedLastModified(final String feedId){
+        return this.modifiyMap.get(feedId);
+    }
+    protected Set<Entry<String,Long>> getLastModified(){
+        return this.modifiyMap.entrySet();
+    }
+    
+    
  
     /** 
      * Returns all entries for the given feed id sorted by the update timestamp 
@@ -173,6 +203,7 @@
             if (tempMap == null) 
                 return; 
             tempMap.remove(entryId); 
+            this.addLastModified(feedId,new Long(System.currentTimeMillis()));
         } finally { 
             this.writeLock.unlock(); 
  
@@ -230,6 +261,7 @@
     private void clearBuffer() { 
         this.bufferMap.clear(); 
         this.excludeList.clear(); 
+        this.modifiyMap.clear();
  
     } 
  
@@ -245,5 +277,36 @@
         } 
  
     } 
+    
+    
+    static class BufferableEntry extends BaseEntry{
+        
+        /**
+         * 
+         */
+        @SuppressWarnings("unchecked")
+        public BufferableEntry() {
+            super();
+            this.links = new LinkedList<Link>();
+        }
+
+        /**
+         * @param arg0
+         */
+        @SuppressWarnings("unchecked")
+        public BufferableEntry(BaseEntry arg0) {
+            super(arg0);
+            this.links = new LinkedList<Link>();
+        }
+
+        /**
+         * @see com.google.gdata.data.BaseEntry#declareExtensions(com.google.gdata.data.ExtensionProfile)
+         */
+        @Override
+        public void declareExtensions(ExtensionProfile arg0) {
+            //
+        }
+        
+    }
  
 } 



Mime
View raw message