diff --git a/src/main/java/com/sun/syndication/propono/atom/client/AtomClientFactory.java b/src/main/java/com/sun/syndication/propono/atom/client/AtomClientFactory.java
deleted file mode 100644
index 4e7935b..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/client/AtomClientFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.client;
-
-import com.sun.syndication.propono.utils.ProponoException;
-import com.sun.syndication.io.impl.Atom10Parser;
-
-
-/**
- * Creates AtomService or ClientCollection based on username, password and
- * end-point URI of Atom protocol service.
- */
-public class AtomClientFactory {
-
- static {
- Atom10Parser.setResolveURIs(true);
- }
-
- /**
- * Create AtomService by reading service doc from Atom Server.
- */
- public static ClientAtomService getAtomService(
- String uri, AuthStrategy authStrategy) throws ProponoException {
- return new ClientAtomService(uri, authStrategy);
- }
-
- /**
- * Create ClientCollection bound to URI.
- */
- public static ClientCollection getCollection(
- String uri, AuthStrategy authStrategy) throws ProponoException {
- return new ClientCollection(uri, authStrategy);
- }
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/client/AuthStrategy.java b/src/main/java/com/sun/syndication/propono/atom/client/AuthStrategy.java
deleted file mode 100644
index e8bd37f..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/client/AuthStrategy.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2007 Dave Johnson (Blogapps project)
- *
- * 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 com.sun.syndication.propono.atom.client;
-
-import com.sun.syndication.propono.utils.ProponoException;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethodBase;
-
-
-public interface AuthStrategy {
-
- /**
- * Add authentication credenticals, tokens, etc. to HTTP method
- */
- void addAuthentication(HttpClient httpClient, HttpMethodBase method)
- throws ProponoException;
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/client/BasicAuthStrategy.java b/src/main/java/com/sun/syndication/propono/atom/client/BasicAuthStrategy.java
deleted file mode 100644
index ce200f5..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/client/BasicAuthStrategy.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2009 Dave Johnson (Blogapps project)
- *
- * 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 com.sun.syndication.propono.atom.client;
-
-import com.sun.syndication.io.impl.Base64;
-import com.sun.syndication.propono.utils.ProponoException;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethodBase;
-
-
-public class BasicAuthStrategy implements AuthStrategy {
- private String credentials;
-
- public BasicAuthStrategy(String username, String password) {
- this.credentials =
- new String(new Base64().encode((username + ":" + password).getBytes()));
- }
-
- public void init() throws ProponoException {
- // op-op
- }
-
- public void addAuthentication(HttpClient httpClient, HttpMethodBase method) throws ProponoException {
- httpClient.getParams().setAuthenticationPreemptive(true);
- String header = "Basic " + credentials;
- method.setRequestHeader("Authorization", header);
- }
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/client/ClientAtomService.java b/src/main/java/com/sun/syndication/propono/atom/client/ClientAtomService.java
deleted file mode 100644
index 873d824..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/client/ClientAtomService.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.client;
-
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.io.impl.Atom10Parser;
-import com.sun.syndication.propono.utils.ProponoException;
-import com.sun.syndication.propono.atom.common.AtomService;
-import java.io.InputStreamReader;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.input.SAXBuilder;
-
-
-/**
- * This class models an Atom Publising Protocol Service Document.
- * It extends the common
- * {@link com.sun.syndication.propono.atom.common.Collection}
- * class to add a To create your own Atom protocol implementation you must implement this
- * interface and create a concrete sub-class of
- * {@link com.sun.syndication.propono.atom.server.AtomHandlerFactory}
- * which is capable of instantiating it. To create your own Atom protocol implementation you must sub-class this
- * class with your own factory that is capable of creating instances of your
- * {@link com.sun.syndication.propono.atom.server.AtomHandler} impementation. Protected constructor to prevent instantiation.
- * Use {@link #newInstance()}. URI structure used for accessing collections and entries Collection feed (URI allows GET to get collection, POST to add to it) Collection entry (URI allows GET, PUT and DELETE) Collection entry media (URI allows GET, PUT and DELETE) Categories URI if not using inline categories (URI allows GET) Directory structure used to store collections and entries Collection feed (kept constantly up to date) Collection entry (individual entries also stored as entry.xml files) Collection entry media (media file stored under entry directory)getEntry()
method and to return
- * {@link com.sun.syndication.propono.atom.client.ClientWorkspace}
- * objects instead of common
- * {@link com.sun.syndication.propono.atom.common.Workspace}s.
- */
-public class ClientAtomService extends AtomService {
- private static Log logger = LogFactory.getLog(ClientAtomService.class);
- private String uri = null;
- private HttpClient httpClient = null;
- private AuthStrategy authStrategy = null;
-
- /**
- * Create Atom blog service instance for specified URL and user account.
- * @param url End-point URL of Atom service
- */
- ClientAtomService(String uri, AuthStrategy authStrategy)
- throws ProponoException {
- this.uri = uri;
- this.authStrategy = authStrategy;
- Document doc = getAtomServiceDocument();
- parseAtomServiceDocument(doc);
- }
-
- /**
- * Get full entry from service by entry edit URI.
- */
- public ClientEntry getEntry(String uri) throws ProponoException {
- GetMethod method = new GetMethod(uri);
- authStrategy.addAuthentication(httpClient, method);
- try {
- httpClient.executeMethod(method);
- if (method.getStatusCode() != 200) {
- throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
- }
- Entry romeEntry = Atom10Parser.parseEntry(
- new InputStreamReader(method.getResponseBodyAsStream()), uri);
- if (!romeEntry.isMediaEntry()) {
- return new ClientEntry(this, null, romeEntry, false);
- } else {
- return new ClientMediaEntry(this, null, romeEntry, false);
- }
- } catch (Exception e) {
- throw new ProponoException("ERROR: getting or parsing entry/media", e);
- } finally {
- method.releaseConnection();
- }
- }
-
- void addAuthentication(HttpMethodBase method) throws ProponoException {
- authStrategy.addAuthentication(httpClient, method);
- }
-
- AuthStrategy getAuthStrategy() {
- return authStrategy;
- }
-
- private Document getAtomServiceDocument() throws ProponoException {
- GetMethod method = null;
- int code = -1;
- try {
- httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
- // TODO: make connection timeout configurable
- httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
-
- method = new GetMethod(uri);
- authStrategy.addAuthentication(httpClient, method);
- httpClient.executeMethod(method);
-
- SAXBuilder builder = new SAXBuilder();
- return builder.build(method.getResponseBodyAsStream());
-
- } catch (Throwable t) {
- String msg = "ERROR retrieving Atom Service Document, code: "+code;
- logger.debug(msg, t);
- throw new ProponoException(msg, t);
- } finally {
- if (method != null) method.releaseConnection();
- }
- }
-
- /** Deserialize an Atom service XML document into an object */
- private void parseAtomServiceDocument(Document document) throws ProponoException {
- Element root = document.getRootElement();
- List spaces = root.getChildren("workspace", AtomService.ATOM_PROTOCOL);
- Iterator iter = spaces.iterator();
- while (iter.hasNext()) {
- Element e = (Element) iter.next();
- addWorkspace(new ClientWorkspace(e, this, uri));
- }
- }
-
- /**
- * Package access to httpClient.
- */
- HttpClient getHttpClient() {
- return httpClient;
- }
-}
-
diff --git a/src/main/java/com/sun/syndication/propono/atom/client/ClientCategories.java b/src/main/java/com/sun/syndication/propono/atom/client/ClientCategories.java
deleted file mode 100644
index 965d1ca..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/client/ClientCategories.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* 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. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-package com.sun.syndication.propono.atom.client;
-
-import com.sun.syndication.feed.atom.Category;
-import com.sun.syndication.propono.atom.common.*;
-import com.sun.syndication.propono.utils.ProponoException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-
-
-/**
- * Models an Atom protocol Categories element, which may contain ROME Atom
- * {@link com.sun.syndication.feed.atom.Category} elements.
- */
-public class ClientCategories extends Categories {
- private ClientCollection clientCollection = null;
-
- /** Load select from XML element */
- public ClientCategories(Element e, ClientCollection clientCollection) throws ProponoException {
- this.clientCollection = clientCollection;
- parseCategoriesElement(e);
- if (getHref() != null) fetchContents();
- }
-
- public void fetchContents() throws ProponoException {
- GetMethod method = new GetMethod(getHrefResolved());
- clientCollection.addAuthentication(method);
- try {
- clientCollection.getHttpClient().executeMethod(method);
- if (method.getStatusCode() != 200) {
- throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
- }
- SAXBuilder builder = new SAXBuilder();
- Document catsDoc = builder.build(
- new InputStreamReader(method.getResponseBodyAsStream()));
- parseCategoriesElement(catsDoc.getRootElement());
-
- } catch (IOException ioe) {
- throw new ProponoException(
- "ERROR: reading out-of-line categories", ioe);
- } catch (JDOMException jde) {
- throw new ProponoException(
- "ERROR: parsing out-of-line categories", jde);
- } finally {
- method.releaseConnection();
- }
- }
-}
-
diff --git a/src/main/java/com/sun/syndication/propono/atom/client/ClientCollection.java b/src/main/java/com/sun/syndication/propono/atom/client/ClientCollection.java
deleted file mode 100644
index 94b270a..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/client/ClientCollection.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.client;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.io.InputStreamReader;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.io.impl.Atom10Parser;
-import com.sun.syndication.propono.atom.common.AtomService;
-import com.sun.syndication.propono.atom.common.Categories;
-import com.sun.syndication.propono.utils.ProponoException;
-import com.sun.syndication.propono.atom.common.Collection;
-import com.sun.syndication.propono.atom.common.Workspace;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jdom.Element;
-
-/**
- * Models an Atom collection, extends Collection and adds methods for adding,
- * retrieving, updateing and deleting entries.
- */
-public class ClientCollection extends Collection {
- static final Log logger = LogFactory.getLog(ClientCollection.class);
-
- private List categories = new ArrayList();
- private HttpClient httpClient = null;
- private AuthStrategy authStrategy = null;
- private boolean writable = true;
-
- private ClientWorkspace workspace = null;
- private ClientAtomService service = null;
-
- ClientCollection(Element e, ClientWorkspace workspace, String baseURI) throws ProponoException {
- super(e, baseURI);
- this.workspace = workspace;
- this.service = workspace.getAtomService();
- this.httpClient = workspace.getAtomService().getHttpClient();
- this.authStrategy = workspace.getAtomService().getAuthStrategy();
- parseCollectionElement(e);
- }
-
- ClientCollection(String href, AuthStrategy authStrategy) throws ProponoException {
- super("Standalone connection", "text", href);
- this.authStrategy = authStrategy;
- try {
- httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
- // TODO: make connection timeout configurable
- httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
- } catch (Throwable t) {
- throw new ProponoException("ERROR creating HTTPClient", t);
- }
- }
-
- void addAuthentication(HttpMethodBase method) throws ProponoException {
- authStrategy.addAuthentication(httpClient, method);
- }
-
- /**
- * Package access to httpClient to allow use by ClientEntry and ClientMediaEntry.
- */
- HttpClient getHttpClient() {
- return httpClient;
- }
-
- /**
- * Get iterator over entries in this collection. Entries returned are
- * considered to be partial entries cannot be saved/updated.
- */
- public Iterator getEntries() throws ProponoException {
- return new EntryIterator(this);
- }
-
- /**
- * Get full entry specified by entry edit URI.
- * Note that entry may or may not be associated with this collection.
- * @return ClientEntry or ClientMediaEntry specified by URI.
- */
- public ClientEntry getEntry(String uri) throws ProponoException {
- GetMethod method = new GetMethod(uri);
- authStrategy.addAuthentication(httpClient, method);
- try {
- httpClient.executeMethod(method);
- if (method.getStatusCode() != 200) {
- throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
- }
- Entry romeEntry = Atom10Parser.parseEntry(
- new InputStreamReader(method.getResponseBodyAsStream()), uri);
- if (!romeEntry.isMediaEntry()) {
- return new ClientEntry(service, this, romeEntry, false);
- } else {
- return new ClientMediaEntry(service, this, romeEntry, false);
- }
- } catch (Exception e) {
- throw new ProponoException("ERROR: getting or parsing entry/media, HTTP code: ", e);
- } finally {
- method.releaseConnection();
- }
- }
-
- /**
- * Get workspace or null if collection is not associated with a workspace.
- */
- public Workspace getWorkspace() {
- return workspace;
- }
-
- /**
- * Determines if collection is writable.
- */
- public boolean isWritable() {
- return writable;
- }
-
- /**
- * Create new entry associated with collection, but do not save to server.
- * @throws ProponoException if collecton is not writable.
- */
- public ClientEntry createEntry() throws ProponoException {
- if (!isWritable()) throw new ProponoException("Collection is not writable");
- return new ClientEntry(service, this);
- }
-
- /**
- * Create new media entry assocaited with collection, but do not save.
- * server. Depending on the Atom server, you may or may not be able to
- * persist the properties of the entry that is returned.
- * @param title Title to used for uploaded file.
- * @param slug String to be used in file-name of stored file
- * @param contentType MIME content-type of file.
- * @param bytes Data to be uploaded as byte array.
- * @throws ProponoException if collecton is not writable
- */
- public ClientMediaEntry createMediaEntry(
- String title, String slug, String contentType, byte[] bytes)
- throws ProponoException {
- if (!isWritable()) throw new ProponoException("Collection is not writable");
- return new ClientMediaEntry(service, this, title, slug, contentType, bytes);
- }
-
- /**
- * Create new media entry assocaited with collection, but do not save.
- * server. Depending on the Atom server, you may or may not be able to.
- * persist the properties of the entry that is returned.
- * @param title Title to used for uploaded file.
- * @param slug String to be used in file-name of stored file
- * @param contentType MIME content-type of file.
- * @param is Data to be uploaded as InputStream.
- * @throws ProponoException if collecton is not writable
- */
- public ClientMediaEntry createMediaEntry(
- String title, String slug, String contentType, InputStream is)
- throws ProponoException {
- if (!isWritable()) throw new ProponoException("Collection is not writable");
- return new ClientMediaEntry(service, this, title, slug, contentType, is);
- }
-
- /**
- * Save to collection a new entry that was created by a createEntry()
- * or createMediaEntry() and save it to the server.
- * @param entry Entry to be saved.
- * @throws ProponoException on error, if collection is not writable or if entry is partial.
- */
- public void addEntry(ClientEntry entry) throws ProponoException {
- if (!isWritable()) throw new ProponoException("Collection is not writable");
- entry.addToCollection(this);
- }
-
- protected void parseCollectionElement(Element element) throws ProponoException {
- if (workspace == null) return;
-
- setHref(element.getAttribute("href").getValue());
-
- Element titleElem = element.getChild("title", AtomService.ATOM_FORMAT);
- if (titleElem != null) {
- setTitle(titleElem.getText());
- if (titleElem.getAttribute("type", AtomService.ATOM_FORMAT) != null) {
- setTitleType(titleElem.getAttribute("type", AtomService.ATOM_FORMAT).getValue());
- }
- }
-
- List acceptElems = element.getChildren("accept", AtomService.ATOM_PROTOCOL);
- if (acceptElems != null && acceptElems.size() > 0) {
- for (Iterator it = acceptElems.iterator(); it.hasNext();) {
- Element acceptElem = (Element)it.next();
- addAccept(acceptElem.getTextTrim());
- }
- }
-
- // Loop to parse getEntry()
- * methods in
- * {@link com.sun.syndication.propono.atom.common.Collection} or
- * {@link com.sun.syndication.propono.atom.common.AtomService}.
- * @throws ProponoException If entry is a "partial" entry.
- */
- public void update() throws ProponoException {
- if (partial) throw new ProponoException("ERROR: attempt to update partial entry");
- EntityEnclosingMethod method = new PutMethod(getEditURI());
- addAuthentication(method);
- StringWriter sw = new StringWriter();
- int code = -1;
- try {
- Atom10Generator.serializeEntry(this, sw);
- method.setRequestEntity(new StringRequestEntity(sw.toString()));
- method.setRequestHeader(
- "Content-type", "application/atom+xml; charset=utf-8");
- getHttpClient().executeMethod(method);
- InputStream is = method.getResponseBodyAsStream();
- if (method.getStatusCode() != 200 && method.getStatusCode() != 201) {
- throw new ProponoException(
- "ERROR HTTP status=" + method.getStatusCode() + " : " + Utilities.streamToString(is));
- }
-
- } catch (Exception e) {
- String msg = "ERROR: updating entry, HTTP code: " + code;
- logger.debug(msg, e);
- throw new ProponoException(msg, e);
- } finally {
- method.releaseConnection();
- }
- }
-
- /**
- * Remove entry from server.
- */
- public void remove() throws ProponoException {
- if (getEditURI() == null) {
- throw new ProponoException("ERROR: cannot delete unsaved entry");
- }
- DeleteMethod method = new DeleteMethod(getEditURI());
- addAuthentication(method);
- try {
- getHttpClient().executeMethod(method);
- } catch (IOException ex) {
- throw new ProponoException("ERROR: removing entry, HTTP code", ex);
- } finally {
- method.releaseConnection();
- }
- }
-
- void setCollection(ClientCollection collection) {
- this.collection = collection;
- }
-
- ClientCollection getCollection() {
- return collection;
- }
-
- /**
- * Get the URI that can be used to edit the entry via HTTP PUT or DELETE.
- */
- public String getEditURI() {
- for (int i=0; iAppModule
form.
- */
-public class AppModuleParser implements ModuleParser {
-
- /** Get URI of module namespace */
- public String getNamespaceUri() {
- return AppModule.URI;
- }
-
- /** Get namespace of module */
- public Namespace getContentNamespace() {
- return Namespace.getNamespace(AppModule.URI);
- }
-
- /** Parse JDOM element into module */
- public Module parse(Element elem) {
- boolean foundSomething = false;
- AppModule m = new AppModuleImpl();
- Element control = elem.getChild("control", getContentNamespace());
- if (control != null) {
- Element draftElem = control.getChild("draft", getContentNamespace());
- if (draftElem != null) {
- if ("yes".equals(draftElem.getText())) m.setDraft(Boolean.TRUE);
- if ("no".equals(draftElem.getText())) m.setDraft(Boolean.FALSE);
- }
- }
- Element edited = elem.getChild("edited", getContentNamespace());
- if (edited != null) {
- try {
- m.setEdited(DateParser.parseW3CDateTime(edited.getTextTrim()));
- } catch (Exception ignored) {}
- }
- return m;
- }
-}
-
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/AtomException.java b/src/main/java/com/sun/syndication/propono/atom/server/AtomException.java
deleted file mode 100644
index 93a8543..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/AtomException.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2007 Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * 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. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package com.sun.syndication.propono.atom.server;
-
-import javax.servlet.http.HttpServletResponse;
-
-
-/**
- * Exception thrown by {@link com.sun.syndication.propono.atom.server.AtomHandler}
- * and extended by other Propono Atom exception classes.
- */
-public class AtomException extends Exception {
- /** Construct new exception */
- public AtomException() {
- super();
- }
- /** Construct new exception with message */
- public AtomException(String msg) {
- super(msg);
- }
- /** Contruct new exception with message and wrapping existing exception */
- public AtomException(String msg, Throwable t) {
- super(msg, t);
- }
- /** Construct new exception to wrap existing one. */
- public AtomException(Throwable t) {
- super(t);
- }
- /* Get HTTP status code associated with exception (HTTP 500 server error) */
- /**
- * Get HTTP status associated with exception.
- */
- public int getStatus() {
- return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
- }
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/AtomHandler.java b/src/main/java/com/sun/syndication/propono/atom/server/AtomHandler.java
deleted file mode 100644
index 8561073..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/AtomHandler.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2007 Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * 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. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package com.sun.syndication.propono.atom.server;
-
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Feed;
-import com.sun.syndication.propono.atom.common.AtomService;
-import com.sun.syndication.propono.atom.common.Categories;
-
-/**
- * Interface for handling single Atom protocol requests.
- *
- * AtomHandlerFactory
. This static
- * method creates a new factory instance. This method uses the following
- * ordered lookup procedure to determine the AtomHandlerFactory
- * implementation class to load:
- *
- *
- *
- * Once an application has obtained a reference to a com.sun.syndication.propono.atom.server.AtomHandlerFactory
- * system property.
- * java.util.Properties
- * format and contains the fully qualified name of the implementation
- * class with the key being the system property defined above.
- *
- * The propono.properties file is read only once by Propono and it's
- * values are then cached for future use. If the file does not exist
- * when the first attempt is made to read from it, no further attempts
- * are made to check for its existence. It is not possible to change
- * the value of any property in propono.properties after it has been
- * read for the first time.
- * META-INF/services/com.sun.syndication.AtomHandlerFactory
- * in jars available to the runtime.
- * AtomHandlerFactory
instance.
- * AtomHandlerFactory
- * it can use the factory to configure and obtain parser instances.
- *
- * @return New instance of a AtomHandlerFactory
- *
- * @throws FactoryConfigurationError if the implementation is not available
- * or cannot be instantiated.
- */
- public static AtomHandlerFactory newInstance() {
- try {
- return (AtomHandlerFactory)
- FactoryFinder.find(DEFAULT_PROPERTY_NAME, FALLBACK_IMPL_NAME);
- } catch (FactoryFinder.ConfigurationError e) {
- log.error("ERROR: finding factory", e);
- throw new FactoryConfigurationError(e.getException(), e.getMessage());
- }
- }
-
- /**
- * Creates a new instance of a {@link com.sun.syndication.propono.atom.server.AtomHandler}
- * using the currently configured parameters.
- *
- * @return A new instance of a AtomHandler.
- *
- * @throws AtomConfigurationException if a AtomHandler cannot be created
- * which satisfies the configuration requested.
- */
- public abstract AtomHandler newAtomHandler(
- HttpServletRequest req, HttpServletResponse res);
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/AtomMediaResource.java b/src/main/java/com/sun/syndication/propono/atom/server/AtomMediaResource.java
deleted file mode 100644
index b9c1882..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/AtomMediaResource.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.server;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Date;
-import javax.activation.FileTypeMap;
-import javax.activation.MimetypesFileTypeMap;
-
-/**
- * Represents a media link entry.
- */
-public class AtomMediaResource {
- private String contentType = null;
- private long contentLength = 0;
- private InputStream inputStream = null;
- private Date lastModified = null;
- private static FileTypeMap map = null;
-
- static {
- // TODO: figure out why PNG is missing from Java MIME types
- map = FileTypeMap.getDefaultFileTypeMap();
- if (map instanceof MimetypesFileTypeMap) {
- try {
- ((MimetypesFileTypeMap)map).addMimeTypes("image/png png PNG");
- } catch (Exception ignored) {}
- }
- }
-
- public AtomMediaResource(File resource) throws FileNotFoundException {
- contentType = map.getContentType(resource.getName());
- contentLength = resource.length();
- lastModified = new Date(resource.lastModified());
- inputStream = new FileInputStream(resource);
- }
-
- public AtomMediaResource(String name, long length, Date lastModified, InputStream is)
- throws FileNotFoundException {
- this.contentType = map.getContentType(name);
- this.contentLength = length;
- this.lastModified = lastModified;
- this.inputStream = is;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- public long getContentLength() {
- return contentLength;
- }
-
- public void setContentLength(long contentLength) {
- this.contentLength = contentLength;
- }
-
- public InputStream getInputStream() {
- return inputStream;
- }
-
- public void setInputStream(InputStream inputStream) {
- this.inputStream = inputStream;
- }
-
- public Date getLastModified() {
- return lastModified;
- }
-
- public void setLastModified(Date lastModified) {
- this.lastModified = lastModified;
- }
-
-
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/AtomNotAuthorizedException.java b/src/main/java/com/sun/syndication/propono/atom/server/AtomNotAuthorizedException.java
deleted file mode 100644
index 6278b76..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/AtomNotAuthorizedException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2007 Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * 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. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package com.sun.syndication.propono.atom.server;
-
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Exception to be thrown by AtomHandler
implementations in the
- * case that a user is not authorized to access a resource.
- */
-public class AtomNotAuthorizedException extends AtomException {
- /** Construct new exception */
- public AtomNotAuthorizedException() {
- super();
- }
- /** Construct new exception with message */
- public AtomNotAuthorizedException(String msg) {
- super(msg);
- }
- /** Construct new exception with message and root cause */
- public AtomNotAuthorizedException(String msg, Throwable t) {
- super(msg, t);
- }
- /** Construct new exception to wrap root cause*/
- public AtomNotAuthorizedException(Throwable t) {
- super(t);
- }
- /** Get HTTP status code of exception (HTTP 403 unauthorized) */
- public int getStatus() {
- return HttpServletResponse.SC_UNAUTHORIZED;
- }
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/AtomNotFoundException.java b/src/main/java/com/sun/syndication/propono/atom/server/AtomNotFoundException.java
deleted file mode 100644
index ad71a68..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/AtomNotFoundException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2007 Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * 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. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package com.sun.syndication.propono.atom.server;
-
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Exception thrown by AtomHandler in that case a resource is not found.
- */
-public class AtomNotFoundException extends AtomException {
- /** Construct new exception */
- public AtomNotFoundException() {
- super();
- }
- /** Construct new exception with message */
- public AtomNotFoundException(String msg) {
- super(msg);
- }
- /** Construct new exception with message and root cause */
- public AtomNotFoundException(String msg, Throwable t) {
- super(msg, t);
- }
- /** Construct new exception with root cause */
- public AtomNotFoundException(Throwable t) {
- super(t);
- }
- /** Get HTTP status code associated with exception (404 not found) */
- public int getStatus() {
- return HttpServletResponse.SC_NOT_FOUND;
- }
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/AtomRequest.java b/src/main/java/com/sun/syndication/propono/atom/server/AtomRequest.java
deleted file mode 100644
index dc1e70d..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/AtomRequest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * 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. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package com.sun.syndication.propono.atom.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.Principal;
-import java.util.Enumeration;
-import java.util.Map;
-
-/**
- * Represents HTTP request to be processed by AtomHandler.
- */
-public interface AtomRequest {
-
- /**
- * Returns any extra path information associated with the URL the client
- * sent when it made this request.
- */
- public String getPathInfo();
-
- /**
- * Returns the query string that is contained in the request URL after
- * the path.
- */
- public String getQueryString();
-
- /**
- * Returns the login of the user making this request, if the user has
- * been authenticated, or null if the user has not been authenticated.
- */
- public String getRemoteUser();
-
- /**
- * Returns a boolean indicating whether the authenticated user is included
- * in the specified logical "role".
- */
- public boolean isUserInRole(String arg0);
-
- /**
- * Returns a java.security.Principal object containing the name of the
- * current authenticated user.
- */
- public Principal getUserPrincipal();
-
- /**
- * Returns the part of this request's URL from the protocol name up to the
- * query string in the first line of the HTTP request.
- */
- public String getRequestURI();
-
- /**
- * Reconstructs the URL the client used to make the request.
- */
- public StringBuffer getRequestURL();
-
- /**
- * Returns the length, in bytes, of the request body and made available by
- * the input stream, or -1 if the length is not known.
- */
- public int getContentLength();
-
- /**
- * Returns the MIME type of the body of the request, or null if the type
- * is not known. */
- public String getContentType();
-
- /**
- * Returns the value of a request parameter as a String, or null if the
- * parameter does not exist.
- */
- public String getParameter(String arg0);
-
- /**
- * Returns an Enumeration of String objects containing the names of the
- * parameters contained in this request.
- */
- public Enumeration getParameterNames();
-
- /**
- * Returns an array of String objects containing all of the values the
- * given request parameter has, or null if the parameter does not exist.
- */
- public String[] getParameterValues(String arg0);
-
- /**
- * Returns a java.util.Map of the parameters of this request.
- */
- public Map getParameterMap();
-
- /**
- * Retrieves the body of the request as binary data using a
- * ServletInputStream.
- */
- public InputStream getInputStream() throws IOException;
-
- /**
- * Returns the value of the specified request header as a long value that
- * represents a Date object. */
- public long getDateHeader(String arg0);
-
- /**
- * Returns the value of the specified request header as a String.
- */
- public String getHeader(String arg0);
-
- /**
- * Returns all the values of the specified request header as an Enumeration
- * of String objects.
- */
- public Enumeration getHeaders(String arg0);
-
- /**
- * Returns an enumeration of all the header names this request contains.
- */
- public Enumeration getHeaderNames();
-
- /**
- * Returns the value of the specified request header as an int.
- */
- public int getIntHeader(String arg0);
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/AtomRequestImpl.java b/src/main/java/com/sun/syndication/propono/atom/server/AtomRequestImpl.java
deleted file mode 100644
index 8be7833..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/AtomRequestImpl.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * 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. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package com.sun.syndication.propono.atom.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.Principal;
-import java.util.Enumeration;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Default request implementation.
- */
-public class AtomRequestImpl implements AtomRequest {
- private HttpServletRequest wrapped = null;
-
- public AtomRequestImpl(HttpServletRequest wrapped) {
- this.wrapped = wrapped;
- }
-
- public String getPathInfo() {
- return wrapped.getPathInfo() != null ? wrapped.getPathInfo() : "";
- }
-
- public String getQueryString() {
- return wrapped.getQueryString();
- }
-
- public String getRemoteUser() {
- return wrapped.getRemoteUser();
- }
-
- public boolean isUserInRole(String arg0) {
- return wrapped.isUserInRole(arg0);
- }
-
- public Principal getUserPrincipal() {
- return wrapped.getUserPrincipal();
- }
-
- public String getRequestURI() {
- return wrapped.getRequestURI();
- }
-
- public StringBuffer getRequestURL() {
- return wrapped.getRequestURL();
- }
-
- public int getContentLength() {
- return wrapped.getContentLength();
- }
-
- public String getContentType() {
- return wrapped.getContentType();
- }
-
- public String getParameter(String arg0) {
- return wrapped.getParameter(arg0);
- }
-
- public Enumeration getParameterNames() {
- return wrapped.getParameterNames();
- }
-
- public String[] getParameterValues(String arg0) {
- return wrapped.getParameterValues(arg0);
- }
-
- public Map getParameterMap() {
- return wrapped.getParameterMap();
- }
-
- public InputStream getInputStream() throws IOException {
- return wrapped.getInputStream();
- }
-
- public long getDateHeader(String arg0) {
- return wrapped.getDateHeader(arg0);
- }
-
- public String getHeader(String arg0) {
- return wrapped.getHeader(arg0);
- }
-
- public Enumeration getHeaders(String arg0) {
- return wrapped.getHeaders(arg0);
- }
-
- public Enumeration getHeaderNames() {
- return wrapped.getHeaderNames();
- }
-
- public int getIntHeader(String arg0) {
- return wrapped.getIntHeader(arg0);
- }
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/AtomServlet.java b/src/main/java/com/sun/syndication/propono/atom/server/AtomServlet.java
deleted file mode 100644
index 83815ea..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/AtomServlet.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright 2007 Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * 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. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package com.sun.syndication.propono.atom.server;
-
-import com.sun.syndication.feed.atom.Content;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Writer;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdom.Document;
-import org.jdom.output.Format;
-import org.jdom.output.XMLOutputter;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Feed;
-import com.sun.syndication.feed.atom.Link;
-import com.sun.syndication.io.WireFeedOutput;
-import com.sun.syndication.io.impl.Atom10Generator;
-import com.sun.syndication.io.impl.Atom10Parser;
-import com.sun.syndication.propono.atom.common.AtomService;
-import com.sun.syndication.propono.atom.common.Categories;
-import com.sun.syndication.propono.utils.Utilities;
-import java.io.BufferedReader;
-import java.util.Collections;
-import java.util.Iterator;
-import javax.servlet.ServletConfig;
-
-/**
- * Atom Servlet implements Atom protocol by calling an
- * {@link com.sun.syndication.propono.atom.server.AtomHandler}
- * implementation. This servlet takes care of parsing incoming XML into ROME
- * Atom {@link com.sun.syndication.feed.atom.Entry} objects, passing those to the handler and serializing
- * to the response the entries and feeds returned by the handler.
- */
-public class AtomServlet extends HttpServlet {
-
- /**
- * Get feed type support by Servlet, "atom_1.0"
- */
- public static final String FEED_TYPE = "atom_1.0";
- private static String contextDirPath = null;
-
- private static Log log =
- LogFactory.getFactory().getInstance(AtomServlet.class);
-
- static {
- Atom10Parser.setResolveURIs(true);
- }
-
- //-----------------------------------------------------------------------------
- /**
- * Create an Atom request handler.
- * TODO: make AtomRequestHandler implementation configurable.
- */
- private AtomHandler createAtomRequestHandler(
- HttpServletRequest request, HttpServletResponse response)
- throws ServletException {
- AtomHandlerFactory ahf = AtomHandlerFactory.newInstance();
- return ahf.newAtomHandler(request, response);
- }
-
- //-----------------------------------------------------------------------------
- /**
- * Handles an Atom GET by calling handler and writing results to response.
- */
- protected void doGet(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
- log.debug("Entering");
- AtomHandler handler = createAtomRequestHandler(req, res);
- String userName = handler.getAuthenticatedUsername();
- if (userName != null) {
- AtomRequest areq = new AtomRequestImpl(req);
- try {
- if (handler.isAtomServiceURI(areq)) {
- // return an Atom Service document
- AtomService service = handler.getAtomService(areq);
- Document doc = service.serviceToDocument();
- res.setContentType("application/atomsvc+xml; charset=utf-8");
- Writer writer = res.getWriter();
- XMLOutputter outputter = new XMLOutputter();
- outputter.setFormat(Format.getPrettyFormat());
- outputter.output(doc, writer);
- writer.close();
- res.setStatus(HttpServletResponse.SC_OK);
- }
- else if (handler.isCategoriesURI(areq)) {
- Categories cats = handler.getCategories(areq);
- res.setContentType("application/xml");
- Writer writer = res.getWriter();
- Document catsDoc = new Document();
- catsDoc.setRootElement(cats.categoriesToElement());
- XMLOutputter outputter = new XMLOutputter();
- outputter.output(catsDoc, writer);
- writer.close();
- res.setStatus(HttpServletResponse.SC_OK);
- }
- else if (handler.isCollectionURI(areq)) {
- // return a collection
- Feed col = handler.getCollection(areq);
- col.setFeedType(FEED_TYPE);
- WireFeedOutput wireFeedOutput = new WireFeedOutput();
- Document feedDoc = wireFeedOutput.outputJDom(col);
- res.setContentType("application/atom+xml; charset=utf-8");
- Writer writer = res.getWriter();
- XMLOutputter outputter = new XMLOutputter();
- outputter.setFormat(Format.getPrettyFormat());
- outputter.output(feedDoc, writer);
- writer.close();
- res.setStatus(HttpServletResponse.SC_OK);
- }
- else if (handler.isEntryURI(areq)) {
- // return an entry
- Entry entry = handler.getEntry(areq);
- if (entry != null) {
- res.setContentType("application/atom+xml; type=entry; charset=utf-8");
- Writer writer = res.getWriter();
- Atom10Generator.serializeEntry(entry, writer);
- writer.close();
- } else {
- res.setStatus(HttpServletResponse.SC_NOT_FOUND);
- }
- }
- else if (handler.isMediaEditURI(areq)) {
- AtomMediaResource entry = handler.getMediaResource(areq);
- res.setContentType(entry.getContentType());
- res.setContentLength((int)entry.getContentLength());
- Utilities.copyInputToOutput(entry.getInputStream(), res.getOutputStream());
- res.getOutputStream().flush();
- res.getOutputStream().close();
- }
- else {
- res.setStatus(HttpServletResponse.SC_NOT_FOUND);
- }
- } catch (AtomException ae) {
- res.sendError(ae.getStatus(), ae.getMessage());
- log.debug("ERROR processing GET", ae);
- } catch (Exception e) {
- res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- log.debug("ERROR processing GET", e);
- }
- } else {
- res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
- res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
- }
- log.debug("Exiting");
- }
-
- //-----------------------------------------------------------------------------
- /**
- * Handles an Atom POST by calling handler to identify URI, reading/parsing
- * data, calling handler and writing results to response.
- */
- protected void doPost(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
- log.debug("Entering");
- AtomHandler handler = createAtomRequestHandler(req, res);
- String userName = handler.getAuthenticatedUsername();
- if (userName != null) {
- AtomRequest areq = new AtomRequestImpl(req);
- try {
- if (handler.isCollectionURI(areq)) {
-
- if (req.getContentType().startsWith("application/atom+xml")) {
-
- // parse incoming entry
- Entry entry = Atom10Parser.parseEntry(new BufferedReader(
- new InputStreamReader(req.getInputStream(), "UTF-8")), null);
-
- // call handler to post it
- Entry newEntry = handler.postEntry(areq, entry);
-
- // set Location and Content-Location headers
- for (Iterator it = newEntry.getOtherLinks().iterator(); it.hasNext();) {
- Link link = (Link) it.next();
- if ("edit".equals(link.getRel())) {
- res.addHeader("Location", link.getHrefResolved());
- break;
- }
- }
- for (Iterator it = newEntry.getAlternateLinks().iterator(); it.hasNext();) {
- Link link = (Link) it.next();
- if ("alternate".equals(link.getRel())) {
- res.addHeader("Content-Location", link.getHrefResolved());
- break;
- }
- }
-
- // write entry back out to response
- res.setStatus(HttpServletResponse.SC_CREATED);
- res.setContentType("application/atom+xml; type=entry; charset=utf-8");
-
- Writer writer = res.getWriter();
- Atom10Generator.serializeEntry(newEntry, writer);
- writer.close();
-
- } else if (req.getContentType() != null) {
-
- // get incoming title and slug from HTTP header
- String title = areq.getHeader("Title");
-
- // create new entry for resource, set title and type
- Entry resource = new Entry();
- resource.setTitle(title);
- Content content = new Content();
- content.setType(areq.getContentType());
- resource.setContents(Collections.singletonList(content));
-
- // hand input stream off to hander to post file
- Entry newEntry = handler.postMedia(areq, resource);
-
- // set Location and Content-Location headers
- for (Iterator it = newEntry.getOtherLinks().iterator(); it.hasNext();) {
- Link link = (Link) it.next();
- if ("edit".equals(link.getRel())) {
- res.addHeader("Location", link.getHrefResolved());
- break;
- }
- }
- for (Iterator it = newEntry.getAlternateLinks().iterator(); it.hasNext();) {
- Link link = (Link) it.next();
- if ("alternate".equals(link.getRel())) {
- res.addHeader("Content-Location", link.getHrefResolved());
- break;
- }
- }
-
- res.setStatus(HttpServletResponse.SC_CREATED);
- res.setContentType("application/atom+xml; type=entry; charset=utf-8");
-
- Writer writer = res.getWriter();
- Atom10Generator.serializeEntry(newEntry, writer);
- writer.close();
-
- } else {
- res.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE,
- "No content-type specified in request");
- }
-
- } else {
- res.sendError(HttpServletResponse.SC_NOT_FOUND,
- "Invalid collection specified in request");
- }
- } catch (AtomException ae) {
- res.sendError(ae.getStatus(), ae.getMessage());
- log.debug("ERROR processing POST", ae);
- } catch (Exception e) {
- res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- log.debug("ERROR processing POST", e);
- }
- } else {
- res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
- res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
- }
- log.debug("Exiting");
- }
-
- //-----------------------------------------------------------------------------
- /**
- * Handles an Atom PUT by calling handler to identify URI, reading/parsing
- * data, calling handler and writing results to response.
- */
- protected void doPut(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
- log.debug("Entering");
- AtomHandler handler = createAtomRequestHandler(req, res);
- String userName = handler.getAuthenticatedUsername();
- if (userName != null) {
- AtomRequest areq = new AtomRequestImpl(req);
- try {
- if (handler.isEntryURI(areq)) {
-
- // parse incoming entry
- Entry unsavedEntry = Atom10Parser.parseEntry(new BufferedReader(
- new InputStreamReader(req.getInputStream(), "UTF-8")), null);
-
- // call handler to put entry
- handler.putEntry(areq, unsavedEntry);
-
- res.setStatus(HttpServletResponse.SC_OK);
-
- } else if (handler.isMediaEditURI(areq)) {
-
- // hand input stream to handler
- handler.putMedia(areq);
-
- res.setStatus(HttpServletResponse.SC_OK);
-
- } else {
- res.setStatus(HttpServletResponse.SC_NOT_FOUND);
- }
- } catch (AtomException ae) {
- res.sendError(ae.getStatus(), ae.getMessage());
- log.debug("ERROR processing PUT", ae);
- } catch (Exception e) {
- res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- log.debug("ERROR processing PUT", e);
- }
- } else {
- res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
- // Wanted to use sendError() here but Tomcat sends 403 forbidden
- // when I do that, so sticking with setStatus() for time being.
- res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- }
- log.debug("Exiting");
- }
-
- //-----------------------------------------------------------------------------
- /**
- * Handle Atom DELETE by calling appropriate handler.
- */
- protected void doDelete(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
- log.debug("Entering");
- AtomHandler handler = createAtomRequestHandler(req, res);
- String userName = handler.getAuthenticatedUsername();
- if (userName != null) {
- AtomRequest areq = new AtomRequestImpl(req);
- try {
- if (handler.isEntryURI(areq)) {
- handler.deleteEntry(areq);
- res.setStatus(HttpServletResponse.SC_OK);
- }
- else {
- res.setStatus(HttpServletResponse.SC_NOT_FOUND);
- }
- } catch (AtomException ae) {
- res.sendError(ae.getStatus(), ae.getMessage());
- log.debug("ERROR processing DELETE", ae);
- } catch (Exception e) {
- res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- log.debug("ERROR processing DELETE", e);
- }
- } else {
- res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
- // Wanted to use sendError() here but Tomcat sends 403 forbidden
- // when I do that, so sticking with setStatus() for time being.
- res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- }
- log.debug("Exiting");
- }
-
- /**
- * Initialize servlet.
- */
- public void init( ServletConfig config ) throws ServletException {
- super.init( config );
- contextDirPath = getServletContext().getRealPath("/");
-
- }
-
- /**
- * Get absolute path to Servlet context directory.
- */
- public static String getContextDirPath() {
- return contextDirPath;
- }
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/FactoryConfigurationError.java b/src/main/java/com/sun/syndication/propono/atom/server/FactoryConfigurationError.java
deleted file mode 100644
index b35e0ff..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/FactoryConfigurationError.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.server;
-
-/**
- * Thrown when a problem with configuration with the
- * {@link com.sun.syndication.propono.atom.server.AtomHandlerFactory} exists.
- * This error will typically be thrown when the class of a parser factory
- * specified in the system properties cannot be found or instantiated.
- */
-public class FactoryConfigurationError extends Error {
-
- /**
- * Exception
that represents the error.
- */
- private Exception exception;
-
- /**
- * Create a new FactoryConfigurationError
with no
- * detail mesage.
- */
- public FactoryConfigurationError() {
- super();
- this.exception = null;
- }
-
- /**
- * Create a new FactoryConfigurationError
with
- * the String
specified as an error message.
- *
- * @param msg The error message for the exception.
- */
- public FactoryConfigurationError(String msg) {
- super(msg);
- this.exception = null;
- }
-
-
- /**
- * Create a new FactoryConfigurationError
with a
- * given Exception
base cause of the error.
- *
- * @param e The exception to be encapsulated in a
- * FactoryConfigurationError.
- */
- public FactoryConfigurationError(Exception e) {
- super(e.toString());
- this.exception = e;
- }
-
- /**
- * Create a new FactoryConfigurationError
with the
- * given Exception
base cause and detail message.
- *
- * @param e The exception to be encapsulated in a
- * FactoryConfigurationError
- * @param msg The detail message.
- */
- public FactoryConfigurationError(Exception e, String msg) {
- super(msg);
- this.exception = e;
- }
-
-
- /**
- * Return the message (if any) for this error . If there is no
- * message for the exception and there is an encapsulated
- * exception then the message of that exception, if it exists will be
- * returned. Else the name of the encapsulated exception will be
- * returned.
- *
- * @return The error message.
- */
- public String getMessage() {
- String message = super.getMessage();
-
- if (message == null && exception != null) {
- return exception.getMessage();
- }
-
- return message;
- }
-
- /**
- * Return the actual exception (if any) that caused this exception to
- * be raised.
- *
- * @return The encapsulated exception, or null if there is none.
- */
- public Exception getException() {
- return exception;
- }
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/FactoryFinder.java b/src/main/java/com/sun/syndication/propono/atom/server/FactoryFinder.java
deleted file mode 100644
index 67fbc6e..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/FactoryFinder.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.server;
-
-import java.io.File;
-import java.io.FileInputStream;
-
-import java.util.Properties;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-
-/**
- * Find {@link com.sun.syndication.propono.atom.server.AtomHandlerFactory} based on properties files.
- */
-class FactoryFinder {
- private static boolean debug = false;
- static Properties cacheProps= new Properties();
- static SecuritySupport ss = new SecuritySupport() ;
- static boolean firstTime = true;
-
- private static void dPrint(String msg) {
- if (debug) {
- System.err.println("Propono: " + msg);
- }
- }
-
- /**
- * Create an instance of a class using the specified ClassLoader and
- * optionally fall back to the current ClassLoader if not found.
- *
- * @param className Name of the concrete class corresponding to the
- * service provider
- *
- * @param cl ClassLoader to use to load the class, null means to use
- * the bootstrap ClassLoader
- *
- * @param doFallback true if the current ClassLoader should be tried as
- * a fallback if the class is not found using cl
- */
- private static Object newInstance(
- String className, ClassLoader cl, boolean doFallback)
- throws ConfigurationError {
-
- try {
- Class providerClass;
- if (cl == null) {
- // If classloader is null Use the bootstrap ClassLoader.
- // Thus Class.forName(String) will use the current
- // ClassLoader which will be the bootstrap ClassLoader.
- providerClass = Class.forName(className);
- } else {
- try {
- providerClass = cl.loadClass(className);
- } catch (ClassNotFoundException x) {
- if (doFallback) {
- // Fall back to current classloader
- cl = FactoryFinder.class.getClassLoader();
- providerClass = cl.loadClass(className);
- } else {
- throw x;
- }
- }
- }
-
- Object instance = providerClass.newInstance();
- dPrint("created new instance of " + providerClass +
- " using ClassLoader: " + cl);
- return instance;
- } catch (ClassNotFoundException x) {
- throw new ConfigurationError(
- "Provider " + className + " not found", x);
- } catch (Exception x) {
- throw new ConfigurationError(
- "Provider " + className + " could not be instantiated: " + x, x);
- }
- }
-
- /**
- * Finds the implementation Class object in the specified order. Main
- * entry point.
- * @return Class object of factory, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * Package private so this code can be shared.
- */
- static Object find(String factoryId, String fallbackClassName)
- throws ConfigurationError {
-
- // Figure out which ClassLoader to use for loading the provider
- // class. If there is a Context ClassLoader then use it.
-
- ClassLoader classLoader = ss.getContextClassLoader();
-
- if (classLoader == null) {
- // if we have no Context ClassLoader
- // so use the current ClassLoader
- classLoader = FactoryFinder.class.getClassLoader();
- }
-
- dPrint("find factoryId =" + factoryId);
-
- // Use the system property first
- try {
- String systemProp = ss.getSystemProperty(factoryId);
- if( systemProp!=null) {
- dPrint("found system property, value=" + systemProp);
- return newInstance(systemProp, classLoader, true );
- }
- } catch (SecurityException se) {
- //if first option fails due to any reason we should try next option in the
- //look up algorithm.
- }
-
- // try to read from /propono.properties
- try {
- String javah = ss.getSystemProperty("java.home");
- String configFile = "/propono.properties";
- String factoryClassName = null;
- if(firstTime){
- synchronized(cacheProps){
- if (firstTime) {
- try {
- InputStream is = FactoryFinder.class.getResourceAsStream(configFile);
- firstTime = false;
- if (is != null) {
- dPrint("Read properties file: " + configFile);
- cacheProps.load(is);
- }
- } catch (Exception intentionallyIgnored) {}
- }
- }
- }
- factoryClassName = cacheProps.getProperty(factoryId);
-
- if(factoryClassName != null){
- dPrint("found in $java.home/propono.properties, value=" + factoryClassName);
- return newInstance(factoryClassName, classLoader, true);
- }
- } catch(Exception ex) {
- if( debug ) ex.printStackTrace();
- }
-
- // Try Jar Service Provider Mechanism
- Object provider = findJarServiceProvider(factoryId);
- if (provider != null) {
- return provider;
- }
- if (fallbackClassName == null) {
- throw new ConfigurationError(
- "Provider for " + factoryId + " cannot be found", null);
- }
-
- dPrint("loaded from fallback value: " + fallbackClassName);
- return newInstance(fallbackClassName, classLoader, true);
- }
-
- /*
- * Try to find provider using Jar Service Provider Mechanism
- *
- * @return instance of provider class if found or null
- */
- private static Object findJarServiceProvider(String factoryId)
- throws ConfigurationError {
-
- String serviceId = "META-INF/services/" + factoryId;
- InputStream is = null;
-
- // First try the Context ClassLoader
- ClassLoader cl = ss.getContextClassLoader();
- if (cl != null) {
- is = ss.getResourceAsStream(cl, serviceId);
-
- // If no provider found then try the current ClassLoader
- if (is == null) {
- cl = FactoryFinder.class.getClassLoader();
- is = ss.getResourceAsStream(cl, serviceId);
- }
- } else {
- // No Context ClassLoader, try the current
- // ClassLoader
- cl = FactoryFinder.class.getClassLoader();
- is = ss.getResourceAsStream(cl, serviceId);
- }
-
- if (is == null) {
- // No provider found
- return null;
- }
-
- dPrint("found jar resource=" + serviceId +
- " using ClassLoader: " + cl);
-
- // Read the service provider name in UTF-8 as specified in
- // the jar spec. Unfortunately this fails in Microsoft
- // VJ++, which does not implement the UTF-8
- // encoding. Theoretically, we should simply let it fail in
- // that case, since the JVM is obviously broken if it
- // doesn't support such a basic standard. But since there
- // are still some users attempting to use VJ++ for
- // development, we have dropped in a fallback which makes a
- // second attempt using the platform's default encoding. In
- // VJ++ this is apparently ASCII, which is a subset of
- // UTF-8... and since the strings we'll be reading here are
- // also primarily limited to the 7-bit ASCII range (at
- // least, in English versions), this should work well
- // enough to keep us on the air until we're ready to
- // officially decommit from VJ++. [Edited comment from
- // jkesselm]
- BufferedReader rd;
- try {
- rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- } catch (java.io.UnsupportedEncodingException e) {
- rd = new BufferedReader(new InputStreamReader(is));
- }
-
- String factoryClassName = null;
- try {
- // XXX Does not handle all possible input as specified by the
- // Jar Service Provider specification
- factoryClassName = rd.readLine();
- rd.close();
- } catch (IOException x) {
- // No provider found
- return null;
- }
-
- if (factoryClassName != null &&
- ! "".equals(factoryClassName)) {
- dPrint("found in resource, value="
- + factoryClassName);
-
- // Note: here we do not want to fall back to the current
- // ClassLoader because we want to avoid the case where the
- // resource file was found using one ClassLoader and the
- // provider class was instantiated using a different one.
- return newInstance(factoryClassName, cl, false);
- }
-
- // No provider found
- return null;
- }
-
- static class ConfigurationError extends Error {
- private Exception exception;
-
- /**
- * Construct a new instance with the specified detail string and
- * exception.
- */
- ConfigurationError(String msg, Exception x) {
- super(msg);
- this.exception = x;
- }
-
- Exception getException() {
- return exception;
- }
- }
-
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/SecuritySupport.java b/src/main/java/com/sun/syndication/propono/atom/server/SecuritySupport.java
deleted file mode 100644
index ab64b57..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/SecuritySupport.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.server;
-
-import java.security.*;
-import java.net.*;
-import java.io.*;
-import java.util.*;
-
-/**
- * This class is duplicated for each subpackage, it is package private and
- * therefore is not exposed as part of the public API.
- */
-class SecuritySupport {
-
- ClassLoader getContextClassLoader() {
- return (ClassLoader)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- ClassLoader cl = null;
- try {
- cl = Thread.currentThread().getContextClassLoader();
- } catch (SecurityException ex) { }
- return cl;
- }
- });
- }
-
- String getSystemProperty(final String propName) {
- return (String)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty(propName);
- }
- });
- }
-
- FileInputStream getFileInputStream(final File file)
- throws FileNotFoundException {
- try {
- return (FileInputStream)
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws FileNotFoundException {
- return new FileInputStream(file);
- }
- });
- } catch (PrivilegedActionException e) {
- throw (FileNotFoundException)e.getException();
- }
- }
-
- InputStream getResourceAsStream(final ClassLoader cl,
- final String name) {
- return (InputStream)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- InputStream ris;
- if (cl == null) {
- ris = ClassLoader.getSystemResourceAsStream(name);
- } else {
- ris = cl.getResourceAsStream(name);
- }
- return ris;
- }
- });
- }
-
- boolean doesFileExist(final File f) {
- return ((Boolean)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new Boolean(f.exists());
- }
- })).booleanValue();
- }
-
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/impl/FileBasedAtomHandler.java b/src/main/java/com/sun/syndication/propono/atom/server/impl/FileBasedAtomHandler.java
deleted file mode 100644
index 018b8b2..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/impl/FileBasedAtomHandler.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.server.impl;
-
-import com.sun.syndication.propono.atom.server.AtomMediaResource;
-import org.apache.commons.codec.binary.Base64;
-import com.sun.syndication.propono.atom.server.AtomHandler;
-import com.sun.syndication.propono.atom.server.AtomException;
-import com.sun.syndication.propono.atom.server.AtomServlet;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Feed;
-import com.sun.syndication.propono.atom.common.AtomService;
-import com.sun.syndication.propono.atom.common.Categories;
-import com.sun.syndication.propono.atom.server.AtomRequest;
-import java.io.File;
-import java.util.StringTokenizer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.lang.StringUtils;
-
-
-/**
- * File-based {@link com.sun.syndication.propono.atom.server.AtomHandler}
- * implementation that stores entries and media-entries to disk. Implemented
- * using {@link com.sun.syndication.propono.atom.server.impl.FileBasedAtomService}.
- */
-public class FileBasedAtomHandler implements AtomHandler {
-
- private static Log log =
- LogFactory.getFactory().getInstance(FileBasedAtomHandler.class);
-
- private static String fileStoreDir = null;
-
- private String userName = null;
- private String atomProtocolURL = null;
- private String contextURI = null;
- private String uploadurl = null;
-
- private FileBasedAtomService service = null;
-
- /**
- * Construct handler to handle one request.
- * @param req Request to be handled.
- */
- public FileBasedAtomHandler( HttpServletRequest req ) {
- this(req, AtomServlet.getContextDirPath());
- }
-
- /**
- * Contruct handler for one request, using specified file storage directory.
- * @param req Request to be handled.
- * @param uploaddir File storage upload dir.
- */
- public FileBasedAtomHandler(HttpServletRequest req, String uploaddir) {
- log.debug("ctor");
-
- userName = authenticateBASIC(req);
-
- atomProtocolURL = req.getScheme() + "://" + req.getServerName() + ":"
- + req.getServerPort() + req.getContextPath() + req.getServletPath();
-
- contextURI = req.getScheme() + "://" + req.getServerName() + ":"
- + req.getServerPort() + req.getContextPath();
-
- try {
- service = new FileBasedAtomService(userName, uploaddir,
- contextURI, req.getContextPath(), req.getServletPath());
- } catch (Throwable t) {
- throw new RuntimeException("ERROR creating FileBasedAtomService", t);
- }
- }
-
- /**
- * Method used for validating user. Developers can overwrite this method
- * and use credentials stored in Database or LDAP to confirm if the user is
- * allowed to access this service.
- * @param login user submitted login id
- * @param password user submitted password
- */
- public boolean validateUser(String login, String password) {
- return true;
- }
-
- /**
- * Get username of authenticated user
- * @return User name.
- */
- public String getAuthenticatedUsername() {
- // For now return userName as the login id entered for authorization
- return userName;
- }
-
- /**
- * Get base URI of Atom protocol implementation.
- * @return Base URI of Atom protocol implemenation.
- */
- public String getAtomProtocolURL( ) {
- if ( atomProtocolURL == null ) {
- return "app";
- } else {
- return atomProtocolURL;
- }
- }
-
- /**
- * Return introspection document
- * @throws com.sun.syndication.propono.atom.server.AtomException Unexpected exception.
- * @return AtomService object with workspaces and collections.
- */
- public AtomService getAtomService(AtomRequest areq) throws AtomException {
- return service;
- }
-
- /**
- * Returns null because we use in-line categories.
- * @throws com.sun.syndication.propono.atom.server.AtomException Unexpected exception.
- * @return Categories object
- */
- public Categories getCategories(AtomRequest areq) throws AtomException {
- log.debug("getCollection");
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- return (Categories)col.getCategories(true).get(0);
- }
-
- /**
- * Get collection specified by pathinfo.
- * @param areq Details of HTTP request
- * @return ROME feed representing collection.
- * @throws com.sun.syndication.propono.atom.server.AtomException Invalid collection or other exception.
- */
- public Feed getCollection(AtomRequest areq) throws AtomException {
- log.debug("getCollection");
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- return col.getFeedDocument();
- }
-
- /**
- * Create a new entry specified by pathInfo and posted entry. We save the
- * submitted Atom entry verbatim, but we do set the id and reset the update
- * time.
- *
- * @param entry Entry to be added to collection.
- * @param areq Details of HTTP request
- * @throws com.sun.syndication.propono.atom.server.AtomException On invalid collection or other error.
- * @return Entry as represented on server.
- */
- public Entry postEntry(AtomRequest areq, Entry entry) throws AtomException {
- log.debug("postEntry");
-
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- try {
- return col.addEntry(entry);
-
- } catch (Exception fe) {
- fe.printStackTrace();
- throw new AtomException( fe );
- }
- }
-
- /**
- * Get entry specified by pathInfo.
- * @param areq Details of HTTP request
- * @throws com.sun.syndication.propono.atom.server.AtomException On invalid pathinfo or other error.
- * @return ROME Entry object.
- */
- public Entry getEntry(AtomRequest areq) throws AtomException {
- log.debug("getEntry");
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- String fileName = pathInfo[2];
- FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- try {
- return col.getEntry(fileName);
-
- } catch (Exception re) {
- if (re instanceof AtomException) throw (AtomException)re;
- throw new AtomException("ERROR: getting entry", re);
- }
- }
-
- /**
- * Update entry specified by pathInfo and posted entry.
- *
- * @param entry
- * @param areq Details of HTTP request
- * @throws com.sun.syndication.propono.atom.server.AtomException
- */
- public void putEntry(AtomRequest areq, Entry entry) throws AtomException {
- log.debug("putEntry");
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- String fileName = pathInfo[2];
- FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- try {
- col.updateEntry(entry, fileName);
-
- } catch ( Exception fe ) {
- throw new AtomException( fe );
- }
- }
-
-
- /**
- * Delete entry specified by pathInfo.
- * @param areq Details of HTTP request
- */
- public void deleteEntry(AtomRequest areq) throws AtomException {
- log.debug("deleteEntry");
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- String fileName = pathInfo[2];
- FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- try {
- col.deleteEntry(fileName);
-
- } catch (Exception e) {
- String msg = "ERROR in atom.deleteResource";
- log.error(msg,e);
- throw new AtomException(msg);
- }
- }
-
-
- /**
- * Store media data in collection specified by pathInfo, create an Atom
- * media-link entry to store metadata for the new media file and return
- * that entry to the caller.
- * @param areq Details of HTTP request
- * @param entry New entry initialzied with only title and content type
- * @return Location URL of new media entry
- */
- public Entry postMedia(AtomRequest areq, Entry entry) throws AtomException {
-
- // get incoming slug from HTTP header
- String slug = areq.getHeader("Slug");
-
- if (log.isDebugEnabled()) {
- log.debug("postMedia - title: "+entry.getTitle()+" slug:"+slug);
- }
-
- try {
- File tempFile = null;
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- try {
- col.addMediaEntry(entry, slug, areq.getInputStream());
-
- } catch (Exception e) {
- e.printStackTrace();
- String msg = "ERROR reading posted file";
- log.error(msg,e);
- throw new AtomException(msg, e);
- } finally {
- if (tempFile != null) tempFile.delete();
- }
-
- } catch (Exception re) {
- throw new AtomException("ERROR: posting media");
- }
- return entry;
- }
-
- /**
- * Update the media file part of a media-link entry.
- * @param areq Details of HTTP request
- * Assuming pathInfo of form /user-name/resource/name
- */
- public void putMedia(AtomRequest areq) throws AtomException {
-
- log.debug("putMedia");
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- String fileName = pathInfo[3];
- FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- try {
- col.updateMediaEntry(fileName, areq.getContentType(), areq.getInputStream());
-
- } catch (Exception re) {
- throw new AtomException("ERROR: posting media");
- }
- }
-
- public AtomMediaResource getMediaResource(AtomRequest areq) throws AtomException {
- log.debug("putMedia");
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- String fileName = pathInfo[3];
- FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- try {
- return col.getMediaResource(fileName);
-
- } catch (Exception re) {
- throw new AtomException("ERROR: posting media");
- }
- }
-
- /**
- * Return true if specified pathinfo represents URI of service doc.
- */
- public boolean isAtomServiceURI(AtomRequest areq) {
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- if (pathInfo.length==0) return true;
- return false;
- }
-
- /**
- * Return true if specified pathinfo represents URI of category doc.
- */
- public boolean isCategoriesURI(AtomRequest areq) {
- log.debug("isCategoriesDocumentURI");
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- if (pathInfo.length == 3 && "categories".equals(pathInfo[2])) {
- return true;
- }
- return false;
- }
-
- /**
- * Return true if specified pathinfo represents URI of a collection.
- */
- public boolean isCollectionURI(AtomRequest areq) {
- log.debug("isCollectionURI");
- // workspace/collection-plural
- // if length is 2 and points to a valid collection then YES
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- if (pathInfo.length == 2) {
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- if (service.findCollectionByHandle(handle, collection) != null) {
- return true;
- }
- }
- return false;
-
- }
-
- /**
- * Return true if specified pathinfo represents URI of an Atom entry.
- */
- public boolean isEntryURI(AtomRequest areq) {
- log.debug("isEntryURI");
- // workspace/collection-singular/fsid
- // if length is 3 and points to a valid collection then YES
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- if (pathInfo.length == 3) {
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- if (service.findCollectionByHandle(handle, collection) != null) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if specified pathinfo represents media-edit URI.
- */
- public boolean isMediaEditURI(AtomRequest areq) {
- log.debug("isMediaEditURI");
- // workspace/collection-singular/fsid/media/fsid
- // if length is 4, points to a valid collection and fsid is mentioned twice then YES
- String[] pathInfo = StringUtils.split(areq.getPathInfo(),"/");
- if (pathInfo.length == 4) {
- String handle = pathInfo[0];
- String collection = pathInfo[1];
- String media = pathInfo[2];
- String fsid = pathInfo[3];
- if (service.findCollectionByHandle(handle, collection) != null && media.equals("media")) {
- return true;
- }
- }
- return false;
-
- }
-
- /**
- * BASIC authentication.
- */
- public String authenticateBASIC(HttpServletRequest request) {
- log.debug("authenticateBASIC");
- boolean valid = false;
- String userID = null;
- String password = null;
- try {
- String authHeader = request.getHeader("Authorization");
- if (authHeader != null) {
- StringTokenizer st = new StringTokenizer(authHeader);
- if (st.hasMoreTokens()) {
- String basic = st.nextToken();
- if (basic.equalsIgnoreCase("Basic")) {
- String credentials = st.nextToken();
- String userPass = new String(Base64.decodeBase64(credentials.getBytes()));
- int p = userPass.indexOf(":");
- if (p != -1) {
- userID = userPass.substring(0, p);
- password = userPass.substring(p+1);
-
- // Validate the User.
- valid = validateUser( userID, password );
- }
- }
- }
- }
- } catch (Exception e) {
- log.debug(e);
- }
- if (valid) {
- //For now assume userID as userName
- return userID;
- }
- return null;
- }
-}
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/impl/FileBasedAtomHandlerFactory.java b/src/main/java/com/sun/syndication/propono/atom/server/impl/FileBasedAtomHandlerFactory.java
deleted file mode 100644
index 74ba434..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/impl/FileBasedAtomHandlerFactory.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.server.impl;
-
-import com.sun.syndication.propono.atom.server.AtomHandlerFactory;
-import com.sun.syndication.propono.atom.server.AtomHandler;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Extends {@link com.sun.syndication.propono.atom.server.AtomHandlerFactory} to create and return
- * {@link com.sun.syndication.propono.atom.server.impl.FileBasedAtomHandler}.
- */
-public class FileBasedAtomHandlerFactory extends AtomHandlerFactory {
-
- /**
- * Create new AtomHandler.
- */
- public AtomHandler newAtomHandler(
- HttpServletRequest req, HttpServletResponse res ) {
- return new FileBasedAtomHandler(req);
- }
-}
-
diff --git a/src/main/java/com/sun/syndication/propono/atom/server/impl/FileBasedAtomService.java b/src/main/java/com/sun/syndication/propono/atom/server/impl/FileBasedAtomService.java
deleted file mode 100644
index 9615a74..0000000
--- a/src/main/java/com/sun/syndication/propono/atom/server/impl/FileBasedAtomService.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright 2007 Sun Microsystems, Inc.
- *
- * 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 com.sun.syndication.propono.atom.server.impl;
-
-import com.sun.syndication.propono.atom.common.AtomService;
-import com.sun.syndication.propono.utils.Utilities;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TreeMap;
-
-/**
- * File based Atom service.
- * Supports one workspace per user.
- * Collections in workspace are defined in /propono.properties, for example:
- *
- *
- * # Define list of collections to be offered
- * propono.atomserver.filebased.collections=entries,gifimages
- *
- * # Defines 'entries' collection, accepts entries
- * propono.atomserver.filebased.collection.entries.title=Entries
- * propono.atomserver.filebased.collection.entries.singular=entry
- * propono.atomserver.filebased.collection.entries.plural=entries
- * propono.atomserver.filebased.collection.entries.accept=application/atom+xml;type=entry
- * propono.atomserver.filebased.collection.entries.categories=general,category1,category2
- *
- * # Defines 'gifimages' collection, accepts only GIF files
- * propono.atomserver.filebased.collection.gifimages.title=GIF Images
- * propono.atomserver.filebased.collection.gifimages.singular=gif
- * propono.atomserver.filebased.collection.gifimages.plural=gifs
- * propono.atomserver.filebased.collection.gifimages.accept=image/gif
- * propono.atomserver.filebased.collection.gifimages.categories=general,category1,category2
- *
- *
- * If no such properties are found, then service will fall back to two
- * collections: 'entries' for Atom entries and 'resources' for any content-type.
- *
- *
- *
- * [servlet-context-uri]/app/[workspace-handle]/[collection-plural]
- *
- * [servlet-context-uri]/app/[workspace-handle]/[collection-singular]/[entryid]
- *
- * [servlet-context-uri]/app/[workspace-handle]/[collection-singular]/media/[entryid]
- *
- * [servlet-context-uri]/app/[workspace-handle]/[collection-plural]/categories
- *
- * [servlet-context-dir]/[workspace-handle]/[collection-plural]/feed.xml
- *
- * [servlet-context-dir]/[workspace-handle]/[collection-plural]/id/entry.xml
- *
- * [servlet-context-dir]/[workspace-handle]/[collection-plural]/id/media/id
- * [collection-plural]/[entryid]/entry.xml
.
- * The entry will be added to the collection's feed in [collection-plural]/feed.xml.
- * @param entry Entry object
- * @param slug String to be used in file-name
- * @param is Source of media data
- * @throws java.lang.Exception On Error
- * @return Location URI of entry
- */
- public String addMediaEntry(Entry entry, String slug, InputStream is) throws Exception {
- synchronized (FileStore.getFileStore()) {
-
- // Save media file temp file
- Content content = (Content)entry.getContents().get(0);
- if (entry.getTitle() == null) {
- entry.setTitle(slug);
- }
- String fileName = createFileName((slug != null) ? slug : entry.getTitle(), content.getType());
- File tempFile = File.createTempFile(fileName, "tmp");
- FileOutputStream fos = new FileOutputStream(tempFile);
- Utilities.copyInputToOutput(is, fos);
- fos.close();
-
- // Save media file
- FileInputStream fis = new FileInputStream(tempFile);
- saveMediaFile(fileName, content.getType(), tempFile.length(), fis);
- fis.close();
- File resourceFile = new File(getEntryMediaPath(fileName));
-
- // Create media-link entry
- updateTimestamps(entry);
-
- // Save media-link entry
- String entryPath = getEntryPath(fileName);
- OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
- updateMediaEntryAppLinks(entry, resourceFile.getName(), true);
- Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
- os.flush();
- os.close();
-
- // Update feed with new entry
- Feed f = getFeedDocument();
- updateMediaEntryAppLinks(entry, resourceFile.getName(), false);
- updateFeedDocumentWithNewEntry(f, entry);
-
- return getEntryEditURI(fileName, false, true);
- }
- }
-
- /**
- * Get an entry from the collection.
- * @param fsid Internal ID of entry to be returned
- * @throws java.lang.Exception On error
- * @return Entry specified by fileName/ID
- */
- public Entry getEntry(String fsid) throws Exception {
- if (fsid.endsWith(".media-link")) {
- fsid = fsid.substring(0, fsid.length() - ".media-link".length());
- }
-
- String entryPath = getEntryPath(fsid);
-
- checkExistence(entryPath);
- InputStream in = FileStore.getFileStore().getFileInputStream(entryPath);
-
- final Entry entry;
- String filePath = getEntryMediaPath(fsid);
- File resource = new File(fsid);
- if (resource.exists()) {
- entry = loadAtomResourceEntry(in, resource);
- updateMediaEntryAppLinks(entry, fsid, true);
- } else {
- entry = loadAtomEntry(in);
- updateEntryAppLinks(entry, fsid, true);
- }
- return entry;
- }
-
- /**
- * Get media resource wrapping a file.
- */
- public AtomMediaResource getMediaResource(String fileName) throws Exception {
- String filePath = getEntryMediaPath(fileName);
- File resource = new File(filePath);
- return new AtomMediaResource(resource);
- }
-
- /**
- * Update an entry in the collection.
- * @param entry Updated entry to be stored
- * @param fsid Internal ID of entry
- * @throws java.lang.Exception On error
- */
- public void updateEntry(Entry entry, String fsid) throws Exception {
- synchronized (FileStore.getFileStore()) {
-
- Feed f = getFeedDocument();
-
- if (fsid.endsWith(".media-link")) {
- fsid = fsid.substring(0, fsid.length() - ".media-link".length());
- }
-
- updateTimestamps(entry);
-
- updateEntryAppLinks(entry, fsid, false);
- updateFeedDocumentWithExistingEntry(f, entry);
-
- String entryPath = getEntryPath(fsid);
- OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
- updateEntryAppLinks(entry, fsid, true);
- Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
- os.flush();
- os.close();
- }
- }
-
- /**
- * Update media associated with a media-link entry.
- * @param fileName Internal ID of entry being updated
- * @param contentType Content type of data
- * @param is Source of updated data
- * @throws java.lang.Exception On error
- * @return Updated Entry as it exists on server
- */
- public Entry updateMediaEntry(String fileName, String contentType, InputStream is) throws Exception {
- synchronized (FileStore.getFileStore()) {
-
- File tempFile = File.createTempFile(fileName, "tmp");
- FileOutputStream fos = new FileOutputStream(tempFile);
- Utilities.copyInputToOutput(is, fos);
- fos.close();
-
- // Update media file
- FileInputStream fis = new FileInputStream(tempFile);
- saveMediaFile(fileName, contentType, tempFile.length(), fis);
- fis.close();
- File resourceFile = new File(getEntryMediaPath(fileName));
-
- // Load media-link entry to return
- String entryPath = getEntryPath(fileName);
- InputStream in = FileStore.getFileStore().getFileInputStream(entryPath);
- Entry atomEntry = loadAtomResourceEntry(in, resourceFile);
-
- updateTimestamps(atomEntry);
- updateMediaEntryAppLinks(atomEntry, fileName, false);
-
- // Update feed with new entry
- Feed f = getFeedDocument();
- updateFeedDocumentWithExistingEntry(f, atomEntry);
-
- // Save updated media-link entry
- OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
- updateMediaEntryAppLinks(atomEntry, fileName, true);
- Atom10Generator.serializeEntry(atomEntry, new OutputStreamWriter(os, "UTF-8"));
- os.flush();
- os.close();
-
- return atomEntry;
- }
- }
-
- /**
- * Delete an entry and any associated media file.
- * @param fsid Internal ID of entry
- * @throws java.lang.Exception On error
- */
- public void deleteEntry(String fsid) throws Exception {
- synchronized (FileStore.getFileStore()) {
-
- // Remove entry from Feed
- Feed feed = getFeedDocument();
- updateFeedDocumentRemovingEntry(feed, fsid);
-
- String entryFilePath = this.getEntryPath(fsid);
- FileStore.getFileStore().deleteFile(entryFilePath);
-
- String entryMediaPath = this.getEntryMediaPath(fsid);
- if (entryMediaPath != null) {
- FileStore.getFileStore().deleteFile(entryMediaPath);
- }
-
- String entryDirPath = getEntryDirPath(fsid);
- FileStore.getFileStore().deleteDirectory(entryDirPath);
-
- try {Thread.sleep(500L);}catch(Exception ignored){}
- }
- }
-
- private void updateFeedDocumentWithNewEntry(Feed f, Entry e) throws AtomException {
- boolean inserted = false;
- for (int i=0; i