use of org.broadleafcommerce.cms.file.domain.StaticAssetStorage 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.cms.file.domain.StaticAssetStorage 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.cms.file.domain.StaticAssetStorage in project BroadleafCommerce by BroadleafCommerce.
the class StaticAssetStorageServiceImpl method lookupAssetAndCreateLocalFile.
protected File lookupAssetAndCreateLocalFile(StaticAsset staticAsset, File baseLocalFile) throws IOException, SQLException {
if (StorageType.FILESYSTEM.equals(staticAsset.getStorageType())) {
File returnFile = broadleafFileService.getResource(staticAsset.getFullUrl());
if (!returnFile.getAbsolutePath().equals(baseLocalFile.getAbsolutePath())) {
createLocalFileFromInputStream(new FileInputStream(returnFile), baseLocalFile);
}
return broadleafFileService.getResource(staticAsset.getFullUrl());
} else {
StaticAssetStorage storage = readStaticAssetStorageByStaticAssetId(staticAsset.getId());
if (storage != null) {
InputStream is = storage.getFileData().getBinaryStream();
createLocalFileFromInputStream(is, baseLocalFile);
}
}
return baseLocalFile;
}
use of org.broadleafcommerce.cms.file.domain.StaticAssetStorage 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.cms.file.domain.StaticAssetStorage in project BroadleafCommerce by BroadleafCommerce.
the class StaticAssetStorageDaoImpl method readStaticAssetStorageByStaticAssetId.
@Override
public StaticAssetStorage readStaticAssetStorageByStaticAssetId(Long id) {
Query query = em.createNamedQuery("BC_READ_STATIC_ASSET_STORAGE_BY_STATIC_ASSET_ID");
query.setParameter("id", id);
return (StaticAssetStorage) query.getSingleResult();
}
Aggregations