Class SimpleDocumentResource
- java.lang.Object
-
- org.silverpeas.core.web.rs.RESTWebService
-
- org.silverpeas.core.webapi.attachment.AbstractSimpleDocumentResource
-
- org.silverpeas.core.webapi.attachment.SimpleDocumentResource
-
- All Implemented Interfaces:
ProtectedWebResource
,WebAuthenticationValidation
,WebAuthorizationValidation
,SilverpeasWebResource
@WebService @Path("documents/{componentId}/document/{id}") @Authorized public class SimpleDocumentResource extends AbstractSimpleDocumentResource
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.silverpeas.core.web.rs.RESTWebService
RESTWebService.WebProcess<R>, RESTWebService.WebTreatment<R>
-
-
Field Summary
-
Fields inherited from class org.silverpeas.core.web.rs.RESTWebService
RESPONSE_HEADER_ARRAYSIZE
-
Fields inherited from interface org.silverpeas.core.web.SilverpeasWebResource
BASE_PATH
-
-
Constructor Summary
Constructors Constructor Description SimpleDocumentResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteContent(String lang)
Deletes the the specified document.void
deleteDocument()
Deletes the the specified document.SimpleDocumentEntity
getDocument(String lang)
Returns the specified document in the specified lang.SimpleDocumentEntity[]
getDocumentTranslations()
Returns all the existing translation of a SimpleDocument.javax.ws.rs.core.Response
getFileContent(String language)
Returns the content of the specified document in the specified language.String
getSimpleDocumentId()
String
lock(String language)
Locks the specified document for exclusive edition.String
moveSimpleDocumentDown()
Moves the specified document down in the list.String
moveSimpleDocumentUp()
Moves the specified document up in the list.String
switchDisplayAsContentEnabled(boolean enabled)
Enable or not the display as content of an attachment.String
switchDocumentVersionState(String comment, String version)
Changes the document version state.String
switchDownloadAllowedForReaders(boolean allowed)
Forbid or allow the download of the document for readers.String
switchEditSimultaneouslyEnabled(boolean enabled)
Enable or not the simultaneous edition of an attachment.String
unlockDocument(boolean force, boolean webdav, boolean privateVersion, String comment)
Unlocks the specified document for exclusive edition.javax.ws.rs.core.Response
updateDocument(String filename)
Updates the document identified by the requested URI.protected SimpleDocumentEntity
updateSimpleDocument(SimpleDocumentUploadData uploadData, String filename)
void
validateUserAuthorization(UserPrivilegeValidation validation)
Validates the authorization of the user to request this web service.-
Methods inherited from class org.silverpeas.core.webapi.attachment.AbstractSimpleDocumentResource
checkUploadedFile, getBundleLocation, getComponentId, getResourceBasePath, performRuntimeException
-
Methods inherited from class org.silverpeas.core.web.rs.RESTWebService
createWebResourceUri, fromPage, getBundle, getHighestUserRole, getHttpRequest, getHttpServletRequest, getHttpServletResponse, getOrganisationController, getSilverpeasContext, getUri, getUser, getUserPreferences, getUserRoles, identifiedBy, identifiedBy, initContext, initWebResourceUri, isUserDefined, process
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.web.rs.WebAuthenticationValidation
validateUserAuthentication
-
-
-
-
Method Detail
-
getSimpleDocumentId
public String getSimpleDocumentId()
-
getDocument
@GET @Path("{lang}") @Produces("application/json") public SimpleDocumentEntity getDocument(@PathParam("lang") String lang)
Returns the specified document in the specified lang.- Parameters:
lang
- the wanted language.- Returns:
- the specified document in the specified lang.
-
deleteDocument
@DELETE @Produces("application/json") public void deleteDocument()
Deletes the the specified document.
-
deleteContent
@DELETE @Path("content/{lang}") @Produces("application/json") public void deleteContent(@PathParam("lang") String lang)
Deletes the the specified document.- Parameters:
lang
- the lang of the content to be deleted.
-
updateDocument
@POST @Path("{filename}") @Consumes("multipart/form-data") public javax.ws.rs.core.Response updateDocument(@PathParam("filename") String filename) throws IOException
Updates the document identified by the requested URI.A
SimpleDocumentUploadData
is extracted from request parameters.- Returns:
- an HTTP response embodied an entity in a format expected by the client (that is
identified by the
xRequestedWith
parameter). - Throws:
IOException
- if an error occurs while updating the document.
-
updateSimpleDocument
protected SimpleDocumentEntity updateSimpleDocument(SimpleDocumentUploadData uploadData, String filename) throws IOException
- Throws:
IOException
-
getDocumentTranslations
@GET @Path("translations") @Produces("application/json") public SimpleDocumentEntity[] getDocumentTranslations()
Returns all the existing translation of a SimpleDocument.- Returns:
- all the existing translation of a SimpleDocument.
-
validateUserAuthorization
public void validateUserAuthorization(UserPrivilegeValidation validation)
Validates the authorization of the user to request this web service. For doing, the user must have the rights to access the component instance that manages this web resource. The validation is actually delegated to the validation service by passing it the required information.This method should be invoked for web service requiring an authorized access. For doing, the authentication of the user must be first validated. Otherwise, the annotation Authorized can be also used instead at class level for both authentication and authorization.
- Parameters:
validation
- the validation instance to use.- Throws:
javax.ws.rs.WebApplicationException
- if the rights of the user are not enough to access this web resource.- See Also:
UserPrivilegeValidator
-
getFileContent
@GET @Path("content/{lang}") @Produces("application/octet-stream") public javax.ws.rs.core.Response getFileContent(@PathParam("lang") String language)
Returns the content of the specified document in the specified language.- Parameters:
language
- the language of the document's content to get.- Returns:
- the content of the specified document in the specified language.
-
lock
@PUT @Path("lock/{lang}") @Produces("application/json") public String lock(@PathParam("lang") String language)
Locks the specified document for exclusive edition.- Returns:
- JSON status to true if the document was locked successfully - JSON status to false otherwise..
-
moveSimpleDocumentUp
@PUT @Path("moveUp") @Produces("application/json") public String moveSimpleDocumentUp()
Moves the specified document up in the list.- Returns:
- JSON status to true if the document was locked successfully - JSON status to false otherwise..
-
moveSimpleDocumentDown
@PUT @Path("moveDown") @Produces("application/json") public String moveSimpleDocumentDown()
Moves the specified document down in the list.- Returns:
- JSON status to true if the document was locked successfully - JSON status to false otherwise..
-
unlockDocument
@POST @Path("unlock") @Produces("application/json") public String unlockDocument(@FormParam("force") boolean force, @FormParam("webdav") boolean webdav, @FormParam("private") boolean privateVersion, @FormParam("comment") String comment)
Unlocks the specified document for exclusive edition.- Parameters:
force
- if the unlocking has to be forced.webdav
- if the unlock is performed while a WebDAV access.privateVersion
- if the document is a private version.comment
- a comment about the unlock.- Returns:
- JSON status to true if the document was locked successfully - JSON status to false otherwise..
-
switchDocumentVersionState
@PUT @Path("switchState") @Produces("application/json") public String switchDocumentVersionState(@FormParam("switch-version-comment") String comment, @FormParam("switch-version") String version)
Changes the document version state.- Parameters:
comment
- comment about the version state switching.version
- the new version state.- Returns:
- JSON status to true if the document was locked successfully - JSON status to false otherwise..
-
switchDownloadAllowedForReaders
@POST @Path("switchDownloadAllowedForReaders") @Produces("application/json") public String switchDownloadAllowedForReaders(@FormParam("allowed") boolean allowed)
Forbid or allow the download of the document for readers.- Returns:
- JSON download state for readers. allowedDownloadForReaders = true or false.
-
switchDisplayAsContentEnabled
@POST @Path("switchDisplayAsContentEnabled") @Produces("application/json") public String switchDisplayAsContentEnabled(@FormParam("enabled") boolean enabled)
Enable or not the display as content of an attachment.- Returns:
- JSON display as content state. displayableAsContent = true or false.
-
switchEditSimultaneouslyEnabled
@POST @Path("switchEditSimultaneouslyEnabled") @Produces("application/json") public String switchEditSimultaneouslyEnabled(@FormParam("enabled") boolean enabled)
Enable or not the simultaneous edition of an attachment.- Returns:
- JSON simultaneous edition state. editableSimultaneously = true or false.
-
-