Example usage for java.util Objects nonNull

List of usage examples for java.util Objects nonNull

Introduction

In this page you can find the example usage for java.util Objects nonNull.

Prototype

public static boolean nonNull(Object obj) 

Source Link

Document

Returns true if the provided reference is non- null otherwise returns false .

Usage

From source file:org.kitodo.export.ExportDms.java

private boolean prepareAndDownloadSaveLocation(Process process, URI destinationDirectory,
        LegacyMetsModsDigitalDocumentHelper gdzfile) throws IOException {
    // TODO: why create again destinationDirectory if it is already given as
    // an/* w  w w  .j  a va2  s  .  c om*/
    // input??
    URI destination;
    URI userHome;
    if (process.getProject().isUseDmsImport()) {
        // TODO: I have got here value usr/local/kitodo/hotfolder
        destination = new File(process.getProject().getDmsImportImagesPath()).toURI();
        userHome = destination;

        // if necessary, create process folder
        if (process.getProject().isDmsImportCreateProcessFolder()) {
            URI userHomeProcess = fileService.createResource(userHome,
                    File.separator + Helper.getNormalizedTitle(process.getTitle()));
            destination = userHomeProcess;
            boolean createProcessFolderResult = createProcessFolder(userHomeProcess, userHome,
                    process.getProject(), process.getTitle());
            if (!createProcessFolderResult) {
                return false;
            }
        }
    } else {
        destination = URI.create(destinationDirectory + atsPpnBand + "/");
        // if the home exists, first delete and then create again
        userHome = destination;
        if (!fileService.delete(userHome)) {
            Helper.setErrorMessage(
                    Helper.getTranslation(ERROR_EXPORT, Collections.singletonList(process.getTitle())),
                    Helper.getTranslation(EXPORT_DIR_DELETE, Collections.singletonList("Home")));
            return false;
        }
        prepareUserDirectory(destination);
    }
    if (Objects.nonNull(exportDmsTask)) {
        exportDmsTask.setProgress(1);
    }

    return exportImagesAndMetsToDestinationUri(process, gdzfile, destination, userHome);
}

From source file:com.qpark.eip.core.sftp.SftpGatewayImpl.java

private void getTreeOfFiles(final List<String> filePathes, final String parent, final String currentDirectory,
        final String fileNamePattern) throws Exception {
    String remotePath = parent;//from   www .j a  v a  2 s .  c  om
    if (currentDirectory != null) {
        remotePath = String.format("%s%s%s", parent, this.getRemoteFileSeparator(), currentDirectory);
    }
    this.logger.trace("getTreeOfFiles {} {}", parent, currentDirectory);
    final LsClientCallback callback = new LsClientCallback(remotePath, null);
    final Vector<LsEntry> entries = this.template.executeWithClient(callback);
    if (callback.getSftpException() != null) {
        this.logger.error("ls {} {}", remotePath, callback.getSftpException().getMessage());
        throw callback.getSftpException();
    } else if (Objects.nonNull(entries)) {
        final String rPath = remotePath;
        entries.stream()
                .filter(lsEntry -> !lsEntry.getFilename().equals(".") && !lsEntry.getFilename().equals(".."))
                .forEach(lsEntry -> {
                    if (lsEntry.getAttrs().isDir()) {
                        try {
                            this.getTreeOfFiles(filePathes, rPath, lsEntry.getFilename(), fileNamePattern);
                        } catch (final Exception e) {
                        }
                    } else if (lsEntry.getFilename().matches(fileNamePattern)) {
                        filePathes.add(
                                new StringBuffer().append(rPath).append(this.template.getRemoteFileSeparator())
                                        .append(lsEntry.getFilename()).toString());
                        this.logger.trace("getTreeOfFiles {} {} added {}", parent, currentDirectory,
                                lsEntry.getFilename());
                    }
                });
    }
}

From source file:org.kitodo.production.helper.VariableReplacer.java

private String replaceStringForTask(String input) {
    if (Objects.nonNull(this.task)) {
        String taskId = String.valueOf(this.task.getId());
        String taskName = this.task.getTitle();

        input = input.replace("(stepid)", taskId);
        input = input.replace("(stepname)", taskName);
    }//from  ww w. ja v  a  2 s .  co m
    return input;
}

From source file:org.kitodo.production.helper.tasks.EmptyTask.java

/**
 * The function getStateDescription() returns a text string representing the
 * state of the current task as read-only property "stateDescription".
 *
 * @return a string representing the state of the task
 *///from w w w  . j  a  v  a  2s .  com
