Class TranskribusUtils
java.lang.Object
io.goobi.viewer.model.transkribus.TranskribusUtils
Utility class for communicating with the Transkribus REST API to submit and monitor HTR jobs.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic org.jdom2.Documentauth.protected static JobStatuscheckJobStatus(String baseUrl, String sessionId, String jobId) checkJobStatus.protected static StringcreateCollection(String baseUrl, String sessionId, String collectionName) createCollection.static StringgetCollectionId(String baseUrl, String sessionId, String collectionName) Returns the ID of the first collection that has the given collection name.protected static booleangrantCollectionPrivsToViewer(String baseUrl, String sessionId, String collectionId, String recipientUserId, boolean sendMail) grantCollectionPrivsToViewer.static TranskribusJobingestRecord(String restApiUrl, TranskribusSession userSession, String pi, String metsResolverUrlRoot) ingestRecord.protected static TranskribusJobingestRecordToCollections(String baseUrl, TranskribusSession session, String pi, String metsUrl, String userCollectionId, String viewerCollectionId) ingestRecordToCollections.static TranskribusSessionlogin.
-
Field Details
-
TRANSRIBUS_REST_URL
ConstantTRANSRIBUS_REST_URL="https://transkribus.eu/TrpServer/rest/".- See Also:
-
TRANSRIBUS_REST_TESTING_URL
ConstantTRANSRIBUS_REST_TESTING_URL="https://transkribus.eu/TrpServerTesting"{trunked}.- See Also:
-
-
Method Details
-
ingestRecord
public static TranskribusJob ingestRecord(String restApiUrl, TranskribusSession userSession, String pi, String metsResolverUrlRoot) throws IOException, HTTPException, org.jdom2.JDOMException, DAOException ingestRecord.- Parameters:
restApiUrl- base URL of the Transkribus REST APIuserSession- authenticated session of the requesting userpi- persistent identifier of the record to ingestmetsResolverUrlRoot- Root of the METS resolver URL (without the identifier).- Returns:
- the TranskribusJob created for the ingest request, or null if the feature is disabled
- Throws:
IOException- if any.HTTPException- if any.org.jdom2.JDOMException- if any.DAOException- if any.
-
login
public static TranskribusSession login(String baseUrl, String userName, String password) throws IOException, org.jdom2.JDOMException login.- Parameters:
baseUrl- base URL of the Transkribus REST APIuserName- Transkribus account user namepassword- Transkribus account password- Returns:
- the authenticated TranskribusSession, or null if login failed
- Throws:
IOException- if any.org.jdom2.JDOMException- if any.
-
auth
public static org.jdom2.Document auth(String baseUrl, String userName, String password) throws IOException, org.jdom2.JDOMException auth.- Parameters:
baseUrl- base URL of the Transkribus REST APIuserName- Transkribus account user namepassword- Transkribus account password- Returns:
- JDOM object containing the API response
- Throws:
IOException- if any.org.jdom2.JDOMException- if any.
-
getCollectionId
public static String getCollectionId(String baseUrl, String sessionId, String collectionName) throws IOException, HTTPException Returns the ID of the first collection that has the given collection name.- Parameters:
baseUrl- base URL of the Transkribus REST APIsessionId- active session ID for authenticationcollectionName- name of the collection to look up- Returns:
- the numeric collection ID as string, or null if not found
- Throws:
IOException- if any.HTTPException- if any.
-
createCollection
protected static String createCollection(String baseUrl, String sessionId, String collectionName) throws IOException createCollection.- Parameters:
baseUrl- base URL of the Transkribus REST APIsessionId- active session ID for authenticationcollectionName- name to assign to the new collection- Returns:
- the numeric ID of the newly created Transkribus collection as string
- Throws:
IOException- if any.
-
grantCollectionPrivsToViewer
protected static boolean grantCollectionPrivsToViewer(String baseUrl, String sessionId, String collectionId, String recipientUserId, boolean sendMail) throws IOException grantCollectionPrivsToViewer.- Parameters:
baseUrl- base URL of the Transkribus REST APIsessionId- active session ID for authenticationcollectionId- numeric ID of the collection to grant access torecipientUserId- Transkribus user ID receiving editor privilegessendMail- whether to send a notification email to the recipient- Returns:
- true if the collection privileges were granted successfully, false otherwise
- Throws:
IOException- if any.
-
ingestRecordToCollections
protected static TranskribusJob ingestRecordToCollections(String baseUrl, TranskribusSession session, String pi, String metsUrl, String userCollectionId, String viewerCollectionId) throws IOException ingestRecordToCollections.- Parameters:
baseUrl- base URL of the Transkribus REST APIsession- authenticated session of the requesting userpi- persistent identifier of the record being ingestedmetsUrl- fully resolved METS URL for the recorduserCollectionId- ID of the user's personal Transkribus collectionviewerCollectionId- ID of the viewer instance's Transkribus collection- Returns:
- the TranskribusJob representing the ingest operation, or null if the request failed
- Throws:
IOException- if any. o
-
checkJobStatus
protected static JobStatus checkJobStatus(String baseUrl, String sessionId, String jobId) throws IOException, HTTPException checkJobStatus.- Parameters:
baseUrl- base URL of the Transkribus REST APIsessionId- active session ID for authenticationjobId- Transkribus job ID whose status is queried- Returns:
- the current status of the Transkribus job, or null if the status could not be determined
- Throws:
IOException- if any.HTTPException- if any.
-