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
|
||||
final SnippetDTO responseSnippetDto = dtoFactory.createSnippetDto(snippet);
|
||||
responseSnippetDto.setContents(snippetUtils.populateFlowSnippet(snippet, false));
|
||||
responseSnippetDto.setContents(snippetUtils.populateFlowSnippet(snippet, false, false));
|
||||
|
||||
// save updated controller if applicable
|
||||
if (snippetDto.getParentGroupId() != null && snippet.isLinked()) {
|
||||
|
@ -995,7 +995,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
// add the snippet
|
||||
final Snippet snippet = snippetDAO.createSnippet(snippetDTO);
|
||||
final SnippetDTO responseSnippetDTO = dtoFactory.createSnippetDto(snippet);
|
||||
responseSnippetDTO.setContents(snippetUtils.populateFlowSnippet(snippet, false));
|
||||
responseSnippetDTO.setContents(snippetUtils.populateFlowSnippet(snippet, false, false));
|
||||
|
||||
return responseSnippetDTO;
|
||||
}
|
||||
|
@ -1092,7 +1092,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
templateDTO.setName(name);
|
||||
templateDTO.setDescription(description);
|
||||
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
|
||||
final ClusterContext clusterContext = ClusterContextThreadLocal.getContext();
|
||||
|
@ -1972,7 +1972,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
public SnippetDTO getSnippet(String snippetId) {
|
||||
final Snippet snippet = snippetDAO.getSnippet(snippetId);
|
||||
final SnippetDTO snippetDTO = dtoFactory.createSnippetDto(snippet);
|
||||
snippetDTO.setContents(snippetUtils.populateFlowSnippet(snippet, false));
|
||||
snippetDTO.setContents(snippetUtils.populateFlowSnippet(snippet, false, false));
|
||||
return snippetDTO;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class StandardSnippetDAO implements SnippetDAO {
|
|||
}
|
||||
|
||||
// generate the snippet contents
|
||||
FlowSnippetDTO snippetContents = snippetUtils.populateFlowSnippet(existingSnippet, true);
|
||||
FlowSnippetDTO snippetContents = snippetUtils.populateFlowSnippet(existingSnippet, true, false);
|
||||
|
||||
// resolve sensitive properties
|
||||
lookupSensitiveProperties(snippetContents);
|
||||
|
|
|
@ -72,9 +72,10 @@ public final class SnippetUtils {
|
|||
*
|
||||
* @param snippet snippet
|
||||
* @param recurse recurse
|
||||
* @param includeControllerServices whether or not to include controller services in the flow snippet dto
|
||||
* @return snippet
|
||||
*/
|
||||
public FlowSnippetDTO populateFlowSnippet(Snippet snippet, boolean recurse) {
|
||||
public FlowSnippetDTO populateFlowSnippet(Snippet snippet, boolean recurse, boolean includeControllerServices) {
|
||||
final FlowSnippetDTO snippetDto = new FlowSnippetDTO();
|
||||
final String groupId = snippet.getParentGroupId();
|
||||
final ProcessGroup processGroup = flowController.getGroup(groupId);
|
||||
|
@ -188,7 +189,9 @@ public final class SnippetUtils {
|
|||
snippetDto.setRemoteProcessGroups(remoteProcessGroups);
|
||||
}
|
||||
|
||||
if (includeControllerServices) {
|
||||
addControllerServicesToSnippet(snippetDto);
|
||||
}
|
||||
|
||||
return snippetDto;
|
||||
}
|
||||
|
@ -570,12 +573,16 @@ public final class SnippetUtils {
|
|||
continue;
|
||||
}
|
||||
|
||||
// if this is a copy/paste action, we can continue to reference the same service, in this case
|
||||
// the serviceIdMap will be empty
|
||||
if (serviceIdMap.containsKey(currentServiceId)) {
|
||||
final String newServiceId = serviceIdMap.get(currentServiceId);
|
||||
properties.put(descriptor.getName(), newServiceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new id for the current id that is specified. If no seed is found, a new random id will be created.
|
||||
|
|
Loading…
Reference in New Issue