targetSet.addAll(objectsToCIs(objects)); if (applyRules) { planOperation(); } else {
/** * Assert that the user may delete the given objects. Never fails for system types. * @param className a class name * @param ids instance IDs * @throws GraphException if the user may not delete all of the objects */ private void assertMayBeDeleted(String className, Collection<Long> ids) throws GraphException { assertPermissions(idsToCIs(className, ids), Collections.singleton(Ability.DELETE)); }
targetObjectCount += targetMultimap.size(); final Entry<SetMultimap<String, Long>, SetMultimap<String, Long>> plan = graphTraversal.planOperation(targetMultimap, true, true); return Maps.immutableEntry(plan.getKey(), GraphUtil.arrangeDeletionTargets(helper.getSession(), plan.getValue())); case 2: graphTraversal.assertNoPolicyViolations(); return null; case 3: processor = graphTraversal.processTargets(); return null; case 4: unlinker = graphTraversal.unlinkTargets(false); graphTraversal = null; return null;
targetObjectCount += targetMultimap.size(); final Entry<SetMultimap<String, Long>, SetMultimap<String, Long>> plan = graphTraversal.planOperation(targetMultimap, true, true); if (plan.getValue().isEmpty()) { graphTraversal.assertNoUnlinking(); } else { final Exception e = new IllegalArgumentException("duplication plan unexpectedly includes deletion"); graphTraversal.assertNoPolicyViolations(); return null; case 2: processor = graphTraversal.processTargets(); return null; case 3:
if (instance.isLoaded() && instance.getDetails() != null) { final CI object = new CI(instance); noteDetails(object, instance.getDetails()); targetSet.add(object); } else { targetSet.addAll(objectsToCIs(objectsToQuery)); if (applyRules) { planOperation(); } else {
case 1: final Map.Entry<SetMultimap<String, Long>, SetMultimap<String, Long>> plan = graphTraversal.planOperation(targetMultimap, true, true); targetMultimap.clear(); if (plan.getValue().isEmpty()) { graphTraversal.assertNoUnlinking(); } else { final Exception e = new IllegalStateException("querying the model graph does not delete any objects"); processor = graphTraversal.processTargets(); return null; case 3:
final CPI linkSource = linkProperty.toCPI(object.id); for (final CI linked : planning.forwardLinksCached.get(linkSource)) { final Action linkedAction = getAction(linked); if (linkedAction == Action.DELETE || isUnlinkIncludeFromExclude && linkedAction == Action.EXCLUDE) { addRemoval(linkerToIdToLinked, linkProperty.toCPI(object.id), linked); } else { toNullByCP.put(linkProperty, object.id); final CPI linkTarget = linkProperty.toCPI(object.id); for (final CI linker : planning.backwardLinksCached.get(linkTarget)) { final Action linkerAction = getAction(linker); if (linkerAction == Action.EXCLUDE) { addRemoval(linkerToIdToLinked, linkProperty.toCPI(linker.id), object); } else { toNullByCP.put(linkProperty, linker.id); final CPI linkTarget = linkProperty.toCPI(object.id); for (final CI linker : planning.backwardLinksCached.get(linkTarget)) { final Action linkerAction = getAction(linker); if (linkerAction != Action.DELETE) { addRemoval(linkerToIdToLinked, linkProperty.toCPI(linker.id), object); } else { toNullByCP.put(linkProperty, linker.id); assertMayBeUpdated(linker.className, allIds);
@Override public Object step(int step) throws Cancel { helper.assertStep(step); try { switch (step) { case 0: final SetMultimap<String, Long> targetMultimap = graphHelper.getTargetMultimap(targetClasses, targetObjects); targetObjectCount += targetMultimap.size(); final Entry<SetMultimap<String, Long>, SetMultimap<String, Long>> plan = graphTraversal.planOperation(targetMultimap, true, true); if (!plan.getValue().isEmpty()) { final Exception e = new IllegalStateException("querying the model graph does not delete any objects"); helper.cancel(new ERR(), e, "graph-fail"); } return plan.getKey(); default: final Exception e = new IllegalArgumentException("model object graph operation has no step " + step); throw helper.cancel(new ERR(), e, "bad-step"); } } catch (Cancel c) { throw c; } catch (GraphException ge) { final omero.cmd.GraphException graphERR = new omero.cmd.GraphException(); graphERR.message = ge.message; throw helper.cancel(graphERR, ge, "graph-fail"); } catch (Throwable t) { throw helper.cancel(new ERR(), t, "graph-fail"); } }
final String className = oneClassToJoin.getKey(); final Collection<Long> allIds = oneClassToJoin.getValue(); assertMayBeProcessed(className, allIds); final String className = oneClassToDelete.getKey(); final Collection<Long> allIds = oneClassToDelete.getValue(); assertMayBeDeleted(className, allIds);
reviewObject(nextObject, false); if (!toCache.isEmpty()) { optimisticReprocess = null; cache(toCache); continue; final Set<CI> previousFindIfLast = new HashSet<CI>(planning.findIfLast); for (final CI nextObject : previousToProcess) { reviewObject(nextObject, false);
@Override public void init(Helper helper) { if (LOGGER.isDebugEnabled()) { final GraphUtil.ParameterReporter arguments = new GraphUtil.ParameterReporter(); arguments.addParameter("targetClasses", targetClasses); arguments.addParameter("targetObjects", targetObjects); LOGGER.debug("request: " + arguments); } this.helper = helper; helper.setSteps(5); this.graphHelper = new GraphHelper(helper, graphPathBean); graphTraversal = new GraphTraversal(helper.getSession(), helper.getEventContext(), aclVoter, graphPathBean, null, graphPolicy, new InternalProcessor()); }
targetObjectCount += targetMultimap.size(); final Entry<SetMultimap<String, Long>, SetMultimap<String, Long>> plan = graphTraversal.planOperation(targetMultimap, true, true); return Maps.immutableEntry(plan.getKey(), GraphUtil.arrangeDeletionTargets(helper.getSession(), plan.getValue())); case 1: graphTraversal.assertNoPolicyViolations(); return null; case 2: processor = graphTraversal.processTargets(); return null; case 3: unlinker = graphTraversal.unlinkTargets(true); graphTraversal = null; return null;
@Override public Object step(int step) throws Cancel { helper.assertStep(step); try { switch (step) { case 0: final SetMultimap<String, Long> targetMultimap = graphHelper.getTargetMultimap(targetClasses, targetObjects); targetObjectCount += targetMultimap.size(); final Entry<SetMultimap<String, Long>, SetMultimap<String, Long>> plan = graphTraversal.planOperation(targetMultimap, true, true); if (!plan.getValue().isEmpty()) { final Exception e = new IllegalStateException("querying the model graph does not delete any objects"); helper.cancel(new ERR(), e, "graph-fail"); } return plan.getKey(); default: final Exception e = new IllegalArgumentException("model object graph operation has no step " + step); throw helper.cancel(new ERR(), e, "bad-step"); } } catch (Cancel c) { throw c; } catch (GraphException ge) { final omero.cmd.GraphException graphERR = new omero.cmd.GraphException(); graphERR.message = ge.message; throw helper.cancel(graphERR, ge, "graph-fail"); } catch (Throwable t) { throw helper.cancel(new ERR(), t, "graph-fail"); } }
return new GraphTraversal(helper.getSession(), helper.getEventContext(), aclVoter, graphPathBean, unnullable, graphPolicy, processor);
if (isToGroupReadable) { plan = graphTraversal.planOperation(targetMultimap, true, false); } else { plan = graphTraversal.planOperation(targetsNotPrivate, true, true); graphTraversal.assertNoPolicyViolations(); return null; case 2: processor = graphTraversal.processTargets(); return null; case 3: unlinker = graphTraversal.unlinkTargets(false); graphTraversal = null; return null;
/** * Assert that the user may update the given objects. Never fails for system types. * @param className a class name * @param ids instance IDs * @throws GraphException if the user may not update all of the objects */ private void assertMayBeUpdated(String className, Collection<Long> ids) throws GraphException { assertPermissions(idsToCIs(className, ids), Collections.singleton(Ability.UPDATE)); }
targetObjectCount += targetMultimap.size(); final Entry<SetMultimap<String, Long>, SetMultimap<String, Long>> plan = graphTraversal.planOperation(targetMultimap, false, true); if (!plan.getKey().isEmpty()) { final Exception e = new IllegalStateException("deletion does not do anything other than delete"); graphTraversal.assertNoPolicyViolations(); return null; case 2: processor = graphTraversal.processTargets(); return null; case 3: unlinker = graphTraversal.unlinkTargets(true); graphTraversal = null; return null;
/** * Assert that the processor may operate upon the given objects with {@link Processor#processInstances(String, Collection)}. * Never fails for system types. * @param className a class name * @param ids instance IDs * @throws GraphException if the user does not have the necessary permissions for all of the objects */ private void assertMayBeProcessed(String className, Collection<Long> ids) throws GraphException { final Set<CI> objects = idsToCIs(className, ids); assertPermissions(objects, processor.getRequiredPermissions()); if (isCheckUserPermissions) { for (final CI object : Sets.difference(objects, planning.overrides)) { try { processor.assertMayProcess(object.className, object.id, planning.detailsNoted.get(object)); } catch (GraphException e) { throw new GraphException("cannot process " + object + ": " + e.message); } } } }