本文整理汇总了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;
}
示例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();
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
示例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;
}
示例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()));
}
示例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;
}
示例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");
}
}
示例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;
}
示例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");
}
示例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");
}
}
示例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");
}
}
示例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);
}
}
示例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", "");
}
}