Package org.fcrepo.http.api
Class FedoraBaseResource
- java.lang.Object
-
- org.fcrepo.http.commons.AbstractResource
-
- org.fcrepo.http.api.FedoraBaseResource
-
- Direct Known Subclasses:
ContentExposingResource
,FedoraReindex
,FedoraRepositoryStats
,FedoraSearch
,Transactions
public abstract class FedoraBaseResource extends AbstractResource
- Since:
- 10/5/14
- Author:
- cabeer
-
-
Field Summary
Fields Modifier and Type Field Description protected DbTransactionExecutor
dbTransactionExecutor
protected HttpIdentifierConverter
identifierConverter
protected ResourceFactory
resourceFactory
protected ResourceHelper
resourceHelper
protected javax.ws.rs.core.SecurityContext
securityContext
protected javax.servlet.http.HttpServletRequest
servletRequest
protected TransactionManager
txManager
-
Fields inherited from class org.fcrepo.http.commons.AbstractResource
defaultPidMinter, fedoraPropsConfig, headers, pidMinter, uriInfo, versionService
-
-
Constructor Summary
Constructors Constructor Description FedoraBaseResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
doesResourceExist(Transaction transaction, FedoraId fedoraId, boolean includeDeleted)
protected void
doInDbTx(Runnable action)
Executes the runnable within a DB transaction.protected void
doInDbTxWithRetry(Runnable action)
Executes the runnable within a DB transaction that will retry entire block on MySQL deadlock exceptions.protected FedoraResource
getFedoraResource(Transaction transaction, FedoraId fedoraId)
Gets a fedora resource by id.protected String
getUserPrincipal()
protected HttpIdentifierConverter
identifierConverter()
protected boolean
isGhostNode(Transaction transaction, FedoraId fedoraId)
protected Transaction
transaction()
-
-
-
Field Detail
-
securityContext
@Context protected javax.ws.rs.core.SecurityContext securityContext
-
resourceFactory
@Inject protected ResourceFactory resourceFactory
-
resourceHelper
@Inject protected ResourceHelper resourceHelper
-
servletRequest
@Context protected javax.servlet.http.HttpServletRequest servletRequest
-
txManager
@Inject protected TransactionManager txManager
-
dbTransactionExecutor
@Inject protected DbTransactionExecutor dbTransactionExecutor
-
identifierConverter
protected HttpIdentifierConverter identifierConverter
-
-
Constructor Detail
-
FedoraBaseResource
public FedoraBaseResource()
-
-
Method Detail
-
identifierConverter
protected HttpIdentifierConverter identifierConverter()
-
getFedoraResource
protected FedoraResource getFedoraResource(Transaction transaction, FedoraId fedoraId) throws PathNotFoundException
Gets a fedora resource by id. Uses the provided transaction if it is uncommitted, or uses a new transaction.- Parameters:
transaction
- the fedora transactionfedoraId
- identifier of the resource- Returns:
- the requested FedoraResource
- Throws:
PathNotFoundException
-
doesResourceExist
protected boolean doesResourceExist(Transaction transaction, FedoraId fedoraId, boolean includeDeleted)
- Parameters:
transaction
- the transaction in which to checkfedoraId
- identifier of the object to checkincludeDeleted
- Whether to check for deleted resources too.- Returns:
- Returns true if an object with the provided id exists
-
isGhostNode
protected boolean isGhostNode(Transaction transaction, FedoraId fedoraId)
- Parameters:
transaction
- the transaction in which to checkfedoraId
- identifier of the object to check- Returns:
- Returns true if object does not exist but whose ID starts other resources that do exist.
-
getUserPrincipal
protected String getUserPrincipal()
-
transaction
protected Transaction transaction()
-
doInDbTxWithRetry
protected void doInDbTxWithRetry(Runnable action)
Executes the runnable within a DB transaction that will retry entire block on MySQL deadlock exceptions. If the runnable throws an exception, after completing any retires, then the Fedora transaction is marked as failed.- Parameters:
action
- the code to execute
-
-