當前位置: 首頁>>代碼示例>>Java>>正文


Java ContextUtils.dpuException方法代碼示例

本文整理匯總了Java中eu.unifiedviews.helpers.dpu.context.ContextUtils.dpuException方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextUtils.dpuException方法的具體用法?Java ContextUtils.dpuException怎麽用?Java ContextUtils.dpuException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eu.unifiedviews.helpers.dpu.context.ContextUtils的用法示例。


在下文中一共展示了ContextUtils.dpuException方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: XsltExecutor

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
public XsltExecutor(XsltConfig_V2 config,
        BlockingQueue<Task> taskQueue, FaultTolerance faultTolerance, UserExecContext ctx,
        Integer totalFileCounter)
        throws DPUException {
    LOG.info("New executor created!");
    this.proc = new Processor(false);
    // register UUID extension function
    proc.registerExtensionFunction(UUIDGenerator.getInstance());
    this.compiler = proc.newXsltCompiler();
    try {
        this.executable = compiler.compile(
                new StreamSource(new StringReader(config.getXsltTemplate())));
    } catch (SaxonApiException ex) {
        throw ContextUtils.dpuException(ctx, ex, "xslt.dpu.executor.errors.xsltCompile");
    }
    this.config = config;
    this.taskQueue = taskQueue;
    this.ctx = ctx;
    this.totalFileCounter = totalFileCounter;
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:21,代碼來源:XsltExecutor.java

示例2: getScriptWithPath

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
private String getScriptWithPath() throws DPUException {
    DPUContext dpuContext = ctx.getExecMasterContext().getDpuContext();
    Map<String, String> environment = dpuContext.getEnvironment();

    String pathToScript = environment.get(SHELL_SCRIPT_PATH);
    if (pathToScript == null || pathToScript.trim().equals("")) {
        LOG.error("Directory with shell scripts is not set in beckend configuration file!");
        throw ContextUtils.dpuException(ctx, "errors.pathToScriptsNotSet.backend");
    }
    File scriptDirFile = new File(pathToScript);
    if (!scriptDirFile.exists()) {
        LOG.error(String.format("Directory with shell scripts %s doesn't exist!", pathToScript));
        throw ContextUtils.dpuException(ctx, "errors.pathToScriptsDoesntExist.backend");
    }
    File scriptFile = new File(pathToScript, config.getScriptName());
    if (scriptFile == null || !scriptFile.exists()) {
        LOG.error(String.format("Script %s doesn't exist!", config.getScriptName()));
        throw ContextUtils.dpuException(ctx, "errors.scriptDoesntExist");
    }
    return scriptFile.getAbsolutePath();
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:22,代碼來源:ExecuteShellScript.java

示例3: innerExecute

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
@Override
protected void innerExecute() throws DPUException {

    ContextUtils.sendShortInfo(ctx, "ExcelToCsv.message");

    try {
        sheetNameSet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); // case-insensitive sheet names
        String sheetNames = config.getSheetNames();
        if (sheetNames != null && sheetNames.length() > 0) {
            sheetNameSet.addAll(Arrays.asList(sheetNames.split(Pattern.quote(":"))));
        }

        Set<FilesDataUnit.Entry> entries = FilesHelper.getFiles(input);
        for (FilesDataUnit.Entry entry : entries) {
            excelToCsv(entry);
        }
    } catch (DataUnitException | EncryptedDocumentException | InvalidFormatException | IOException ex) {
        throw ContextUtils.dpuException(ctx, ex, "ExcelToCsv.dpuFailed");
    }
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:21,代碼來源:ExcelToCsv.java

示例4: generateGraphFile

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
/**
 * Check if file graph should be generated and if so, then generate new graph file.
 * 
 * @param rdfFile
 * @param graphName
 *            Name of the graph, that will be written into .graph file.
 * @throws DPUException
 */
private void generateGraphFile(final FilesDataUnit.Entry rdfFile, String graphName) throws DPUException {
    final FilesDataUnit.Entry graphFileEntry = faultTolerance.execute(new FaultTolerance.ActionReturn<FilesDataUnit.Entry>() {

        @Override
        public FilesDataUnit.Entry action() throws Exception {
            final String rdfFilePath = MetadataUtils.get(inRdfData, rdfFile, FilesVocabulary.UV_VIRTUAL_PATH);
            return FilesDataUnitUtils.createFile(outFilesData, rdfFilePath + ".graph");
        }
    });
    try {
        FileUtils.writeStringToFile(FaultToleranceUtils.asFile(faultTolerance, graphFileEntry), graphName);
    } catch (IOException ex) {
        throw ContextUtils.dpuException(ctx, ex, "rdfToFiles.error.graphFile");
    }
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:24,代碼來源:RdfToFiles.java

示例5: createOutputGraph

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
/**
 * Creates new output graph. Symbolic name is completely new (using time stamp in suffix).
 * Data graph IRI is generated.
 * @return New output graph.
 * @throws DPUException
 */
protected IRI createOutputGraph() throws DPUException {
    // Register new output graph
    final String symbolicName = "http://unifiedviews.eu/resource/sparql-construct/"
            + Long.toString((new Date()).getTime());
    try {
        return rdfOutput.addNewDataGraph(symbolicName);
    } catch (DataUnitException ex) {
        throw ContextUtils.dpuException(ctx, ex, "sparqlUpdate.dpu.error.cantAddGraph");
    }
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:17,代碼來源:SparqlUpdate.java

示例6: getGraphUriList

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
/**
 * Get graph URIs from entry list.
 * 
 * @param entries
 * @return
 * @throws DPUException
 */
protected List<IRI> getGraphUriList(final List<RDFDataUnit.Entry> entries) throws DPUException {
    final List<IRI> result = new ArrayList<>(entries.size());

    for (RDFDataUnit.Entry entry : entries) {
        try {
            result.add(entry.getDataGraphURI());
        } catch (DataUnitException ex) {
            throw ContextUtils.dpuException(ctx, ex, "sparqlUpdate.dpu.error.dataUnit");
        }
    }

    return result;
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:21,代碼來源:SparqlUpdate.java

示例7: innerExecute

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
@Override
protected void innerExecute() throws DPUException {
    final Date dateStart = new Date();

    try {
        distributionOutput.addNewDataGraph(outputSymbolicName);
        ResourceHelpers.setResource(distributionOutput, outputSymbolicName, DistributionMetadataConfigToResourceConverter.v1ToResource(config));
    } catch (DataUnitException ex) {
        ContextUtils.dpuException(ctx, ex, "DistributionMetadata.execute.exception");
    }

    final Date dateEnd = new Date();
    ContextUtils.sendShortInfo(ctx, "DistributionMetadata.innerExecute.done", (dateEnd.getTime() - dateStart.getTime()));
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:15,代碼來源:DistributionMetadata.java

示例8: addZipEntry

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
/**
 * Add single file into stream as zip entry.
 *
 * @param zos
 * @param buffer
 * @param entry
 * @return True if file has been added.
 * @throws DataUnitException
 */
private boolean addZipEntry(ZipOutputStream zos, byte[] buffer, final FilesDataUnit.Entry entry) throws DPUException {
    // Get virtual path.
    final String virtualPath = faultTolerance.execute(new FaultTolerance.ActionReturn<String>() {

        @Override
        public String action() throws Exception {
            return MetadataUtils.getFirst(inFilesData, entry, VirtualPathHelper.PREDICATE_VIRTUAL_PATH);
        }
    });
    if (virtualPath == null) {
        throw ContextUtils.dpuException(ctx, "zipper.error.missing.virtual.path", entry.toString());
    }
    // Add to the zip file.
    final File sourceFile = FaultToleranceUtils.asFile(faultTolerance, entry);
    LOG.info("Adding file '{}' from source '{}'", virtualPath, sourceFile);
    try (FileInputStream in = new FileInputStream(sourceFile)) {
        final ZipEntry ze = new ZipEntry(virtualPath);
        zos.putNextEntry(ze);
        // Copy data into zip file.
        int len;
        while ((len = in.read(buffer)) > 0) {
            zos.write(buffer, 0, len);
        }
    } catch (Exception ex) {
        LOG.error("Failed to add file: {}", entry.toString(), ex);
        return false;
    }
    return true;
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:39,代碼來源:Zipper.java

示例9: unzip

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
/**
 * Extract given zip file into given directory.
 *
 * @param zipFile
 * @param targetDirectory
 * @throws DPUException
 */
private void unzip(File zipFile, File targetDirectory) throws DPUException{
    try {
        final ZipFile zip = new ZipFile(zipFile);
        if (zip.isEncrypted()) {
            throw ContextUtils.dpuException(ctx, "unzipper.errors.file.encrypted");
        }
        zip.extractAll(targetDirectory.toString());
    } catch (ZipException ex) {
        throw ContextUtils.dpuException(ctx, ex, "unzipper.errors.dpu.extraction.failed");
    }
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:19,代碼來源:UnZipper.java

示例10: createTempOutputDir

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
private File createTempOutputDir() throws DataUnitException, DPUException {
    File parentDir = new File(URI.create(filesOutput.getBaseFileURIString()));
    File outputDir = null;
    if (parentDir.getAbsolutePath().endsWith(File.separator)) {
        outputDir = new File(parentDir, "tmp");
    } else {
        outputDir = new File(parentDir, File.separator + "tmp");
    }

    if (!outputDir.mkdirs()) {
        throw ContextUtils.dpuException(ctx, "errors.creatingTempOutputDir");
    }
    return outputDir;
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:15,代碼來源:ExecuteShellScript.java

示例11: checkResponseAndCreateFile

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
private void checkResponseAndCreateFile(CloseableHttpResponse httpResponse, String fileName) throws DPUException {
    if (httpResponse == null) {
        throw ContextUtils.dpuException(this.ctx, "dpu.errors.response");
    }

    LOG.debug("Going to create file from HTTP response body");
    createFileFromResponse(httpResponse, fileName);
    LOG.debug("File from HTTP response successfully created");
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:10,代碼來源:HttpRequest.java

示例12: createFileFromResponse

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
/**
 * Creates file data unit from HTTP response
 * 
 * @param response
 *            HTTP response
 * @param fileName
 *            File name of result file
 * @throws DPUException
 */
private void createFileFromResponse(CloseableHttpResponse response, final String fileName) throws DPUException {
    LOG.debug("Filename is: {}", fileName);
    // Prepare new output file record.
    final FilesDataUnit.Entry destinationFile = this.faultTolerance.execute(new FaultTolerance.ActionReturn<FilesDataUnit.Entry>() {

        @SuppressWarnings("unqualified-field-access")
        @Override
        public FilesDataUnit.Entry action() throws Exception {
            return FilesDataUnitUtils.createFile(HttpRequest.this.requestOutput, fileName);
        }
    });

    this.faultTolerance.execute(new FaultTolerance.Action() {

        @SuppressWarnings("unqualified-field-access")
        @Override
        public void action() throws Exception {
            final Resource resource = ResourceHelpers.getResource(HttpRequest.this.requestOutput, fileName);
            final Date now = new Date();
            resource.setCreated(now);
            resource.setLast_modified(now);
            ResourceHelpers.setResource(HttpRequest.this.requestOutput, fileName, resource);
        }
    }, "dpu.errors.resource");

    try {
        FileUtils.copyInputStreamToFile(response.getEntity().getContent(),
                FaultToleranceUtils.asFile(this.faultTolerance, destinationFile));
    } catch (IOException ex) {
        LOG.error("Failed to create file from response input stream", ex);
        throw ContextUtils.dpuException(this.ctx, ex, "dpu.errors.response.store");
    }
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:43,代碼來源:HttpRequest.java

示例13: createOutputGraph

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
/**
 * @return New output graph.
 * @throws DPUException
 */
protected IRI createOutputGraph() throws DPUException {
    // Register new output graph
    final String symbolicName = "http://unifiedviews.eu/resource/sparql-construct/"
            + Long.toString((new Date()).getTime());
    try {
        return rdfOutput.addNewDataGraph(symbolicName);
    } catch (DataUnitException ex) {
        throw ContextUtils.dpuException(ctx, ex, "SparqlConstruct.execute.exception.addGraph");
    }
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:15,代碼來源:SparqlConstruct.java

示例14: execute

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
/**
 *
 * @param codeToExecute
 * @param failMessage   Text of exception that should be thrown in case of failure. Message is localized
 *                      before use.
 * @param args
 * @throws DPUException
 */
public void execute(Action codeToExecute, String failMessage, Object... args) throws DPUException {
    try {
        execute(codeToExecute);
    } catch (DPUException ex) {
        // Rethrow with custom user message.
        throw ContextUtils.dpuException(context.asUserContext(), ex, failMessage, args);
    }
}
 
開發者ID:UnifiedViews,項目名稱:Plugin-DevEnv,代碼行數:17,代碼來源:FaultTolerance.java

示例15: innerExecute

import eu.unifiedviews.helpers.dpu.context.ContextUtils; //導入方法依賴的package包/類
@Override
protected void innerExecute() throws DPUException {

    Set<RDFFormat> rdfFormats = RDFParserRegistry.getInstance().getKeys();

    rdfFormat = selectFormat(config.getRdfFileFormat(), rdfFormats); //RDFFormat.matchFileName(config.getRdfFileFormat(), rdfFormats).get();
    if (rdfFormat == null) {
        throw ContextUtils.dpuException(ctx, "rdfToFiles.error.rdfFortmat.null");
    }

    final List<RDFDataUnit.Entry> graphs = FaultToleranceUtils.getEntries(faultTolerance, inRdfData,
            RDFDataUnit.Entry.class);

    if (graphs.size() > 0) {

        // Create output file.
        final String outputFileName = config.getOutFileName() + "." + rdfFormat.getDefaultFileExtension();
        // Prepare output file entity.
        final FilesDataUnit.Entry outputFile = faultTolerance.execute(new FaultTolerance.ActionReturn<FilesDataUnit.Entry>() {

            @Override
            public FilesDataUnit.Entry action() throws Exception {
                return FilesDataUnitUtils.createFile(outFilesData, outputFileName);
            }
        });

        exportGraph(graphs, outputFile);
    } else {
        //no data to be exported, no file being produced. 
        ContextUtils.sendMessage(ctx, MessageType.INFO, "rdfToFiles.nodata", "");
    }

}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:34,代碼來源:RdfToFiles.java


注:本文中的eu.unifiedviews.helpers.dpu.context.ContextUtils.dpuException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。