Search in sources :

Example 11 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NifiConnectionOrderVisitor method fetchProcessGroup.

private NifiVisitableProcessGroup fetchProcessGroup(String groupId) {
    NifiVisitableProcessGroup group = processGroup;
    // fetch it
    ProcessGroupDTO processGroupEntity = null;
    try {
        try {
            log.debug("fetchProcessGroup {} ", groupId);
            processGroupEntity = getGroup(groupId);
        } catch (NifiComponentNotFoundException e) {
            log.debug("Unable to find the process group " + groupId);
        }
        // if the parent is null the parent is the starting process group
        if (processGroupEntity != null) {
            group = new NifiVisitableProcessGroup(processGroupEntity);
        }
    } catch (Exception e) {
        log.error("Exception fetching the process group " + groupId);
    }
    return group;
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)

Example 12 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NiFiPortsRestClientV1 method deleteInputPort.

@Override
public PortDTO deleteInputPort(@Nonnull String portId) {
    try {
        PortEntity current = client.get("/input-ports/" + portId, null, PortEntity.class);
        if (current != null) {
            Map<String, Object> params = new HashMap<>();
            params.put("version", current.getRevision().getVersion());
            params.put("clientId", current.getRevision().getClientId());
            PortEntity inputPortsEntity = client.delete("/input-ports/" + portId, params, PortEntity.class);
            if (inputPortsEntity != null) {
                return inputPortsEntity.getComponent();
            }
        }
    } catch (NotFoundException e) {
        throw new NifiComponentNotFoundException(portId, NifiConstants.NIFI_COMPONENT_TYPE.INPUT_PORT, e);
    }
    return null;
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) HashMap(java.util.HashMap) NotFoundException(javax.ws.rs.NotFoundException) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) PortEntity(org.apache.nifi.web.api.entity.PortEntity)

Example 13 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NiFiPortsRestClientV1 method updateOutputPort.

@Nonnull
@Override
public PortDTO updateOutputPort(@Nonnull final String processGroupId, @Nonnull final PortDTO outputPort) {
    // Get revision
    final PortEntity current;
    try {
        current = client.get("/output-ports/" + outputPort.getId(), null, PortEntity.class);
    } catch (NotFoundException e) {
        throw new NifiComponentNotFoundException(outputPort.getId(), NifiConstants.NIFI_COMPONENT_TYPE.OUTPUT_PORT, e);
    }
    // Update output port
    final PortEntity entity = new PortEntity();
    entity.setComponent(outputPort);
    final RevisionDTO revision = new RevisionDTO();
    revision.setVersion(current.getRevision().getVersion());
    entity.setRevision(revision);
    try {
        return client.put("/output-ports/" + outputPort.getId(), entity, PortEntity.class).getComponent();
    } catch (final NotFoundException e) {
        throw new NifiComponentNotFoundException(outputPort.getId(), NifiConstants.NIFI_COMPONENT_TYPE.OUTPUT_PORT, e);
    }
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NotFoundException(javax.ws.rs.NotFoundException) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) PortEntity(org.apache.nifi.web.api.entity.PortEntity) Nonnull(javax.annotation.Nonnull)

Example 14 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NiFiPortsRestClientV1 method updateInputPort.

@Nonnull
@Override
public PortDTO updateInputPort(@Nonnull final String processGroupId, @Nonnull final PortDTO inputPort) {
    // Get revision
    final PortEntity current;
    try {
        current = client.get("/input-ports/" + inputPort.getId(), null, PortEntity.class);
    } catch (NotFoundException e) {
        throw new NifiComponentNotFoundException(inputPort.getId(), NifiConstants.NIFI_COMPONENT_TYPE.INPUT_PORT, e);
    }
    // Update input port
    final PortEntity entity = new PortEntity();
    entity.setComponent(inputPort);
    final RevisionDTO revision = new RevisionDTO();
    revision.setVersion(current.getRevision().getVersion());
    entity.setRevision(revision);
    try {
        return client.put("/input-ports/" + inputPort.getId(), entity, PortEntity.class).getComponent();
    } catch (final NotFoundException e) {
        throw new NifiComponentNotFoundException(inputPort.getId(), NifiConstants.NIFI_COMPONENT_TYPE.INPUT_PORT, e);
    }
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NotFoundException(javax.ws.rs.NotFoundException) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) PortEntity(org.apache.nifi.web.api.entity.PortEntity) Nonnull(javax.annotation.Nonnull)

Example 15 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NiFiProcessGroupsRestClientV1 method createConnection.

@Nonnull
@Override
public ConnectionDTO createConnection(@Nonnull final String processGroupId, @Nonnull final ConnectableDTO source, @Nonnull final ConnectableDTO dest) {
    final ConnectionEntity entity = new ConnectionEntity();
    final ConnectionDTO connection = new ConnectionDTO();
    connection.setDestination(dest);
    connection.setName(source.getName() + "-" + dest.getName());
    connection.setSource(source);
    entity.setComponent(connection);
    final RevisionDTO revision = new RevisionDTO();
    revision.setVersion(0L);
    entity.setRevision(revision);
    try {
        return client.post(BASE_PATH + processGroupId + "/connections", entity, ConnectionEntity.class).getComponent();
    } catch (final NotFoundException e) {
        throw new NifiComponentNotFoundException(processGroupId, NifiConstants.NIFI_COMPONENT_TYPE.PROCESS_GROUP, e);
    }
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) ConnectionDTO(org.apache.nifi.web.api.dto.ConnectionDTO) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NotFoundException(javax.ws.rs.NotFoundException) ConnectionEntity(org.apache.nifi.web.api.entity.ConnectionEntity) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) Nonnull(javax.annotation.Nonnull)

Aggregations

NifiComponentNotFoundException (com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)22 Nonnull (javax.annotation.Nonnull)10 NotFoundException (javax.ws.rs.NotFoundException)10 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)10 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)6 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)6 HashMap (java.util.HashMap)5 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)5 PortEntity (org.apache.nifi.web.api.entity.PortEntity)5 NifiClientRuntimeException (com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException)4 NifiVisitableProcessGroup (com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup)4 LegacyNifiRestClient (com.thinkbiganalytics.nifi.rest.client.LegacyNifiRestClient)3 NifiProperty (com.thinkbiganalytics.nifi.rest.model.NifiProperty)3 NifiConstants (com.thinkbiganalytics.nifi.rest.support.NifiConstants)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 Iterables (com.google.common.collect.Iterables)2 ReusableTemplateConnectionInfo (com.thinkbiganalytics.feedmgr.rest.model.ReusableTemplateConnectionInfo)2 NifiPropertyUtil (com.thinkbiganalytics.nifi.rest.support.NifiPropertyUtil)2 HashSet (java.util.HashSet)2