List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:org.kitodo.config.ConfigProject.java
private String cleanXmlFormattedString(String inString) { if (Objects.nonNull(inString)) { inString = inString.replaceAll("\t", " "); inString = inString.replaceAll("\n", " "); while (inString.contains(" ")) { inString = inString.replaceAll(" {2}", " "); }//from ww w . jav a2 s .com } return inString; }
From source file:org.kitodo.production.services.data.LdapServerService.java
/** * Retrieve home directory of given user. * * @param user/*from ww w .j av a 2 s .co m*/ * User object * @return path as URI */ public URI getUserHomeDirectory(User user) { String userFolderBasePath = ConfigCore.getParameter(ParameterCore.DIR_USERS); if (ConfigCore.getBooleanParameterOrDefaultValue(ParameterCore.LDAP_USE_LOCAL_DIRECTORY)) { return Paths.get(userFolderBasePath, user.getLogin()).toUri(); } Hashtable<String, String> env = initializeWithLdapConnectionSettings(user.getLdapGroup().getLdapServer()); if (ConfigCore.getBooleanParameterOrDefaultValue(ParameterCore.LDAP_USE_TLS)) { return getUserHomeDirectoryWithTLS(env, userFolderBasePath, user); } if (ConfigCore.getBooleanParameter(ParameterCore.LDAP_USE_SIMPLE_AUTH, false)) { env.put(Context.SECURITY_AUTHENTICATION, "none"); } DirContext ctx; URI userFolderPath = null; try { ctx = new InitialDirContext(env); Attributes attrs = ctx.getAttributes(buildUserDN(user)); Attribute ldapAttribute = attrs.get("homeDirectory"); userFolderPath = URI.create((String) ldapAttribute.get(0)); ctx.close(); } catch (NamingException e) { logger.error(e.getMessage(), e); } if (Objects.nonNull(userFolderPath) && !userFolderPath.isAbsolute()) { if (userFolderPath.getPath().startsWith("/")) { userFolderPath = ServiceManager.getFileService().deleteFirstSlashFromPath(userFolderPath); } return Paths.get(userFolderBasePath, userFolderPath.getRawPath()).toUri(); } else { return userFolderPath; } }
From source file:org.eclipse.winery.repository.rest.resources._support.AbstractComponentsResource.java
/** * Used by org.eclipse.winery.repository.repository.client and by the artifactcreationdialog.tag. Especially the * "name" field is used there at the UI/*from ww w .j a v a 2s. co m*/ * * @param grouped if given, the JSON output is grouped by namespace * @return A list of all ids of all instances of this component type. Format: <code>[({"namespace": * "[namespace]", "id": "[id]"},)* ]</code>. * <p> * If grouped is set, the list will be grouped by namespace. * <code>[{"id": "[namsepace encoded]", "test": "[namespace decoded]", "children":[{"id": "[qName]", "text": * "[id]"}]}]</code> */ @GET @Produces(MediaType.APPLICATION_JSON) public Object getListOfAllIds(@QueryParam("grouped") String grouped, @QueryParam("includeVersions") String includeVersions, @QueryParam("full") @ApiParam("If set, the full information of the definition's child is returned. E.g., in the case of node types, the same result as a GET on {ns}/{id] is returned. Works only in the case of grouped.") String full) { Class<? extends DefinitionsChildId> idClass = RestUtils .getComponentIdClassForComponentContainer(this.getClass()); boolean supportsNameAttribute = Util.instanceSupportsNameAttribute(idClass); final IRepository repository = RepositoryFactory.getRepository(); SortedSet<? extends DefinitionsChildId> allDefinitionsChildIds = null; allDefinitionsChildIds = repository.getAllDefinitionsChildIds(idClass); if (Objects.nonNull(grouped)) { return getGroupedListOfIds(allDefinitionsChildIds, full, includeVersions); } else { return getListOfIds(allDefinitionsChildIds, supportsNameAttribute, full, includeVersions); } }
From source file:com.qpark.maven.plugin.servletconfig.WebXmlGenerator.java
private String getWebXml() { StringBuffer sb = new StringBuffer(1024); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); sb.append("<web-app xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"); sb.append("\txmlns=\"http://java.sun.com/xml/ns/javaee\" \n"); sb.append("\txmlns:web=\"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\" \n"); sb.append(/*w w w .ja va 2s . c o m*/ "\txsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\" \n"); sb.append("\tid=\"WebApp_ID\" version=\"2.5\"> \n"); sb.append(Util.getGeneratedAtXmlComment(this.getClass(), this.eipVersion)); sb.append("\n"); sb.append("\t<context-param>\n"); sb.append("\t\t<param-name>contextConfigLocation</param-name>\n"); sb.append("\t\t<param-value>classpath:MainApplicationContext.xml</param-value>\n"); sb.append("\t</context-param>\n"); sb.append("\t<display-name>Service bus: "); sb.append(this.serviceId); sb.append(" service "); sb.append(this.serviceVersion); sb.append("-r"); sb.append(this.revisionNumber); sb.append(" build time: "); sb.append(Util.getXsdDateTime(this.d)); sb.append("</display-name>\n"); sb.append("\t<env-entry>\n"); sb.append("\t\t<env-entry-name>servicebus-name</env-entry-name>\n"); sb.append("\t\t<env-entry-type>java.lang.String</env-entry-type>\n"); sb.append("\t\t<env-entry-value>Service bus: "); sb.append(this.serviceId); sb.append(" service "); sb.append(this.serviceVersion); sb.append("-"); sb.append(this.revisionNumber); sb.append(" build time: "); sb.append(Util.getXsdDateTime(this.d)); sb.append("</env-entry-value>\n"); sb.append("\t</env-entry>\n"); sb.append("\t<env-entry>\n"); sb.append("\t\t<env-entry-name>servicebus-service-name</env-entry-name>\n"); sb.append("\t\t<env-entry-type>java.lang.String</env-entry-type>\n"); sb.append("\t\t<env-entry-value>"); sb.append(this.serviceId); sb.append("</env-entry-value>\n"); sb.append("\t</env-entry>\n"); sb.append("\t<env-entry>\n"); sb.append("\t\t<env-entry-name>servicebus-version-name</env-entry-name>\n"); sb.append("\t\t<env-entry-type>java.lang.String</env-entry-type>\n"); sb.append("\t\t<env-entry-value>"); sb.append(this.serviceVersion); sb.append("</env-entry-value>\n"); sb.append("\t</env-entry>\n"); sb.append("\t<env-entry>\n"); sb.append("\t\t<env-entry-name>servicebus-build-svnrevision</env-entry-name>\n"); sb.append("\t\t<env-entry-type>java.lang.String</env-entry-type>\n"); sb.append("\t\t<env-entry-value>"); sb.append(this.revisionNumber); sb.append("</env-entry-value>\n"); sb.append("\t</env-entry>\n"); sb.append("\t<env-entry>\n"); sb.append("\t\t<env-entry-name>servicebus-build-time</env-entry-name>\n"); sb.append("\t\t<env-entry-type>java.lang.String</env-entry-type>\n"); sb.append("\t\t<env-entry-value>"); sb.append(Util.getXsdDateTime(this.d)); sb.append("</env-entry-value>\n"); sb.append("\t</env-entry>\n"); sb.append("\t<env-entry>\n"); sb.append("\t\t<env-entry-name>servicebus-war-name</env-entry-name>\n"); sb.append("\t\t<env-entry-type>java.lang.String</env-entry-type>\n"); sb.append("\t\t<env-entry-value>"); sb.append(this.warName); sb.append(".war</env-entry-value>\n"); sb.append("\t</env-entry>\n"); sb.append("\t<!-- logback definitions -->\n"); sb.append("\t<env-entry>\n"); sb.append("\t\t<env-entry-name>logback/context-name</env-entry-name>\n"); sb.append("\t\t<env-entry-type>java.lang.String</env-entry-type>\n"); sb.append("\t\t<env-entry-value>"); sb.append(this.warName); sb.append("</env-entry-value>\n"); sb.append("\t</env-entry>\n"); sb.append("\t<env-entry>\n"); sb.append("\t\t<env-entry-name>logback/configuration-resource</env-entry-name>\n"); sb.append("\t\t<env-entry-type>java.lang.String</env-entry-type>\n"); sb.append("\t\t<env-entry-value>logback.xml</env-entry-value>\n"); sb.append("\t</env-entry>\n"); sb.append("\t<!-- Spring security -->\n"); sb.append("\t<filter>\n"); sb.append("\t\t<filter-name>springSecurityFilterChain</filter-name>\n"); sb.append("\t\t<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>\n"); sb.append("\t</filter>\n"); if (this.additionalWebappFilter != null && this.additionalWebappFilter.trim().length() > 0) { sb.append("\t<!-- Additional filter -->\n"); sb.append("\t<filter>\n"); sb.append("\t\t<filter-name>comQparkMavenPluginServletConfigAdditionalFilter</filter-name>\n"); sb.append("\t\t<filter-class>"); sb.append(this.additionalWebappFilter.trim()); sb.append("</filter-class>\n"); sb.append("\t</filter>\n"); } sb.append("\t<!-- logback avoiding JNDI calls -->\n"); sb.append("\t<filter>\n"); sb.append("\t\t<filter-name>LoggerContextFilter</filter-name>\n"); sb.append("\t\t<filter-class>ch.qos.logback.classic.selector.servlet.LoggerContextFilter</filter-class>\n"); sb.append("\t</filter>\n"); sb.append("\t<filter-mapping>\n"); sb.append("\t\t<filter-name>springSecurityFilterChain</filter-name>\n"); sb.append("\t\t<url-pattern>/*</url-pattern>\n"); sb.append("\t</filter-mapping>\n"); sb.append("\t<filter-mapping>\n"); sb.append("\t\t<filter-name>LoggerContextFilter</filter-name>\n"); sb.append("\t\t<url-pattern>/*</url-pattern>\n"); sb.append("\t</filter-mapping>\n"); if (this.additionalWebappFilter != null && this.additionalWebappFilter.trim().length() > 0) { sb.append("\t<filter-mapping>\n"); sb.append("\t\t<filter-name>comQparkMavenPluginServletConfigAdditionalFilter</filter-name>\n"); sb.append("\t\t<url-pattern>/*</url-pattern>\n"); sb.append("\t</filter-mapping>\n"); } sb.append( "\t<!-- logback should be the first in the list (http://logback.qos.ch/manual/loggingSeparation.html)! -->\n"); sb.append("\t<listener>\n"); sb.append( "\t\t<listener-class>ch.qos.logback.classic.selector.servlet.ContextDetachingSCL</listener-class>\n"); sb.append("\t</listener>\n"); sb.append("\t<listener>\n"); sb.append("\t\t<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\n"); sb.append("\t</listener>\n"); sb.append("\t<servlet>\n"); sb.append("\t\t<servlet-name>ws</servlet-name>\n"); sb.append( "\t\t<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>\n"); sb.append("\t\t\t<init-param>\n"); sb.append("\t\t\t<param-name>transformWsdlLocations</param-name>\n"); sb.append("\t\t\t<param-value>true</param-value>\n"); sb.append("\t\t\t</init-param>\n"); sb.append("\t</servlet>\n"); if (Objects.nonNull(this.mvcUrlPattern) && this.mvcUrlPattern.trim().length() > 0) { sb.append("\t<servlet>\n"); sb.append("\t\t<servlet-name>mvc</servlet-name>\n"); sb.append("\t\t<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>\n"); sb.append("\t\t<load-on-startup>1</load-on-startup>\n"); sb.append("\t</servlet>\n"); } sb.append("\t<servlet-mapping>\n"); sb.append("\t\t<servlet-name>ws</servlet-name>\n"); sb.append("\t\t<url-pattern>/"); if (this.warName.contains("##")) { sb.append(this.serviceVersion); sb.append("/"); } sb.append("services/*</url-pattern>\n"); sb.append("\t</servlet-mapping>\n"); sb.append("\t<servlet-mapping>\n"); sb.append("\t\t<servlet-name>ws</servlet-name>\n"); sb.append("\t\t<url-pattern>*.wsdl</url-pattern>\n"); sb.append("\t</servlet-mapping>\n"); if (Objects.nonNull(this.mvcUrlPattern) && this.mvcUrlPattern.trim().length() > 0) { sb.append("\t<servlet-mapping>\n"); sb.append("\t\t<servlet-name>mvc</servlet-name>\n"); sb.append("\t\t<url-pattern>"); sb.append(this.mvcUrlPattern); sb.append("</url-pattern>\n"); sb.append("\t</servlet-mapping>\n"); } if (Objects.nonNull(this.mvcUrlPattern) && this.mvcUrlPattern.trim().length() > 0) { sb.append("\t<filter>\n"); sb.append("\t\t<filter-name>httpMethodFilter</filter-name>\n"); sb.append("\t\t\t<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>\n"); sb.append("\t</filter>\n"); sb.append("\t<filter-mapping>\n"); sb.append("\t\t<filter-name>httpMethodFilter</filter-name>\n"); sb.append("\t\t<servlet-name>mvc</servlet-name>\n"); sb.append("\t</filter-mapping>\n"); } sb.append("\t<error-page>\n"); sb.append("\t\t<exception-type>java.lang.Throwable</exception-type>\n"); sb.append("\t\t<location>/WEB-INF/views/errors/container-exceptions.jsp</location>\n"); sb.append("\t</error-page>\n"); sb.append("\t<mime-mapping>\n"); sb.append("\t\t<extension>xsd</extension>\n"); sb.append("\t\t<mime-type>text/xml</mime-type>\n"); sb.append("\t</mime-mapping>\n"); sb.append("</web-app>\n"); return sb.toString(); }
From source file:org.openecomp.sdc.validation.impl.util.HeatValidationService.java
/** * Loop over output map and validate get attr from nested. * * @param fileName the file name * @param outputMap the output map * @param heatOrchestrationTemplate the heat orchestration template * @param globalContext the global context *//* www. ja v a 2 s. c o m*/ @SuppressWarnings("unchecked") public static void loopOverOutputMapAndValidateGetAttrFromNested(String fileName, Map<String, Output> outputMap, HeatOrchestrationTemplate heatOrchestrationTemplate, GlobalValidationContext globalContext) { for (Output output : outputMap.values()) { Object outputValue = output.getValue(); if (outputValue != null && outputValue instanceof Map) { Map<String, Object> outputValueMap = (Map<String, Object>) outputValue; List<String> getAttrValue = (List<String>) outputValueMap .get(ResourceReferenceFunctions.GET_ATTR.getFunction()); if (!CollectionUtils.isEmpty(getAttrValue)) { String resourceName = getAttrValue.get(0); String propertyName = getAttrValue.get(1); String resourceType = getResourceTypeFromResourcesMap(resourceName, heatOrchestrationTemplate); if (Objects.nonNull(resourceType) && HeatValidationService.isNestedResource(resourceType)) { Map<String, Output> nestedOutputMap; HeatOrchestrationTemplate nestedHeatOrchestrationTemplate; try { nestedHeatOrchestrationTemplate = new YamlUtil().yamlToObject( globalContext.getFileContent(resourceType), HeatOrchestrationTemplate.class); } catch (Exception e0) { return; } nestedOutputMap = nestedHeatOrchestrationTemplate.getOutputs(); if (MapUtils.isEmpty(nestedOutputMap) || !nestedOutputMap.containsKey(propertyName)) { globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.GET_ATTR_NOT_FOUND.getErrorMessage(), propertyName, resourceName)); } } } } } }
From source file:org.kitodo.production.helper.tasks.EmptyTask.java
/** * The function getTaskState() returns the task state. It can be one of * the followings:// w w w. j av a 2s . c o m * * <dl> * <dt><code>CRASHED</code></dt> * <dd>The thread has terminated abnormally. The field exception? is * holding the exception that has occurred.</dd> * <dt><code>FINISHED</code></dt> * <dd>The thread has finished its work without errors and is available for * clean-up.</dd> * <dt><code>NEW</code></dt> * <dd>The thread has not yet been started.</dd> * <dt><code>STOPPED</code></dt> * <dd>The thread was stopped by a front end userresulting in a call to its * {@link #interrupt(Behaviour)} method with {@link Behaviour} * .PREPARE_FOR_RESTART and is able to restart after cloning and replacing * it.</dd> * <dt><code>STOPPING</code></dt> * <dd>The thread has received a request to interrupt but didnt stop * yet.</dd> * <dt><code>WORKING</code></dt> * <dd>The thread is in operation.</dd> * </dl> * * @return the task state */ TaskState getTaskState() { switch (getState()) { case NEW: return TaskState.NEW; case TERMINATED: if (Objects.isNull(behaviour)) { behaviour = DEFAULT_BEHAVIOUR; } if (Objects.nonNull(exception)) { return TaskState.CRASHED; } if (Behaviour.PREPARE_FOR_RESTART.equals(behaviour)) { return TaskState.STOPPED; } else { return TaskState.FINISHED; } default: if (isInterrupted()) { return TaskState.STOPPING; } else { return TaskState.WORKING; } } }
From source file:org.esa.s3tbx.olci.radiometry.rayleigh.RayleighAux.java
public double[] getSunAzimuthAnglesRad() { if (Objects.nonNull(sunAzimuthAnglesRad)) { return sunAzimuthAnglesRad; }//from www . ja v a 2 s . co m throw new NullPointerException("The sun azimuth angles is null."); }
From source file:org.kitodo.export.ExportDms.java
private boolean executeDataCopierProcess(LegacyMetsModsDigitalDocumentHelper gdzfile, Process process, String rules) {// w ww .j a va2 s . c o m try { new DataCopier(rules).process(new CopierData(gdzfile, process)); } catch (ConfigurationException e) { if (Objects.nonNull(exportDmsTask)) { exportDmsTask.setException(e); } else { Helper.setErrorMessage("dataCopier.syntaxError", e.getMessage(), logger, e); return false; } } return true; }
From source file:org.kitodo.production.services.data.BatchService.java
/** * Returns the translated batch type label. * * @return the display label for the batch type *//*from www . j a v a 2 s. c o m*/ public String getTypeTranslated(Batch batch) { if (Objects.nonNull(batch.getType())) { return Helper.getTranslation(BATCH + "_type_".concat(batch.getType().toString().toLowerCase())); } else { return ""; } }
From source file:com.qpark.maven.plugin.flowmapper.AbstractGenerator.java
protected final ComplexContent getMapperDefinition(final ComplexType ct) { ComplexContent cc = this.complexContentList.getComplexContent(ct.getTargetNamespace(), ct.getQNameLocalPart());/*from w ww . ja v a 2 s .co m*/ if (Objects.nonNull(cc) && cc.isInterfaceType) { cc = null; } return cc; }