|
|
@ -76,18 +76,20 @@ public class AssetController extends BaseController { |
|
|
try { |
|
|
try { |
|
|
asset.setTenantId(getCurrentUser().getTenantId()); |
|
|
asset.setTenantId(getCurrentUser().getTenantId()); |
|
|
|
|
|
|
|
|
Operation operation = asset.getId() == null ? Operation.CREATE : Operation.WRITE; |
|
|
if (asset.getId() == null) { |
|
|
|
|
|
accessControlService |
|
|
accessControlService.checkPermission(getCurrentUser(), Resource.ASSET, operation, |
|
|
.checkPermission(getCurrentUser(), Resource.ASSET, Operation.CREATE, asset.getId(), asset); |
|
|
asset.getId(), asset); |
|
|
} else { |
|
|
|
|
|
checkAssetId(asset.getId(), Operation.WRITE); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Asset savedAsset = checkNotNull(assetService.saveAsset(asset)); |
|
|
Asset savedAsset = checkNotNull(assetService.saveAsset(asset)); |
|
|
|
|
|
|
|
|
logEntityAction(savedAsset.getId(), savedAsset, |
|
|
logEntityAction(savedAsset.getId(), savedAsset, |
|
|
savedAsset.getCustomerId(), |
|
|
savedAsset.getCustomerId(), |
|
|
asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); |
|
|
asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); |
|
|
|
|
|
|
|
|
return savedAsset; |
|
|
return savedAsset; |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
logEntityAction(emptyId(EntityType.ASSET), asset, |
|
|
logEntityAction(emptyId(EntityType.ASSET), asset, |
|
|
null, asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, e); |
|
|
null, asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, e); |
|
|
@ -138,7 +140,7 @@ public class AssetController extends BaseController { |
|
|
savedAsset.getCustomerId(), |
|
|
savedAsset.getCustomerId(), |
|
|
ActionType.ASSIGNED_TO_CUSTOMER, null, strAssetId, strCustomerId, customer.getName()); |
|
|
ActionType.ASSIGNED_TO_CUSTOMER, null, strAssetId, strCustomerId, customer.getName()); |
|
|
|
|
|
|
|
|
return savedAsset; |
|
|
return savedAsset; |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
logEntityAction(emptyId(EntityType.ASSET), null, |
|
|
logEntityAction(emptyId(EntityType.ASSET), null, |
|
|
@ -218,7 +220,7 @@ public class AssetController extends BaseController { |
|
|
try { |
|
|
try { |
|
|
TenantId tenantId = getCurrentUser().getTenantId(); |
|
|
TenantId tenantId = getCurrentUser().getTenantId(); |
|
|
TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); |
|
|
TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); |
|
|
if (type != null && type.trim().length()>0) { |
|
|
if (type != null && type.trim().length() > 0) { |
|
|
return checkNotNull(assetService.findAssetsByTenantIdAndType(tenantId, type, pageLink)); |
|
|
return checkNotNull(assetService.findAssetsByTenantIdAndType(tenantId, type, pageLink)); |
|
|
} else { |
|
|
} else { |
|
|
return checkNotNull(assetService.findAssetsByTenantId(tenantId, pageLink)); |
|
|
return checkNotNull(assetService.findAssetsByTenantId(tenantId, pageLink)); |
|
|
@ -257,7 +259,7 @@ public class AssetController extends BaseController { |
|
|
CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
|
|
CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
|
|
checkCustomerId(customerId, Operation.READ); |
|
|
checkCustomerId(customerId, Operation.READ); |
|
|
TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); |
|
|
TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); |
|
|
if (type != null && type.trim().length()>0) { |
|
|
if (type != null && type.trim().length() > 0) { |
|
|
return checkNotNull(assetService.findAssetsByTenantIdAndCustomerIdAndType(tenantId, customerId, type, pageLink)); |
|
|
return checkNotNull(assetService.findAssetsByTenantIdAndCustomerIdAndType(tenantId, customerId, type, pageLink)); |
|
|
} else { |
|
|
} else { |
|
|
return checkNotNull(assetService.findAssetsByTenantIdAndCustomerId(tenantId, customerId, pageLink)); |
|
|
return checkNotNull(assetService.findAssetsByTenantIdAndCustomerId(tenantId, customerId, pageLink)); |
|
|
|