@Override public int getResourceId() { if (resource == null) { return 0; } return resource.getId(); }
private Collection<Resource> filterOutAlreadySelectedResources(Collection<Resource> foundResources, Collection<Integer> alreadySelectedResourceIds) { List<Resource> result = new LinkedList<Resource>(); for (Resource foundResource : foundResources) { if (!alreadySelectedResourceIds.contains(foundResource.getId())) { result.add(foundResource); } } return result; } }
private String getDetailsURL(Resource resource, HttpServletRequest request) { String protocol; if (request.isSecure()) { protocol = "https"; } else { protocol = "http"; } return protocol + "://" + request.getServerName() + ":" + request.getServerPort() + "/coregui/#Resource/" + resource.getId(); } }
public static void externalizeJobValues(JobDataMap jobDataMap, String key, List<Resource> resources) { if (resources != null && resources.size() > 0) { StringBuilder valuesCommaSeparated = new StringBuilder(); valuesCommaSeparated.append(resources.get(0).getId()); for (int i = 1; i < resources.size(); i++) { valuesCommaSeparated.append(",").append(resources.get(i).getId()); } jobDataMap.put(key, valuesCommaSeparated.toString()); } }
public EventSource(@NotNull String location, @NotNull EventDefinition eventDefinition, @NotNull Resource resource) { if (location == null) throw new IllegalArgumentException("location parameter must not be null."); if (eventDefinition == null) throw new IllegalArgumentException("eventDefinition parameter must not be null."); if (resource == null) throw new IllegalArgumentException("resource parameter must not be null."); this.location = location; this.eventDefinition = eventDefinition; this.resource = resource; this.resourceId = this.resource.getId(); }
@Override public void resourceActivated(Resource resource) { // Schedule content discovery if resource is synchronized and COMMITED if (resource.getId() != 0 && resource.getInventoryStatus() == COMMITTED) { ContentManager.this.scheduleDiscoveries(resource); } }
@Override public String toString() { return "org.rhq.core.domain.alert.AlertDefinition" + "[ " + "id=" + id + ", " + "name=" + name + ", " + "conditionExpression=" + conditionExpression + ", " + "priority=" + priority + ", " + ((resource != null) ? ("resourceId=" + resource.getId()) : "") + ((resourceType != null) ? ("resourceTypeId=" + resourceType.getId()) : "") + " ]"; } }
private String getDetailsURL(ResourceConfigurationUpdate configUpdate) { String protocol; if (request.isSecure()) { protocol = "https"; } else { protocol = "http"; } return protocol + "://" + request.getServerName() + ":" + request.getServerPort() + "/coregui/#Resource/" + configUpdate.getResource().getId() + "/Configuration/History/" + configUpdate.getId(); } };
private String getDetailsURL(ResourceOperationHistory history) { String protocol; if (request.isSecure()) { protocol = "https"; } else { protocol = "http"; } return protocol + "://" + request.getServerName() + ":" + request.getServerPort() + "/coregui/#Resource/" + history.getResource().getId() + "/Operations/History/" + history.getId(); }
@Override public Map<Integer, InventoryStatus> getResourceStatuses(int rootResourceId, boolean descendents) { Resource root = entityManager.find(Resource.class, rootResourceId); Map<Integer, InventoryStatus> statuses = new LinkedHashMap<Integer, InventoryStatus>(); statuses.put(root.getId(), root.getInventoryStatus()); getResourceStatuses(rootResourceId, descendents, statuses); return statuses; }
@Override public Resource getParentResource(Subject subject, int resourceId) { Resource resource = getParentResource(resourceId); if (!authorizationManager.canViewResource(subject, resource.getId())) { throw new PermissionException("User [" + subject + "] does not have permission to view resource [" + resource.getId() + "]"); } return resource; }
@Override public void updateDriftDefinition(Subject subject, DriftDefinition driftDefinition) { authorizeOrFail(subject, driftDefinition.getResource().getId(), "Can not update drifts"); entityManager.merge(driftDefinition); }
private String getDetailsURL(Alert alert) { String protocol; if (request.isSecure()) { protocol = "https"; } else { protocol = "http"; } return protocol + "://" + request.getServerName() + ":" + request.getServerPort() + "/coregui/#Resource/" + alert.getAlertDefinition().getResource().getId() + "/Alerts/History/" + alert.getId(); }
static public Configuration getResourceConfiguration(InventoryManager inventoryManager, Resource resource) { Configuration result = resource.getResourceConfiguration(); if (null == result) { result = loadConfigurationFromFile(inventoryManager, resource.getId()); } return result; }
void registerEventPoller(EventPoller poller, int pollingInterval, Resource resource, String sourceLocation) { EventPollerRunner pollerRunner = new EventPollerRunner(poller, resource, this); Runnable pollerFuture = (Runnable) this.pollerThreadPool.scheduleAtFixedRate(pollerRunner, POLLER_INITIAL_DELAY_SECS, pollingInterval, TimeUnit.SECONDS); PollerKey pollerKey = new PollerKey(resource.getId(), poller.getEventType(), sourceLocation); this.pollerThreads.put(pollerKey, pollerFuture); }
private String getDetailsURL(DriftComposite driftDetails) { String protocol; if (request.isSecure()) { protocol = "https"; } else { protocol = "http"; } return protocol + "://" + request.getServerName() + ":" + request.getServerPort() + "/coregui/#Resource/" + driftDetails.getResource().getId() + "/Drift/Definitions/" + driftDetails.getDrift().getChangeSet().getDriftDefinitionId() + "/Drift/0id_" + driftDetails.getDrift().getId(); }
private void initChildren() { ResourceCriteria criteria = new ResourceCriteria(); criteria.addFilterParentResourceId(resourceId); criteria.clearPaging();//disable paging as the code assumes all the results will be returned. PageList<Resource> childResources = remoteClient.getProxy(ResourceManagerRemote.class).findResourcesByCriteria( remoteClient.getSubject(), criteria); for (Resource child : childResources) { this.children.add(proxyFactory.getResource(child.getId())); } }
private boolean checkViewPermission(Subject subject, AlertDefinition alertDefinition) { if (alertDefinition.getResourceType() != null) { // an alert template return true; // anyone can view templates } else if (alertDefinition.getGroup() != null) { // a groupAlertDefinition return authorizationManager.canViewGroup(subject, alertDefinition.getGroup().getId()); } else { // an alert definition return authorizationManager.canViewResource(subject, alertDefinition.getResource().getId()); } }
public static EntityContext forGroup(ResourceGroup group) { EntityContext context = new EntityContext(null, group.getId(), null, null); context.isAutoCluster = group.getClusterResourceGroup() != null; context.isAutoGroup = group.getSubject() != null; if (context.isAutoGroup) { context.parentResourceId = group.getAutoGroupParentResource().getId(); context.resourceTypeId = group.getResourceType().getId(); } return context; }