use of org.apache.nifi.remote.RootGroupPort in project nifi by apache.
the class StandardOutputPortDAO method updatePort.
@Override
public Port updatePort(PortDTO portDTO) {
Port outputPort = locatePort(portDTO.getId());
// ensure we can do this update
verifyUpdate(outputPort, portDTO);
// handle state transition
if (portDTO.getState() != null) {
final ScheduledState purposedScheduledState = ScheduledState.valueOf(portDTO.getState());
// only attempt an action if it is changing
if (!purposedScheduledState.equals(outputPort.getScheduledState())) {
try {
// perform the appropriate action
switch(purposedScheduledState) {
case RUNNING:
outputPort.getProcessGroup().startOutputPort(outputPort);
break;
case STOPPED:
switch(outputPort.getScheduledState()) {
case RUNNING:
outputPort.getProcessGroup().stopOutputPort(outputPort);
break;
case DISABLED:
outputPort.getProcessGroup().enableOutputPort(outputPort);
break;
}
break;
case DISABLED:
outputPort.getProcessGroup().disableOutputPort(outputPort);
break;
}
} catch (IllegalStateException ise) {
throw new NiFiCoreException(ise.getMessage(), ise);
}
}
}
if (outputPort instanceof RootGroupPort) {
final RootGroupPort rootPort = (RootGroupPort) outputPort;
if (isNotNull(portDTO.getGroupAccessControl())) {
rootPort.setGroupAccessControl(portDTO.getGroupAccessControl());
}
if (isNotNull(portDTO.getUserAccessControl())) {
rootPort.setUserAccessControl(portDTO.getUserAccessControl());
}
}
// perform the configuration
final String name = portDTO.getName();
final String comments = portDTO.getComments();
final Integer concurrentTasks = portDTO.getConcurrentlySchedulableTaskCount();
if (isNotNull(portDTO.getPosition())) {
outputPort.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
}
if (isNotNull(name)) {
outputPort.setName(name);
}
if (isNotNull(comments)) {
outputPort.setComments(comments);
}
if (isNotNull(concurrentTasks)) {
outputPort.setMaxConcurrentTasks(concurrentTasks);
}
outputPort.getProcessGroup().onComponentModified();
return outputPort;
}
Aggregations