- * 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 + * 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. *
*/ public abstract class AtomHandlerFactory { - private static Log log = LogFactory.getFactory().getInstance(AtomHandlerFactory.class); + private static final Logger LOG = LoggerFactory.getLogger(AtomHandlerFactory.class); private static final String DEFAULT_PROPERTY_NAME = "org.rometools.propono.atom.server.AtomHandlerFactory"; - private static final String FALLBACK_IMPL_NAME = "org.rometools.propono.atom.server.impl.FileBasedAtomHandlerFactory"; /* @@ -45,46 +46,55 @@ public abstract class AtomHandlerFactory { } /** - * Obtain a new instance of aAtomHandlerFactory
. This static method creates a new factory instance. This method uses the following ordered
- * lookup procedure to determine the AtomHandlerFactory
implementation class to load:
+ * Obtain a new instance of a 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:
* com.sun.syndication.propono.atom.server.AtomHandlerFactory
system property.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.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.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.
- *
+ *
+ * Once an application has obtained a reference to a 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.
+ *
+ * @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 (final ConfigurationError e) {
- log.error("ERROR: finding factory", e);
+ LOG.error("An error occured while 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.
- *
+ * 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.
+ *
+ * @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/org/rometools/propono/atom/server/AtomServlet.java b/src/main/java/org/rometools/propono/atom/server/AtomServlet.java
index 99530a7..f64b56d 100644
--- a/src/main/java/org/rometools/propono/atom/server/AtomServlet.java
+++ b/src/main/java/org/rometools/propono/atom/server/AtomServlet.java
@@ -32,14 +32,14 @@ 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.jdom2.Document;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
import org.rometools.propono.atom.common.AtomService;
import org.rometools.propono.atom.common.Categories;
import org.rometools.propono.utils.Utilities;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.sun.syndication.feed.atom.Content;
import com.sun.syndication.feed.atom.Entry;
@@ -66,7 +66,7 @@ public class AtomServlet extends HttpServlet {
public static final String FEED_TYPE = "atom_1.0";
private static String contextDirPath = null;
- private static Log log = LogFactory.getFactory().getInstance(AtomServlet.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AtomServlet.class);
static {
Atom10Parser.setResolveURIs(true);
@@ -87,7 +87,7 @@ public class AtomServlet extends HttpServlet {
*/
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
- log.debug("Entering");
+ LOG.debug("Entering");
final AtomHandler handler = createAtomRequestHandler(req, res);
final String userName = handler.getAuthenticatedUsername();
if (userName != null) {
@@ -150,16 +150,16 @@ public class AtomServlet extends HttpServlet {
}
} catch (final AtomException ae) {
res.sendError(ae.getStatus(), ae.getMessage());
- log.debug("ERROR processing GET", ae);
+ LOG.debug("An error occured while processing GET", ae);
} catch (final Exception e) {
res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- log.debug("ERROR processing GET", e);
+ LOG.debug("An error occured while processing GET", e);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
}
- log.debug("Exiting");
+ LOG.debug("Exiting");
}
// -----------------------------------------------------------------------------
@@ -169,7 +169,7 @@ public class AtomServlet extends HttpServlet {
*/
@Override
protected void doPost(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
- log.debug("Entering");
+ LOG.debug("Entering");
final AtomHandler handler = createAtomRequestHandler(req, res);
final String userName = handler.getAuthenticatedUsername();
if (userName != null) {
@@ -256,16 +256,16 @@ public class AtomServlet extends HttpServlet {
}
} catch (final AtomException ae) {
res.sendError(ae.getStatus(), ae.getMessage());
- log.debug("ERROR processing POST", ae);
+ LOG.debug("An error occured while processing POST", ae);
} catch (final Exception e) {
res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- log.debug("ERROR processing POST", e);
+ LOG.debug("An error occured while processing POST", e);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
}
- log.debug("Exiting");
+ LOG.debug("Exiting");
}
// -----------------------------------------------------------------------------
@@ -275,7 +275,7 @@ public class AtomServlet extends HttpServlet {
*/
@Override
protected void doPut(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
- log.debug("Entering");
+ LOG.debug("Entering");
final AtomHandler handler = createAtomRequestHandler(req, res);
final String userName = handler.getAuthenticatedUsername();
if (userName != null) {
@@ -304,10 +304,10 @@ public class AtomServlet extends HttpServlet {
}
} catch (final AtomException ae) {
res.sendError(ae.getStatus(), ae.getMessage());
- log.debug("ERROR processing PUT", ae);
+ LOG.debug("An error occured while processing PUT", ae);
} catch (final Exception e) {
res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- log.debug("ERROR processing PUT", e);
+ LOG.debug("An error occured while processing PUT", e);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
@@ -315,7 +315,7 @@ public class AtomServlet extends HttpServlet {
// when I do that, so sticking with setStatus() for time being.
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
- log.debug("Exiting");
+ LOG.debug("Exiting");
}
// -----------------------------------------------------------------------------
@@ -324,7 +324,7 @@ public class AtomServlet extends HttpServlet {
*/
@Override
protected void doDelete(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
- log.debug("Entering");
+ LOG.debug("Entering");
final AtomHandler handler = createAtomRequestHandler(req, res);
final String userName = handler.getAuthenticatedUsername();
if (userName != null) {
@@ -338,10 +338,10 @@ public class AtomServlet extends HttpServlet {
}
} catch (final AtomException ae) {
res.sendError(ae.getStatus(), ae.getMessage());
- log.debug("ERROR processing DELETE", ae);
+ LOG.debug("An error occured while processing DELETE", ae);
} catch (final Exception e) {
res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- log.debug("ERROR processing DELETE", e);
+ LOG.debug("An error occured while processing DELETE", e);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
@@ -349,7 +349,7 @@ public class AtomServlet extends HttpServlet {
// when I do that, so sticking with setStatus() for time being.
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
- log.debug("Exiting");
+ LOG.debug("Exiting");
}
/**
diff --git a/src/main/java/org/rometools/propono/atom/server/impl/FileBasedAtomHandler.java b/src/main/java/org/rometools/propono/atom/server/impl/FileBasedAtomHandler.java
index 2f777e4..a8a0bbe 100644
--- a/src/main/java/org/rometools/propono/atom/server/impl/FileBasedAtomHandler.java
+++ b/src/main/java/org/rometools/propono/atom/server/impl/FileBasedAtomHandler.java
@@ -22,8 +22,6 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.rometools.propono.atom.common.AtomService;
import org.rometools.propono.atom.common.Categories;
import org.rometools.propono.atom.server.AtomException;
@@ -31,6 +29,8 @@ import org.rometools.propono.atom.server.AtomHandler;
import org.rometools.propono.atom.server.AtomMediaResource;
import org.rometools.propono.atom.server.AtomRequest;
import org.rometools.propono.atom.server.AtomServlet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.sun.syndication.feed.atom.Entry;
import com.sun.syndication.feed.atom.Feed;
@@ -42,7 +42,7 @@ import com.sun.syndication.feed.atom.Feed;
*/
public class FileBasedAtomHandler implements AtomHandler {
- private static final Log LOGGER = LogFactory.getFactory().getInstance(FileBasedAtomHandler.class);
+ private static final Logger LOG = LoggerFactory.getLogger(FileBasedAtomHandler.class);
private String userName = null;
private String atomProtocolURL = null;
@@ -65,7 +65,7 @@ public class FileBasedAtomHandler implements AtomHandler {
* @param uploaddir File storage upload dir.
*/
public FileBasedAtomHandler(final HttpServletRequest req, final String uploaddir) {
- LOGGER.debug("ctor");
+ LOG.debug("ctor");
userName = authenticateBASIC(req);
@@ -134,12 +134,12 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public Categories getCategories(final AtomRequest areq) throws AtomException {
- LOGGER.debug("getCollection");
+ LOG.debug("getCollection");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
- return (Categories) col.getCategories(true).get(0);
+ return col.getCategories(true).get(0);
}
/**
@@ -152,7 +152,7 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public Feed getCollection(final AtomRequest areq) throws AtomException {
- LOGGER.debug("getCollection");
+ LOG.debug("getCollection");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
@@ -172,7 +172,7 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public Entry postEntry(final AtomRequest areq, final Entry entry) throws AtomException {
- LOGGER.debug("postEntry");
+ LOG.debug("postEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
@@ -197,7 +197,7 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public Entry getEntry(final AtomRequest areq) throws AtomException {
- LOGGER.debug("getEntry");
+ LOG.debug("getEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
@@ -223,7 +223,7 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public void putEntry(final AtomRequest areq, final Entry entry) throws AtomException {
- LOGGER.debug("putEntry");
+ LOG.debug("putEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
@@ -244,7 +244,7 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public void deleteEntry(final AtomRequest areq) throws AtomException {
- LOGGER.debug("deleteEntry");
+ LOG.debug("deleteEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
@@ -255,7 +255,7 @@ public class FileBasedAtomHandler implements AtomHandler {
} catch (final Exception e) {
final String msg = "ERROR in atom.deleteResource";
- LOGGER.error(msg, e);
+ LOG.error(msg, e);
throw new AtomException(msg);
}
}
@@ -274,8 +274,8 @@ public class FileBasedAtomHandler implements AtomHandler {
// get incoming slug from HTTP header
final String slug = areq.getHeader("Slug");
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("postMedia - title: " + entry.getTitle() + " slug:" + slug);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("postMedia - title: " + entry.getTitle() + " slug:" + slug);
}
try {
@@ -290,7 +290,7 @@ public class FileBasedAtomHandler implements AtomHandler {
} catch (final Exception e) {
e.printStackTrace();
final String msg = "ERROR reading posted file";
- LOGGER.error(msg, e);
+ LOG.error(msg, e);
throw new AtomException(msg, e);
} finally {
if (tempFile != null) {
@@ -312,7 +312,7 @@ public class FileBasedAtomHandler implements AtomHandler {
@Override
public void putMedia(final AtomRequest areq) throws AtomException {
- LOGGER.debug("putMedia");
+ LOG.debug("putMedia");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
@@ -328,7 +328,7 @@ public class FileBasedAtomHandler implements AtomHandler {
@Override
public AtomMediaResource getMediaResource(final AtomRequest areq) throws AtomException {
- LOGGER.debug("putMedia");
+ LOG.debug("putMedia");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
@@ -359,7 +359,7 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public boolean isCategoriesURI(final AtomRequest areq) {
- LOGGER.debug("isCategoriesDocumentURI");
+ LOG.debug("isCategoriesDocumentURI");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
if (pathInfo.length == 3 && "categories".equals(pathInfo[2])) {
return true;
@@ -372,7 +372,7 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public boolean isCollectionURI(final AtomRequest areq) {
- LOGGER.debug("isCollectionURI");
+ LOG.debug("isCollectionURI");
// workspace/collection-plural
// if length is 2 and points to a valid collection then YES
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
@@ -392,7 +392,7 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public boolean isEntryURI(final AtomRequest areq) {
- LOGGER.debug("isEntryURI");
+ LOG.debug("isEntryURI");
// workspace/collection-singular/fsid
// if length is 3 and points to a valid collection then YES
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
@@ -411,7 +411,7 @@ public class FileBasedAtomHandler implements AtomHandler {
*/
@Override
public boolean isMediaEditURI(final AtomRequest areq) {
- LOGGER.debug("isMediaEditURI");
+ 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
@@ -433,7 +433,7 @@ public class FileBasedAtomHandler implements AtomHandler {
* BASIC authentication.
*/
public String authenticateBASIC(final HttpServletRequest request) {
- LOGGER.debug("authenticateBASIC");
+ LOG.debug("authenticateBASIC");
boolean valid = false;
String userID = null;
String password = null;
@@ -458,7 +458,7 @@ public class FileBasedAtomHandler implements AtomHandler {
}
}
} catch (final Exception e) {
- LOGGER.debug(e);
+ LOG.debug("An error occured while processing Basic authentication", e);
}
if (valid) {
// For now assume userID as userName
diff --git a/src/main/java/org/rometools/propono/atom/server/impl/FileStore.java b/src/main/java/org/rometools/propono/atom/server/impl/FileStore.java
index 6c3589b..43112eb 100644
--- a/src/main/java/org/rometools/propono/atom/server/impl/FileStore.java
+++ b/src/main/java/org/rometools/propono/atom/server/impl/FileStore.java
@@ -26,15 +26,15 @@ import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class which helps in handling File persistence related operations.
*/
class FileStore {
- private static final Log LOG = LogFactory.getFactory().getInstance(FileStore.class);
+ private static final Logger LOG = LoggerFactory.getLogger(FileStore.class);
private static final FileStore fileStore = new FileStore();
diff --git a/src/main/java/org/rometools/propono/blogclient/atomprotocol/AtomEntry.java b/src/main/java/org/rometools/propono/blogclient/atomprotocol/AtomEntry.java
index 0f8bca6..5e72660 100644
--- a/src/main/java/org/rometools/propono/blogclient/atomprotocol/AtomEntry.java
+++ b/src/main/java/org/rometools/propono/blogclient/atomprotocol/AtomEntry.java
@@ -17,11 +17,8 @@ package org.rometools.propono.blogclient.atomprotocol;
import java.util.ArrayList;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.rometools.propono.atom.client.ClientEntry;
import org.rometools.propono.atom.common.rome.AppModule;
import org.rometools.propono.atom.common.rome.AppModuleImpl;
@@ -39,7 +36,6 @@ import com.sun.syndication.feed.synd.SyndPerson;
* Atom protocol implementation of BlogEntry.
*/
public class AtomEntry extends BaseBlogEntry implements BlogEntry {
- static final Log logger = LogFactory.getLog(AtomCollection.class);
String editURI = null;
AtomCollection collection = null;
@@ -61,9 +57,6 @@ public class AtomEntry extends BaseBlogEntry implements BlogEntry {
copyFromRomeEntry(entry);
}
- /**
- * {@inheritDoc}
- */
@Override
public String getToken() {
return editURI;
@@ -91,9 +84,6 @@ public class AtomEntry extends BaseBlogEntry implements BlogEntry {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public void save() throws BlogClientException {
final boolean create = getToken() == null;
@@ -120,9 +110,6 @@ public class AtomEntry extends BaseBlogEntry implements BlogEntry {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public void delete() throws BlogClientException {
if (getToken() == null) {
@@ -216,8 +203,7 @@ public class AtomEntry extends BaseBlogEntry implements BlogEntry {
}
if (categories != null) {
final List