[DS-2763] Clean up some other artifacts while I'm at it

This commit is contained in:
Mark H. Wood
2015-11-18 14:55:08 -05:00
parent ac181bb31d
commit 5033b69c5c
7 changed files with 81 additions and 56 deletions

View File

@@ -50,17 +50,17 @@ public class UsageEvent extends Event {
*/
private static final long serialVersionUID = 1L;
private transient HttpServletRequest request;
private HttpServletRequest request;
private transient String ip;
private String ip;
private transient String userAgent;
private String userAgent;
private transient String xforwardedfor;
private String xforwardedfor;
private transient Context context;
private Context context;
private transient DSpaceObject object;
private DSpaceObject object;
private Action action;

View File

@@ -35,7 +35,7 @@ public class DataProviderServlet extends HttpServlet {
private static final Logger log = Logger.getLogger(DataProviderServlet.class);
protected HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
protected final transient HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
/**
* Processes requests for both HTTP

View File

@@ -32,7 +32,7 @@ public class LocalURIRedirectionServlet extends HttpServlet
private final static Logger log = Logger.getLogger(LocalURIRedirectionServlet.class);
protected HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
protected final transient HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
/**
* Processes requests for both HTTP
@@ -114,6 +114,7 @@ public class LocalURIRedirectionServlet extends HttpServlet
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
@@ -128,6 +129,7 @@ public class LocalURIRedirectionServlet extends HttpServlet
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
@@ -138,6 +140,7 @@ public class LocalURIRedirectionServlet extends HttpServlet
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Ensures that URIs used in RDF can be dereferenced.";
}

View File

@@ -28,9 +28,16 @@ import org.purl.sword.base.SWORDException;
*/
public class AtomDocumentServlet extends DepositServlet {
public AtomDocumentServlet()
throws ServletException
{
super();
}
/**
* Process the get request.
*/
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
try {

View File

@@ -47,7 +47,7 @@ import org.purl.sword.base.SWORDErrorException;
public class DepositServlet extends HttpServlet {
/** Sword repository */
protected SWORDServer myRepository;
protected final transient SWORDServer myRepository;
/** Authentication type */
private String authN;
@@ -59,29 +59,27 @@ public class DepositServlet extends HttpServlet {
private String tempDirectory;
/** Counter */
private static AtomicInteger counter = new AtomicInteger(0);
private static final AtomicInteger counter = new AtomicInteger(0);
/** Logger */
private static Logger log = Logger.getLogger(DepositServlet.class);
private static final Logger log = Logger.getLogger(DepositServlet.class);
/**
* Initialise the servlet
*
* @throws ServletException
*/
public void init() throws ServletException {
public DepositServlet()
throws ServletException
{
// Instantiate the correct SWORD Server class
String className = getServletContext().getInitParameter("sword-server-class");
if (className == null) {
log.fatal("Unable to read value of 'sword-server-class' from Servlet context");
} else {
throw new ServletException("Unable to read value of 'sword-server-class' from Servlet context");
}
try {
myRepository = (SWORDServer) Class.forName(className)
.newInstance();
log.info("Using " + className + " as the SWORDServer");
} catch (Exception e) {
log
.fatal("Unable to instantiate class from 'sword-server-class': "
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
log.fatal("Unable to instantiate class from 'sword-server-class': "
+ className);
throw new ServletException(
"Unable to instantiate class from 'sword-server-class': "
@@ -89,6 +87,13 @@ public class DepositServlet extends HttpServlet {
}
}
/**
* Initialise the servlet
*
* @throws ServletException
*/
@Override
public void init() throws ServletException {
authN = getServletContext().getInitParameter("authentication-method");
if ((authN == null) || (authN.equals(""))) {
authN = "None";
@@ -145,6 +150,7 @@ public class DepositServlet extends HttpServlet {
/**
* Process the Get request. This will return an unimplemented response.
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Send a '501 Not Implemented'
response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
@@ -153,6 +159,7 @@ public class DepositServlet extends HttpServlet {
/**
* Process a post request.
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Create the Deposit request
Deposit d = new Deposit();
@@ -235,7 +242,7 @@ public class DepositServlet extends HttpServlet {
d.setFile(file);
// Set the X-On-Behalf-Of header
String onBehalfOf = request.getHeader(HttpHeaders.X_ON_BEHALF_OF.toString());
String onBehalfOf = request.getHeader(HttpHeaders.X_ON_BEHALF_OF);
if ((onBehalfOf != null) && (onBehalfOf.equals("reject"))) {
// user name is "reject", so throw a not know error to allow the client to be tested
throw new SWORDErrorException(ErrorCodes.TARGET_OWNER_UKNOWN,"unknown user \"reject\"");
@@ -299,13 +306,13 @@ public class DepositServlet extends HttpServlet {
DepositResponse dr = myRepository.doDeposit(d);
// Echo back the user agent
if (request.getHeader(HttpHeaders.USER_AGENT.toString()) != null) {
dr.getEntry().setUserAgent(request.getHeader(HttpHeaders.USER_AGENT.toString()));
if (request.getHeader(HttpHeaders.USER_AGENT) != null) {
dr.getEntry().setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
}
// Echo back the packaging format
if (request.getHeader(HttpHeaders.X_PACKAGING.toString()) != null) {
dr.getEntry().setPackaging(request.getHeader(HttpHeaders.X_PACKAGING.toString()));
if (request.getHeader(HttpHeaders.X_PACKAGING) != null) {
dr.getEntry().setPackaging(request.getHeader(HttpHeaders.X_PACKAGING));
}
// Print out the Deposit Response
@@ -380,8 +387,8 @@ public class DepositServlet extends HttpServlet {
Summary sum = new Summary();
sum.setContent(summary);
sed.setSummary(sum);
if (request.getHeader(HttpHeaders.USER_AGENT.toString()) != null) {
sed.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT.toString()));
if (request.getHeader(HttpHeaders.USER_AGENT) != null) {
sed.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
}
response.setStatus(status);
response.setContentType("application/atom+xml; charset=UTF-8");

View File

@@ -33,7 +33,7 @@ import org.purl.sword.base.ServiceDocumentRequest;
public class ServiceDocumentServlet extends HttpServlet {
/** The repository */
private SWORDServer myRepository;
private final transient SWORDServer myRepository;
/** Authentication type. */
private String authN;
@@ -42,24 +42,22 @@ public class ServiceDocumentServlet extends HttpServlet {
private int maxUploadSize;
/** Logger */
private static Logger log = Logger.getLogger(ServiceDocumentServlet.class);
private static final Logger log = Logger.getLogger(ServiceDocumentServlet.class);
/**
* Initialise the servlet.
*
* @throws ServletException
*/
public void init() throws ServletException {
public ServiceDocumentServlet()
throws ServletException
{
// Instantiate the correct SWORD Server class
String className = getServletContext().getInitParameter("sword-server-class");
if (className == null) {
log.fatal("Unable to read value of 'sword-server-class' from Servlet context");
throw new ServletException("Unable to read value of 'sword-server-class' from Servlet context");
} else {
try {
myRepository = (SWORDServer) Class.forName(className)
.newInstance();
log.info("Using " + className + " as the SWORDServer");
} catch (Exception e) {
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
log.fatal("Unable to instantiate class from 'server-class': "
+ className);
throw new ServletException(
@@ -67,6 +65,15 @@ public class ServiceDocumentServlet extends HttpServlet {
+ className, e);
}
}
}
/**
* Initialise the servlet.
*
* @throws ServletException
*/
@Override
public void init() throws ServletException {
// Set the authentication method
authN = getServletContext().getInitParameter("authentication-method");
@@ -95,6 +102,7 @@ public class ServiceDocumentServlet extends HttpServlet {
/**
* Process the get request.
*/
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// Create the ServiceDocumentRequest
@@ -116,8 +124,7 @@ public class ServiceDocumentServlet extends HttpServlet {
}
// Set the x-on-behalf-of header
sdr.setOnBehalfOf(request.getHeader(HttpHeaders.X_ON_BEHALF_OF
.toString()));
sdr.setOnBehalfOf(request.getHeader(HttpHeaders.X_ON_BEHALF_OF));
// Set the IP address
sdr.setIPAddress(request.getRemoteAddr());
@@ -156,6 +163,7 @@ public class ServiceDocumentServlet extends HttpServlet {
/**
* Process the post request. This will return an unimplemented response.
*/
@Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// Send a '501 Not Implemented'

View File

@@ -54,7 +54,7 @@ public class DSpaceValidity implements SourceValidity
/** Simple flag to note if the object has been completed. */
protected boolean completed = false;
/** A hash of the validityKey taken after completetion */
/** A hash of the validityKey taken after completion */
protected long hash;
/** The time when the validity is no longer assumed to be valid */
@@ -64,9 +64,9 @@ public class DSpaceValidity implements SourceValidity
protected long assumedValidityDelay = 0;
protected CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
protected CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
protected ItemService itemService = ContentServiceFactory.getInstance().getItemService();
transient protected CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
transient protected CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
transient protected ItemService itemService = ContentServiceFactory.getInstance().getItemService();
/**