Search in sources :

Example 1 with ResourceIcon

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);
    }
}
Also used : ResourceIconResponse(org.apache.cloudstack.api.response.ResourceIconResponse) DomainResponse(org.apache.cloudstack.api.response.DomainResponse) ResourceIcon(com.cloud.server.ResourceIcon)

Example 2 with ResourceIcon

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);
    }
}
Also used : ResourceIconResponse(org.apache.cloudstack.api.response.ResourceIconResponse) DomainResponse(org.apache.cloudstack.api.response.DomainResponse) ResourceIcon(com.cloud.server.ResourceIcon)

Example 3 with ResourceIcon

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);
    }
}
Also used : ResourceIconResponse(org.apache.cloudstack.api.response.ResourceIconResponse) PhysicalNetworkResponse(org.apache.cloudstack.api.response.PhysicalNetworkResponse) NetworkResponse(org.apache.cloudstack.api.response.NetworkResponse) ResourceIcon(com.cloud.server.ResourceIcon)

Example 4 with ResourceIcon

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);
    }
}
Also used : ResourceTag(com.cloud.server.ResourceTag) ResourceIconResponse(org.apache.cloudstack.api.response.ResourceIconResponse) ResourceIcon(com.cloud.server.ResourceIcon) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse)

Example 5 with ResourceIcon

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;
}
Also used : Account(com.cloud.user.Account) TransactionStatus(com.cloud.utils.db.TransactionStatus) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) ResourceIcon(com.cloud.server.ResourceIcon) Pair(com.cloud.utils.Pair) ActionEvent(com.cloud.event.ActionEvent)

Aggregations

ResourceIcon (com.cloud.server.ResourceIcon)11 ResourceIconResponse (org.apache.cloudstack.api.response.ResourceIconResponse)10 DomainResponse (org.apache.cloudstack.api.response.DomainResponse)2 TemplateResponse (org.apache.cloudstack.api.response.TemplateResponse)2 ActionEvent (com.cloud.event.ActionEvent)1 ResourceTag (com.cloud.server.ResourceTag)1 Account (com.cloud.user.Account)1 Pair (com.cloud.utils.Pair)1 TransactionCallbackNoReturn (com.cloud.utils.db.TransactionCallbackNoReturn)1 TransactionStatus (com.cloud.utils.db.TransactionStatus)1 AccountResponse (org.apache.cloudstack.api.response.AccountResponse)1 NetworkResponse (org.apache.cloudstack.api.response.NetworkResponse)1 PhysicalNetworkResponse (org.apache.cloudstack.api.response.PhysicalNetworkResponse)1 ProjectResponse (org.apache.cloudstack.api.response.ProjectResponse)1 UserResponse (org.apache.cloudstack.api.response.UserResponse)1 UserVmResponse (org.apache.cloudstack.api.response.UserVmResponse)1 VpcResponse (org.apache.cloudstack.api.response.VpcResponse)1