Class TranskribusUtils

java.lang.Object
io.goobi.viewer.model.transkribus.TranskribusUtils

public final class TranskribusUtils extends Object
Utility class for communicating with the Transkribus REST API to submit and monitor HTR jobs.
  • Field Details

    • TRANSRIBUS_REST_URL

      public static final String TRANSRIBUS_REST_URL
      Constant TRANSRIBUS_REST_URL="https://transkribus.eu/TrpServer/rest/".
      See Also:
    • TRANSRIBUS_REST_TESTING_URL

      public static final String TRANSRIBUS_REST_TESTING_URL
      Constant TRANSRIBUS_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 API
      userSession - authenticated session of the requesting user
      pi - persistent identifier of the record to ingest
      metsResolverUrlRoot - 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 API
      userName - Transkribus account user name
      password - 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 API
      userName - Transkribus account user name
      password - 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 API
      sessionId - active session ID for authentication
      collectionName - 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 API
      sessionId - active session ID for authentication
      collectionName - 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 API
      sessionId - active session ID for authentication
      collectionId - numeric ID of the collection to grant access to
      recipientUserId - Transkribus user ID receiving editor privileges
      sendMail - 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 API
      session - authenticated session of the requesting user
      pi - persistent identifier of the record being ingested
      metsUrl - fully resolved METS URL for the record
      userCollectionId - ID of the user's personal Transkribus collection
      viewerCollectionId - 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 API
      sessionId - active session ID for authentication
      jobId - 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.