use of com.cloud.server.ResourceIcon in project cloudstack by apache.
the class ListDomainChildrenCmd method updateDomainResponse.
private void updateDomainResponse(List<DomainResponse> response) {
for (DomainResponse domainResponse : response) {
ResourceIcon resourceIcon = resourceIconManager.getByResourceTypeAndUuid(ResourceTag.ResourceObjectType.Domain, domainResponse.getId());
if (resourceIcon == null) {
continue;
}
ResourceIconResponse iconResponse = _responseGenerator.createResourceIconResponse(resourceIcon);
domainResponse.setResourceIconResponse(iconResponse);
}
}
use of com.cloud.server.ResourceIcon in project cloudstack by apache.
the class ListDomainsCmd method updateDomainResponse.
private void updateDomainResponse(List<DomainResponse> response) {
for (DomainResponse domainResponse : response) {
ResourceIcon resourceIcon = resourceIconManager.getByResourceTypeAndUuid(ResourceTag.ResourceObjectType.Domain, domainResponse.getId());
if (resourceIcon == null) {
continue;
}
ResourceIconResponse iconResponse = _responseGenerator.createResourceIconResponse(resourceIcon);
domainResponse.setResourceIconResponse(iconResponse);
}
}
use of com.cloud.server.ResourceIcon in project cloudstack by apache.
the class ListNetworksCmd method updateNetworkResponse.
private void updateNetworkResponse(List<NetworkResponse> response) {
for (NetworkResponse networkResponse : response) {
ResourceIcon resourceIcon = resourceIconManager.getByResourceTypeAndUuid(ResourceTag.ResourceObjectType.Network, networkResponse.getId());
if (resourceIcon == null) {
resourceIcon = resourceIconManager.getByResourceTypeAndUuid(ResourceTag.ResourceObjectType.Vpc, networkResponse.getVpcId());
if (resourceIcon == null) {
continue;
}
}
ResourceIconResponse iconResponse = _responseGenerator.createResourceIconResponse(resourceIcon);
networkResponse.setResourceIconResponse(iconResponse);
}
}
use of com.cloud.server.ResourceIcon in project cloudstack by apache.
the class ListVMsCmd method updateVMResponse.
protected void updateVMResponse(List<UserVmResponse> response) {
for (UserVmResponse vmResponse : response) {
ResourceIcon resourceIcon = resourceIconManager.getByResourceTypeAndUuid(ResourceTag.ResourceObjectType.UserVm, vmResponse.getId());
if (resourceIcon == null) {
ResourceTag.ResourceObjectType type = ResourceTag.ResourceObjectType.Template;
String uuid = vmResponse.getTemplateId();
if (vmResponse.getIsoId() != null) {
uuid = vmResponse.getIsoId();
type = ResourceTag.ResourceObjectType.ISO;
}
resourceIcon = resourceIconManager.getByResourceTypeAndUuid(type, uuid);
if (resourceIcon == null) {
continue;
}
}
ResourceIconResponse iconResponse = _responseGenerator.createResourceIconResponse(resourceIcon);
vmResponse.setResourceIconResponse(iconResponse);
}
}
use of com.cloud.server.ResourceIcon in project cloudstack by apache.
the class ResourceIconManagerImpl method deleteResourceIcon.
@Override
@ActionEvent(eventType = EventTypes.EVENT_RESOURCE_ICON_DELETE, eventDescription = "deleting resource icon")
public boolean deleteResourceIcon(List<String> resourceIds, ResourceTag.ResourceObjectType resourceType) {
Account caller = CallContext.current().getCallingAccount();
List<? extends ResourceIcon> resourceIcons = searchResourceIcons(resourceIds, resourceType);
if (resourceIcons.isEmpty()) {
s_logger.debug("No resource Icon(s) uploaded for the specified resources");
return false;
}
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
for (ResourceIcon resourceIcon : resourceIcons) {
String resourceId = resourceIcon.getResourceUuid();
long id = resourceManagerUtil.getResourceId(resourceId, resourceType);
Pair<Long, Long> accountDomainPair = getAccountDomain(id, resourceType);
Long domainId = accountDomainPair.second();
Long accountId = accountDomainPair.first();
resourceManagerUtil.checkResourceAccessible(accountId, domainId, String.format("Account ' %s ' doesn't have permissions to upload icon for resource ' %s ", caller, id));
resourceIconDao.remove(resourceIcon.getId());
s_logger.debug("Removed icon for resources (" + String.join(", ", resourceIds) + ")");
}
}
});
return true;
}
Aggregations