List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:org.kitodo.export.ExportDms.java
/** * Starts copying all directories configured as export folder. * * @param process// w ww .j a v a2s . co m * object * @param destination * the destination directory * @throws InterruptedException * if the user clicked stop on the thread running the export DMS * task * */ private void directoryDownload(Process process, URI destination) throws IOException, InterruptedException { Collection<Subfolder> processDirs = process.getProject().getFolders().parallelStream() .filter(Folder::isCopyFolder).map(folder -> new Subfolder(process, folder)) .collect(Collectors.toList()); VariableReplacer variableReplacer = new VariableReplacer(null, null, process, null); for (Subfolder processDir : processDirs) { URI dstDir = destination.resolve(variableReplacer.replace(processDir.getFolder().getRelativePath())); fileService.createDirectories(dstDir); Collection<URI> srcs = processDir.listContents().values(); int progress = 0; for (URI src : srcs) { if (Objects.nonNull(exportDmsTask)) { exportDmsTask.setWorkDetail(fileService.getFileName(src)); } fileService.copyFileToDirectory(src, dstDir); if (Objects.nonNull(exportDmsTask)) { exportDmsTask .setProgress((int) ((progress++ + 1) * 98d / processDirs.size() / srcs.size() + 1)); if (exportDmsTask.isInterrupted()) { throw new InterruptedException(); } } } } }
From source file:org.keycloak.models.jpa.JpaRealmProvider.java
@Override public List<GroupModel> searchForGroupByName(RealmModel realm, String search, Integer first, Integer max) { TypedQuery<String> query = em.createNamedQuery("getGroupIdsByNameContaining", String.class) .setParameter("realm", realm.getId()).setParameter("search", search); if (Objects.nonNull(first) && Objects.nonNull(max)) { query = query.setFirstResult(first).setMaxResults(max); }/*from w w w .j a va 2 s . c o m*/ List<String> groups = query.getResultList(); if (Objects.isNull(groups)) return Collections.EMPTY_LIST; List<GroupModel> list = new ArrayList<>(); for (String id : groups) { GroupModel groupById = session.realms().getGroupById(id, realm); while (Objects.nonNull(groupById.getParentId())) { groupById = session.realms().getGroupById(groupById.getParentId(), realm); } if (!list.contains(groupById)) { list.add(groupById); } } list.sort(Comparator.comparing(GroupModel::getName)); return Collections.unmodifiableList(list); }
From source file:org.kitodo.production.plugin.importer.massimport.googlecode.fascinator.redbox.sru.SRUClient.java
/** * <p>//ww w. jav a2s. c o m * Search for a record from the National Library of Australia with the * provided identifier. If multiple records match this identifier only the * first will be returned. * </p> * * @param id * The identifier to search for * @return String The record matching this identifier. Null if not found */ private Node nlaGetRecordNodeById(String id) { nlaNamespaces(); // Run a search String query = "rec.identifier=\"" + id + "\""; String rawXml = getSearchResponse(query); // Get the results nodes if (Objects.nonNull(rawXml)) { List<Node> results = getResultList(rawXml); if (results.isEmpty()) { logger.warn("This identifier matches no records."); return null; } if (results.size() > 1) { logger.warn("This identifier matches multiple records! Returning only the first."); } // Return first(only?) record if ("xml".equals(responsePacking)) { return results.get(0).selectSingleNode("*[1]"); } else { return results.get(0); } } else { logger.warn("This identifier matches no records."); return null; } }
From source file:org.kitodo.production.forms.MassImportForm.java
/** * Get next page./*from w ww .j av a 2s . c o m*/ * * @return next page */ public String nextPage() { if (!testForData()) { Helper.setErrorMessage("missingData"); return this.stayOnCurrentPage; } java.lang.reflect.Method method; try { method = this.plugin.getClass().getMethod(GET_CURRENT_DOC_STRUCTS); Object o = method.invoke(this.plugin); @SuppressWarnings("unchecked") List<? extends DocstructElement> list = (List<? extends DocstructElement>) o; if (Objects.nonNull(list)) { return "/pages/MultiMassImportPage2"; } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | RuntimeException e) { Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); } return massImportTwoPath; }
From source file:org.kitodo.production.forms.IndexingForm.java
private void updateCount(ObjectType objectType) { SearchService searchService = getService(objectType); if (Objects.nonNull(searchService)) { try {// ww w. j a v a 2 s .com indexedObjects.put(objectType, toIntExact(searchService.count())); } catch (DataException e) { Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); } } }
From source file:org.kitodo.production.metadata.MetadataProcessor.java
private void createDefaultValues(LegacyDocStructHelperInterface element) { if (ConfigCore.getBooleanParameterOrDefaultValue(ParameterCore.METS_EDITOR_ENABLE_DEFAULT_INITIALISATION)) { saveMetadataAsBean(element);//from w w w . ja va 2s .co m List allChildren = element.getAllChildren(); if (Objects.nonNull(allChildren)) { for (LegacyDocStructHelperInterface ds : element.getAllChildren()) { createDefaultValues(ds); } } } }
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
private void checkImageAndFlavorNames(String fileName, String imageOrFlavor, String resourceId, Map<String, Object> propertiesMap, GlobalValidationContext globalContext) { Object nameValue = propertiesMap.get(imageOrFlavor) == null ? null : propertiesMap.get(imageOrFlavor); String[] regexList = new String[] { ".*_" + imageOrFlavor + "_name" }; if (Objects.nonNull(nameValue)) { if (nameValue instanceof Map) { String imageOrFlavorName = getWantedNameFromPropertyValueGetParam(nameValue); if (Objects.nonNull(imageOrFlavorName)) { if (!evalPattern(imageOrFlavorName, regexList)) { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.WRONG_IMAGE_OR_FLAVOR_NAME_NOVA_SERVER.getErrorMessage(), imageOrFlavor, resourceId)); }//from w w w .j a v a2 s. c o m } } else { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.MISSING_GET_PARAM.getErrorMessage(), imageOrFlavor, resourceId)); } } }
From source file:org.kitodo.production.forms.MassImportForm.java
/** * Get properties./*from w ww. j a v a2 s .c o m*/ * * @return list of ImportProperty objects */ public List<ImportProperty> getProperties() { if (Objects.nonNull(this.plugin)) { return this.plugin.getProperties(); } return new ArrayList<>(); }
From source file:org.kitodo.production.forms.ProzesskopieForm.java
/** * If there is an RDF configuration (for example, from the OPAC import, or * freshly created), then supplement these. *///from ww w .jav a 2s . c o m private void processRdfConfiguration() { // create RDF config if there is none if (Objects.isNull(this.rdf)) { createNewFileformat(); } try { if (Objects.nonNull(this.rdf)) { insertLogicalDocStruct(); for (AdditionalField field : this.additionalFields) { if (field.isUghBinding() && field.showDependingOnDoctype()) { processAdditionalField(field); } } updateMetadata(); insertCollections(); insertImagePath(); } ServiceManager.getProcessService().readMetadataFile(this.prozessKopie); startTaskScriptThreads(); } catch (IOException e) { Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); } }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the last model version (lexical compare). * * @return the last model version./*from ww w . j a va 2 s . co m*/ * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public String getLastModelVersion() { String value = null; final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<String> q = cb.createQuery(String.class); final Root<EnterpriseType> f = q.from(EnterpriseType.class); q.select(f.<String>get(EnterpriseType_.modelVersion)); q.orderBy(cb.desc(f.<String>get(EnterpriseType_.modelVersion))); final TypedQuery<String> typedQuery = this.em.createQuery(q); final List<String> list = typedQuery.getResultList(); if (Objects.nonNull(list) && list.size() > 0) { value = list.get(0); } return value; }