org.silverpeas.attachment.web
Class SimpleDocumentResource

java.lang.Object
  extended by com.silverpeas.web.RESTWebService
      extended by org.silverpeas.attachment.web.AbstractSimpleDocumentResource
          extended by org.silverpeas.attachment.web.SimpleDocumentResource

@Service
@RequestScoped
@Authorized
public class SimpleDocumentResource
extends AbstractSimpleDocumentResource


Nested Class Summary
 
Nested classes/interfaces inherited from class com.silverpeas.web.RESTWebService
RESTWebService.WebProcess<RETURN_VALUE>, RESTWebService.WebTreatment<RETURN_VALUE>
 
Field Summary
 
Fields inherited from class com.silverpeas.web.RESTWebService
RESPONSE_HEADER_ARRAYSIZE, REST_WEB_SERVICES_URI_BASE
 
Constructor Summary
SimpleDocumentResource()
           
 
Method Summary
 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[] getDocumentTanslations()
          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 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 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(UserPriviledgeValidation validation)
          Validates the authorization of the user to request this web service.
 
Methods inherited from class org.silverpeas.attachment.web.AbstractSimpleDocumentResource
checkUploadedFile, getBundleLocation, getComponentId, performRuntimeException
 
Methods inherited from class com.silverpeas.web.RESTWebService
getBundle, getGreaterUserRole, getHttpRequest, getHttpServletRequest, getHttpServletResponse, getOrganisationController, getUriInfo, getUserDetail, getUserPreferences, getUserRoles, process, validateUserAuthentication
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDocumentResource

public SimpleDocumentResource()
Method Detail

getSimpleDocumentId

public String getSimpleDocumentId()

getDocument

public SimpleDocumentEntity getDocument(String lang)
Returns the specified document in the specified lang.

Parameters:
lang - the wanted language.
Returns:
the specified document in the specified lang.

deleteDocument

public void deleteDocument()
Deletes the the specified document.


deleteContent

public void deleteContent(String lang)
Deletes the the specified document.

Parameters:
lang - the lang of the content to be deleted.

updateDocument

public javax.ws.rs.core.Response updateDocument(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

getDocumentTanslations

public SimpleDocumentEntity[] getDocumentTanslations()
Returns all the existing translation of a SimpleDocument.

Returns:
all the existing translation of a SimpleDocument.

validateUserAuthorization

public void validateUserAuthorization(UserPriviledgeValidation validation)
                               throws javax.ws.rs.WebApplicationException
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 valdiated. Otherwise, the annotation Authorized can be also used instead at class level for both authentication and authorization.

Overrides:
validateUserAuthorization in class RESTWebService
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:
UserPriviledgeValidation

getFileContent

public javax.ws.rs.core.Response getFileContent(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

public String lock(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

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

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

public String unlockDocument(boolean force,
                             boolean webdav,
                             boolean privateVersion,
                             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

public String switchDocumentVersionState(String comment,
                                         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

public String switchDownloadAllowedForReaders(boolean allowed)
Forbid or allow the download of the document for readers.

Returns:
JSON download state for readers. allowedDownloadForReaders = true or false.


Copyright © 2016 Silverpeas. All Rights Reserved.