@Test public void testInvalidActionParameters() throws Exception { DocumentModel model = session.getDocument(new PathRef("/default-domain/workspaces/test")); String nxql = String.format("SELECT * from ComplexDoc where ecm:parentId='%s'", model.getId()); Map<String, Serializable> params = new HashMap<>(); params.put("action", SetPropertiesAction.ACTION_NAME); params.put("query", nxql); HashMap<String, Serializable> actionParams = new HashMap<>(); actionParams.put("unknown:path", "unknown"); params.put("parameters", OBJECT_MAPPER.writeValueAsString(actionParams)); try { service.run(ctx, BulkRunAction.ID, params); fail("Command should have failed"); } catch (OperationException e) { } }
@OperationMethod(asyncService = BulkService.class) public BulkStatus run() throws IOException, OperationException { if (!admin.getActions().contains(action)) { throw new NuxeoException("Action '" + action + "' not found", HttpServletResponse.SC_NOT_FOUND); } if (!admin.isHttpEnabled(action) && !session.getPrincipal().isAdministrator()) { throw new NuxeoException("Action '" + action + "' denied", HttpServletResponse.SC_FORBIDDEN); } if (query == null && providerName == null) { throw new OperationException("Query and ProviderName cannot be both null"); } PageProviderDefinition def = query != null ? PageProviderHelper.getQueryPageProviderDefinition(query) : PageProviderHelper.getPageProviderDefinition(providerName); if (def == null) { throw new OperationException("Could not get Provider Definition from either query or provider name"); } PageProvider<?> provider = PageProviderHelper.getPageProvider(session, def, namedParameters, null, null, null, null, null, quickFilters, queryParams != null ? queryParams.toArray(new String[0]) : null); query = PageProviderHelper.buildQueryStringWithAggregates(provider); if (query.contains("?")) { throw new OperationException("Query parameters could not be parsed"); } BulkCommand.Builder builder = new BulkCommand.Builder(action, query, session.getPrincipal().getName()); try { builder.params(BulkParameters.paramsToMap(parametersAsJson)); } catch (IOException e) { throw new OperationException("Could not parse parameters, expecting valid json value", e); } if (repositoryName != null) { builder.repository(repositoryName); } else { builder.repository(session.getRepositoryName()); } if (bucketSize > 0) { builder.bucket(bucketSize); } if (batchSize > 0) { builder.batch(batchSize); } String commandId = service.submit(builder.build()); return service.getStatus(commandId); }
BulkRunAction { @OperationMethod(asyncService = BulkService.class) public BulkStatus run() throws IOException, OperationException { if (!admin.getActions().contains(action)) { throw new NuxeoException("Action '" + action + "' not found", HttpServletResponse.SC_NOT_FOUND); } if (!admin.isHttpEnabled(action) && !session.getPrincipal().isAdministrator()) { throw new NuxeoException("Action '" + action + "' denied", HttpServletResponse.SC_FORBIDDEN); } if (query == null && providerName == null) { throw new OperationException("Query and ProviderName cannot be both null"); } PageProviderDefinition def = query != null ? PageProviderHelper.getQueryPageProviderDefinition(query) : PageProviderHelper.getPageProviderDefinition(providerName); if (def == null) { throw new OperationException("Could not get Provider Definition from either query or provider name"); } PageProvider<?> provider = PageProviderHelper.getPageProvider(session, def, namedParameters, null, null, null, null, null, quickFilters, queryParams != null ? queryParams.toArray(new String[0]) : null); query = PageProviderHelper.buildQueryStringWithAggregates(provider); if (query.contains("?")) { throw new OperationException("Query parameters could not be parsed"); } BulkCommand.Builder builder = new BulkCommand.Builder(action, query, session.getPrincipal().getName()); try { builder.params(BulkParameters.paramsToMap(parametersAsJson)); } catch (IOException e) { throw new OperationException("Could not parse parameters, expecting valid json value", e); } if (repositoryName != null) { builder.repository(repositoryName); } else { builder.repository(session.getRepositoryName()); } if (bucketSize > 0) { builder.bucket(bucketSize); } if (batchSize > 0) { builder.batch(batchSize); } String commandId = service.submit(builder.build()); return service.getStatus(commandId); } }
BulkRunAction { @OperationMethod(asyncService = BulkService.class) public BulkStatus run() throws IOException, OperationException { if (!admin.getActions().contains(action)) { throw new NuxeoException("Action '" + action + "' not found", HttpServletResponse.SC_NOT_FOUND); } if (!admin.isHttpEnabled(action) && !session.getPrincipal().isAdministrator()) { throw new NuxeoException("Action '" + action + "' denied", HttpServletResponse.SC_FORBIDDEN); } if (query == null && providerName == null) { throw new OperationException("Query and ProviderName cannot be both null"); } PageProviderDefinition def = query != null ? PageProviderHelper.getQueryPageProviderDefinition(query) : PageProviderHelper.getPageProviderDefinition(providerName); if (def == null) { throw new OperationException("Could not get Provider Definition from either query or provider name"); } PageProvider<?> provider = PageProviderHelper.getPageProvider(session, def, namedParameters, null, null, null, null, null, quickFilters, queryParams != null ? queryParams.toArray(new String[0]) : null); query = PageProviderHelper.buildQueryStringWithAggregates(provider); if (query.contains("?")) { throw new OperationException("Query parameters could not be parsed"); } BulkCommand.Builder builder = new BulkCommand.Builder(action, query, session.getPrincipal().getName()); try { builder.params(BulkParameters.paramsToMap(parametersAsJson)); } catch (IOException e) { throw new OperationException("Could not parse parameters, expecting valid json value", e); } if (repositoryName != null) { builder.repository(repositoryName); } else { builder.repository(session.getRepositoryName()); } if (bucketSize > 0) { builder.bucket(bucketSize); } if (batchSize > 0) { builder.batch(batchSize); } String commandId = service.submit(builder.build()); return service.getStatus(commandId); }  }
BulkRunAction { @OperationMethod(asyncService = BulkService.class) public BulkStatus run() throws IOException, OperationException { if (!admin.getActions().contains(action)) { throw new NuxeoException("Action '" + action + "' not found", HttpServletResponse.SC_NOT_FOUND); } if (!admin.isHttpEnabled(action) && !session.getPrincipal().isAdministrator()) { throw new NuxeoException("Action '" + action + "' denied", HttpServletResponse.SC_FORBIDDEN); } if (query == null && providerName == null) { throw new OperationException("Query and ProviderName cannot be both null"); } PageProviderDefinition def = query != null ? PageProviderHelper.getQueryPageProviderDefinition(query) : PageProviderHelper.getPageProviderDefinition(providerName); if (def == null) { throw new OperationException("Could not get Provider Definition from either query or provider name"); } PageProvider<?> provider = PageProviderHelper.getPageProvider(session, def, namedParameters, null, null, null, null, null, quickFilters, queryParams != null ? queryParams.toArray(new String[0]) : null); query = PageProviderHelper.buildQueryStringWithAggregates(provider); if (query.contains("?")) { throw new OperationException("Query parameters could not be parsed"); } BulkCommand.Builder builder = new BulkCommand.Builder(action, query, session.getPrincipal().getName()); try { builder.params(BulkParameters.paramsToMap(parametersAsJson)); } catch (IOException e) { throw new OperationException("Could not parse parameters, expecting valid json value", e); } if (repositoryName != null) { builder.repository(repositoryName); } else { builder.repository(session.getRepositoryName()); } if (bucketSize > 0) { builder.bucket(bucketSize); } if (batchSize > 0) { builder.batch(batchSize); } String commandId = service.submit(builder.build()); return service.getStatus(commandId); }  @OperationMethod(asyncService = BulkService.class) BulkStatus run(); }
BulkRunAction { @OperationMethod(asyncService = BulkService.class) public BulkStatus run() throws IOException, OperationException { if (!admin.getActions().contains(action)) { throw new NuxeoException("Action '" + action + "' not found", HttpServletResponse.SC_NOT_FOUND); } if (!admin.isHttpEnabled(action) && !session.getPrincipal().isAdministrator()) { throw new NuxeoException("Action '" + action + "' denied", HttpServletResponse.SC_FORBIDDEN); } if (query == null && providerName == null) { throw new OperationException("Query and ProviderName cannot be both null"); } PageProviderDefinition def = query != null ? PageProviderHelper.getQueryPageProviderDefinition(query) : PageProviderHelper.getPageProviderDefinition(providerName); if (def == null) { throw new OperationException("Could not get Provider Definition from either query or provider name"); } PageProvider<?> provider = PageProviderHelper.getPageProvider(session, def, namedParameters, null, null, null, null, null, quickFilters, queryParams != null ? queryParams.toArray(new String[0]) : null); query = PageProviderHelper.buildQueryStringWithAggregates(provider); if (query.contains("?")) { throw new OperationException("Query parameters could not be parsed"); } BulkCommand.Builder builder = new BulkCommand.Builder(action, query, session.getPrincipal().getName()); try { builder.params(BulkParameters.paramsToMap(parametersAsJson)); } catch (IOException e) { throw new OperationException("Could not parse parameters, expecting valid json value", e); } if (repositoryName != null) { builder.repository(repositoryName); } else { builder.repository(session.getRepositoryName()); } if (bucketSize > 0) { builder.bucket(bucketSize); } if (batchSize > 0) { builder.batch(batchSize); } String commandId = service.submit(builder.build()); return service.getStatus(commandId); }  @OperationMethod(asyncService = BulkService.class) BulkStatus run(); static final String ID; }