@SuppressWarnings("unchecked") @Override public AbstractGeoGigOp<?> decorate(Object subject) { Preconditions.checkNotNull(subject); AbstractGeoGigOp<?> operation = (AbstractGeoGigOp<?>) subject; Boolean conflicts = operation.command(ConflictsCheckOp.class).call(); if (conflicts.booleanValue()) { throw new ConflictsException( "Cannot run operation while merge or rebase conflicts exist."); } return (AbstractGeoGigOp<?>) subject; }
@Override public AbstractGeoGigOp<?> decorate(Object subject) { Preconditions.checkNotNull(subject); AbstractGeoGigOp<?> operation = (AbstractGeoGigOp<?>) subject; Boolean conflicts = operation.command(ConflictsCheckOp.class).call(); if (conflicts.booleanValue()) { throw new ConflictsException( "Cannot run operation while merge or rebase conflicts exist."); } return (AbstractGeoGigOp<?>) subject; }
@Override public <C extends AbstractGeoGigOp<?>> C pre(C command) throws CannotRunGeogigOperationException { /* * Store the ref name and its old value in the command's user properties to be used in the * post-hook if the operation was successful */ Map<String, Object> params = Scripting.getParamMap(command); String refName = (String) params.get("name"); command.getClientData().put("name", refName); // ignore if still inside a transaction or updating a known symref boolean ignore = command.context() instanceof GeogigTransaction; ignore |= (Ref.WORK_HEAD.equals(refName) || Ref.STAGE_HEAD.equals(refName)); if (ignore) { command.getClientData().put("ignore", Boolean.TRUE); // ignore updates to work/stage heads, we only care of updates to branches return command; } Optional<Ref> currentValue = command.command(RefParse.class).setName(refName).call(); command.getClientData().put("oldValue", currentValue); LOGGER.debug("GWC geogig truncate pre-hook engaged for ref '{}'", refName); return command; }
Map<String, Object> params = getParamMap(operation); engine.put(PARAMS, params); Repository repo = operation.command(ResolveRepository.class).call(); GeoGigAPI api = new GeoGigAPI(repo); engine.put(GEOGIG, api);
assertEquals(context, testOp.context()); testOp.command(AbstractGeoGigOp.class); verify(context).command(AbstractGeoGigOp.class);