public String getStateDescription() {
    TaskState state = getTaskState();
    String label = Helper.getTranslation(state.toString().toLowerCase());
    switch (state) {
    case WORKING:
        if (Objects.nonNull(detail)) {
            return label + " (" + detail + ")";
        } else {
            return label;
        }
    case CRASHED:
        if (Objects.nonNull(exception.getMessage())) {
            return label + " (" + exception.getMessage() + ")";
        } else if (Objects.nonNull(detail)) {
            return label + " (" + detail + ")";
        } else {
            return label + " (" + exception.getClass().getSimpleName() + ")";
        }
    default:
        return label;
    }
}

From source file:org.openecomp.sdc.validation.impl.util.HeatValidationService.java

/**
 * Is nested loop exist in file boolean.
 *
 * @param callingFileName the calling file name
 * @param nestedFileName  the nested file name
 * @param filesInLoop     the files in loop
 * @param globalContext   the global context
 * @return the boolean//from   w w w.j  a va2  s .co  m
 */
public static boolean isNestedLoopExistInFile(String callingFileName, String nestedFileName,
        List<String> filesInLoop, GlobalValidationContext globalContext) {
    HeatOrchestrationTemplate nestedHeatOrchestrationTemplate;
    try {
        nestedHeatOrchestrationTemplate = new YamlUtil()
                .yamlToObject(globalContext.getFileContent(nestedFileName), HeatOrchestrationTemplate.class);
    } catch (Exception e0) {
        logger.warn("HEAT Validator will not be executed on file " + nestedFileName
                + " due to illegal HEAT format");
        return false;
    }
    filesInLoop.add(nestedFileName);
    Collection<Resource> nestedResources = nestedHeatOrchestrationTemplate.getResources() == null ? null
            : nestedHeatOrchestrationTemplate.getResources().values();
    if (CollectionUtils.isNotEmpty(nestedResources)) {
        for (Resource resource : nestedResources) {
            String resourceType = resource.getType();

            if (Objects.nonNull(resourceType) && isNestedResource(resourceType)) {
                return resourceType.equals(callingFileName) || !filesInLoop.contains(resourceType)
                        && isNestedLoopExistInFile(callingFileName, resourceType, filesInLoop, globalContext);
            }
        }
    }
    return false;
}

From source file:org.kitodo.production.services.command.KitodoScriptService.java

private void runScript(List<Process> processes, String taskName, String scriptName) throws DataException {
    for (Process process : processes) {
        for (Task task : process.getTasks()) {
            if (task.getTitle().equalsIgnoreCase(taskName)) {
                if (Objects.nonNull(scriptName)) {
                    if (task.getScriptName().equals(scriptName)) {
                        String path = task.getScriptPath();
                        ServiceManager.getTaskService().executeScript(task, path, false);
                    }/*from  ww  w . ja v a2 s  .co  m*/
                } else {
                    ServiceManager.getTaskService().executeScript(task, false);
                }
            }
        }
    }
}

From source file:de.speexx.csv.table.app.Application.java

void doVerboseLog(final Configuration conf, final String message, final Object... values) {
    assert Objects.nonNull(conf);
    if (conf.isVerbose()) {
        LOG.info(message, values);/*from w  w  w .j  a v  a 2 s.c  o  m*/
    }
}

From source file:com.github.rutledgepaulv.qbuilders.visitors.PredicateVisitor.java

private Predicate<T> exists(ComparisonNode node) {
    return t -> resolveSingleField(t, node.getField().asKey(), node, (one, two) -> Objects.nonNull(one));
}

From source file:org.kitodo.production.forms.MassImportForm.java

private void iterateOverAnswer(List<ImportObject> answer) throws IOException {
    Batch batch = null;//from w ww  .ja v a2s.c o m
    if (answer.size() > 1) {
        batch = getBatch();
    }

    for (ImportObject io : answer) {
        if (Objects.nonNull(batch)) {
            io.getBatches().add(batch);
        }

        if (io.getImportReturnValue().equals(ImportReturnValue.EXPORT_FINISHED)) {
            addProcessToList(io);
        } else {
            removeImportFileNameFromSelectedFileNames(io);
        }
    }
}

From source file:org.kitodo.production.services.data.BatchService.java

/**
 * The function getLabel() returns a readable label for the batch, which is
 * either its title, if defined, or, for batches not having a title (in
 * recent versions of Production, batches didnt support titles) its ancient
 * label, consisting of the prefix Batch ? (in the desired translation)
 * together with its id number.// w ww  .  j a  v a  2  s. c  o m
 *
 * @return a readable label for the batch
 */
public String getLabel(Batch batch) {
    return Objects.nonNull(batch.getTitle()) ? batch.getTitle() : getNumericLabel(batch);
}