Search in sources :

Example 16 with StreamCapableTransactionalOperationAdapter

use of org.broadleafcommerce.common.util.StreamCapableTransactionalOperationAdapter in project BroadleafCommerce by BroadleafCommerce.

the class StaticAssetStorageServiceImpl method createBlob.

@Override
public Blob createBlob(final InputStream uploadedFileInputStream, final long fileSize) throws IOException {
    final Blob[] blob = new Blob[1];
    transUtil.runTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {

        @Override
        public void execute() {
            try {
                blob[0] = staticAssetStorageDao.createBlob(uploadedFileInputStream, fileSize);
            } catch (IOException e) {
                LOG.error("Unable to create blob from InputStream.", e);
            }
        }
    }, RuntimeException.class);
    return blob[0];
}
Also used : Blob(java.sql.Blob) StreamCapableTransactionalOperationAdapter(org.broadleafcommerce.common.util.StreamCapableTransactionalOperationAdapter) IOException(java.io.IOException)

Aggregations

StreamCapableTransactionalOperationAdapter (org.broadleafcommerce.common.util.StreamCapableTransactionalOperationAdapter)16 ServiceException (org.broadleafcommerce.common.exception.ServiceException)6 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)6 PersistenceResponse (org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse)5 StaticAssetStorage (org.broadleafcommerce.cms.file.domain.StaticAssetStorage)3 IOException (java.io.IOException)2 Blob (java.sql.Blob)2 Map (java.util.Map)2 Session (org.hibernate.Session)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 EntityManager (javax.persistence.EntityManager)1 Site (org.broadleafcommerce.common.site.domain.Site)1 OfferCode (org.broadleafcommerce.core.offer.domain.OfferCode)1 OfferImpl (org.broadleafcommerce.core.offer.domain.OfferImpl)1