本文整理汇总了Java中eu.unifiedviews.helpers.dpu.context.ContextUtils.sendError方法的典型用法代码示例。如果您正苦于以下问题:Java ContextUtils.sendError方法的具体用法?Java ContextUtils.sendError怎么用?Java ContextUtils.sendError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.unifiedviews.helpers.dpu.context.ContextUtils
的用法示例。
在下文中一共展示了ContextUtils.sendError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: zipFiles
import eu.unifiedviews.helpers.dpu.context.ContextUtils; //导入方法依赖的package包/类
/**
* Pack files in given iterator into zip file and add metadata.
*
* @param zipFile
* @param filesIteration
*/
private void zipFiles(File zipFile, List<FilesDataUnit.Entry> filesIteration) throws DPUException {
final byte[] buffer = new byte[8196];
// Used to publish the error mesage only for the first time.
boolean firstFailure = true;
try (FileOutputStream fos = new FileOutputStream(zipFile); ZipOutputStream zos = new ZipOutputStream(fos)) {
// Itarate over files and zip them.
int counter = 0;
for (FilesDataUnit.Entry entry : filesIteration) {
LOG.info("Processing: {}/{}", counter++, filesIteration.size());
if (ctx.canceled()) {
break;
}
if (!addZipEntry(zos, buffer, entry)) {
if (firstFailure) {
// TODO This needs rework, we fail but not instantly?
ContextUtils.sendError(ctx, "zipper.errors.zip.failed", "");
}
firstFailure = false;
}
}
} catch (IOException ex) {
throw new DPUException(ex);
}
}
示例2: executeAddons
import eu.unifiedviews.helpers.dpu.context.ContextUtils; //导入方法依赖的package包/类
/**
* Execute all {@link ExecutableAddon}s of this DPU.
*
* @param execPoint
* @return If exception is thrown then return false.
*/
private boolean executeAddons(Extension.ExecutionPoint execPoint) {
boolean result = true;
for (Extension item : this.masterContext.getExtensions()) {
if (item instanceof Extension.Executable) {
final Extension.Executable executable = (Extension.Executable) item;
try {
LOG.debug("Executing '{}' with on '{}' point", executable.getClass().getSimpleName(),
execPoint.toString());
executable.execute(execPoint);
} catch (ExtensionException ex) {
ContextUtils.sendError(this.ctx, "Addon execution failed",
ex, "Addon: s", item.getClass().getSimpleName());
result = false;
}
}
}
return result;
}
示例3: executeFormDataHttpRequestsForInputRdfConfiguration
import eu.unifiedviews.helpers.dpu.context.ContextUtils; //导入方法依赖的package包/类
/**
* Executes HTTP request for each input file
*
* @param client
* @throws DPUException
*/
private void executeFormDataHttpRequestsForInputRdfConfiguration(CloseableHttpClient client) throws DPUException {
CloseableHttpResponse httpResponse = null;
int errorCounter = 0;
int counter = 1;
if (config.getFormParamBodies() == null || config.getFormParamBodies().isEmpty()) {
throw new DPUException("RDF configuration with form param bodies is missing. The processing ends with an error");
}
LOG.info("Sending POST/PUT requests with bodies coming over RDF data unit");
LOG.info("Number of bodies: {}", config.getFormParamBodies().size());
for (FormParamBody paramBody : config.getFormParamBodies()) {
LOG.info("ParamBody: {}", paramBody);
try {
String targetFileName = String.format("%03d", counter++);
if (this.config.getRequestType() == RequestType.PUT) {
httpResponse = this.requestExecutor.sendMultipartFormPutRequestFromRdf(this.config, paramBody, client);
} else {
httpResponse = this.requestExecutor.sendMultipartFormPostRequestFromRdf(this.config, paramBody, client);
}
checkResponseAndCreateFile(httpResponse, targetFileName);
} catch (Exception e) {
ContextUtils.sendShortWarn(this.ctx, "dpu.errors.request.formParamRdf", paramBody);
errorCounter++;
} finally {
HttpRequestHelper.tryCloseHttpResponse(httpResponse);
}
}
if (errorCounter == config.getFormParamBodies().size()) {
ContextUtils.sendError(this.ctx, "dpu.errors.files.all", "dpu.errors.files.all.long");
return;
}
}
示例4: excelToCsv
import eu.unifiedviews.helpers.dpu.context.ContextUtils; //导入方法依赖的package包/类
private void excelToCsv(FilesDataUnit.Entry entry) throws EncryptedDocumentException, InvalidFormatException, IOException,
DataUnitException {
ContextUtils.sendShortInfo(ctx, "ExcelToCsv.excelTransformationStared", entry.getSymbolicName());
File excelFile = FilesHelper.asFile(entry);
try (Workbook wb = WorkbookFactory.create(OPCPackage.open(excelFile, PackageAccess.READ))) {
for (int s = 0; s < wb.getNumberOfSheets(); s++) {
Sheet sheet = wb.getSheetAt(s);
ContextUtils.sendShortInfo(ctx, "ExcelToCsv.sheetName", sheet.getSheetName());
if (sheetNameSet.isEmpty() || sheetNameSet.contains(sheet.getSheetName())) {
DpuFile csvFile = createCsvFile(entry.getSymbolicName(), sheet.getSheetName());
ContextUtils.sendShortInfo(ctx, "ExcelToCsv.csvGenerationStarted", csvFile.symbolicName);
sheetToCsv(sheet, csvFile.file);
ContextUtils.sendShortInfo(ctx, "ExcelToCsv.csvGenerationFinished", csvFile.symbolicName);
} else {
ContextUtils.sendShortInfo(ctx, "ExcelToCsv.sheetIgnored", sheet.getSheetName());
}
}
} catch (EncryptedDocumentException | InvalidFormatException | IOException ex) {
ContextUtils.sendError(ctx, "ExcelToCsv.excelTransformationFailed", ex, "ExcelToCsv.excelTransformationFailed", entry.getSymbolicName());
throw ex;
}
ContextUtils.sendShortInfo(ctx, "ExcelToCsv.excelTransformationFinishedSuccessfully", entry.getSymbolicName());
}
示例5: isCsvFileValid
import eu.unifiedviews.helpers.dpu.context.ContextUtils; //导入方法依赖的package包/类
private boolean isCsvFileValid(File inputFile) {
boolean isValid = false;
CsvPreference csvPreference;
if (this.config.getFieldDelimiter() == null || this.config.getFieldDelimiter().isEmpty()) {
final QuoteMode customQuoteMode = new QuoteMode() {
@Override
public boolean quotesRequired(String csvColumn, CsvContext context, CsvPreference preference) {
return false;
}
};
csvPreference = new CsvPreference.Builder(' ', this.config.getFieldSeparator().charAt(0),
"\\n").useQuoteMode(customQuoteMode).build();
} else {
csvPreference = new CsvPreference.Builder(this.config.getFieldDelimiter().charAt(0),
this.config.getFieldSeparator().charAt(0), "\\n").build();
}
try (FileInputStream fileInputStream = new FileInputStream(inputFile);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, this.config.getEncoding());
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
CsvListReader csvListReader = new CsvListReader(bufferedReader, csvPreference)) {
for (int i = 1; i <= this.config.getDataBegginningRow(); i++) {
bufferedReader.readLine();
}
int rowNum = this.config.getDataBegginningRow();
List<String> row = csvListReader.read();
if (row == null) {
// no data
LOG.warn("No data found!");
return true;
}
while (row != null && !this.ctx.canceled()) {
if (row.size() < this.config.getColumnMapping().size()) {
ContextUtils.sendError(this.ctx, "csv.errors.invalid.input.short", "csv.errors.invalid.input.long", rowNum, row.size(), this.config.getColumnMapping().size());
return false;
}
row = csvListReader.read();
rowNum++;
}
isValid = true;
} catch (IOException e) {
LOG.error("Failed to parse input CSV file", e);
isValid = false;
}
return isValid;
}