Package org.nuxeo.wopi.jaxrs
Class FilesEndpoint
- java.lang.Object
-
- org.nuxeo.ecm.webengine.model.impl.AbstractResource<ResourceTypeImpl>
-
- org.nuxeo.ecm.webengine.model.impl.DefaultObject
-
- org.nuxeo.wopi.jaxrs.FilesEndpoint
-
public class FilesEndpoint extends DefaultObject
Implementation of the Files endpoint.See Files endpoint.
- Since:
- 10.3
-
-
Field Summary
Fields Modifier and Type Field Description protected StringbaseURLprotected Blobblobprotected DocumentModeldocprotected StringfileIdprotected javax.ws.rs.core.HttpHeadershttpHeadersprotected javax.servlet.http.HttpServletRequestrequestprotected javax.servlet.http.HttpServletResponseresponseprotected CoreSessionsessionprotected StringwopiBaseURLprotected Stringxpath
-
Constructor Summary
Constructors Constructor Description FilesEndpoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddBreadcrumbProperties(Map<String,Serializable> map)protected voidaddFileURLProperties(Map<String,Serializable> map)protected voidaddHostCapabilitiesProperties(Map<String,Serializable> map)protected voidaddRequiredProperties(Map<String,Serializable> map)protected voidaddUserMetadataProperties(Map<String,Serializable> map)protected voidaddUserPermissionsProperties(Map<String,Serializable> map)protected Map<String,Serializable>buildCheckFileInfoMap()protected javax.ws.rs.core.ResponsebuildConflictResponse(String operation, String lock)Builds a conflict response with the given WOPI lock as a header.protected javax.ws.rs.core.ResponsebuildItemVersionResponse(String operation, Blob blob)javax.ws.rs.core.ResponsecheckFileInfo()Implements the CheckFileInfo operation.protected voidcheckWritePropertiesPermission(String operation)protected BlobcreateBlobFromRequestBody(String filename, String mimeType)Creates a new blob from the request body, given afilenameand an optionalmimeType.protected DocumentModelcreateVersionFromRequestBody(String filename)ObjectdoPost(Operation operation)ObjectdoPostContents(Operation operation)protected StringgetCurrentLock(String operation)Returns the WOPI lock if not null and throws aConflictExceptionotherwise.protected StringgetDocumentURL(DocumentModel doc)protected StringgetEntityString(Object entity)ObjectgetFile(String maxExpectedSizeHeader)Implements the GetFile operation.protected StringgetHeader(String operation, String headerName)protected StringgetHeader(String operation, String headerName, boolean nullable)protected StringgetHeaderString(String... headers)protected StringgetItemVersion()protected ObjectgetLock()Implements the GetLock operation.protected intgetMaxExpectedSize(String maxExpectedSizeHeader)ObjectgetShareUrl()Implements the GetShareUrl operation.voidinitialize(Object... args)protected Objectlock(String lock)protected ObjectlockOrUnlockAndRelock()Implements the Lock and UnlockAndRelock operations.protected voidlogCondition(String condition)protected voidlogCondition(Supplier<String> condition)protected voidlogNuxeoAction(String action)protected voidlogNuxeoAction(Supplier<String> action)protected voidlogRequest(String operation, String... headers)protected voidlogResponse(String operation, int status, Object entity, String... headers)protected voidlogResponse(String operation, int status, String... headers)ObjectputFile()Implements the PutFile operation.ObjectputRelativeFile()Implements the PutRelativeFile operation.protected ObjectrefreshLock()Implements the RefreshLock operation.protected javax.ws.rs.core.ResponserenameBlob(String requestedName)Renames the blob with therequestedName.ObjectrenameFile()Implements the RenameFile operation.protected Objectunlock()Implements the Unlock operation.protected ObjectunlockAndRelock(String lock, String oldLock)protected ObjectunlockOrRefresh(String operation, String lock, boolean unlock)protected javax.ws.rs.core.ResponseupdateBlob()Updates the document's blob from a new one.-
Methods inherited from class org.nuxeo.ecm.webengine.model.impl.DefaultObject
disptachAdapter, isAdapter
-
Methods inherited from class org.nuxeo.ecm.webengine.model.impl.AbstractResource
checkGuard, dispose, getActiveAdapter, getAdapter, getContext, getFacets, getLinks, getModule, getName, getNext, getNextSegment, getPath, getPrevious, getTemplate, getTrailingPath, getType, getURL, getView, hasFacet, initialize, isInstanceOf, isRoot, newAdapter, newObject, redirect, setNext, setPrevious, setRoot, toString
-
-
-
-
Field Detail
-
request
@Context protected javax.servlet.http.HttpServletRequest request
-
response
@Context protected javax.servlet.http.HttpServletResponse response
-
httpHeaders
@Context protected javax.ws.rs.core.HttpHeaders httpHeaders
-
session
protected CoreSession session
-
doc
protected DocumentModel doc
-
blob
protected Blob blob
-
xpath
protected String xpath
-
fileId
protected String fileId
-
baseURL
protected String baseURL
-
wopiBaseURL
protected String wopiBaseURL
-
-
Method Detail
-
initialize
public void initialize(Object... args)
- Overrides:
initializein classAbstractResource<ResourceTypeImpl>
-
checkFileInfo
public javax.ws.rs.core.Response checkFileInfo()
Implements the CheckFileInfo operation.See CheckFileInfo.
-
getFile
public Object getFile(@HeaderParam("X-WOPI-MaxExpectedSize") String maxExpectedSizeHeader)
Implements the GetFile operation.See GetFile.
-
lockOrUnlockAndRelock
protected Object lockOrUnlockAndRelock()
Implements the Lock and UnlockAndRelock operations.See Lock and UnlockAndRelock.
-
buildItemVersionResponse
protected javax.ws.rs.core.Response buildItemVersionResponse(String operation, Blob blob)
-
getCurrentLock
protected String getCurrentLock(String operation)
Returns the WOPI lock if not null and throws aConflictExceptionotherwise.Must be called to check that a locked document is not locked by Nuxeo.
-
buildConflictResponse
protected javax.ws.rs.core.Response buildConflictResponse(String operation, String lock)
Builds a conflict response with the given WOPI lock as a header.Must be called in case of "lock mismatch", for instance when a document is locked by another WOPI client.
-
putRelativeFile
public Object putRelativeFile()
Implements the PutRelativeFile operation.New file creation is not supported, only the binary document conversion is supported.
See PutRelativeFile.
-
createVersionFromRequestBody
protected DocumentModel createVersionFromRequestBody(String filename)
-
renameFile
public Object renameFile()
Implements the RenameFile operation.See RenameFile.
-
renameBlob
protected javax.ws.rs.core.Response renameBlob(String requestedName)
Renames the blob with therequestedName.- Returns:
- the expected JSON response for the RenameFile operation.
-
getShareUrl
public Object getShareUrl()
Implements the GetShareUrl operation.See GetShareUrl.
-
updateBlob
protected javax.ws.rs.core.Response updateBlob()
Updates the document's blob from a new one.- Returns:
- the expected response for the PutFile operation, with the 'X-WOPI-ItemVersion' header set.
-
createBlobFromRequestBody
protected Blob createBlobFromRequestBody(String filename, String mimeType)
Creates a new blob from the request body, given afilenameand an optionalmimeType.- Returns:
- the new blob
-
refreshLock
protected Object refreshLock()
Implements the RefreshLock operation.See RefreshLock.
-
getMaxExpectedSize
protected int getMaxExpectedSize(String maxExpectedSizeHeader)
-
checkWritePropertiesPermission
protected void checkWritePropertiesPermission(String operation)
-
buildCheckFileInfoMap
protected Map<String,Serializable> buildCheckFileInfoMap()
-
addRequiredProperties
protected void addRequiredProperties(Map<String,Serializable> map)
-
addHostCapabilitiesProperties
protected void addHostCapabilitiesProperties(Map<String,Serializable> map)
-
addUserMetadataProperties
protected void addUserMetadataProperties(Map<String,Serializable> map)
-
addUserPermissionsProperties
protected void addUserPermissionsProperties(Map<String,Serializable> map)
-
addFileURLProperties
protected void addFileURLProperties(Map<String,Serializable> map)
-
addBreadcrumbProperties
protected void addBreadcrumbProperties(Map<String,Serializable> map)
-
getItemVersion
protected String getItemVersion()
-
getDocumentURL
protected String getDocumentURL(DocumentModel doc)
-
logCondition
protected void logCondition(String condition)
-
logNuxeoAction
protected void logNuxeoAction(String action)
-
logResponse
protected void logResponse(String operation, int status, Object entity, String... headers)
-
-