@Override public void write(OutputStream os) throws IOException, WebApplicationException { PrintWriter pw = new PrintWriter(os); Iterator<CallTimeDataComposite> i = callTimes.iterator(); if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) { pw.print("[");
for (Iterator<Resource> i = results.iterator(); i.hasNext();) { Resource r = i.next(); Integer typeId = r.getResourceType().getId();
Iterator<ResourceGroupComposite> iterator = groupComposites.iterator(); while (iterator.hasNext()) { ResourceGroupComposite groupComposite = iterator.next();
@Override public List<BundleResourceDeploymentHistory> getBundleResourceDeploymentHistories(Subject subject, int resourceDeploymentId) { // First check if this user can actually see this resource deployment // by calling #findBundleResourceDeploymentsByCriteria) BundleResourceDeploymentCriteria criteria = new BundleResourceDeploymentCriteria(); criteria.addFilterId(resourceDeploymentId); criteria.fetchHistories(true); criteria.setPageControl(PageControl.getSingleRowInstance()); PageList<BundleResourceDeployment> bundleResourceDeploymentsByCriteria = findBundleResourceDeploymentsByCriteria( subject, criteria); if (bundleResourceDeploymentsByCriteria.isEmpty()) { return Collections.emptyList(); } BundleResourceDeployment resourceDeployment = bundleResourceDeploymentsByCriteria.iterator().next(); return new ArrayList<BundleResourceDeploymentHistory>(resourceDeployment.getBundleResourceDeploymentHistories()); }
@Override public PageList<BundleDeployment> findBundleDeploymentsByCriteria(Subject subject, BundleDeploymentCriteria criteria) { CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria); // filter by bundles that are viewable if (!authorizationManager.hasGlobalPermission(subject, Permission.VIEW_BUNDLES)) { generator.setAuthorizationBundleFragment(CriteriaQueryGenerator.AuthorizationTokenType.BUNDLE, subject.getId(), "bundleVersion.bundle"); } CriteriaQueryRunner<BundleDeployment> queryRunner = new CriteriaQueryRunner<BundleDeployment>(criteria, generator, entityManager); PageList<BundleDeployment> result = queryRunner.execute(); // The result currently holds bundle deployments for bundles viewable by the caller, but we must remove // those bundle deployments for destinations not viewable by the user. In essence we wanted two authz tokens, // one for bundle and one for resource group, but we can only supply one. if (!(result.isEmpty() || authorizationManager.isInventoryManager(subject))) { for (Iterator<BundleDeployment> i = result.iterator(); i.hasNext();) { BundleDeployment bd = i.next(); int groupId = bd.getDestination().getGroup().getId(); if (!authorizationManager.canViewGroup(subject, groupId)) { i.remove(); } } } return result; }
for (Integer resourceId : resourceIds) { if (!authorizationManager.canViewResource(subject, resourceId)) { for (Iterator<BundleResourceDeployment> i = result.iterator(); i.hasNext();) { BundleResourceDeployment brd = i.next(); if (brd.getResource().getId() == resourceId.intValue()) {
PageList<ResourceOperationHistory> historyItems = operationManager .findResourceOperationHistoriesByCriteria(subject, criteria); Iterator<ResourceOperationHistory> iter = historyItems.iterator(); if (iter.hasNext()) { if (log.isDebugEnabled()) {