List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:org.kitodo.production.services.image.ImageGenerator.java
/** * If there is a supervisor, lets him take an action. Otherwise nothing * happens.// ww w .j a v a 2s . c o m * * @param action * what the supervisor should do */ public void letTheSupervisorDo(Consumer<EmptyTask> action) { if (Objects.nonNull(supervisor)) { action.accept(supervisor); } }
From source file:org.kitodo.production.exporter.ExportXmlLog.java
private Element getTemplateElement(Process process, Namespace xmlns) { Element template = new Element("original", xmlns); template.setAttribute("originalID", String.valueOf(process.getId())); List<Element> templateProperties = new ArrayList<>(); for (Property property : process.getTemplates()) { Element propertyElement = preparePropertyElement(xmlns, property); Element label = new Element(LABEL, xmlns); label.setText(property.getTitle()); propertyElement.addContent(label); templateProperties.add(propertyElement); if (property.getTitle().equals("Signatur")) { Element secondProperty = new Element(PROPERTY, xmlns); secondProperty.setAttribute(PROPERTY_IDENTIFIER, property.getTitle() + "Encoded"); if (Objects.nonNull(property.getValue())) { secondProperty.setAttribute(VALUE, "vorl:" + replacer(property.getValue())); Element secondLabel = new Element(LABEL, xmlns); secondLabel.setText(property.getTitle()); secondProperty.addContent(secondLabel); templateProperties.add(secondProperty); }// w w w .java 2s. c om } } if (!templateProperties.isEmpty()) { Element properties = new Element(PROPERTIES, xmlns); properties.addContent(templateProperties); template.addContent(properties); } return template; }
From source file:org.eclipse.winery.accountability.AccountabilityManagerImpl.java
protected Map<String, ProvenanceVerification> validateBlockchainInput( List<ModelProvenanceElement> historyElements, String manifestId, Map<String, File> files, AuthorizationInfo authorizationInfo) throws IOException, NoSuchAlgorithmException { LOGGER.info("Start validating..."); Map<String, ProvenanceVerification> verificationMap = new HashMap<>(); ModelProvenanceElement validHistoryElement = verifyManifest(historyElements, manifestId, files, verificationMap, authorizationInfo); if (Objects.nonNull(validHistoryElement) && verificationMap.get(manifestId) == VERIFIED) { verifyFiles(validHistoryElement, files, verificationMap); }/*from w w w . j a v a 2 s.c o m*/ LOGGER.info("Completed validation."); return verificationMap; }
From source file:org.kitodo.production.forms.MassImportForm.java
private void addProcessToList(ImportObject importObject) throws IOException { URI importFileName = importObject.getImportFileName(); Process process = JobCreation.generateProcess(importObject, this.template); if (Objects.isNull(process)) { if (Objects.nonNull(importFileName) && !ServiceManager.getFileService().getFileName(importFileName).isEmpty() && Objects.nonNull(selectedFilenames) && !selectedFilenames.isEmpty()) { selectedFilenames.remove(importFileName.getRawPath()); }/*from ww w . j a v a 2 s. c om*/ Helper.setErrorMessage( "import failed for " + importObject.getProcessTitle() + ", process generation failed"); } else { Helper.setMessage( ImportReturnValue.EXPORT_FINISHED.getValue() + " for " + importObject.getProcessTitle()); this.processList.add(process); } }
From source file:org.eclipse.winery.repository.rest.resources._support.AbstractComponentsResource.java
private List<ComponentId> getListOfIds(SortedSet<? extends DefinitionsChildId> allDefinitionsChildIds, boolean supportsNameAttribute, String full, String includeVersions) { return allDefinitionsChildIds.stream().sorted().map(id -> { String name = id.getXmlId().getDecoded(); Definitions definitions = null;/*from ww w . ja va 2 s .co m*/ WineryVersion version = null; if (supportsNameAttribute) { AbstractComponentInstanceResource componentInstanceResource = AbstractComponentsResource .getComponentInstanceResource(id); name = ((IHasName) componentInstanceResource).getName(); } if (Objects.nonNull(full)) { definitions = getFullComponentData(id); } if (Objects.nonNull(includeVersions)) { version = VersionUtils.getVersion(id.getXmlId().getDecoded()); } return new ComponentId(id.getXmlId().getDecoded(), name, id.getNamespace().getDecoded(), id.getQName(), definitions, version); }).collect(Collectors.toList()); }
From source file:org.kitodo.production.ldap.LdapUser.java
@Override public Attributes getAttributes(String name, String[] ids) throws NamingException { if (!name.equals("")) { throw new NameNotFoundException(); }// ww w . j a v a2 s. c om Attributes answer = new BasicAttributes(true); Attribute target; for (String id : ids) { target = this.attributes.get(id); if (Objects.nonNull(target)) { answer.put(target); } } return answer; }
From source file:org.kitodo.production.plugin.importer.massimport.PicaMassImport.java
private void readVolumeNumber(LegacyDocStructHelperInterface child) { // reading volume number if (child != null) { LegacyMetadataTypeHelper mdt = prefs.getMetadataTypeByName("CurrentNoSorting"); List<? extends LegacyMetadataHelper> mdList = child.getAllMetadataByType(mdt); if (Objects.nonNull(mdList) && !mdList.isEmpty()) { LegacyMetadataHelper md = mdList.get(0); volumeNumber = md.getValue(); } else {/* w ww . j av a 2 s .c o m*/ mdt = prefs.getMetadataTypeByName("DateIssuedSort"); mdList = child.getAllMetadataByType(mdt); if (Objects.nonNull(mdList) && !mdList.isEmpty()) { LegacyMetadataHelper md = mdList.get(0); volumeNumber = md.getValue(); } } } }
From source file:org.esa.s3tbx.olci.radiometry.rayleigh.RayleighAux.java
public double[] getCosSZARads() { if (Objects.nonNull(cosSZARads)) { return cosSZARads; }/* w w w .j a va2 s .com*/ throw new NullPointerException("The sun zenith angles is null."); }
From source file:org.kitodo.export.ExportDms.java
private LegacyMetsModsDigitalDocumentHelper readDocument(Process process, LegacyMetsModsDigitalDocumentHelper newFile) { LegacyMetsModsDigitalDocumentHelper gdzfile; try {/*from w ww .j a va2s .c o m*/ switch (MetadataFormat.findFileFormatsHelperByName(process.getProject().getFileFormatDmsExport())) { case METS: gdzfile = new LegacyMetsModsDigitalDocumentHelper(this.myPrefs.getRuleset()); break; case METS_AND_RDF: default: throw new UnsupportedOperationException("Dead code pending removal"); } gdzfile.setDigitalDocument(newFile); return gdzfile; } catch (RuntimeException e) { if (Objects.nonNull(exportDmsTask)) { exportDmsTask.setException(e); logger.error(Helper.getTranslation(ERROR_EXPORT, Collections.singletonList(process.getTitle())), e); } else { Helper.setErrorMessage(ERROR_EXPORT, new Object[] { process.getTitle() }, logger, e); } return null; } }
From source file:org.esa.s3tbx.olci.radiometry.rayleigh.RayleighAux.java
public void setCosSZARads(double[] sunZenithAnglesRad) { if (Objects.nonNull(sunZenithAnglesRad)) { cosSZARads = Arrays.stream(sunZenithAnglesRad).map(Math::cos).toArray(); }/* w w w .j ava 2 s .c o m*/ }