@Override public FlowControllerSchema apply(TemplateDTO templateDTO) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.NAME_KEY, templateDTO.getName()); map.put(CommonPropertyKeys.COMMENT_KEY, templateDTO.getDescription()); return new FlowControllerSchema(map); } }
public FlowControllerSchema(Map map) { name = getRequiredKeyAsType(map, NAME_KEY, String.class, FLOW_CONTROLLER_PROPS_KEY); comment = getOptionalKeyAsType(map, COMMENT_KEY, String.class, FLOW_CONTROLLER_PROPS_KEY, ""); }
@Override public ConfigSchema apply(final VersionedFlowSnapshot versionedFlowSnapshot) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.FLOW_CONTROLLER_PROPS_KEY, flowControllerSchemaFunction.apply(versionedFlowSnapshot).toMap()); VersionedProcessGroup versionedProcessGroup = versionedFlowSnapshot.getFlowContents(); addVersionedProcessGroup(map, versionedProcessGroup); return new ConfigSchema(map); }
@Test public void testUser3() throws Exception { SSLContext sslContext = loadSslContext("user3"); assertReturnCode("", sslContext, 400); ConfigSchema configSchema = assertReturnCode("?class=raspi2", sslContext, 200); assertEquals("raspi2.v1", configSchema.getFlowControllerProperties().getName()); configSchema = assertReturnCode("?class=raspi3", sslContext, 200); assertEquals("raspi3.v2", configSchema.getFlowControllerProperties().getName()); }
processGroupSchema.setName(flowControllerProperties.getName()); processGroupSchema.setComment(flowControllerProperties.getComment());
@Test public void testCurrentVersion() throws IOException, SchemaLoaderException { ConfigSchema configSchema = getConfigSchema(c2Url + "?class=raspi3"); assertEquals(3, configSchema.getVersion()); assertEquals("raspi3.v2", configSchema.getFlowControllerProperties().getName()); }
@Test public void testVersion1() throws IOException, SchemaLoaderException { ConfigSchema configSchema = getConfigSchema(c2Url + "?class=raspi3&version=1"); assertEquals(3, configSchema.getVersion()); assertEquals("raspi3.v1", configSchema.getFlowControllerProperties().getName()); }
@Override public ConfigSchema apply(TemplateDTO templateDTO) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.FLOW_CONTROLLER_PROPS_KEY, flowControllerSchemaFunction.apply(templateDTO).toMap()); FlowSnippetDTO snippet = templateDTO.getSnippet(); addSnippet(map, snippet); return new ConfigSchema(map); }
@Override public FlowControllerSchema apply(TemplateDTO templateDTO) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.NAME_KEY, templateDTO.getName()); map.put(CommonPropertyKeys.COMMENT_KEY, templateDTO.getDescription()); return new FlowControllerSchema(map); } }
@Test public void testVersion2() throws IOException, SchemaLoaderException { ConfigSchema configSchema = getConfigSchema(c2Url + "?class=raspi3&version=2"); assertEquals(3, configSchema.getVersion()); assertEquals("raspi3.v2", configSchema.getFlowControllerProperties().getName()); }
@Override public ConfigSchema apply(TemplateDTO templateDTO) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.FLOW_CONTROLLER_PROPS_KEY, flowControllerSchemaFunction.apply(templateDTO).toMap()); FlowSnippetDTO snippet = templateDTO.getSnippet(); addSnippet(map, snippet); return new ConfigSchema(map); }
@Override public FlowControllerSchema apply(final VersionedFlowSnapshot versionedFlowSnapshot) { // If the VersionedFlowSnapshot came directly from NiFi Registry without modification, as would be the // case with C2 server, then we should have a non-null VersionedFlow, but if we're using a snapshot that // was export from another tool like the CLI, the flow may be null'd out, so fall back to root group. String name; String description; if (versionedFlowSnapshot.getFlow() == null) { name = versionedFlowSnapshot.getFlowContents().getName(); description = versionedFlowSnapshot.getFlowContents().getComments(); } else { name = versionedFlowSnapshot.getFlow().getName(); description = versionedFlowSnapshot.getFlow().getDescription(); } Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.NAME_KEY, name); map.put(CommonPropertyKeys.COMMENT_KEY, description); return new FlowControllerSchema(map); } }
@Test public void testUser1() throws Exception { SSLContext sslContext = loadSslContext("user1"); assertReturnCode("", sslContext, 403); ConfigSchema configSchema = assertReturnCode("?class=raspi2", sslContext, 200); assertEquals("raspi2.v1", configSchema.getFlowControllerProperties().getName()); assertReturnCode("?class=raspi3", sslContext, 403); }
@Override public ConfigSchema apply(final VersionedFlowSnapshot versionedFlowSnapshot) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.FLOW_CONTROLLER_PROPS_KEY, flowControllerSchemaFunction.apply(versionedFlowSnapshot).toMap()); VersionedProcessGroup versionedProcessGroup = versionedFlowSnapshot.getFlowContents(); addVersionedProcessGroup(map, versionedProcessGroup); return new ConfigSchema(map); }
@Override public FlowControllerSchema apply(final VersionedFlowSnapshot versionedFlowSnapshot) { // If the VersionedFlowSnapshot came directly from NiFi Registry without modification, as would be the // case with C2 server, then we should have a non-null VersionedFlow, but if we're using a snapshot that // was export from another tool like the CLI, the flow may be null'd out, so fall back to root group. String name; String description; if (versionedFlowSnapshot.getFlow() == null) { name = versionedFlowSnapshot.getFlowContents().getName(); description = versionedFlowSnapshot.getFlowContents().getComments(); } else { name = versionedFlowSnapshot.getFlow().getName(); description = versionedFlowSnapshot.getFlow().getDescription(); } Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.NAME_KEY, name); map.put(CommonPropertyKeys.COMMENT_KEY, description); return new FlowControllerSchema(map); } }
@Test public void testUser2() throws Exception { SSLContext sslContext = loadSslContext("user2"); assertReturnCode("", sslContext, 403); assertReturnCode("?class=raspi2", sslContext, 403); ConfigSchema configSchema = assertReturnCode("?class=raspi3", sslContext, 200); assertEquals("raspi3.v2", configSchema.getFlowControllerProperties().getName()); }