Esempio n. 1
0
  @GET
  public Blob convert(
      @QueryParam("converter") String converter,
      @QueryParam("type") String type,
      @QueryParam("format") String format,
      @Context UriInfo uriInfo) {
    BlobHolder bh = getBlobHolderToConvert();

    boolean txWasActive = false;
    try {
      if (TransactionHelper.isTransactionActive()) {
        txWasActive = true;
        TransactionHelper.commitOrRollbackTransaction();
      }

      if (StringUtils.isNotBlank(converter)) {
        return convertWithConverter(bh, converter, uriInfo);
      } else if (StringUtils.isNotBlank(type)) {
        return convertWithMimeType(bh, type, uriInfo);
      } else if (StringUtils.isNotBlank(format)) {
        return convertWithFormat(bh, format, uriInfo);
      } else {
        throw new IllegalParameterException("No converter, type or format parameter specified");
      }
    } finally {
      if (txWasActive && !TransactionHelper.isTransactionActiveOrMarkedRollback()) {
        TransactionHelper.startTransaction();
      }
    }
  }
Esempio n. 2
0
 protected void triggerReloadWithNewTransaction(String id) {
   if (TransactionHelper.isTransactionMarkedRollback()) {
     throw new AssertionError("The calling transaction is marked rollback");
   } else if (TransactionHelper.isTransactionActive()) { // should flush
     // the calling
     // transaction
     TransactionHelper.commitOrRollbackTransaction();
     TransactionHelper.startTransaction();
   }
   try {
     try {
       triggerReload(id);
     } catch (RuntimeException cause) {
       TransactionHelper.setTransactionRollbackOnly();
       throw cause;
     }
   } finally {
     if (TransactionHelper.isTransactionActiveOrMarkedRollback()) {
       boolean wasRollbacked = TransactionHelper.isTransactionMarkedRollback();
       TransactionHelper.commitOrRollbackTransaction();
       TransactionHelper.startTransaction();
       if (wasRollbacked) {
         TransactionHelper.setTransactionRollbackOnly();
       }
     }
   }
 }
 protected void nextTransaction() {
   if (TransactionHelper.isTransactionActiveOrMarkedRollback()) {
     TransactionHelper.commitOrRollbackTransaction();
     TransactionHelper.startTransaction();
   }
 }