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();
}
}
}
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;
}
Aggregations