mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
[DS-2763] Clean up some other artifacts while I'm at it
This commit is contained in:
@@ -50,20 +50,20 @@ public class UsageEvent extends Event {
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
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;
|
private Action action;
|
||||||
|
|
||||||
private static String checkParams(Action action, HttpServletRequest request, Context context, DSpaceObject object)
|
private static String checkParams(Action action, HttpServletRequest request, Context context, DSpaceObject object)
|
||||||
{
|
{
|
||||||
StringBuilder eventName = new StringBuilder();
|
StringBuilder eventName = new StringBuilder();
|
||||||
|
@@ -35,8 +35,8 @@ public class DataProviderServlet extends HttpServlet {
|
|||||||
|
|
||||||
private static final Logger log = Logger.getLogger(DataProviderServlet.class);
|
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
|
* Processes requests for both HTTP
|
||||||
* <code>GET</code> and
|
* <code>GET</code> and
|
||||||
|
@@ -32,8 +32,8 @@ public class LocalURIRedirectionServlet extends HttpServlet
|
|||||||
|
|
||||||
private final static Logger log = Logger.getLogger(LocalURIRedirectionServlet.class);
|
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
|
* Processes requests for both HTTP
|
||||||
* <code>GET</code> and
|
* <code>GET</code> and
|
||||||
@@ -114,6 +114,7 @@ public class LocalURIRedirectionServlet extends HttpServlet
|
|||||||
* @throws ServletException if a servlet-specific error occurs
|
* @throws ServletException if a servlet-specific error occurs
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
processRequest(request, response);
|
processRequest(request, response);
|
||||||
@@ -128,6 +129,7 @@ public class LocalURIRedirectionServlet extends HttpServlet
|
|||||||
* @throws ServletException if a servlet-specific error occurs
|
* @throws ServletException if a servlet-specific error occurs
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
processRequest(request, response);
|
processRequest(request, response);
|
||||||
@@ -138,6 +140,7 @@ public class LocalURIRedirectionServlet extends HttpServlet
|
|||||||
*
|
*
|
||||||
* @return a String containing servlet description
|
* @return a String containing servlet description
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getServletInfo() {
|
public String getServletInfo() {
|
||||||
return "Ensures that URIs used in RDF can be dereferenced.";
|
return "Ensures that URIs used in RDF can be dereferenced.";
|
||||||
}
|
}
|
||||||
|
@@ -28,9 +28,16 @@ import org.purl.sword.base.SWORDException;
|
|||||||
*/
|
*/
|
||||||
public class AtomDocumentServlet extends DepositServlet {
|
public class AtomDocumentServlet extends DepositServlet {
|
||||||
|
|
||||||
/**
|
public AtomDocumentServlet()
|
||||||
|
throws ServletException
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Process the get request.
|
* Process the get request.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doGet(HttpServletRequest request,
|
protected void doGet(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws ServletException, IOException {
|
HttpServletResponse response) throws ServletException, IOException {
|
||||||
try {
|
try {
|
||||||
|
@@ -47,7 +47,7 @@ import org.purl.sword.base.SWORDErrorException;
|
|||||||
public class DepositServlet extends HttpServlet {
|
public class DepositServlet extends HttpServlet {
|
||||||
|
|
||||||
/** Sword repository */
|
/** Sword repository */
|
||||||
protected SWORDServer myRepository;
|
protected final transient SWORDServer myRepository;
|
||||||
|
|
||||||
/** Authentication type */
|
/** Authentication type */
|
||||||
private String authN;
|
private String authN;
|
||||||
@@ -59,36 +59,41 @@ public class DepositServlet extends HttpServlet {
|
|||||||
private String tempDirectory;
|
private String tempDirectory;
|
||||||
|
|
||||||
/** Counter */
|
/** Counter */
|
||||||
private static AtomicInteger counter = new AtomicInteger(0);
|
private static final AtomicInteger counter = new AtomicInteger(0);
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static Logger log = Logger.getLogger(DepositServlet.class);
|
private static final Logger log = Logger.getLogger(DepositServlet.class);
|
||||||
|
|
||||||
/**
|
public DepositServlet()
|
||||||
* Initialise the servlet
|
throws ServletException
|
||||||
*
|
{
|
||||||
* @throws ServletException
|
|
||||||
*/
|
|
||||||
public void init() throws ServletException {
|
|
||||||
// Instantiate the correct SWORD Server class
|
// Instantiate the correct SWORD Server class
|
||||||
String className = getServletContext().getInitParameter("sword-server-class");
|
String className = getServletContext().getInitParameter("sword-server-class");
|
||||||
if (className == null) {
|
if (className == null) {
|
||||||
log.fatal("Unable to read value of 'sword-server-class' from Servlet context");
|
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': "
|
|
||||||
+ className);
|
|
||||||
throw new ServletException(
|
|
||||||
"Unable to instantiate class from 'sword-server-class': "
|
|
||||||
+ className, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
myRepository = (SWORDServer) Class.forName(className)
|
||||||
|
.newInstance();
|
||||||
|
log.info("Using " + className + " as the SWORDServer");
|
||||||
|
} 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': "
|
||||||
|
+ className, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise the servlet
|
||||||
|
*
|
||||||
|
* @throws ServletException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() throws ServletException {
|
||||||
authN = getServletContext().getInitParameter("authentication-method");
|
authN = getServletContext().getInitParameter("authentication-method");
|
||||||
if ((authN == null) || (authN.equals(""))) {
|
if ((authN == null) || (authN.equals(""))) {
|
||||||
authN = "None";
|
authN = "None";
|
||||||
@@ -145,6 +150,7 @@ public class DepositServlet extends HttpServlet {
|
|||||||
/**
|
/**
|
||||||
* Process the Get request. This will return an unimplemented response.
|
* Process the Get request. This will return an unimplemented response.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
// Send a '501 Not Implemented'
|
// Send a '501 Not Implemented'
|
||||||
response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
|
response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
|
||||||
@@ -153,6 +159,7 @@ public class DepositServlet extends HttpServlet {
|
|||||||
/**
|
/**
|
||||||
* Process a post request.
|
* Process a post request.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
// Create the Deposit request
|
// Create the Deposit request
|
||||||
Deposit d = new Deposit();
|
Deposit d = new Deposit();
|
||||||
@@ -235,7 +242,7 @@ public class DepositServlet extends HttpServlet {
|
|||||||
d.setFile(file);
|
d.setFile(file);
|
||||||
|
|
||||||
// Set the X-On-Behalf-Of header
|
// 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"))) {
|
if ((onBehalfOf != null) && (onBehalfOf.equals("reject"))) {
|
||||||
// user name is "reject", so throw a not know error to allow the client to be tested
|
// 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\"");
|
throw new SWORDErrorException(ErrorCodes.TARGET_OWNER_UKNOWN,"unknown user \"reject\"");
|
||||||
@@ -299,13 +306,13 @@ public class DepositServlet extends HttpServlet {
|
|||||||
DepositResponse dr = myRepository.doDeposit(d);
|
DepositResponse dr = myRepository.doDeposit(d);
|
||||||
|
|
||||||
// Echo back the user agent
|
// Echo back the user agent
|
||||||
if (request.getHeader(HttpHeaders.USER_AGENT.toString()) != null) {
|
if (request.getHeader(HttpHeaders.USER_AGENT) != null) {
|
||||||
dr.getEntry().setUserAgent(request.getHeader(HttpHeaders.USER_AGENT.toString()));
|
dr.getEntry().setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Echo back the packaging format
|
// Echo back the packaging format
|
||||||
if (request.getHeader(HttpHeaders.X_PACKAGING.toString()) != null) {
|
if (request.getHeader(HttpHeaders.X_PACKAGING) != null) {
|
||||||
dr.getEntry().setPackaging(request.getHeader(HttpHeaders.X_PACKAGING.toString()));
|
dr.getEntry().setPackaging(request.getHeader(HttpHeaders.X_PACKAGING));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print out the Deposit Response
|
// Print out the Deposit Response
|
||||||
@@ -380,8 +387,8 @@ public class DepositServlet extends HttpServlet {
|
|||||||
Summary sum = new Summary();
|
Summary sum = new Summary();
|
||||||
sum.setContent(summary);
|
sum.setContent(summary);
|
||||||
sed.setSummary(sum);
|
sed.setSummary(sum);
|
||||||
if (request.getHeader(HttpHeaders.USER_AGENT.toString()) != null) {
|
if (request.getHeader(HttpHeaders.USER_AGENT) != null) {
|
||||||
sed.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT.toString()));
|
sed.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
|
||||||
}
|
}
|
||||||
response.setStatus(status);
|
response.setStatus(status);
|
||||||
response.setContentType("application/atom+xml; charset=UTF-8");
|
response.setContentType("application/atom+xml; charset=UTF-8");
|
||||||
|
@@ -33,7 +33,7 @@ import org.purl.sword.base.ServiceDocumentRequest;
|
|||||||
public class ServiceDocumentServlet extends HttpServlet {
|
public class ServiceDocumentServlet extends HttpServlet {
|
||||||
|
|
||||||
/** The repository */
|
/** The repository */
|
||||||
private SWORDServer myRepository;
|
private final transient SWORDServer myRepository;
|
||||||
|
|
||||||
/** Authentication type. */
|
/** Authentication type. */
|
||||||
private String authN;
|
private String authN;
|
||||||
@@ -42,24 +42,22 @@ public class ServiceDocumentServlet extends HttpServlet {
|
|||||||
private int maxUploadSize;
|
private int maxUploadSize;
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static Logger log = Logger.getLogger(ServiceDocumentServlet.class);
|
private static final Logger log = Logger.getLogger(ServiceDocumentServlet.class);
|
||||||
|
|
||||||
/**
|
public ServiceDocumentServlet()
|
||||||
* Initialise the servlet.
|
throws ServletException
|
||||||
*
|
{
|
||||||
* @throws ServletException
|
|
||||||
*/
|
|
||||||
public void init() throws ServletException {
|
|
||||||
// Instantiate the correct SWORD Server class
|
// Instantiate the correct SWORD Server class
|
||||||
String className = getServletContext().getInitParameter("sword-server-class");
|
String className = getServletContext().getInitParameter("sword-server-class");
|
||||||
if (className == null) {
|
if (className == null) {
|
||||||
log.fatal("Unable to read value of 'sword-server-class' from Servlet context");
|
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 {
|
} else {
|
||||||
try {
|
try {
|
||||||
myRepository = (SWORDServer) Class.forName(className)
|
myRepository = (SWORDServer) Class.forName(className)
|
||||||
.newInstance();
|
.newInstance();
|
||||||
log.info("Using " + className + " as the SWORDServer");
|
log.info("Using " + className + " as the SWORDServer");
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||||
log.fatal("Unable to instantiate class from 'server-class': "
|
log.fatal("Unable to instantiate class from 'server-class': "
|
||||||
+ className);
|
+ className);
|
||||||
throw new ServletException(
|
throw new ServletException(
|
||||||
@@ -67,6 +65,15 @@ public class ServiceDocumentServlet extends HttpServlet {
|
|||||||
+ className, e);
|
+ className, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise the servlet.
|
||||||
|
*
|
||||||
|
* @throws ServletException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() throws ServletException {
|
||||||
|
|
||||||
// Set the authentication method
|
// Set the authentication method
|
||||||
authN = getServletContext().getInitParameter("authentication-method");
|
authN = getServletContext().getInitParameter("authentication-method");
|
||||||
@@ -95,6 +102,7 @@ public class ServiceDocumentServlet extends HttpServlet {
|
|||||||
/**
|
/**
|
||||||
* Process the get request.
|
* Process the get request.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doGet(HttpServletRequest request,
|
protected void doGet(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws ServletException, IOException {
|
HttpServletResponse response) throws ServletException, IOException {
|
||||||
// Create the ServiceDocumentRequest
|
// Create the ServiceDocumentRequest
|
||||||
@@ -116,8 +124,7 @@ public class ServiceDocumentServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the x-on-behalf-of header
|
// Set the x-on-behalf-of header
|
||||||
sdr.setOnBehalfOf(request.getHeader(HttpHeaders.X_ON_BEHALF_OF
|
sdr.setOnBehalfOf(request.getHeader(HttpHeaders.X_ON_BEHALF_OF));
|
||||||
.toString()));
|
|
||||||
|
|
||||||
// Set the IP address
|
// Set the IP address
|
||||||
sdr.setIPAddress(request.getRemoteAddr());
|
sdr.setIPAddress(request.getRemoteAddr());
|
||||||
@@ -156,6 +163,7 @@ public class ServiceDocumentServlet extends HttpServlet {
|
|||||||
/**
|
/**
|
||||||
* Process the post request. This will return an unimplemented response.
|
* Process the post request. This will return an unimplemented response.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doPost(HttpServletRequest request,
|
protected void doPost(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws ServletException, IOException {
|
HttpServletResponse response) throws ServletException, IOException {
|
||||||
// Send a '501 Not Implemented'
|
// Send a '501 Not Implemented'
|
||||||
|
@@ -54,7 +54,7 @@ public class DSpaceValidity implements SourceValidity
|
|||||||
/** Simple flag to note if the object has been completed. */
|
/** Simple flag to note if the object has been completed. */
|
||||||
protected boolean completed = false;
|
protected boolean completed = false;
|
||||||
|
|
||||||
/** A hash of the validityKey taken after completetion */
|
/** A hash of the validityKey taken after completion */
|
||||||
protected long hash;
|
protected long hash;
|
||||||
|
|
||||||
/** The time when the validity is no longer assumed to be valid */
|
/** 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 long assumedValidityDelay = 0;
|
||||||
|
|
||||||
|
|
||||||
protected CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
transient protected CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||||
protected CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
transient protected CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
||||||
protected ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
transient protected ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user