List of usage examples for java.util Objects isNull
public static boolean isNull(Object obj)
From source file:com.qpark.eip.core.model.analysis.operation.GetElementTypeOperation.java
/** * @param message/*from w w w .j a v a 2 s .co m*/ * the {@link JAXBElement} containing a * {@link GetElementTypeRequestType}. * @return the {@link JAXBElement} with a {@link GetElementTypeResponseType} * . */ @Override public final JAXBElement<GetElementTypeResponseType> invoke( final JAXBElement<GetElementTypeRequestType> message) { this.logger.debug("+getElementType"); GetElementTypeRequestType request = message.getValue(); GetElementTypeResponseType response = this.of.createGetElementTypeResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.getElementType().addAll(this.dao.getElementTypesById(modelVersion, request.getId())); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getElementType duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getElementType #{}", response.getElementType().size()); } return this.of.createGetElementTypeResponse(response); }
From source file:org.openecomp.sdc.heat.datatypes.DefinedHeatParameterTypes.java
public static boolean isEmptyValueInEnv(Object value) { return Objects.isNull(value); }
From source file:com.qpark.eip.core.model.analysis.operation.GetTargetNamespaceOperation.java
/** * @param message/*from w w w. j a v a 2 s . c o m*/ * the {@link JAXBElement} containing a * {@link GetTargetNamespaceRequestType}. * @return the {@link JAXBElement} with a * {@link GetTargetNamespaceResponseType}. */ @Override public final JAXBElement<GetTargetNamespaceResponseType> invoke( final JAXBElement<GetTargetNamespaceRequestType> message) { this.logger.debug("+getTargetNamespace"); GetTargetNamespaceRequestType request = message.getValue(); GetTargetNamespaceResponseType response = this.of.createGetTargetNamespaceResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.getTargetNamespace().addAll(this.dao.getTargetNamespaces(modelVersion)); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getTargetNamespace duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getTargetNamespace #{}", response.getTargetNamespace().size()); } return this.of.createGetTargetNamespaceResponse(response); }
From source file:com.qpark.eip.core.model.analysis.operation.GetFieldMappingTypeOperation.java
/** * @param message//w w w .j a va2 s. c o m * the {@link JAXBElement} containing a * {@link GetFieldMappingTypeRequestType}. * @return the {@link JAXBElement} with a * {@link GetFieldMappingTypeResponseType} . */ @Override public final JAXBElement<GetFieldMappingTypeResponseType> invoke( final JAXBElement<GetFieldMappingTypeRequestType> message) { this.logger.debug("+getFieldMappingType"); GetFieldMappingTypeRequestType request = message.getValue(); GetFieldMappingTypeResponseType response = this.of.createGetFieldMappingTypeResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.getFieldMappingType().addAll(this.dao.getFieldMappingTypesById(modelVersion, request.getId())); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getFieldMappingType duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getFieldMappingType #{}", response.getFieldMappingType().size()); } return this.of.createGetFieldMappingTypeResponse(response); }
From source file:org.kitodo.production.process.ProcessValidator.java
/** * Check if process title is correct.// w w w .j a va 2 s . co m * * @param title * of the process for validation * @return true or false */ public static boolean isProcessTitleCorrect(String title) { boolean valid = true; if (StringUtils.isBlank(title)) { valid = false; Helper.setErrorMessage(INCOMPLETE_DATA, "processTitleEmpty"); } String validateRegEx = ConfigCore.getParameterOrDefaultValue(ParameterCore.VALIDATE_PROCESS_TITLE_REGEX); if (Objects.isNull(title) || !title.matches(validateRegEx)) { valid = false; Helper.setErrorMessage("processTitleInvalid", new Object[] { validateRegEx }); } if (valid) { valid = isProcessTitleAvailable(title); } return valid; }
From source file:io.kamax.mxisd.backend.wordpress.WordpressThreePidProvider.java
protected Optional<_MatrixID> find(ThreePid tpid) { String query = cfg.getSql().getQuery().getThreepid().get(tpid.getMedium()); if (Objects.isNull(query)) { return Optional.empty(); }/*from w w w . j av a 2 s .c om*/ try (Connection conn = wordpress.getConnection()) { PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, tpid.getAddress()); try (ResultSet rSet = stmt.executeQuery()) { while (rSet.next()) { String uid = rSet.getString("uid"); log.info("Found match: {}", uid); try { return Optional.of(MatrixID.from(uid, mxCfg.getDomain()).valid()); } catch (IllegalArgumentException ex) { log.warn("Ignoring match {} - Invalid characters for a Matrix ID", uid); } } log.info("No valid match found in Wordpress"); return Optional.empty(); } } catch (SQLException e) { throw new RuntimeException(e); } }
From source file:com.qpark.eip.core.model.analysis.operation.GetFlowInterfaceMappingTypeOperation.java
/** * @param message//from www . java 2 s . co m * the {@link JAXBElement} containing a * {@link GetFlowInterfaceMappingTypeRequestType}. * @return the {@link JAXBElement} with a * {@link GetFlowInterfaceMappingTypeResponseType}. */ @Override public final JAXBElement<GetFlowInterfaceMappingTypeResponseType> invoke( final JAXBElement<GetFlowInterfaceMappingTypeRequestType> message) { this.logger.debug("+getFlowInterfaceMappingType"); GetFlowInterfaceMappingTypeRequestType request = message.getValue(); GetFlowInterfaceMappingTypeResponseType response = this.of.createGetFlowInterfaceMappingTypeResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.getInterfaceType() .addAll(this.dao.getFlowInterfaceMappingTypes(modelVersion, request.getFlowId())); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getFlowInterfaceMappingType duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getFlowInterfaceMappingType #{}", response.getInterfaceType().size()); } return this.of.createGetFlowInterfaceMappingTypeResponse(response); }
From source file:org.sonarqube.shell.commands.ConnectCommands.java
@CliCommand(value = CONNECT, help = "Connects to the SonarQube server." + "If this is not specified, attempts to connect to port 9000.\n" + "\tEXAMPLE to connect to SonarQube:\n\n" + "\tconnect --host sonarqube.com --port 443 --protocol https\n") public void connect(@CliOption(key = { "host" }, help = "Specifies the name of the host machine where the SonarQube is running. " + "If this is not specified, attempts to connect to a SonarQube process running on the localhost.", unspecifiedDefaultValue = "localhost", specifiedDefaultValue = "localhost") final String host, @CliOption(key = {/*www . j a va2s. c o m*/ "port" }, help = "Specifies the port where the SonarQube is listening.", unspecifiedDefaultValue = "9000", specifiedDefaultValue = "9000") final Integer port, @CliOption(key = "protocol", help = "Specified the protocol used to connect to SonarQube." + "If this is not specified, the HTTP protocol is used.", unspecifiedDefaultValue = "http", specifiedDefaultValue = "http") final String protocol) { String sonarHost = Objects.isNull(host) ? "localhost" : host; Integer sonarPort = Objects.isNull(port) ? 9000 : port; String sonarProtocol = Objects.isNull(protocol) || !SUPPORTED_PROTOCOLS.contains(protocol.toLowerCase()) ? "http" : protocol; session.connect(sonarHost, sonarPort, sonarProtocol); }
From source file:io.redlink.solrlib.embedded.EmbeddedCoreContainer.java
@Override @SuppressWarnings({ "squid:S3725", "squid:S3776" }) protected synchronized void init(ExecutorService executorService) throws IOException { Preconditions.checkState(Objects.isNull(coreContainer), "Already initialized!"); if (solrHome == null) { solrHome = Files.createTempDirectory("solr-home"); log.debug("No solr-home set, using temp directory {}", solrHome); deleteOnShutdown = true;//from w ww.j a v a 2s. co m } final Path absoluteSolrHome = this.solrHome.toAbsolutePath(); if (Files.isDirectory(absoluteSolrHome)) { log.trace("solr-home exists: {}", absoluteSolrHome); } else { Files.createDirectories(absoluteSolrHome); log.debug("Created solr-home: {}", absoluteSolrHome); } final Path lib = absoluteSolrHome.resolve("lib"); if (Files.isDirectory(lib)) { log.trace("lib-directory exists: {}", lib); } else { Files.createDirectories(lib); log.debug("Created solr-lib directory: {}", lib); } final Path solrXml = absoluteSolrHome.resolve("solr.xml"); if (!Files.exists(solrXml)) { log.info("no solr.xml found, creating new at {}", solrXml); try (PrintStream writer = new PrintStream(Files.newOutputStream(solrXml, StandardOpenOption.CREATE))) { writer.printf("<!-- Generated by %s on %tF %<tT -->%n", getClass().getSimpleName(), new Date()); writer.println("<solr>"); writer.printf(" <str name=\"%s\">%s</str>%n", "sharedLib", absoluteSolrHome.relativize(lib)); writer.println("</solr>"); } } else { log.trace("found solr.xml: {}", solrXml); } for (SolrCoreDescriptor coreDescriptor : coreDescriptors) { final String coreName = coreDescriptor.getCoreName(); if (availableCores.containsKey(coreName)) { log.warn("CoreName-Clash: {} already initialized. Skipping {}", coreName, coreDescriptor.getClass()); continue; } final Path coreDir = absoluteSolrHome.resolve(coreName); Files.createDirectories(coreDir); coreDescriptor.initCoreDirectory(coreDir, lib); final Properties coreProperties = new Properties(); final Path corePropertiesFile = coreDir.resolve("core.properties"); if (Files.exists(corePropertiesFile)) { try (InputStream inStream = Files.newInputStream(corePropertiesFile, StandardOpenOption.CREATE)) { coreProperties.load(inStream); } log.debug("core.properties for {} found, updating", coreName); } else { log.debug("Creating new core {} in {}", coreName, coreDir); } coreProperties.setProperty("name", coreName); try (OutputStream outputStream = Files.newOutputStream(corePropertiesFile)) { coreProperties.store(outputStream, null); } if (coreDescriptor.getNumShards() > 1 || coreDescriptor.getReplicationFactor() > 1) { log.warn("Deploying {} to EmbeddedCoreContainer, ignoring config of shards={},replication={}", coreName, coreDescriptor.getNumShards(), coreDescriptor.getReplicationFactor()); } availableCores.put(coreName, coreDescriptor); } log.info("Starting {} in solr-home '{}'", getClass().getSimpleName(), absoluteSolrHome); coreContainer = CoreContainer.createAndLoad(absoluteSolrHome, solrXml); availableCores.values().forEach(coreDescriptor -> { final String coreName = coreDescriptor.getCoreName(); try (SolrClient solrClient = createSolrClient(coreName)) { final NamedList<Object> coreStatus = CoreAdminRequest.getStatus(coreName, solrClient) .getCoreStatus(coreName); final NamedList<Object> indexStatus = coreStatus == null ? null : (NamedList<Object>) coreStatus.get("index"); final Object lastModified = indexStatus == null ? null : indexStatus.get("lastModified"); // lastModified is null if there was never a update scheduleCoreInit(executorService, coreDescriptor, lastModified == null); } catch (SolrServerException | IOException e) { if (log.isDebugEnabled()) { log.error("Error initializing core {}", coreName, e); } //noinspection ThrowableResultOfMethodCallIgnored coreInitExceptions.put(coreName, e); } }); }
From source file:org.kitodo.production.services.command.KitodoScriptService.java
/** * Start the script execution.//from w w w. ja v a2 s . c om * * @param processes * list of Process objects * @param script * from frontend passed as String */ public void execute(List<Process> processes, String script) throws DataException { this.parameters = new HashMap<>(); // decompose and capture all script parameters StrTokenizer tokenizer = new StrTokenizer(script, ' ', '\"'); while (tokenizer.hasNext()) { String tok = tokenizer.nextToken(); if (Objects.isNull(tok) || !tok.contains(":")) { Helper.setErrorMessage(KITODO_SCRIPT_FIELD, "missing delimiter / unknown parameter: ", tok); } else { String key = tok.substring(0, tok.indexOf(':')); String value = tok.substring(tok.indexOf(':') + 1); this.parameters.put(key, value); } } // pass the appropriate method with the correct parameters if (Objects.isNull(this.parameters.get("action"))) { Helper.setErrorMessage(KITODO_SCRIPT_FIELD, "missing action", " - possible: 'action:addRole, action:setTaskProperty, action:setStepStatus, " + "action:swapprozessesout, action:swapprozessesin, action:deleteTiffHeaderFile, " + "action:importFromFileSystem'"); return; } if (executeScript(processes)) { Helper.setMessage(KITODO_SCRIPT_FIELD, "", "kitodoScript finished"); } }