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 String
baseURL
protected Blob
blob
protected DocumentModel
doc
protected String
fileId
protected javax.ws.rs.core.HttpHeaders
httpHeaders
protected javax.servlet.http.HttpServletRequest
request
protected javax.servlet.http.HttpServletResponse
response
protected CoreSession
session
protected String
wopiBaseURL
protected String
xpath
-
Constructor Summary
Constructors Constructor Description FilesEndpoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addBreadcrumbProperties(Map<String,Serializable> map)
protected void
addFileURLProperties(Map<String,Serializable> map)
protected void
addHostCapabilitiesProperties(Map<String,Serializable> map)
protected void
addRequiredProperties(Map<String,Serializable> map)
protected void
addUserMetadataProperties(Map<String,Serializable> map)
protected void
addUserPermissionsProperties(Map<String,Serializable> map)
protected Map<String,Serializable>
buildCheckFileInfoMap()
protected javax.ws.rs.core.Response
buildConflictResponse(String operation, String lock)
Builds a conflict response with the given WOPI lock as a header.protected javax.ws.rs.core.Response
buildItemVersionResponse(String operation, Blob blob)
javax.ws.rs.core.Response
checkFileInfo()
Implements the CheckFileInfo operation.protected void
checkWritePropertiesPermission(String operation)
protected Blob
createBlobFromRequestBody(String filename, String mimeType)
Creates a new blob from the request body, given afilename
and an optionalmimeType
.protected DocumentModel
createVersionFromRequestBody(String filename)
Object
doPost(Operation operation)
Object
doPostContents(Operation operation)
protected String
getCurrentLock(String operation)
Returns the WOPI lock if not null and throws aConflictException
otherwise.protected String
getDocumentURL(DocumentModel doc)
protected String
getEntityString(Object entity)
Object
getFile(String maxExpectedSizeHeader)
Implements the GetFile operation.protected String
getHeader(String operation, String headerName)
protected String
getHeader(String operation, String headerName, boolean nullable)
protected String
getHeaderString(String... headers)
protected String
getItemVersion()
protected Object
getLock()
Implements the GetLock operation.protected int
getMaxExpectedSize(String maxExpectedSizeHeader)
Object
getShareUrl()
Implements the GetShareUrl operation.void
initialize(Object... args)
protected Object
lock(String lock)
protected Object
lockOrUnlockAndRelock()
Implements the Lock and UnlockAndRelock operations.protected void
logCondition(String condition)
protected void
logCondition(Supplier<String> condition)
protected void
logNuxeoAction(String action)
protected void
logNuxeoAction(Supplier<String> action)
protected void
logRequest(String operation, String... headers)
protected void
logResponse(String operation, int status, Object entity, String... headers)
protected void
logResponse(String operation, int status, String... headers)
Object
putFile()
Implements the PutFile operation.Object
putRelativeFile()
Implements the PutRelativeFile operation.protected Object
refreshLock()
Implements the RefreshLock operation.protected javax.ws.rs.core.Response
renameBlob(String requestedName)
Renames the blob with therequestedName
.Object
renameFile()
Implements the RenameFile operation.protected Object
unlock()
Implements the Unlock operation.protected Object
unlockAndRelock(String lock, String oldLock)
protected Object
unlockOrRefresh(String operation, String lock, boolean unlock)
protected javax.ws.rs.core.Response
updateBlob()
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:
initialize
in 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 aConflictException
otherwise.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 afilename
and 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)
-
-