List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:org.openecomp.sdc.validation.impl.util.ResourceValidationHeatValidator.java
private static Set<String> getSharedResourcesNamesFromOutputs(String filename, Map<String, Output> outputsMap, GlobalValidationContext globalContext) { Set<String> sharedResources = new HashSet<>(); if (MapUtils.isEmpty(outputsMap)) { return null; }// w w w. j a va 2 s .c o m for (Map.Entry<String, Output> outputEntry : outputsMap.entrySet()) { Output output = outputEntry.getValue(); Object valueObject = output.getValue(); if (valueObject instanceof Map) { Map<String, Object> outputValueMap = (Map<String, Object>) valueObject; Object getResourceValue = outputValueMap.get(ResourceReferenceFunctions.GET_RESOURCE.getFunction()); if (Objects.nonNull(getResourceValue)) { if (getResourceValue instanceof String) { String resourceName = (String) outputValueMap .get(ResourceReferenceFunctions.GET_RESOURCE.getFunction()); sharedResources.add(resourceName); } else { globalContext.addMessage(filename, ErrorLevel.ERROR, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.INVALID_GET_RESOURCE_SYNTAX.getErrorMessage(), getResourceValue.toString())); } } } } return sharedResources; }
From source file:org.kitodo.production.forms.ProzesskopieForm.java
/** * There must be at least one non-anchor level doc struct, if missing, * insert logical doc structures until you reach it. *//*from w ww.ja v a 2 s . c o m*/ private void insertLogicalDocStruct() { LegacyDocStructHelperInterface populizer = null; try { populizer = rdf.getDigitalDocument().getLogicalDocStruct(); if (Objects.nonNull(populizer.getAnchorClass()) && Objects.isNull(populizer.getAllChildren())) { LegacyLogicalDocStructTypeHelper docStructType = populizer.getDocStructType(); while (Objects.nonNull(docStructType.getAnchorClass())) { throw new UnsupportedOperationException("Dead code pending removal"); } } } catch (NullPointerException | IndexOutOfBoundsException e) { String name = Objects.nonNull(populizer) && Objects.nonNull(populizer.getDocStructType()) ? populizer.getDocStructType().getName() : null; Helper.setErrorMessage( "DocStrctType: " + name + " is configured as anchor but has no allowedchildtype.", logger, e); } }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of serviceIds available. * * @param modelVersion/*w w w .j a va 2 s .c o m*/ * the model version. * @return the list of serviceIds available. * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<String> getServiceIds(final String modelVersion) { final List<String> value = new ArrayList<String>(); final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<ServiceType> q = cb.createQuery(ServiceType.class); final Root<ServiceType> f = q.from(ServiceType.class); q.where(cb.equal(f.<String>get(ServiceType_.modelVersion), modelVersion)); q.orderBy(cb.asc(f.<String>get(ServiceType_.serviceId)), cb.asc(f.<String>get(ServiceType_.namespace))); final TypedQuery<ServiceType> typedQuery = this.em.createQuery(q); final List<ServiceType> services = typedQuery.getResultList(); services.stream().filter(s -> Objects.nonNull(s.getServiceId())).forEach(s -> value.add(s.getServiceId())); return value; }
From source file:org.kitodo.production.forms.ProzesskopieForm.java
private void insertCollections() { LegacyDocStructHelperInterface colStruct = this.rdf.getDigitalDocument().getLogicalDocStruct(); if (Objects.nonNull(colStruct) && Objects.nonNull(colStruct.getAllChildren()) && !colStruct.getAllChildren().isEmpty()) { try {//from ww w. ja va 2 s .com addCollections(colStruct); // falls ein erstes Kind vorhanden ist, sind die Collectionen // dafr colStruct = colStruct.getAllChildren().get(0); addCollections(colStruct); } catch (RuntimeException e) { Helper.setErrorMessage("The first child below the top structure could not be determined!", logger, e); } } }
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
private void checkIfNovaNameParameterInEnvIsStringOrList(String fileName, String envFileName, Map.Entry<String, Resource> resourceEntry, String novaServerName, GlobalValidationContext globalContext) { if (Objects.nonNull(envFileName)) { Environment environment = validateEnvContent(envFileName, globalContext); if (environment != null && MapUtils.isNotEmpty(environment.getParameters())) { Object novaServerNameEnvValue = environment.getParameters().containsKey(novaServerName) ? environment.getParameters().get(novaServerName) : null;// w w w.j a v a 2 s.c om if (Objects.nonNull(novaServerNameEnvValue)) { if (!DefinedHeatParameterTypes.isNovaServerEnvValueIsFromRightType(novaServerNameEnvValue)) { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.NOVA_SERVER_NAME_NOT_ALIGNED_WITH_GUIDE_LINES.getErrorMessage(), resourceEntry.getKey())); } } } } }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of target name spaces available. * * @param modelVersion/*from ww w .j av a 2 s .c o m*/ * the model version. * @return the list of target name spaces available. * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<String> getTargetNamespaces(final String modelVersion) { final List<String> value = new ArrayList<String>(); final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<ClusterType> q = cb.createQuery(ClusterType.class); final Root<ClusterType> f = q.from(ClusterType.class); q.where(cb.equal(f.<String>get(ClusterType_.modelVersion), modelVersion)); q.orderBy(cb.asc(f.<String>get(ClusterType_.name)), cb.asc(f.<String>get(ClusterType_.id))); final TypedQuery<ClusterType> typedQuery = this.em.createQuery(q); final List<ClusterType> cluster = typedQuery.getResultList(); cluster.stream().filter(c -> Objects.nonNull(c.getName())).forEach(c -> value.add(c.getName())); return value; }
From source file:org.kitodo.production.services.data.TaskService.java
/** * Only lets projects pass where a source folder is selected. * /* www .ja v a 2s . co m*/ * @param projects * the unpurified stream of projects * @return a stream only of projects that define a source to generate images */ private static Stream<Project> skipProjectsWithoutSourceFolder(Stream<Project> projects) { return projects.filter(project -> Objects.nonNull(project.getGeneratorSource())); }
From source file:org.kitodo.production.forms.ProzesskopieForm.java
/** * Insert image path and delete any existing ones first. *//*from w w w . j a v a 2 s. c o m*/ private void insertImagePath() throws IOException { LegacyMetsModsDigitalDocumentHelper digitalDocument = this.rdf.getDigitalDocument(); try { LegacyMetadataTypeHelper mdt = ProcessService.getMetadataType(this.prozessKopie, "pathimagefiles"); List<? extends LegacyMetadataHelper> allImagePaths = digitalDocument.getPhysicalDocStruct() .getAllMetadataByType(mdt); if (Objects.nonNull(allImagePaths)) { for (LegacyMetadataHelper metadata : allImagePaths) { digitalDocument.getPhysicalDocStruct().getAllMetadata().remove(metadata); } } LegacyMetadataHelper newMetadata = new LegacyMetadataHelper(mdt); String path = ServiceManager.getFileService().getImagesDirectory(this.prozessKopie) + this.prozessKopie.getTitle().trim() + "_" + DIRECTORY_SUFFIX; if (SystemUtils.IS_OS_WINDOWS) { newMetadata.setStringValue("file:/" + path); } else { newMetadata.setStringValue("file://" + path); } digitalDocument.getPhysicalDocStruct().addMetadata(newMetadata); // write Rdf file ServiceManager.getFileService().writeMetadataFile(this.rdf, this.prozessKopie); } catch (IllegalArgumentException e) { Helper.setErrorMessage("UghHelperException", logger, e); } }
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
private void validateNovaServerAvailabilityZoneName(String fileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext) { String[] regexList = new String[] { "availability_zone_(\\d+)" }; if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { return;/*from w ww .j a va 2s . com*/ } Object availabilityZoneMap = resourceEntry.getValue().getProperties().containsKey("availability_zone") ? resourceEntry.getValue().getProperties().get("availability_zone") : null; if (Objects.nonNull(availabilityZoneMap)) { if (availabilityZoneMap instanceof Map) { String availabilityZoneName = getWantedNameFromPropertyValueGetParam(availabilityZoneMap); if (availabilityZoneName != null) { if (!evalPattern(availabilityZoneName, regexList)) { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.AVAILABILITY_ZONE_NOT_ALIGNED_WITH_GUIDE_LINES.getErrorMessage(), resourceEntry.getKey())); } } } else { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.MISSING_GET_PARAM.getErrorMessage(), "availability_zone", resourceEntry.getKey())); } } }
From source file:org.geowebcache.sqlite.MbtilesBlobStore.java
protected void persistParameterMap(TileObject stObj) { if (Objects.nonNull(stObj.getParametersId())) { putLayerMetadata(stObj.getLayerName(), "parameters." + stObj.getParametersId(), ParametersUtils.getKvp(stObj.getParameters())); }//from w w w. j a v a2 s . com }