org.apache.nifi.util.StringUtils Java Examples
The following examples show how to use
org.apache.nifi.util.StringUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PutBigQueryBatch.java From nifi with Apache License 2.0 | 6 votes |
@Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { final ValidationResult.Builder builder = new ValidationResult.Builder(); builder.subject(subject).input(input); if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return builder.valid(true).explanation("Contains Expression Language").build(); } if (TYPES.contains(input.toUpperCase())) { builder.valid(true); } else { builder.valid(false).explanation("Load File Type must be one of the following options: " + StringUtils.join(TYPES, ", ")); } return builder.build(); }
Example #2
Source File: StandardHttpFlowFileServerProtocol.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override protected HandshakeProperties doHandshake(Peer peer) throws IOException, HandshakeException { HttpServerCommunicationsSession commsSession = (HttpServerCommunicationsSession) peer.getCommunicationsSession(); final String transactionId = commsSession.getTransactionId(); HandshakeProperties confirmed = null; if (!StringUtils.isEmpty(transactionId)) { // If handshake is already done, use it. confirmed = transactionManager.getHandshakenProperties(transactionId); } if (confirmed == null) { // If it's not, then do handshake. confirmed = new HandshakeProperties(); confirmed.setCommsIdentifier(transactionId); validateHandshakeRequest(confirmed, peer, commsSession.getHandshakeParams()); } logger.debug("{} Done handshake, confirmed={}", this, confirmed); return confirmed; }
Example #3
Source File: StandardExtensionDiscoveringManager.java From nifi with Apache License 2.0 | 6 votes |
private static boolean checkControllerServiceReferenceEligibility(final ConfigurableComponent component, final ClassLoader classLoader) { // if the extension does not require instance classloading, its eligible final boolean requiresInstanceClassLoading = component.getClass().isAnnotationPresent(RequiresInstanceClassLoading.class); final Set<Class> cobundledApis = new HashSet<>(); try (final NarCloseable closeable = NarCloseable.withComponentNarLoader(component.getClass().getClassLoader())) { final List<PropertyDescriptor> descriptors = component.getPropertyDescriptors(); if (descriptors != null && !descriptors.isEmpty()) { for (final PropertyDescriptor descriptor : descriptors) { final Class<? extends ControllerService> serviceApi = descriptor.getControllerServiceDefinition(); if (serviceApi != null && classLoader.equals(serviceApi.getClassLoader())) { cobundledApis.add(serviceApi); } } } } if (!cobundledApis.isEmpty()) { logger.warn(String.format( "Component %s is bundled with its referenced Controller Service APIs %s. The service APIs should not be bundled with component implementations that reference it.", component.getClass().getName(), StringUtils.join(cobundledApis.stream().map(Class::getName).collect(Collectors.toSet()), ", "))); } // the component is eligible when it does not require instance classloading or when the supporting APIs are bundled in a parent NAR return requiresInstanceClassLoading == false || cobundledApis.isEmpty(); }
Example #4
Source File: TlsConfiguration.java From nifi with Apache License 2.0 | 6 votes |
private boolean isStorePopulated(String path, String password, KeystoreType type, String label) { boolean isPopulated; String passwordForLogging; // Legacy truststores can be populated without a password; only check the path and type isPopulated = StringUtils.isNotBlank(path) && type != null; if ("truststore".equalsIgnoreCase(label)) { passwordForLogging = getTruststorePasswordForLogging(); } else { // Keystores require a password isPopulated = isPopulated && StringUtils.isNotBlank(password); passwordForLogging = getKeystorePasswordForLogging(); } if (logger.isDebugEnabled()) { logger.debug("TLS config {} is {}: {}, {}, {}", label, isPopulated ? "populated" : "not populated", path, passwordForLogging, type); } return isPopulated; }
Example #5
Source File: FlowConfigurationArchiveManager.java From localization_nifi with Apache License 2.0 | 6 votes |
public FlowConfigurationArchiveManager(final Path flowConfigFile, final NiFiProperties properties) { final String archiveDirVal = properties.getFlowConfigurationArchiveDir(); final Path archiveDir = (archiveDirVal == null || archiveDirVal.equals("")) ? flowConfigFile.getParent().resolve("archive") : new File(archiveDirVal).toPath(); this.maxCount = properties.getFlowConfigurationArchiveMaxCount(); String maxTime = properties.getFlowConfigurationArchiveMaxTime(); String maxStorage = properties.getFlowConfigurationArchiveMaxStorage(); if (maxCount == null && StringUtils.isBlank(maxTime) && StringUtils.isBlank(maxStorage)) { // None of limitation is specified, fall back to the default configuration; maxTime = NiFiProperties.DEFAULT_FLOW_CONFIGURATION_ARCHIVE_MAX_TIME; maxStorage = NiFiProperties.DEFAULT_FLOW_CONFIGURATION_ARCHIVE_MAX_STORAGE; logger.info("None of archive max limitation is specified, fall back to the default configuration, maxTime={}, maxStorage={}", maxTime, maxStorage); } this.maxTimeMillis = StringUtils.isBlank(maxTime) ? null : FormatUtils.getTimeDuration(maxTime, TimeUnit.MILLISECONDS); this.maxStorageBytes = StringUtils.isBlank(maxStorage) ? null : DataUnit.parseDataSize(maxStorage, DataUnit.B).longValue(); this.flowConfigFile = flowConfigFile; this.archiveDir = archiveDir; }
Example #6
Source File: ToDate.java From nifi with Apache License 2.0 | 6 votes |
private java.text.DateFormat getDateFormat(final RecordPathSegment dateFormatSegment, final RecordPathSegment timeZoneID, final RecordPathEvaluationContext context) { if (dateFormatSegment == null) { return null; } final String dateFormatString = RecordPathUtils.getFirstStringValue(dateFormatSegment, context); if (StringUtils.isEmpty(dateFormatString)) { return null; } try { if (timeZoneID == null) { return DataTypeUtils.getDateFormat(dateFormatString); } else { final String timeZoneStr = RecordPathUtils.getFirstStringValue(timeZoneID, context); if (StringUtils.isEmpty(timeZoneStr)) { return null; } return DataTypeUtils.getDateFormat(dateFormatString, timeZoneStr); } } catch (final Exception e) { return null; } }
Example #7
Source File: TestEvaluateJsonPath.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testExtractPath_destinationAttributes_twoPaths_oneFound() throws Exception { final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateJsonPath()); testRunner.setProperty(EvaluateJsonPath.DESTINATION, EvaluateJsonPath.DESTINATION_ATTRIBUTE); String jsonPathIdAttrKey = "evaluatejson.id"; String jsonPathNameAttrKey = "evaluatejson.name"; testRunner.setProperty(jsonPathIdAttrKey, "$[0]._id"); testRunner.setProperty(jsonPathNameAttrKey, "$[0].name.nonexistent"); testRunner.enqueue(JSON_SNIPPET); testRunner.run(); Relationship expectedRel = EvaluateJsonPath.REL_MATCH; testRunner.assertAllFlowFilesTransferred(expectedRel, 1); final MockFlowFile out = testRunner.getFlowFilesForRelationship(expectedRel).get(0); Assert.assertEquals("Transferred flow file did not have the correct result for id attribute", "54df94072d5dbf7dc6340cc5", out.getAttribute(jsonPathIdAttrKey)); Assert.assertEquals("Transferred flow file did not have the correct result for name attribute", StringUtils.EMPTY, out.getAttribute(jsonPathNameAttrKey)); }
Example #8
Source File: MongoDBLookupService.java From nifi with Apache License 2.0 | 6 votes |
@OnEnabled public void onEnabled(final ConfigurationContext context) { this.lookupValueField = context.getProperty(LOOKUP_VALUE_FIELD).getValue(); this.controllerService = context.getProperty(CONTROLLER_SERVICE).asControllerService(MongoDBClientService.class); this.schemaNameProperty = context.getProperty(SchemaAccessUtils.SCHEMA_NAME).getValue(); this.databaseName = context.getProperty(DATABASE_NAME).evaluateAttributeExpressions().getValue(); this.collection = context.getProperty(COLLECTION_NAME).evaluateAttributeExpressions().getValue(); String configuredProjection = context.getProperty(PROJECTION).isSet() ? context.getProperty(PROJECTION).getValue() : null; if (!StringUtils.isBlank(configuredProjection)) { projection = Document.parse(configuredProjection); } super.onEnabled(context); }
Example #9
Source File: FlowConfigurationArchiveManager.java From nifi with Apache License 2.0 | 6 votes |
public FlowConfigurationArchiveManager(final Path flowConfigFile, final NiFiProperties properties) { final String archiveDirVal = properties.getFlowConfigurationArchiveDir(); final Path archiveDir = (archiveDirVal == null || archiveDirVal.equals("")) ? flowConfigFile.getParent().resolve("archive") : new File(archiveDirVal).toPath(); this.maxCount = properties.getFlowConfigurationArchiveMaxCount(); String maxTime = properties.getFlowConfigurationArchiveMaxTime(); String maxStorage = properties.getFlowConfigurationArchiveMaxStorage(); if (maxCount == null && StringUtils.isBlank(maxTime) && StringUtils.isBlank(maxStorage)) { // None of limitation is specified, fall back to the default configuration; maxTime = NiFiProperties.DEFAULT_FLOW_CONFIGURATION_ARCHIVE_MAX_TIME; maxStorage = NiFiProperties.DEFAULT_FLOW_CONFIGURATION_ARCHIVE_MAX_STORAGE; logger.info("None of archive max limitation is specified, fall back to the default configuration, maxTime={}, maxStorage={}", maxTime, maxStorage); } this.maxTimeMillis = StringUtils.isBlank(maxTime) ? null : FormatUtils.getTimeDuration(maxTime, TimeUnit.MILLISECONDS); this.maxStorageBytes = StringUtils.isBlank(maxStorage) ? null : DataUnit.parseDataSize(maxStorage, DataUnit.B).longValue(); this.flowConfigFile = flowConfigFile; this.archiveDir = archiveDir; }
Example #10
Source File: AbstractEasyRulesEngineController.java From nifi with Apache License 2.0 | 6 votes |
@OnEnabled public void onEnabled(final ConfigurationContext context) throws InitializationException { final String rulesFile = context.getProperty(RULES_FILE_PATH).getValue(); final String rulesBody = context.getProperty(RULES_BODY).getValue(); final String rulesFileType = context.getProperty(RULES_FILE_TYPE).getValue(); rulesFileFormat = context.getProperty(RULES_FILE_FORMAT).getValue(); ignoreConditionErrors = context.getProperty(IGNORE_CONDITION_ERRORS).asBoolean(); filterRules = context.getProperty(FILTER_RULES_MISSING_FACTS).asBoolean(); try{ if(StringUtils.isEmpty(rulesFile)){ rules = RulesFactory.createRulesFromString(rulesBody, rulesFileType, rulesFileFormat); }else{ rules = RulesFactory.createRulesFromFile(rulesFile, rulesFileType, rulesFileFormat); } } catch (Exception fex){ throw new InitializationException(fex); } }
Example #11
Source File: PrometheusMetricsUtil.java From nifi with Apache License 2.0 | 6 votes |
public static CollectorRegistry createJvmMetrics(JvmMetricsRegistry jvmMetricsRegistry, JvmMetrics jvmMetrics, String instId) { final String instanceId = StringUtils.isEmpty(instId) ? DEFAULT_LABEL_STRING : instId; jvmMetricsRegistry.setDataPoint(jvmMetrics.heapUsed(DataUnit.B), "JVM_HEAP_USED", instanceId); jvmMetricsRegistry.setDataPoint(jvmMetrics.heapUsage(), "JVM_HEAP_USAGE", instanceId); jvmMetricsRegistry.setDataPoint(jvmMetrics.nonHeapUsage(), "JVM_HEAP_NON_USAGE", instanceId); jvmMetricsRegistry.setDataPoint(jvmMetrics.threadCount(), "JVM_THREAD_COUNT", instanceId); jvmMetricsRegistry.setDataPoint(jvmMetrics.daemonThreadCount(), "JVM_DAEMON_THREAD_COUNT", instanceId); jvmMetricsRegistry.setDataPoint(jvmMetrics.uptime(), "JVM_UPTIME", instanceId); jvmMetricsRegistry.setDataPoint(jvmMetrics.fileDescriptorUsage(), "JVM_FILE_DESCRIPTOR_USAGE", instanceId); jvmMetrics.garbageCollectors() .forEach((name, stat) -> { jvmMetricsRegistry.setDataPoint(stat.getRuns(), "JVM_GC_RUNS", instanceId, name); jvmMetricsRegistry.setDataPoint(stat.getTime(TimeUnit.MILLISECONDS), "JVM_GC_TIME", instanceId, name); }); return jvmMetricsRegistry.getRegistry(); }
Example #12
Source File: KerberosPrincipalParser.java From nifi with Apache License 2.0 | 6 votes |
/** * <p>Determines the realm specified in the given kerberos principal. * * <p>The content of the given {@code principal} after the occurrence * of the last non-escaped realm delimiter ("@") will be considered * the realm of the principal. * * <p>The validity of the given {@code principal} and the determined realm * is not be verified by this method. * * @param principal the principal for which the realm will be determined * @return the realm of the given principal */ public static String getRealm(String principal) { if (StringUtils.isBlank(principal)) { throw new IllegalArgumentException("principal can not be null or empty"); } char previousChar = 0; int realmDelimiterIndex = -1; char currentChar; boolean realmDelimiterFound = false; int principalLength = principal.length(); // find the last non-escaped occurrence of the realm delimiter for (int i = 0; i < principalLength; ++i) { currentChar = principal.charAt(i); if (currentChar == '@' && previousChar != '\\' ) { realmDelimiterIndex = i; realmDelimiterFound = true; } previousChar = currentChar; } String principalAfterLastRealmDelimiter = principal.substring(realmDelimiterIndex + 1); return realmDelimiterFound && realmDelimiterIndex + 1 < principalLength ? principalAfterLastRealmDelimiter : null; }
Example #13
Source File: BaseTlsManager.java From localization_nifi with Apache License 2.0 | 6 votes |
private String getKeyPassword() { if (keyStore.getType().equalsIgnoreCase(KeystoreType.PKCS12.toString())) { tlsConfig.setKeyPassword(null); return null; } else { String result = tlsConfig.getKeyPassword(); if (StringUtils.isEmpty(result)) { if (differentKeyAndKeyStorePassword) { result = passwordUtil.generatePassword(); } else { result = getKeyStorePassword(); } tlsConfig.setKeyPassword(result); } return result; } }
Example #14
Source File: VisibilityFetchSupport.java From nifi with Apache License 2.0 | 5 votes |
default List<String> getAuthorizations(ProcessContext context, FlowFile flowFile) { final String authorizationString = context.getProperty(AUTHORIZATIONS).isSet() ? context.getProperty(AUTHORIZATIONS).evaluateAttributeExpressions(flowFile).getValue().trim() : ""; List<String> authorizations = new ArrayList<>(); if (!StringUtils.isBlank(authorizationString)) { String[] parts = authorizationString.split(","); for (String part : parts) { authorizations.add(part.trim()); } } return authorizations; }
Example #15
Source File: TlsCertificateAuthorityServiceCommandLine.java From nifi with Apache License 2.0 | 5 votes |
@Override protected String getDnHostname() { String dnHostname = getCertificateAuthorityHostname(); if (StringUtils.isEmpty(dnHostname)) { return "YOUR_CA_HOSTNAME"; } return dnHostname; }
Example #16
Source File: AbstractElasticsearchHttpProcessor.java From localization_nifi with Apache License 2.0 | 5 votes |
protected Response sendRequestToElasticsearch(OkHttpClient client, URL url, String username, String password, String verb, RequestBody body) throws IOException { final ComponentLog log = getLogger(); Request.Builder requestBuilder = new Request.Builder() .url(url); if ("get".equalsIgnoreCase(verb)) { requestBuilder = requestBuilder.get(); } else if ("put".equalsIgnoreCase(verb)) { requestBuilder = requestBuilder.put(body); } else { throw new IllegalArgumentException("Elasticsearch REST API verb not supported by this processor: " + verb); } if(!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) { String credential = Credentials.basic(username, password); requestBuilder = requestBuilder.header("Authorization", credential); } Request httpRequest = requestBuilder.build(); log.debug("Sending Elasticsearch request to {}", new Object[]{url}); Response responseHttp = client.newCall(httpRequest).execute(); // store the status code and message int statusCode = responseHttp.code(); if (statusCode == 0) { throw new IllegalStateException("Status code unknown, connection hasn't been attempted."); } log.debug("Received response from Elasticsearch with status code {}", new Object[]{statusCode}); return responseHttp; }
Example #17
Source File: NiFiAnonymousAuthenticationProviderTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testAnonymousEnabledNotSecure() throws Exception { final NiFiProperties nifiProperties = Mockito.mock(NiFiProperties.class); when(nifiProperties.isAnonymousAuthenticationAllowed()).thenReturn(true); final NiFiAnonymousAuthenticationProvider anonymousAuthenticationProvider = new NiFiAnonymousAuthenticationProvider(nifiProperties, mock(Authorizer.class)); final NiFiAnonymousAuthenticationRequestToken authenticationRequest = new NiFiAnonymousAuthenticationRequestToken(false, StringUtils.EMPTY); final NiFiAuthenticationToken authentication = (NiFiAuthenticationToken) anonymousAuthenticationProvider.authenticate(authenticationRequest); final NiFiUserDetails userDetails = (NiFiUserDetails) authentication.getDetails(); assertTrue(userDetails.getNiFiUser().isAnonymous()); }
Example #18
Source File: NifiPropertiesTlsClientConfigWriter.java From nifi with Apache License 2.0 | 5 votes |
private Stream<String> getCommaSeparatedPropertyStream(String property) { String hostnamePropertyString = overlayProperties.getProperty(property); if (!StringUtils.isEmpty(hostnamePropertyString)) { return Arrays.stream(hostnamePropertyString.split(",")).map(String::trim); } return Stream.of(); }
Example #19
Source File: AbstractElasticsearch5Processor.java From nifi with Apache License 2.0 | 5 votes |
@Override protected Collection<ValidationResult> customValidate(ValidationContext validationContext) { Set<ValidationResult> results = new HashSet<>(); // Ensure that if username or password is set, then the other is too String userName = validationContext.getProperty(USERNAME).evaluateAttributeExpressions().getValue(); String password = validationContext.getProperty(PASSWORD).evaluateAttributeExpressions().getValue(); if (StringUtils.isEmpty(userName) != StringUtils.isEmpty(password)) { results.add(new ValidationResult.Builder().valid(false).explanation( "If username or password is specified, then the other must be specified as well").build()); } return results; }
Example #20
Source File: HBase_1_1_2_RecordLookupService.java From nifi with Apache License 2.0 | 5 votes |
@Override public Optional<Record> lookup(Map<String, Object> coordinates) throws LookupFailureException { if (coordinates.get(ROW_KEY_KEY) == null) { return Optional.empty(); } final String rowKey = coordinates.get(ROW_KEY_KEY).toString(); if (StringUtils.isBlank(rowKey)) { return Optional.empty(); } final byte[] rowKeyBytes = rowKey.getBytes(StandardCharsets.UTF_8); try { final Map<String, Object> values = scan(rowKeyBytes); if (values.size() > 0) { final List<RecordField> fields = new ArrayList<>(); for (String key : values.keySet()) { fields.add(new RecordField(key, RecordFieldType.STRING.getDataType())); } final RecordSchema schema = new SimpleRecordSchema(fields); return Optional.ofNullable(new MapRecord(schema, values)); } else { return Optional.empty(); } } catch (IOException e) { getLogger().error("Error occurred loading {}", new Object[] { coordinates.get("rowKey") }, e); throw new LookupFailureException(e); } }
Example #21
Source File: HtmlDocumentationWriter.java From nifi with Apache License 2.0 | 5 votes |
/** * Writes a warning about the deprecation of a component. * * @param configurableComponent the component to describe * @param xmlStreamWriter the stream writer * @throws XMLStreamException thrown if there was a problem writing to the * XML stream */ private void writeDeprecationWarning(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { final DeprecationNotice deprecationNotice = configurableComponent.getClass().getAnnotation(DeprecationNotice.class); if (deprecationNotice != null) { xmlStreamWriter.writeStartElement("h2"); xmlStreamWriter.writeCharacters("Deprecation notice: "); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeStartElement("p"); xmlStreamWriter.writeCharacters(""); if (!StringUtils.isEmpty(deprecationNotice.reason())) { xmlStreamWriter.writeCharacters(deprecationNotice.reason()); } else { // Write a default note xmlStreamWriter.writeCharacters("Please be aware this processor is deprecated and may be removed in " + "the near future."); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeStartElement("p"); xmlStreamWriter.writeCharacters("Please consider using one the following alternatives: "); Class<? extends ConfigurableComponent>[] componentNames = deprecationNotice.alternatives(); String[] classNames = deprecationNotice.classNames(); if (componentNames.length > 0 || classNames.length > 0) { // Write alternatives iterateAndLinkComponents(xmlStreamWriter, componentNames, classNames, ",", configurableComponent.getClass().getSimpleName()); } else { xmlStreamWriter.writeCharacters("No alternative components suggested."); } xmlStreamWriter.writeEndElement(); } }
Example #22
Source File: VisibilityLabelUtils.java From nifi with Apache License 2.0 | 5 votes |
static List<String> getAuthorizations(ConfigurationContext context) { List<String> tokens = new ArrayList<>(); String authorizationString = context.getProperty(AUTHORIZATIONS).isSet() ? context.getProperty(AUTHORIZATIONS).getValue() : ""; if (!StringUtils.isEmpty(authorizationString)) { tokens = Arrays.asList(authorizationString.split(",[\\s]*")); } return tokens; }
Example #23
Source File: ScriptingComponentHelper.java From nifi with Apache License 2.0 | 5 votes |
public void setupVariables(ProcessContext context) { scriptEngineName = context.getProperty(SCRIPT_ENGINE).getValue(); scriptPath = context.getProperty(ScriptingComponentUtils.SCRIPT_FILE).evaluateAttributeExpressions().getValue(); scriptBody = context.getProperty(ScriptingComponentUtils.SCRIPT_BODY).getValue(); String modulePath = context.getProperty(ScriptingComponentUtils.MODULES).evaluateAttributeExpressions().getValue(); if (!StringUtils.isEmpty(modulePath)) { modules = modulePath.split(","); } else { modules = new String[0]; } }
Example #24
Source File: HBase_2_ListLookupService.java From nifi with Apache License 2.0 | 5 votes |
@Override public Optional<List> lookup(Map<String, Object> coordinates) throws LookupFailureException { if (coordinates.get(ROW_KEY_KEY) == null) { return Optional.empty(); } final String rowKey = coordinates.get(ROW_KEY_KEY).toString(); if (StringUtils.isBlank(rowKey)) { return Optional.empty(); } final byte[] rowKeyBytes = rowKey.getBytes(StandardCharsets.UTF_8); try { final Map<String, Object> values = scan(rowKeyBytes); if (values.size() > 0) { List<String> retVal = returnType.equals(KEY_LIST.getValue()) ? new ArrayList<>(values.keySet()) : values.values().stream().map( obj -> obj.toString() ).collect(Collectors.toList()); return Optional.ofNullable(retVal); } else { return Optional.empty(); } } catch (IOException e) { getLogger().error("Error occurred loading {}", new Object[] { coordinates.get("rowKey") }, e); throw new LookupFailureException(e); } }
Example #25
Source File: RegistryManualIT.java From nifi with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { assertFalse("truststore not set", StringUtils.isBlank(TRUSTSTORE)); assertFalse("truststorePasswd not set", StringUtils.isBlank(TRUSTSTORE_PASSWD)); assertFalse("keystore not set", StringUtils.isBlank(KEYSTORE)); assertFalse("keystorePassed not set", StringUtils.isBlank(KEYSTORE_PASSWD)); }
Example #26
Source File: NoConnectedNodesExceptionMapper.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public Response toResponse(NoConnectedNodesException ex) { // log the error logger.info(String.format("Cluster failed processing request: %s. Returning %s response.", ex, Response.Status.INTERNAL_SERVER_ERROR)); if (logger.isDebugEnabled()) { logger.debug(StringUtils.EMPTY, ex); } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Action was performed, but no nodes are connected.").type("text/plain").build(); }
Example #27
Source File: IllegalNodeDeletionExceptionMapper.java From nifi with Apache License 2.0 | 5 votes |
@Override public Response toResponse(IllegalNodeDeletionException exception) { // log the error logger.info(String.format("%s. Returning %s response.", exception, Response.Status.CONFLICT)); if (logger.isDebugEnabled()) { logger.debug(StringUtils.EMPTY, exception); } return Response.status(Response.Status.CONFLICT).entity(exception.getMessage()).type("text/plain").build(); }
Example #28
Source File: ResourceNotFoundExceptionMapper.java From nifi with Apache License 2.0 | 5 votes |
@Override public Response toResponse(ResourceNotFoundException exception) { // log the error logger.info(String.format("%s. Returning %s response.", exception, Response.Status.NOT_FOUND)); if (logger.isDebugEnabled()) { logger.debug(StringUtils.EMPTY, exception); } return Response.status(Status.NOT_FOUND).entity(exception.getMessage()).type("text/plain").build(); }
Example #29
Source File: IllegalArgumentExceptionMapper.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public Response toResponse(IllegalArgumentException exception) { // log the error logger.info(String.format("%s. Returning %s response.", exception, Response.Status.BAD_REQUEST)); logger.debug(StringUtils.EMPTY, exception); return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build(); }
Example #30
Source File: JsonParseExceptionMapper.java From nifi with Apache License 2.0 | 5 votes |
@Override public Response toResponse(JsonParseException ex) { // log the error logger.info(String.format("%s. Returning %s response.", ex, Response.Status.BAD_REQUEST)); if (logger.isDebugEnabled()) { logger.debug(StringUtils.EMPTY, ex); } return Response.status(Response.Status.BAD_REQUEST).entity("Unable to parse body as JSON.").type("text/plain").build(); }