mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 21:13:19 +00:00
fix typos and comments
This commit is contained in:
@@ -58,23 +58,23 @@ public class BitstreamResource extends Resource
|
|||||||
private static Logger log = Logger.getLogger(BitstreamResource.class);
|
private static Logger log = Logger.getLogger(BitstreamResource.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return bitstream properties without file data. It can throws
|
* Return bitstream properties without file data. It can throw
|
||||||
* WebApplicationException with three response codes. Response code
|
* WebApplicationException with three response codes. Response code
|
||||||
* NOT_FOUND(404) or UNAUTHORIZED(401) or INTERNAL_SERVER_ERROR(500). Bad
|
* NOT_FOUND(404) or UNAUTHORIZED(401) or INTERNAL_SERVER_ERROR(500). Bad
|
||||||
* request is when id of bitstream does not exist. UNAUTHORIZED is if logged
|
* request is when the bitstream id does not exist. UNAUTHORIZED if the user
|
||||||
* user into DSpace context have not permission to access bitstream. Server
|
* logged into the DSpace context does not have the permission to access the
|
||||||
* error when something went wrong.
|
* bitstream. Server error when something went wrong.
|
||||||
*
|
*
|
||||||
* @param bitstreamId
|
* @param bitstreamId
|
||||||
* Id of bitstream in DSpace.
|
* Id of bitstream in DSpace.
|
||||||
* @param expand
|
* @param expand
|
||||||
* This string defined, which additional options will be added
|
* This string defines which additional optional fields will be added
|
||||||
* into bitstream. Single options are separated by commas without
|
* to bitstream response. Individual options are separated by commas without
|
||||||
* space. Options are: "all", "parent".
|
* spaces. The options are: "all", "parent".
|
||||||
* @param headers
|
* @param headers
|
||||||
* If you want to access to item under logged user into context.
|
* If you want to access the item as the user logged into the context.
|
||||||
* In headers must be set header "rest-dspace-token" with passed
|
* The header "rest-dspace-token" with the token passed
|
||||||
* token from login method.
|
* from the login method must be set.
|
||||||
* @return If user is allowed to read bitstream, it returns instance of
|
* @return If user is allowed to read bitstream, it returns instance of
|
||||||
* bitstream. Otherwise, it throws WebApplicationException with
|
* bitstream. Otherwise, it throws WebApplicationException with
|
||||||
* response code UNAUTHORIZED.
|
* response code UNAUTHORIZED.
|
||||||
@@ -128,15 +128,15 @@ public class BitstreamResource extends Resource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all bitstream resource policies from all bundles, in which
|
* Return all bitstream resource policies from all bundles, in which
|
||||||
* bitstream is.
|
* the bitstream is present.
|
||||||
*
|
*
|
||||||
* @param bitstreamId
|
* @param bitstreamId
|
||||||
* Id of bitstream in DSpace.
|
* Id of bitstream in DSpace.
|
||||||
* @param headers
|
* @param headers
|
||||||
* If you want to access to item under logged user into context.
|
* If you want to access the item as the user logged into the context.
|
||||||
* In headers must be set header "rest-dspace-token" with passed
|
* The header "rest-dspace-token" with the token passed
|
||||||
* token from login method.
|
* from the login method must be set.
|
||||||
* @return It returns array of ResourcePolicy.
|
* @return Returns an array of ResourcePolicy objects.
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/{bitstream_id}/policy")
|
@Path("/{bitstream_id}/policy")
|
||||||
@@ -166,7 +166,7 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.complete();
|
context.complete();
|
||||||
log.trace("Policies for bitsream(id=" + bitstreamId + ") was successfully read.");
|
log.trace("Policies for bitstream(id=" + bitstreamId + ") was successfully read.");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@@ -193,18 +193,18 @@ public class BitstreamResource extends Resource
|
|||||||
* bitstreams from database.
|
* bitstreams from database.
|
||||||
*
|
*
|
||||||
* @param limit
|
* @param limit
|
||||||
* How much bitstreams in list will be. Default value is 100.
|
* How many bitstreams will be in the list. Default value is 100.
|
||||||
* @param offset
|
* @param offset
|
||||||
* On which index will list starts. Default values is 0.
|
* On which offset (item) the list starts. Default value is 0.
|
||||||
* @param headers
|
* @param headers
|
||||||
* If you want to access to item under logged user into context.
|
* If you want to access the item as the user logged into the context.
|
||||||
* In headers must be set header "rest-dspace-token" with passed
|
* The header "rest-dspace-token" with the token passed
|
||||||
* token from login method.
|
* from the login method must be set.
|
||||||
* @return It returns array of bistreams. In array are not bitstreams on
|
* @return Returns an array of bistreams. Array doesn't contain bitstreams for
|
||||||
* which user has not permission to read.
|
* which the user doesn't have read permission.
|
||||||
* @throws WebApplicationException
|
* @throws WebApplicationException
|
||||||
* It is thrown when was problem with database reading or with
|
* Thrown in case of a problem with reading the database or with
|
||||||
* creating context.
|
* creating a context.
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@@ -231,7 +231,7 @@ public class BitstreamResource extends Resource
|
|||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO If bitsream doesnt not exist it throw exception.
|
// TODO If bitstream doesn't exist, throws exception.
|
||||||
for (int i = offset; (i < (offset + limit)) && (i < dspaceBitstreams.length); i++)
|
for (int i = offset; (i < (offset + limit)) && (i < dspaceBitstreams.length); i++)
|
||||||
{
|
{
|
||||||
if (AuthorizeManager.authorizeActionBoolean(context, dspaceBitstreams[i], org.dspace.core.Constants.READ))
|
if (AuthorizeManager.authorizeActionBoolean(context, dspaceBitstreams[i], org.dspace.core.Constants.READ))
|
||||||
@@ -252,11 +252,11 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
processException("Something get wrong while reading bitstreams from database!. Message: " + e, context);
|
processException("Something went wrong while reading bitstreams from database!. Message: " + e, context);
|
||||||
}
|
}
|
||||||
catch (ContextException e)
|
catch (ContextException e)
|
||||||
{
|
{
|
||||||
processException("Something get wrong while reading bitstreams, ContextException. Message: " + e.getMessage(),
|
processException("Something went wrong while reading bitstreams, ContextException. Message: " + e.getMessage(),
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -268,26 +268,25 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read bitstream data. It can throw WebApplicationException with code
|
* Read bitstream data. May throw WebApplicationException with the
|
||||||
* INTERNAL_SERVER_ERROR(500). Caused by three exceptions: IOException if
|
* INTERNAL_SERVER_ERROR(500) code. Caused by three exceptions: IOException if
|
||||||
* there was problem with reading bitstream file. SQLException if there was
|
* there was a problem with reading bitstream file. SQLException if there was
|
||||||
* problem while reading from database. And AuthorizeException if there was
|
* a problem while reading from database. And AuthorizeException if there was
|
||||||
* problem with authorization of user logged to DSpace context.
|
* a problem with authorization of user logged to DSpace context.
|
||||||
*
|
*
|
||||||
* @param bitstreamId
|
* @param bitstreamId
|
||||||
* Id of bitstream, of which will be read data.
|
* Id of the bitstream, whose data will be read.
|
||||||
* @param headers
|
* @param headers
|
||||||
* If you want to access to item under logged user into context.
|
* If you want to access the item as the user logged into the context.
|
||||||
* In headers must be set header "rest-dspace-token" with passed
|
* The header "rest-dspace-token" with the token passed
|
||||||
* token from login method.
|
* from the login method must be set.
|
||||||
* @return Returns response with data with content type of file. It can
|
* @return Returns response with data with file content type. It can
|
||||||
* return response code NOT_FOUND(404) if there was bad id of
|
* return the NOT_FOUND(404) response code in case of wrong bitstream
|
||||||
* bitstream. Or response code UNAUTHORIZED(401) if user is not
|
* id. Or response code UNAUTHORIZED(401) if user is not
|
||||||
* allowed to read bitstream.
|
* allowed to read bitstream.
|
||||||
* @throws WebApplicationException
|
* @throws WebApplicationException
|
||||||
* It is throw in this cases: When was problem with reading file
|
* Thrown if there was a problem: reading the file data; or reading
|
||||||
* data. Or was problem with database reading. Or was problem
|
* the database; or creating the context; or with authorization.
|
||||||
* with creating context. Or problem with authorization.
|
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/{bitstream_id}/retrieve")
|
@Path("/{bitstream_id}/retrieve")
|
||||||
@@ -322,7 +321,7 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
processException("Something get wrong while reading bitsream(id=" + bitstreamId + ") from database! Message: " + e,
|
processException("Something went wrong while reading bitstream(id=" + bitstreamId + ") from database! Message: " + e,
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
catch (AuthorizeException e)
|
catch (AuthorizeException e)
|
||||||
@@ -345,18 +344,18 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add bitstream policy to all bundles in which bitstream is.
|
* Add bitstream policy to all bundles containing the bitstream.
|
||||||
*
|
*
|
||||||
* @param bitstreamId
|
* @param bitstreamId
|
||||||
* Id of bitstream in DSpace.
|
* Id of bitstream in DSpace.
|
||||||
* @param policy
|
* @param policy
|
||||||
* Policy which will be added. But this atributes does not be
|
* Policy to be added. The following attributes are not
|
||||||
* applied: epersonId,
|
* applied: epersonId,
|
||||||
* @param headers
|
* @param headers
|
||||||
* If you want to access to item under logged user into context.
|
* If you want to access the item as the user logged into the context.
|
||||||
* In headers must be set header "rest-dspace-token" with passed
|
* The header "rest-dspace-token" with the token passed
|
||||||
* token from login method.
|
* from the login method must be set.
|
||||||
* @return Returns ok, if was all ok. Otherwise status code 500.
|
* @return Returns ok, if all was ok. Otherwise status code 500.
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/{bitstream_id}/policy")
|
@Path("/{bitstream_id}/policy")
|
||||||
@@ -398,7 +397,7 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.complete();
|
context.complete();
|
||||||
log.trace("Policy for bitsream(id=" + bitstreamId + ") was successfully added.");
|
log.trace("Policy for bitstream(id=" + bitstreamId + ") was successfully added.");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@@ -424,26 +423,26 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update bitstream metadata. It replace everything on targeted bitstream.
|
* Update bitstream metadata. Replaces everything on targeted bitstream.
|
||||||
* It can throws WebApplicationException caused by two exceptions:
|
* May throw WebApplicationException caused by two exceptions:
|
||||||
* SQLException, if there was problem with database. AuthorizeException if
|
* SQLException, if there was a problem with the database. AuthorizeException if
|
||||||
* there was problem with authorization to edit bitstream metadata.
|
* there was a problem with the authorization to edit bitstream metadata.
|
||||||
*
|
*
|
||||||
* @param bitstreamId
|
* @param bitstreamId
|
||||||
* Id of bistream, wich will be updated.
|
* Id of bistream to be updated.
|
||||||
* @param bitstream
|
* @param bitstream
|
||||||
* Bitstream with will be placed. It muset have filled user
|
* Bitstream with will be placed. It must have filled user
|
||||||
* creditials.
|
* credentials.
|
||||||
* @param headers
|
* @param headers
|
||||||
* If you want to access to item under logged user into context.
|
* If you want to access the item as the user logged into the context.
|
||||||
* In headers must be set header "rest-dspace-token" with passed
|
* The header "rest-dspace-token" with the token passed
|
||||||
* token from login method.
|
* from the login method must be set.
|
||||||
* @return Return response codes: OK(200), NOT_FOUND(404) if bitstream does
|
* @return Return response codes: OK(200), NOT_FOUND(404) if bitstream does
|
||||||
* not exist and UNAUTHORIZED(401) if user is not allowed to write
|
* not exist and UNAUTHORIZED(401) if user is not allowed to write
|
||||||
* to bitstream.
|
* to bitstream.
|
||||||
* @throws WebApplicationException
|
* @throws WebApplicationException
|
||||||
* It can be thrown by: Error in reading from database. Or
|
* Thrown when: Error reading from database; or error
|
||||||
* creating context or with authorization to bitstream.
|
* creating context; or error regarding bitstream authorization.
|
||||||
*/
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{bitstream_id}")
|
@Path("/{bitstream_id}")
|
||||||
@@ -554,27 +553,27 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update bitstream data. It change bitstream data by editing database rows.
|
* Update bitstream data. Changes bitstream data by editing database rows.
|
||||||
* It can throw WebApplicationException caused by: SQLException if there was
|
* May throw WebApplicationException caused by: SQLException if there was
|
||||||
* problem with database editing or reading, IOException if there was
|
* a problem editing or reading the database, IOException if there was
|
||||||
* problem with reading from inputstream, Exception if there was another
|
* a problem with reading from InputStream, Exception if there was another
|
||||||
* problem.
|
* problem.
|
||||||
*
|
*
|
||||||
* @param bitstreamId
|
* @param bitstreamId
|
||||||
* Id of bistream, which will be updated.
|
* Id of bistream to be updated.
|
||||||
* @param is
|
* @param is
|
||||||
* Inputstream filled with new data.
|
* InputStream filled with new data.
|
||||||
* @param headers
|
* @param headers
|
||||||
* If you want to access to item under logged user into context.
|
* If you want to access the item as the user logged into the context.
|
||||||
* In headers must be set header "rest-dspace-token" with passed
|
* The header "rest-dspace-token" with the token passed
|
||||||
* token from login method.
|
* from the login method must be set.
|
||||||
* @return Return response if bitstream was updated. Response codes:
|
* @return Return response if bitstream was updated. Response codes:
|
||||||
* OK(200), NOT_FOUND(404) if id of bitstream was bad. And
|
* OK(200), NOT_FOUND(404) if id of bitstream was bad. And
|
||||||
* UNAUTHORIZED(401) if user is not allowed to update bitstream.
|
* UNAUTHORIZED(401) if user is not allowed to update bitstream.
|
||||||
* @throws WebApplicationException
|
* @throws WebApplicationException
|
||||||
* This exception can be thrown in this cases: Problem with
|
* This exception can be thrown in this cases: Problem with
|
||||||
* reading or writing to database. Or problem with reading from
|
* reading or writing to database. Or problem with reading from
|
||||||
* inputstream.
|
* InputStream.
|
||||||
*/
|
*/
|
||||||
// TODO Change to better logic, without editing database.
|
// TODO Change to better logic, without editing database.
|
||||||
@PUT
|
@PUT
|
||||||
@@ -641,24 +640,24 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete bitstream from all bundles in dspace. It can throw
|
* Delete bitstream from all bundles in DSpace. May throw
|
||||||
* WebApplicationException, which can be caused by three exceptions.
|
* WebApplicationException, which can be caused by three exceptions.
|
||||||
* SQLException if there was problem with reading from database or removing
|
* SQLException if there was a problem reading from database or removing
|
||||||
* from database. AuthorizeException, if user has not permission to delete
|
* from database. AuthorizeException, if user doesn't have permission to delete
|
||||||
* bitstream or file. IOException, if there was problem with file deleting.
|
* the bitstream or file. IOException, if there was a problem deleting the file.
|
||||||
*
|
*
|
||||||
* @param bitstreamId
|
* @param bitstreamId
|
||||||
* Id of bitsream, which will be deleted.
|
* Id of bitstream to be deleted.
|
||||||
* @param headers
|
* @param headers
|
||||||
* If you want to access to item under logged user into context.
|
* If you want to access the item as the user logged into the context.
|
||||||
* In headers must be set header "rest-dspace-token" with passed
|
* The header "rest-dspace-token" with the token passed
|
||||||
* token from login method.
|
* from the login method must be set.
|
||||||
* @return Return response codes: OK(200), NOT_FOUND(404) if bitstream of
|
* @return Return response codes: OK(200), NOT_FOUND(404) if bitstream of
|
||||||
* that id does not exist and UNAUTHORIZED(401) if user is not
|
* that id does not exist and UNAUTHORIZED(401) if user is not
|
||||||
* allowed to delete bitstream.
|
* allowed to delete bitstream.
|
||||||
* @throws WebApplicationException
|
* @throws WebApplicationException
|
||||||
* It can be throw when was problem with reading or editting
|
* Can be thron if there was a problem reading or editting
|
||||||
* database. Or problem with file deleting. Or problem with
|
* the database. Or problem deleting the file. Or problem with
|
||||||
* authorization to bitstream and bundles. Or problem with
|
* authorization to bitstream and bundles. Or problem with
|
||||||
* creating context.
|
* creating context.
|
||||||
*/
|
*/
|
||||||
@@ -719,13 +718,13 @@ public class BitstreamResource extends Resource
|
|||||||
* Delete policy.
|
* Delete policy.
|
||||||
*
|
*
|
||||||
* @param bitstreamId
|
* @param bitstreamId
|
||||||
* Id of bitstream in dspace, which policy will be deleted.
|
* Id of the DSpace bitstream whose policy will be deleted.
|
||||||
* @param policyId
|
* @param policyId
|
||||||
* Id of policy which will be deleted.
|
* Id of the policy to delete.
|
||||||
* @param headers
|
* @param headers
|
||||||
* If you want to access to item under logged user into context.
|
* If you want to access the item as the user logged into the context.
|
||||||
* In headers must be set header "rest-dspace-token" with passed
|
* The header "rest-dspace-token" with the token passed
|
||||||
* token from login method.
|
* from the login method must be set.
|
||||||
* @return It returns Ok, if was all ok. Otherwise status code 500.
|
* @return It returns Ok, if was all ok. Otherwise status code 500.
|
||||||
*/
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@@ -762,7 +761,7 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.complete();
|
context.complete();
|
||||||
log.trace("Policy for bitsream(id=" + bitstreamId + ") was successfully added.");
|
log.trace("Policy for bitstream(id=" + bitstreamId + ") was successfully added.");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@@ -789,7 +788,7 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return type of file in MIME, by file extension.
|
* Return the MIME type of the file, by file extension.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* Name of file.
|
* Name of file.
|
||||||
@@ -801,9 +800,9 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find bitstream from DSpace database. It is encapsulation of method
|
* Find bitstream from DSpace database. This encapsulatets the
|
||||||
* org.dspace.content.Bitstream.find with checking if item exist and if user
|
* org.dspace.content.Bitstream.find method with a check whether the item exists and
|
||||||
* logged into context has permission to do passed action.
|
* whether the user logged into the context has permission to preform the requested action.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* Context of actual logged user.
|
* Context of actual logged user.
|
||||||
@@ -811,7 +810,7 @@ public class BitstreamResource extends Resource
|
|||||||
* Id of bitstream in DSpace.
|
* Id of bitstream in DSpace.
|
||||||
* @param action
|
* @param action
|
||||||
* Constant from org.dspace.core.Constants.
|
* Constant from org.dspace.core.Constants.
|
||||||
* @return It returns DSpace bitstream.
|
* @return Returns DSpace bitstream.
|
||||||
* @throws WebApplicationException
|
* @throws WebApplicationException
|
||||||
* Is thrown when item with passed id is not exists and if user
|
* Is thrown when item with passed id is not exists and if user
|
||||||
* has no permission to do passed action.
|
* has no permission to do passed action.
|
||||||
@@ -835,12 +834,12 @@ public class BitstreamResource extends Resource
|
|||||||
context.abort();
|
context.abort();
|
||||||
if (context.getCurrentUser() != null)
|
if (context.getCurrentUser() != null)
|
||||||
{
|
{
|
||||||
log.error("User(" + context.getCurrentUser().getEmail() + ") has not permission to "
|
log.error("User(" + context.getCurrentUser().getEmail() + ") doesn't have the permission to "
|
||||||
+ getActionString(action) + " bitstream!");
|
+ getActionString(action) + " bitstream!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.error("User(anonymous) has not permission to " + getActionString(action) + " bitsteam!");
|
log.error("User(anonymous) doesn't have the permission to " + getActionString(action) + " bitsteam!");
|
||||||
}
|
}
|
||||||
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
@@ -848,7 +847,7 @@ public class BitstreamResource extends Resource
|
|||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
processException("Something get wrong while finding bitstream. SQLException, Message:" + e, context);
|
processException("Something went wrong while finding bitstream. SQLException, Message:" + e, context);
|
||||||
}
|
}
|
||||||
return bitstream;
|
return bitstream;
|
||||||
}
|
}
|
||||||
|
@@ -431,7 +431,7 @@ public class ItemsResource extends Resource
|
|||||||
* ContextException. When was problem with creating context of
|
* ContextException. When was problem with creating context of
|
||||||
* DSpace.
|
* DSpace.
|
||||||
*/
|
*/
|
||||||
// TODO Add option to add bitsream by URI.(for very big files)
|
// TODO Add option to add bitstream by URI.(for very big files)
|
||||||
@POST
|
@POST
|
||||||
@Path("/{item_id}/bitstreams")
|
@Path("/{item_id}/bitstreams")
|
||||||
public Bitstream addItemBitstream(@PathParam("item_id") Integer itemId, InputStream inputStream,
|
public Bitstream addItemBitstream(@PathParam("item_id") Integer itemId, InputStream inputStream,
|
||||||
|
@@ -26,9 +26,10 @@ import org.dspace.usage.UsageEvent;
|
|||||||
import org.dspace.utils.DSpace;
|
import org.dspace.utils.DSpace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Superclass of all resource class in REST api. It has methods for creating
|
* Superclass of all resource classes in REST API. It has methods for creating
|
||||||
* context, write statistics, process exception, splitting key of metadata,
|
* context, write statistics, processsing exceptions, splitting a key of
|
||||||
* string representation of action and method for getting user from header.
|
* metadata, string representation of action and method for getting the logged
|
||||||
|
* in user from the token in request header.
|
||||||
*
|
*
|
||||||
* @author Rostislav Novak (Computing and Information Centre, CTU in Prague)
|
* @author Rostislav Novak (Computing and Information Centre, CTU in Prague)
|
||||||
*
|
*
|
||||||
@@ -46,21 +47,21 @@ public class Resource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create context to work with DSpace database. It can create context
|
* Create context to work with DSpace database. It can create context
|
||||||
* without logged user (parameter user is null) or with. It can throws
|
* with or without a logged in user (parameter user is null). Throws
|
||||||
* WebApplicationException caused by: SQLException, if there was problem
|
* WebApplicationException caused by: SQLException if there was a problem
|
||||||
* with reading from database. AuthorizeException, if there was problem with
|
* with reading from database. Throws AuthorizeException if there was
|
||||||
* authorization to read form database. And Exception, if there was some
|
* a problem with authorization to read from the database. Throws Exception
|
||||||
* problem with creating context.
|
* if there was a problem creating context.
|
||||||
*
|
*
|
||||||
* @param person
|
* @param person
|
||||||
* User which will be logged in context.
|
* User which will be logged in context.
|
||||||
* @return New created context with logged user if user was not null.
|
* @return Newly created context with the logged in user unless the specified user was null.
|
||||||
* Otherwise, without logged user.
|
* If user is null, create the context without a logged in user.
|
||||||
* @throws ContextException
|
* @throws ContextException
|
||||||
* Throw if was problem to create context. It can be caused by
|
* Thrown in case of a problem creating context. Can be caused by
|
||||||
* SQLException, error in creating context or find user to log
|
* SQLException error in creating context or finding the user to
|
||||||
* in. Or can be caused by AuthorizeException if was problem to
|
* log in. Can be caused by AuthorizeException if there was a
|
||||||
* authorize to find user.
|
* problem authorizing the found user.
|
||||||
*/
|
*/
|
||||||
protected static org.dspace.core.Context createContext(EPerson person) throws ContextException
|
protected static org.dspace.core.Context createContext(EPerson person) throws ContextException
|
||||||
{
|
{
|
||||||
@@ -90,11 +91,11 @@ public class Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It write statistic about using REST api.
|
* Records a statistics event about an object used via REST API.
|
||||||
* @param dspaceObject
|
* @param dspaceObject
|
||||||
* Object of DSpace which is performed.
|
* DSpace object on which a request was performed.
|
||||||
* @param action
|
* @param action
|
||||||
* What action is performed with object.
|
* Action that was performed.
|
||||||
* @param user_ip
|
* @param user_ip
|
||||||
* @param user_agent
|
* @param user_agent
|
||||||
* @param xforwarderfor
|
* @param xforwarderfor
|
||||||
|
@@ -58,68 +58,68 @@ public class RestIndex {
|
|||||||
"Server path: " + servletContext.getContextPath() +
|
"Server path: " + servletContext.getContextPath() +
|
||||||
"<h2>Index</h2>" +
|
"<h2>Index</h2>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li>GET / - It returns this page.</li>" +
|
"<li>GET / - Return this page.</li>" +
|
||||||
"<li>GET /test - Return string \"REST api is running\". It is method for testing.</li>" +
|
"<li>GET /test - Return the string \"REST api is running\" for testing purposes.</li>" +
|
||||||
"<li>POST /login - Method for login into DSpace RESTful api. You must post User class. Example: {\"email\":\"test@dspace\",\"password\":\"pass\"}. It returns token under which will must sending requests. In header \"rest-dspace-token\"</li>" +
|
"<li>POST /login - Method for logging into the DSpace RESTful API. You must post User class. Example: {\"email\":\"test@dspace\",\"password\":\"pass\"}. Returns a token which must be included in future requests in the \"rest-dspace-token\" header.</li>" +
|
||||||
"<li>POST /logout - Method for logout from DSpace RESTful api. You must post request with header \"rest-dspace-token\" token</li>" +
|
"<li>POST /logout - Method for logging out of the DSpace RESTful API. The request must include the \"rest-dspace-token\" token</li> header." +
|
||||||
"</ul>" +
|
"</ul>" +
|
||||||
"<h2>Communities</h2>" +
|
"<h2>Communities</h2>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li>GET /communities - Returns array of all communities in DSpace.</li>" +
|
"<li>GET /communities - Return an array of all communities in DSpace.</li>" +
|
||||||
"<li>GET /communities/top-communities - Returns array of all top communities in DSpace.</li>" +
|
"<li>GET /communities/top-communities - Returns an array of all top-leve communities in DSpace.</li>" +
|
||||||
"<li>GET /communities/{communityId} - Returns community.</li>" +
|
"<li>GET /communities/{communityId} - Returns a community with the specified ID.</li>" +
|
||||||
"<li>GET /communities/{communityId}/collections - Returns array of collections of community.</li>" +
|
"<li>GET /communities/{communityId}/collections - Returns an array of collections of the specified community.</li>" +
|
||||||
"<li>GET /communities/{communityId}/communities - Returns array of subcommunities of community.</li>" +
|
"<li>GET /communities/{communityId}/communities - Returns an array of subcommunities of the specified community.</li>" +
|
||||||
"<li>POST /communities - Create new community at top level. You must post community.</li>" +
|
"<li>POST /communities - Create a new top-level community. You must post a community.</li>" +
|
||||||
"<li>POST /communities/{communityId}/collections - Create new collections in community. You must post collection.</li>" +
|
"<li>POST /communities/{communityId}/collections - Create a new collection in the specified community. You must post a collection.</li>" +
|
||||||
"<li>POST /communities/{communityId}/communities - Create new subcommunity in community. You must post community.</li>" +
|
"<li>POST /communities/{communityId}/communities - Create a new subcommunity in the specified community. You must post a community.</li>" +
|
||||||
"<li>PUT /communities/{communityId} - Update community.</li>" +
|
"<li>PUT /communities/{communityId} - Update the specified community.</li>" +
|
||||||
"<li>DELETE /communities/{communityId} - Delete community.</li>" +
|
"<li>DELETE /communities/{communityId} - Delete the specified community.</li>" +
|
||||||
"<li>DELETE /communities/{communityId}/collections/{collectionId} - Delete collection in community.</li>" +
|
"<li>DELETE /communities/{communityId}/collections/{collectionId} - Delete the specified collection in the specified community.</li>" +
|
||||||
"<li>DELETE /communities/{communityId}/communities/{communityId2} - Delete subcommunity in community.</li>" +
|
"<li>DELETE /communities/{communityId}/communities/{communityId2} - Delete the specified subcommunity (communityId2) in the specified community (communityId).</li>" +
|
||||||
"</ul>" +
|
"</ul>" +
|
||||||
"<h2>Collections</h2>" +
|
"<h2>Collections</h2>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li>GET /collections - Return all collections of DSpace in array.</li>" +
|
"<li>GET /collections - Return all DSpace collections in array.</li>" +
|
||||||
"<li>GET /collections/{collectionId} - Return collection with id.</li>" +
|
"<li>GET /collections/{collectionId} - Return a collection with the specified ID.</li>" +
|
||||||
"<li>GET /collections/{collectionId}/items - Return all items of collection.</li>" +
|
"<li>GET /collections/{collectionId}/items - Return all items of the specified collection.</li>" +
|
||||||
"<li>POST /collections/{collectionId}/items - Create posted item in collection.</li>" +
|
"<li>POST /collections/{collectionId}/items - Create an item in the specified collection. You must post an item.</li>" +
|
||||||
"<li>POST /collections/find-collection - Find collection by passed name.</li>" +
|
"<li>POST /collections/find-collection - Find a collection by name.</li>" +
|
||||||
"<li>PUT /collections/{collectionId} </li> - Update collection. You muset post collection." +
|
"<li>PUT /collections/{collectionId} </li> - Update the specified collection. You must post a collection." +
|
||||||
"<li>DELETE /collections/{collectionId} - Delete collection from DSpace.</li>" +
|
"<li>DELETE /collections/{collectionId} - Delete the specified collection from DSpace.</li>" +
|
||||||
"<li>DELETE /collections/{collectionId}/items/{itemId} - Delete item in collection. </li>" +
|
"<li>DELETE /collections/{collectionId}/items/{itemId} - Delete the specified item (itemId) in the specified collection (collectionId). </li>" +
|
||||||
"</ul>" +
|
"</ul>" +
|
||||||
"<h2>Items</h2>" +
|
"<h2>Items</h2>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li>GET /items - Return list of items.</li>" +
|
"<li>GET /items - Return a list of items.</li>" +
|
||||||
"<li>GET /items/{item id} - Return item.</li>" +
|
"<li>GET /items/{item id} - Return the specified item.</li>" +
|
||||||
"<li>GET /items/{item id}/metadata - Return item metadata.</li>" +
|
"<li>GET /items/{item id}/metadata - Return metadata of the specified item.</li>" +
|
||||||
"<li>GET /items/{item id}/bitstreams - Return item bitstreams.</li>" +
|
"<li>GET /items/{item id}/bitstreams - Return bitstreams of the specified item.</li>" +
|
||||||
"<li>POST /items/find-by-metadata-field - Find items by metadata entry.</li>" +
|
"<li>POST /items/find-by-metadata-field - Find items by the specified metadata value.</li>" +
|
||||||
"<li>POST /items/{item id}/metadata - Add metadata to item.</li>" +
|
"<li>POST /items/{item id}/metadata - Add metadata to the specified item.</li>" +
|
||||||
"<li>POST /items/{item id}/bitstreams - Add bitstream to item.</li>" +
|
"<li>POST /items/{item id}/bitstreams - Add a bitstream to the specified item.</li>" +
|
||||||
"<li>PUT /items/{item id}/metadata - Update metadata in item.</li>" +
|
"<li>PUT /items/{item id}/metadata - Update metadata in the specified item.</li>" +
|
||||||
"<li>DELETE /items/{item id} - Delete item.</li>" +
|
"<li>DELETE /items/{item id} - Delete the specified item.</li>" +
|
||||||
"<li>DELETE /items/{item id}/metadata - Clear item metadata.</li>" +
|
"<li>DELETE /items/{item id}/metadata - Clear metadata of the specified item.</li>" +
|
||||||
"<li>DELETE /items/{item id}/bitstreams/{bitstream id} - Delete item bitstream.</li>" +
|
"<li>DELETE /items/{item id}/bitstreams/{bitstream id} - Delete the specified bitstream of the specified item.</li>" +
|
||||||
"</ul>" +
|
"</ul>" +
|
||||||
"<h2>Bitstreams</h2>" +
|
"<h2>Bitstreams</h2>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li>GET /bitstreams - Return all bitstreams in DSpace.</li>" +
|
"<li>GET /bitstreams - Return all bitstreams in DSpace.</li>" +
|
||||||
"<li>GET /bitstreams/{bitstream id} - Return bitstream.</li>" +
|
"<li>GET /bitstreams/{bitstream id} - Return the specified bitstream.</li>" +
|
||||||
"<li>GET /bitstreams/{bitstream id}/policy - Return bitstream policies.</li>" +
|
"<li>GET /bitstreams/{bitstream id}/policy - Return policies of the specified bitstream.</li>" +
|
||||||
"<li>POST /bitstreams/{bitstream id}/retrieve - Return data of bitstream.</li>" +
|
"<li>GET /bitstreams/{bitstream id}/retrieve - Return the contents of the specified bitstream.</li>" +
|
||||||
"<li>POST /bitstreams/{bitstream id}/policy - Add policy to item.</li>" +
|
"<li>POST /bitstreams/{bitstream id}/policy - Add a policy to the specified bitstream.</li>" +
|
||||||
"<li>PUT /bitstreams/{bitstream id}/data - Update data of bitstream.</li>" +
|
"<li>PUT /bitstreams/{bitstream id}/data - Update the contents of the specified bitstream.</li>" +
|
||||||
"<li>PUT /bitstreams/{bitstream id} - Update metadata of bitstream.</li>" +
|
"<li>PUT /bitstreams/{bitstream id} - Update metadata of the specified bitstream.</li>" +
|
||||||
"<li>DELETE /bitstreams/{bitstream id} - Delete bitstream from DSpace.</li>" +
|
"<li>DELETE /bitstreams/{bitstream id} - Delete the specified bitstream from DSpace.</li>" +
|
||||||
"<li>DELETE /bitstreams/{bitstream id}/policy/{policy_id} - Delete bitstream policy.</li>" +
|
"<li>DELETE /bitstreams/{bitstream id}/policy/{policy_id} - Delete the specified bitstream policy.</li>" +
|
||||||
"</ul>" +
|
"</ul>" +
|
||||||
"</body></html> ";
|
"</body></html> ";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method for only test if rest api is running.
|
* Method only for testing whether the REST API is running.
|
||||||
*
|
*
|
||||||
* @return String "REST api is running."
|
* @return String "REST api is running."
|
||||||
*/
|
*/
|
||||||
@@ -131,11 +131,11 @@ public class RestIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method for login user into REST api.
|
* Method to login a user into REST API.
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* User which will be logged into REST api.
|
* User which will be logged in to REST API.
|
||||||
* @return Returns response code OK with token. Otherwise returns response
|
* @return Returns response code OK and a token. Otherwise returns response
|
||||||
* code FORBIDDEN(403).
|
* code FORBIDDEN(403).
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@@ -155,14 +155,14 @@ public class RestIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method for logout from DSpace REST api. It removes token and user from
|
* Method to logout a user from DSpace REST API. Removes the token and user from
|
||||||
* TokenHolder.
|
* TokenHolder.
|
||||||
*
|
*
|
||||||
* @param headers
|
* @param headers
|
||||||
* Request header which contains header with key
|
* Request header which contains the header named
|
||||||
* "rest-dspace-token" and value of token.
|
* "rest-dspace-token" containing the token as value.
|
||||||
* @return Return response OK, otherwise BAD_REQUEST, if was problem with
|
* @return Return response OK, otherwise BAD_REQUEST, if there was a problem with
|
||||||
* logout or token is incorrect.
|
* logout or the token is incorrect.
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/logout")
|
@Path("/logout")
|
||||||
@@ -191,10 +191,12 @@ public class RestIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ? status: OK
|
* Method to check current status of the service and logged in user.
|
||||||
* authenticated: TRUE | FALSE
|
*
|
||||||
* epersonEMAIL: user@dspace.org
|
* okay: true | false
|
||||||
* epersonNAME: Joe User
|
* authenticated: true | false
|
||||||
|
* epersonEMAIL: user@example.com
|
||||||
|
* epersonNAME: John Doe
|
||||||
* @param headers
|
* @param headers
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@@ -164,7 +164,7 @@
|
|||||||
<xsl:call-template name="standardAttributes">
|
<xsl:call-template name="standardAttributes">
|
||||||
<xsl:with-param name="class">ds-table</xsl:with-param>
|
<xsl:with-param name="class">ds-table</xsl:with-param>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<!-- rows and cols atributes are not allowed in strict
|
<!-- rows and cols attributes are not allowed in strict
|
||||||
<xsl:attribute name="rows"><xsl:value-of select="@rows"/></xsl:attribute>
|
<xsl:attribute name="rows"><xsl:value-of select="@rows"/></xsl:attribute>
|
||||||
<xsl:attribute name="cols"><xsl:value-of select="@cols"/></xsl:attribute>
|
<xsl:attribute name="cols"><xsl:value-of select="@cols"/></xsl:attribute>
|
||||||
|
|
||||||
|
@@ -891,7 +891,7 @@
|
|||||||
<xsl:call-template name="standardAttributes">
|
<xsl:call-template name="standardAttributes">
|
||||||
<xsl:with-param name="class">ds-table</xsl:with-param>
|
<xsl:with-param name="class">ds-table</xsl:with-param>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<!-- rows and cols atributes are not allowed in strict
|
<!-- rows and cols attributes are not allowed in strict
|
||||||
<xsl:attribute name="rows"><xsl:value-of select="@rows"/></xsl:attribute>
|
<xsl:attribute name="rows"><xsl:value-of select="@rows"/></xsl:attribute>
|
||||||
<xsl:attribute name="cols"><xsl:value-of select="@cols"/></xsl:attribute>
|
<xsl:attribute name="cols"><xsl:value-of select="@cols"/></xsl:attribute>
|
||||||
|
|
||||||
|
@@ -244,11 +244,11 @@ log.dir = ${dspace.dir}/log
|
|||||||
identifier.doi.user = username
|
identifier.doi.user = username
|
||||||
identifier.doi.password = password
|
identifier.doi.password = password
|
||||||
# DOI prefix used to mint DOIs. All DOIs minted by DSpace will use this prefix.
|
# DOI prefix used to mint DOIs. All DOIs minted by DSpace will use this prefix.
|
||||||
# The Prefix will be assinged by the registration agency.
|
# The Prefix will be assigned by the registration agency.
|
||||||
identifier.doi.prefix = 10.5072
|
identifier.doi.prefix = 10.5072
|
||||||
# If you want to, you can further separate your namespace. Should all the suffix
|
# If you want to, you can further separate your namespace. Should all the
|
||||||
# of all DOIs minted by DSpace start with a special string to separate it from
|
# suffixes of all DOIs minted by DSpace start with a special string to separate
|
||||||
# other services also minting DOIs under your prefix?
|
# it from other services also minting DOIs under your prefix?
|
||||||
identifier.doi.namespaceseparator = dspace/
|
identifier.doi.namespaceseparator = dspace/
|
||||||
|
|
||||||
##### Plugin management #####
|
##### Plugin management #####
|
||||||
|
Reference in New Issue
Block a user