use of org.broadleafcommerce.common.util.StreamCapableTransactionalOperationAdapter in project BroadleafCommerce by BroadleafCommerce.
the class StaticAssetStorageServiceImpl method readStaticAssetStorageByStaticAssetId.
@Override
public StaticAssetStorage readStaticAssetStorageByStaticAssetId(final Long id) {
final StaticAssetStorage[] storage = new StaticAssetStorage[1];
transUtil.runTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
@Override
public void execute() {
storage[0] = staticAssetStorageDao.readStaticAssetStorageByStaticAssetId(id);
}
}, RuntimeException.class);
return storage[0];
}
use of org.broadleafcommerce.common.util.StreamCapableTransactionalOperationAdapter in project BroadleafCommerce by BroadleafCommerce.
the class StaticAssetStorageServiceImpl method createBlob.
@Override
public Blob createBlob(final MultipartFile uploadedFile) throws IOException {
final Blob[] blob = new Blob[1];
transUtil.runTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
@Override
public void execute() {
try {
blob[0] = staticAssetStorageDao.createBlob(uploadedFile);
} catch (IOException e) {
LOG.error("Unable to create blob from MultipartFile.", e);
}
}
}, RuntimeException.class);
return blob[0];
}
use of org.broadleafcommerce.common.util.StreamCapableTransactionalOperationAdapter in project BroadleafCommerce by BroadleafCommerce.
the class StaticAssetStorageServiceImpl method findStaticAssetStorageById.
@Override
public StaticAssetStorage findStaticAssetStorageById(final Long id) {
final StaticAssetStorage[] storage = new StaticAssetStorage[1];
transUtil.runTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
@Override
public void execute() {
storage[0] = staticAssetStorageDao.readStaticAssetStorageById(id);
}
}, RuntimeException.class);
return storage[0];
}
use of org.broadleafcommerce.common.util.StreamCapableTransactionalOperationAdapter in project BroadleafCommerce by BroadleafCommerce.
the class StaticAssetStorageServiceImpl method save.
@Override
public StaticAssetStorage save(final StaticAssetStorage assetStorage) {
final StaticAssetStorage[] storage = new StaticAssetStorage[1];
transUtil.runTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
@Override
public void execute() {
storage[0] = staticAssetStorageDao.save(assetStorage);
}
}, RuntimeException.class);
return storage[0];
}
use of org.broadleafcommerce.common.util.StreamCapableTransactionalOperationAdapter in project BroadleafCommerce by BroadleafCommerce.
the class OfferServiceImpl method refreshOfferCodesIfApplicable.
/**
* For enterprise installations, this will refresh any OfferCodes found to be out-of-date with
* current sandbox status.
*
* @param order the order to check
* @return the refreshed list of OfferCodes
*/
protected List<OfferCode> refreshOfferCodesIfApplicable(final Order order) {
final List<OfferCode> orderOfferCodes = order.getAddedOfferCodes();
transUtil.runTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
@Override
public void execute() {
for (OfferCode offerCode : orderOfferCodes) {
if (offerCode.getOffer() != null) {
Long sandBoxVersionId = sandBoxHelper.getSandBoxVersionId(OfferImpl.class, offerCode.getOffer().getId());
if (sandBoxVersionId != null && !Objects.equals(sandBoxVersionId, offerCode.getOffer().getId())) {
em.refresh(offerCode);
}
}
}
}
@Override
public boolean shouldRetryOnTransactionLockAcquisitionFailure() {
return true;
}
}, RuntimeException.class);
return orderOfferCodes;
}
Aggregations