mirror of https://github.com/apache/nifi.git
NIFI-670:
- Preventing duplicate controller services from being created when copying and pasting processors. A new controller service will be included/created when using templates.
This commit is contained in:
parent
e50b20c4ce
commit
b7b42c7423
|
@ -472,7 +472,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
|
|
||||||
// build the snippet dto
|
// build the snippet dto
|
||||||
final SnippetDTO responseSnippetDto = dtoFactory.createSnippetDto(snippet);
|
final SnippetDTO responseSnippetDto = dtoFactory.createSnippetDto(snippet);
|
||||||
responseSnippetDto.setContents(snippetUtils.populateFlowSnippet(snippet, false));
|
responseSnippetDto.setContents(snippetUtils.populateFlowSnippet(snippet, false, false));
|
||||||
|
|
||||||
// save updated controller if applicable
|
// save updated controller if applicable
|
||||||
if (snippetDto.getParentGroupId() != null && snippet.isLinked()) {
|
if (snippetDto.getParentGroupId() != null && snippet.isLinked()) {
|
||||||
|
@ -995,7 +995,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
// add the snippet
|
// add the snippet
|
||||||
final Snippet snippet = snippetDAO.createSnippet(snippetDTO);
|
final Snippet snippet = snippetDAO.createSnippet(snippetDTO);
|
||||||
final SnippetDTO responseSnippetDTO = dtoFactory.createSnippetDto(snippet);
|
final SnippetDTO responseSnippetDTO = dtoFactory.createSnippetDto(snippet);
|
||||||
responseSnippetDTO.setContents(snippetUtils.populateFlowSnippet(snippet, false));
|
responseSnippetDTO.setContents(snippetUtils.populateFlowSnippet(snippet, false, false));
|
||||||
|
|
||||||
return responseSnippetDTO;
|
return responseSnippetDTO;
|
||||||
}
|
}
|
||||||
|
@ -1092,7 +1092,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
templateDTO.setName(name);
|
templateDTO.setName(name);
|
||||||
templateDTO.setDescription(description);
|
templateDTO.setDescription(description);
|
||||||
templateDTO.setTimestamp(new Date());
|
templateDTO.setTimestamp(new Date());
|
||||||
templateDTO.setSnippet(snippetUtils.populateFlowSnippet(snippet, true));
|
templateDTO.setSnippet(snippetUtils.populateFlowSnippet(snippet, true, true));
|
||||||
|
|
||||||
// set the id based on the specified seed
|
// set the id based on the specified seed
|
||||||
final ClusterContext clusterContext = ClusterContextThreadLocal.getContext();
|
final ClusterContext clusterContext = ClusterContextThreadLocal.getContext();
|
||||||
|
@ -1972,7 +1972,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
public SnippetDTO getSnippet(String snippetId) {
|
public SnippetDTO getSnippet(String snippetId) {
|
||||||
final Snippet snippet = snippetDAO.getSnippet(snippetId);
|
final Snippet snippet = snippetDAO.getSnippet(snippetId);
|
||||||
final SnippetDTO snippetDTO = dtoFactory.createSnippetDto(snippet);
|
final SnippetDTO snippetDTO = dtoFactory.createSnippetDto(snippet);
|
||||||
snippetDTO.setContents(snippetUtils.populateFlowSnippet(snippet, false));
|
snippetDTO.setContents(snippetUtils.populateFlowSnippet(snippet, false, false));
|
||||||
return snippetDTO;
|
return snippetDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class StandardSnippetDAO implements SnippetDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate the snippet contents
|
// generate the snippet contents
|
||||||
FlowSnippetDTO snippetContents = snippetUtils.populateFlowSnippet(existingSnippet, true);
|
FlowSnippetDTO snippetContents = snippetUtils.populateFlowSnippet(existingSnippet, true, false);
|
||||||
|
|
||||||
// resolve sensitive properties
|
// resolve sensitive properties
|
||||||
lookupSensitiveProperties(snippetContents);
|
lookupSensitiveProperties(snippetContents);
|
||||||
|
|
|
@ -72,9 +72,10 @@ public final class SnippetUtils {
|
||||||
*
|
*
|
||||||
* @param snippet snippet
|
* @param snippet snippet
|
||||||
* @param recurse recurse
|
* @param recurse recurse
|
||||||
|
* @param includeControllerServices whether or not to include controller services in the flow snippet dto
|
||||||
* @return snippet
|
* @return snippet
|
||||||
*/
|
*/
|
||||||
public FlowSnippetDTO populateFlowSnippet(Snippet snippet, boolean recurse) {
|
public FlowSnippetDTO populateFlowSnippet(Snippet snippet, boolean recurse, boolean includeControllerServices) {
|
||||||
final FlowSnippetDTO snippetDto = new FlowSnippetDTO();
|
final FlowSnippetDTO snippetDto = new FlowSnippetDTO();
|
||||||
final String groupId = snippet.getParentGroupId();
|
final String groupId = snippet.getParentGroupId();
|
||||||
final ProcessGroup processGroup = flowController.getGroup(groupId);
|
final ProcessGroup processGroup = flowController.getGroup(groupId);
|
||||||
|
@ -188,7 +189,9 @@ public final class SnippetUtils {
|
||||||
snippetDto.setRemoteProcessGroups(remoteProcessGroups);
|
snippetDto.setRemoteProcessGroups(remoteProcessGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
addControllerServicesToSnippet(snippetDto);
|
if (includeControllerServices) {
|
||||||
|
addControllerServicesToSnippet(snippetDto);
|
||||||
|
}
|
||||||
|
|
||||||
return snippetDto;
|
return snippetDto;
|
||||||
}
|
}
|
||||||
|
@ -570,8 +573,12 @@ public final class SnippetUtils {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String newServiceId = serviceIdMap.get(currentServiceId);
|
// if this is a copy/paste action, we can continue to reference the same service, in this case
|
||||||
properties.put(descriptor.getName(), newServiceId);
|
// the serviceIdMap will be empty
|
||||||
|
if (serviceIdMap.containsKey(currentServiceId)) {
|
||||||
|
final String newServiceId = serviceIdMap.get(currentServiceId);
|
||||||
|
properties.put(descriptor.getName(), newServiceId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue