Search in sources :

Example 1 with InvalidLRAIdException

use of io.narayana.lra.client.InvalidLRAIdException in project narayana by jbosstm.

the class LRAService method startLRA.

public synchronized URL startLRA(String baseUri, URL parentLRA, String clientId, Long timelimit) {
    Transaction lra;
    try {
        lra = new Transaction(this, baseUri, parentLRA, clientId);
    } catch (MalformedURLException e) {
        throw new InvalidLRAIdException(baseUri, "Invalid base uri", e);
    }
    if (lra.currentLRA() != null)
        if (LRALogger.logger.isInfoEnabled())
            LRALogger.logger.infof("LRAServicve.startLRA LRA %s is already associated%n", lra.currentLRA().get_uid().fileStringForm());
    int status = lra.begin(timelimit);
    if (status != ActionStatus.RUNNING) {
        lraTrace(lra.getId(), "failed to start LRA");
        lra.abort();
        throw new InternalServerErrorException("Could not start LRA: " + ActionStatus.stringForm(status));
    } else {
        try {
            addTransaction(lra);
            lraTrace(lra.getId(), "started LRA");
            return lra.getId();
        } finally {
            AtomicAction.suspend();
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Transaction(io.narayana.lra.coordinator.domain.model.Transaction) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) InvalidLRAIdException(io.narayana.lra.client.InvalidLRAIdException)

Example 2 with InvalidLRAIdException

use of io.narayana.lra.client.InvalidLRAIdException in project narayana by jbosstm.

the class Coordinator method toURL.

private URL toURL(String lraId) {
    URL url;
    try {
        // see if it already in the correct format
        url = new URL(lraId);
        url.toURI();
    } catch (Exception e) {
        try {
            url = new URL(String.format("%s%s/%s", context.getBaseUri(), COORDINATOR_PATH_NAME, lraId));
        } catch (MalformedURLException e1) {
            LRALogger.i18NLogger.error_invalidStringFormatOfUrl(lraId, e1);
            throw new InvalidLRAIdException(lraId, "Invalid LRA id format", e1);
        }
    }
    return url;
}
Also used : MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) IllegalLRAStateException(io.narayana.lra.client.IllegalLRAStateException) URISyntaxException(java.net.URISyntaxException) GenericLRAException(io.narayana.lra.client.GenericLRAException) NotFoundException(javax.ws.rs.NotFoundException) WebApplicationException(javax.ws.rs.WebApplicationException) InvalidLRAIdException(io.narayana.lra.client.InvalidLRAIdException) MalformedURLException(java.net.MalformedURLException) InvalidLRAIdException(io.narayana.lra.client.InvalidLRAIdException)

Aggregations

InvalidLRAIdException (io.narayana.lra.client.InvalidLRAIdException)2 MalformedURLException (java.net.MalformedURLException)2 GenericLRAException (io.narayana.lra.client.GenericLRAException)1 IllegalLRAStateException (io.narayana.lra.client.IllegalLRAStateException)1 Transaction (io.narayana.lra.coordinator.domain.model.Transaction)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)1 NotFoundException (javax.ws.rs.NotFoundException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1