Migrated logging to SLF4J
This commit is contained in:
parent
5926dd2bd2
commit
1072990373
15 changed files with 151 additions and 136 deletions
5
pom.xml
5
pom.xml
|
@ -89,6 +89,11 @@
|
|||
<artifactId>servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -23,13 +23,13 @@ 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.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.rometools.propono.atom.common.AtomService;
|
||||
import org.rometools.propono.utils.ProponoException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.sun.syndication.feed.atom.Entry;
|
||||
import com.sun.syndication.io.impl.Atom10Parser;
|
||||
|
@ -42,7 +42,7 @@ import com.sun.syndication.io.impl.Atom10Parser;
|
|||
*/
|
||||
public class ClientAtomService extends AtomService {
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(ClientAtomService.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ClientAtomService.class);
|
||||
|
||||
private String uri = null;
|
||||
private HttpClient httpClient = null;
|
||||
|
@ -106,12 +106,12 @@ public class ClientAtomService extends AtomService {
|
|||
|
||||
final SAXBuilder builder = new SAXBuilder();
|
||||
final String doc = method.getResponseBodyAsString();
|
||||
LOGGER.debug(doc);
|
||||
LOG.debug(doc);
|
||||
return builder.build(method.getResponseBodyAsStream());
|
||||
|
||||
} catch (final Throwable t) {
|
||||
final String msg = "ERROR retrieving Atom Service Document, code: " + code;
|
||||
LOGGER.debug(msg, t);
|
||||
LOG.debug(msg, t);
|
||||
throw new ProponoException(msg, t);
|
||||
} finally {
|
||||
if (method != null) {
|
||||
|
|
|
@ -33,10 +33,10 @@ import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
|
|||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.PutMethod;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.rometools.propono.utils.ProponoException;
|
||||
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;
|
||||
|
@ -51,7 +51,8 @@ import com.sun.syndication.io.impl.Atom10Parser;
|
|||
public class ClientEntry extends Entry {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log LOGGER = LogFactory.getLog(ClientEntry.class);
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ClientEntry.class);
|
||||
|
||||
private ClientAtomService service = null;
|
||||
private ClientCollection collection = null;
|
||||
|
@ -154,7 +155,7 @@ public class ClientEntry extends Entry {
|
|||
|
||||
} catch (final Exception e) {
|
||||
final String msg = "ERROR: updating entry, HTTP code: " + code;
|
||||
LOGGER.debug(msg, e);
|
||||
LOG.debug(msg, e);
|
||||
throw new ProponoException(msg, e);
|
||||
} finally {
|
||||
method.releaseConnection();
|
||||
|
@ -221,14 +222,14 @@ public class ClientEntry extends Entry {
|
|||
|
||||
} catch (final Exception e) {
|
||||
final String msg = "ERROR: saving entry, HTTP code: " + code;
|
||||
LOGGER.debug(msg, e);
|
||||
LOG.debug(msg, e);
|
||||
throw new ProponoException(msg, e);
|
||||
} finally {
|
||||
method.releaseConnection();
|
||||
}
|
||||
final Header locationHeader = method.getResponseHeader("Location");
|
||||
if (locationHeader == null) {
|
||||
LOGGER.warn("WARNING added entry, but no location header returned");
|
||||
LOG.warn("WARNING added entry, but no location header returned");
|
||||
} else if (getEditURI() == null) {
|
||||
final List<Link> links = getOtherLinks();
|
||||
final Link link = new Link();
|
||||
|
|
|
@ -33,11 +33,11 @@ import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
|
|||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.PutMethod;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.rometools.propono.utils.ProponoException;
|
||||
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;
|
||||
|
@ -53,7 +53,8 @@ import com.sun.syndication.io.impl.Atom10Parser;
|
|||
public class ClientMediaEntry extends ClientEntry {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log LOGGER = LogFactory.getLog(ClientMediaEntry.class);
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ClientMediaEntry.class);
|
||||
|
||||
private String slug = null;
|
||||
private byte[] bytes;
|
||||
|
@ -279,7 +280,7 @@ public class ClientMediaEntry extends ClientEntry {
|
|||
}
|
||||
final Header locationHeader = method.getResponseHeader("Location");
|
||||
if (locationHeader == null) {
|
||||
LOGGER.warn("WARNING added entry, but no location header returned");
|
||||
LOG.warn("WARNING added entry, but no location header returned");
|
||||
} else if (getEditURI() == null) {
|
||||
final List<Link> links = getOtherLinks();
|
||||
final Link link = new Link();
|
||||
|
|
|
@ -20,11 +20,11 @@ import java.util.List;
|
|||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.rometools.propono.utils.ProponoException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.sun.syndication.feed.atom.Entry;
|
||||
import com.sun.syndication.feed.atom.Feed;
|
||||
|
@ -36,7 +36,8 @@ import com.sun.syndication.io.WireFeedInput;
|
|||
*/
|
||||
public class EntryIterator implements Iterator<ClientEntry> {
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(EntryIterator.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(EntryIterator.class);
|
||||
|
||||
private final ClientCollection collection;
|
||||
|
||||
private Iterator<Entry> members = null;
|
||||
|
@ -60,7 +61,7 @@ public class EntryIterator implements Iterator<ClientEntry> {
|
|||
try {
|
||||
getNextEntries();
|
||||
} catch (final Exception ignored) {
|
||||
LOGGER.error("ERROR getting next entries", ignored);
|
||||
LOG.error("An error occured while getting next entries", ignored);
|
||||
}
|
||||
}
|
||||
return members.hasNext();
|
||||
|
|
|
@ -18,24 +18,25 @@ package org.rometools.propono.atom.server;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Defines a factory that enables the {@link com.sun.syndication.propono.atom.server.AtomServlet} to obtain an
|
||||
* {@link com.sun.syndication.propono.atom.server.AtomHandler} that handles an Atom request.
|
||||
* Defines a factory that enables the {@link com.sun.syndication.propono.atom.server.AtomServlet} to
|
||||
* obtain an {@link com.sun.syndication.propono.atom.server.AtomHandler} that handles an Atom
|
||||
* request.
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
*/
|
||||
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 a <code>AtomHandlerFactory</code>. This static method creates a new factory instance. This method uses the following ordered
|
||||
* lookup procedure to determine the <code>AtomHandlerFactory</code> implementation class to load:
|
||||
* Obtain a new instance of a <code>AtomHandlerFactory</code>. This static method creates a new
|
||||
* factory instance. This method uses the following ordered lookup procedure to determine the
|
||||
* <code>AtomHandlerFactory</code> implementation class to load:
|
||||
* <ul>
|
||||
* <li>
|
||||
* Use the <code>com.sun.syndication.propono.atom.server.AtomHandlerFactory</code> system property.</li>
|
||||
* Use the <code>com.sun.syndication.propono.atom.server.AtomHandlerFactory</code> system
|
||||
* property.</li>
|
||||
* <li>
|
||||
* Use the properties file "/propono.properties" in the classpath. This configuration file is in standard <code>java.util.Properties</code> format and
|
||||
* contains the fully qualified name of the implementation class with the key being the system property defined above.
|
||||
* Use the properties file "/propono.properties" in the classpath. This configuration file is in
|
||||
* standard <code>java.util.Properties</code> 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.</li>
|
||||
* 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.</li>
|
||||
* <li>
|
||||
* If not available, to determine the classname. The Services API will look for a classname in the file:
|
||||
* <code>META-INF/services/com.sun.syndication.AtomHandlerFactory</code> in jars available to the runtime.</li>
|
||||
* If not available, to determine the classname. The Services API will look for a classname in
|
||||
* the file: <code>META-INF/services/com.sun.syndication.AtomHandlerFactory</code> in jars
|
||||
* available to the runtime.</li>
|
||||
* <li>
|
||||
* Platform default <code>AtomHandlerFactory</code> instance.</li>
|
||||
* </ul>
|
||||
*
|
||||
* Once an application has obtained a reference to a <code>AtomHandlerFactory</code> it can use the factory to configure and obtain parser instances.
|
||||
* Once an application has obtained a reference to a <code>AtomHandlerFactory</code> it can use
|
||||
* the factory to configure and obtain parser instances.
|
||||
*
|
||||
* @return New instance of a <code>AtomHandlerFactory</code>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<com.sun.syndication.feed.atom.Category> romeCats = new ArrayList<com.sun.syndication.feed.atom.Category>();
|
||||
for (final Iterator<Category> iter = categories.iterator(); iter.hasNext();) {
|
||||
final BlogEntry.Category cat = iter.next();
|
||||
for (final Category cat : categories) {
|
||||
final com.sun.syndication.feed.atom.Category romeCategory = new com.sun.syndication.feed.atom.Category();
|
||||
romeCategory.setTerm(cat.getId());
|
||||
romeCategory.setScheme(cat.getUrl());
|
||||
|
|
|
@ -17,19 +17,20 @@ package org.rometools.propono.blogclient.atomprotocol;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.rometools.propono.atom.client.ClientEntry;
|
||||
import org.rometools.propono.atom.client.ClientMediaEntry;
|
||||
import org.rometools.propono.blogclient.BlogClientException;
|
||||
import org.rometools.propono.blogclient.BlogEntry;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Atom protocol implementation of BlogClient entry iterator.
|
||||
*/
|
||||
public class AtomEntryIterator implements Iterator<BlogEntry> {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AtomEntryIterator.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AtomEntryIterator.class);
|
||||
|
||||
private Iterator<ClientEntry> iterator = null;
|
||||
private AtomCollection collection = null;
|
||||
|
||||
|
@ -63,7 +64,7 @@ public class AtomEntryIterator implements Iterator<BlogEntry> {
|
|||
return new AtomEntry(collection, entry);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
logger.error("ERROR fetching entry", e);
|
||||
LOG.error("An error occured while fetching entry", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ import junit.framework.Test;
|
|||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Ignore;
|
||||
import org.rometools.propono.atom.common.Categories;
|
||||
import org.rometools.propono.atom.common.Collection;
|
||||
import org.rometools.propono.utils.ProponoException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.sun.syndication.feed.atom.Category;
|
||||
import com.sun.syndication.feed.atom.Content;
|
||||
|
@ -39,7 +39,7 @@ import com.sun.syndication.feed.atom.Content;
|
|||
@Ignore
|
||||
public class AtomClientTest extends TestCase {
|
||||
|
||||
private static Log log = LogFactory.getFactory().getInstance(AtomClientTest.class);
|
||||
private static Logger log = LoggerFactory.getLogger(AtomClientTest.class);
|
||||
|
||||
private static ClientAtomService service = null;
|
||||
|
||||
|
|
|
@ -23,12 +23,7 @@ import static junit.framework.TestCase.assertTrue;
|
|||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -47,6 +42,8 @@ import org.rometools.propono.atom.common.Categories;
|
|||
import org.rometools.propono.atom.common.Collection;
|
||||
import org.rometools.propono.atom.common.Workspace;
|
||||
import org.rometools.propono.utils.ProponoException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.sun.syndication.feed.atom.Category;
|
||||
import com.sun.syndication.feed.atom.Content;
|
||||
|
@ -57,7 +54,7 @@ import com.sun.syndication.feed.atom.Content;
|
|||
*/
|
||||
public class AtomClientServerTest {
|
||||
|
||||
private static final Log log = LogFactory.getFactory().getInstance(AtomClientServerTest.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AtomClientServerTest.class);
|
||||
|
||||
private HttpServer server = null;
|
||||
public static final int TESTPORT = 8283;
|
||||
|
@ -85,14 +82,10 @@ public class AtomClientServerTest {
|
|||
|
||||
@Before
|
||||
public void setUpClass() throws Exception {
|
||||
log.info("---------------------------------------------");
|
||||
log.info("Starting Jetty");
|
||||
log.info("---------------------------------------------");
|
||||
|
||||
final ConsoleHandler handler = new ConsoleHandler();
|
||||
final Logger logger = Logger.getLogger("org.rometools.propono");
|
||||
logger.setLevel(Level.FINEST);
|
||||
logger.addHandler(handler);
|
||||
LOG.info("---------------------------------------------");
|
||||
LOG.info("Starting Jetty");
|
||||
LOG.info("---------------------------------------------");
|
||||
|
||||
setupServer();
|
||||
final HttpContext context = createContext();
|
||||
|
@ -107,7 +100,7 @@ public class AtomClientServerTest {
|
|||
@After
|
||||
public void tearDownClass() throws Exception {
|
||||
if (server != null) {
|
||||
log.info("Stoping Jetty");
|
||||
LOG.info("Stoping Jetty");
|
||||
server.stop();
|
||||
server.destroy();
|
||||
server = null;
|
||||
|
@ -151,11 +144,11 @@ public class AtomClientServerTest {
|
|||
for (final Workspace workspace : service.getWorkspaces()) {
|
||||
final ClientWorkspace space = (ClientWorkspace) workspace;
|
||||
assertNotNull(space.getTitle());
|
||||
log.debug("Workspace: " + space.getTitle());
|
||||
LOG.debug("Workspace: {}", space.getTitle());
|
||||
for (final Object element : space.getCollections()) {
|
||||
final ClientCollection col = (ClientCollection) element;
|
||||
log.debug(" Collection: " + col.getTitle() + " Accepts: " + col.getAccepts());
|
||||
log.debug(" href: " + col.getHrefResolved());
|
||||
LOG.debug(" Collection: {} Accepts: {}", col.getTitle(), col.getAccepts());
|
||||
LOG.debug(" href: {}", col.getHrefResolved());
|
||||
assertNotNull(col.getTitle());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ import junit.framework.TestSuite;
|
|||
import org.junit.Ignore;
|
||||
import org.rometools.propono.blogclient.Blog.Collection;
|
||||
import org.rometools.propono.utils.Utilities;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.sun.syndication.io.impl.Atom10Parser;
|
||||
|
||||
|
@ -35,6 +37,8 @@ import com.sun.syndication.io.impl.Atom10Parser;
|
|||
@Ignore
|
||||
public class SimpleBlogClientTest extends TestCase {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SimpleBlogClientTest.class);
|
||||
|
||||
private final String metaweblogEndpoint = "http://localhost:8080/roller/roller-services/xmlrpc";
|
||||
// private String atomEndpoint = "http://localhost:8080/roller/roller-services/app";
|
||||
private final String atomEndpoint = "http://localhost:8080/sample-atomserver/app";
|
||||
|
@ -68,7 +72,7 @@ public class SimpleBlogClientTest extends TestCase {
|
|||
|
||||
int blogCount = 0;
|
||||
for (final Blog blog : conn.getBlogs()) {
|
||||
System.out.println(blog.getName());
|
||||
LOG.debug(blog.getName());
|
||||
blogCount++;
|
||||
}
|
||||
assertTrue(blogCount > 0);
|
||||
|
|
13
src/test/resources/logback-test.xml
Normal file
13
src/test/resources/logback-test.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="warn">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
Loading…
Reference in a new issue