private State askForState(PrismObject object) throws IOException { log.info("Do you really want to delete object '" + object.toDebugName() + "'? Yes/No/Cancel");
public void print(Log log) { log.info(print()); lastPrintoutNow(); }
private RestService setupRestService(ConnectionOptions options) { log.info("Initializing rest service"); String url = options.getUrl(); String username = options.getUsername(); String password = getPassword(options); if (url == null) { throw new IllegalStateException("Url is not defined"); } return new RestService(url, username, password); }
@Override public void execute() throws Exception { OperationResult result = new OperationResult(getOperationName()); OperationStatus operation = new OperationStatus(context, result); // "+ 2" will be used for consumer and progress reporter ExecutorService executor = Executors.newFixedThreadPool(options.getMultiThread() + 2); BlockingQueue<PrismObject> queue = new LinkedBlockingQueue<>(QUEUE_CAPACITY_PER_THREAD * options.getMultiThread()); List<SearchProducerWorker> producers = createProducers(queue, operation); log.info("Starting " + getOperationShortName()); operation.start(); // execute as many producers as there are threads for them for (int i = 0; i < producers.size() && i < options.getMultiThread(); i++) { executor.execute(producers.get(i)); } Thread.sleep(CONSUMERS_WAIT_FOR_START); executor.execute(new ProgressReporterWorker(context, options, queue, operation)); Runnable consumer = createConsumer(queue, operation); executor.execute(consumer); // execute rest of the producers for (int i = options.getMultiThread(); i < producers.size(); i++) { executor.execute(producers.get(i)); } executor.shutdown(); executor.awaitTermination(NinjaUtils.WAIT_FOR_EXECUTOR_FINISH, TimeUnit.DAYS); handleResultOnFinish(operation, "Finished " + getOperationShortName()); }
private void deleteByFilter(ObjectQuery query) throws SchemaException, IOException { OperationResult result = new OperationResult(OPERATION_DELETE); OperationStatus operation = new OperationStatus(context, result); operation.start(); log.info("Starting delete"); ObjectTypes type = options.getType(); if (type != null) { deleteByFilter(type, query, operation, result); } else { for (ObjectTypes t : ObjectTypes.values()) { if (Modifier.isAbstract(t.getClassDefinition().getModifiers())) { continue; } deleteByFilter(t, query, operation, result); } } handleResultOnFinish(operation, "Delete finished"); }
protected void handleResultOnFinish(OperationStatus operation, String finishMessage) { OperationResult result = operation.getResult(); result.recomputeStatus(); if (result.isAcceptable()) { log.info("{} in {}s. {}", finishMessage, NinjaUtils.DECIMAL_FORMAT.format(operation.getTotalTime()), operation.print()); } else { log.error("{} in {}s with some problems, reason: {}. {}", finishMessage, NinjaUtils.DECIMAL_FORMAT.format(operation.getTotalTime()), result.getMessage(), operation.print()); if (context.isVerbose()) { log.error("Full result\n{}", result.debugDumpLazily()); } } }
@Override public void execute() throws Exception { RepositoryService repository = context.getRepository(); FileReference fileReference = options.getFilter(); if (fileReference != null && options.getFilter() == null) { throw new NinjaException("Type must be defined"); } List<ObjectTypes> types = NinjaUtils.getTypes(options.getType()); int total = 0; OperationResult result = new OperationResult(OPERATION_COUNT); for (ObjectTypes type : types) { ObjectQuery query = NinjaUtils.createObjectQuery(options.getFilter(), context, type.getClassDefinition()); int count = repository.countObjects(type.getClassDefinition(), query, new ArrayList<>(), result); if (count == 0 && options.getType() == null) { continue; } log.info("{}:\t{}", type.name(), count); total += count; } log.info("===\nTotal:\t{}", total); } }
private RepositoryService setupRepositoryViaMidPointHome(ConnectionOptions options) { log.info("Initializing repository using midpoint home"); System.setProperty(MIDPOINT_SILENT_PROPERTY_NAME, "true"); String midpointHome = options.getMidpointHome(); String jdbcUrl = options.getUrl(); String jdbcUsername = options.getUsername(); String jdbcPassword = getPassword(options); System.setProperty(MIDPOINT_HOME_OPTION, midpointHome); InitializationBeanPostprocessor postprocessor = new InitializationBeanPostprocessor(); postprocessor.setJdbcUrl(jdbcUrl); postprocessor.setJdbcUsername(jdbcUsername); postprocessor.setJdbcPassword(jdbcPassword); GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.addBeanFactoryPostProcessor(beanFactory -> beanFactory.addBeanPostProcessor(postprocessor)); ctx.load(CTX_NINJA); ctx.load(CTX_MIDPOINT); ctx.refresh(); context = ctx; return context.getBean(REPOSITORY_SERVICE_BEAN, RepositoryService.class); }