use of org.pentaho.platform.engine.core.output.FileContentItem in project pentaho-platform by pentaho.
the class FileOutputHandler method getFileOutputContentItem.
@Override
public IContentItem getFileOutputContentItem() {
String contentRef = getContentRef();
File file = new File(contentRef);
File dir = file.getParentFile();
if ((dir != null) && !dir.exists()) {
boolean result = dir.mkdirs();
if (!result) {
try {
URI uri = new URI(contentRef);
file = new File(uri);
dir = file.getParentFile();
} catch (URISyntaxException e) {
logger.error(Messages.getInstance().getErrorString("FileOutputHandler.ERROR_0001_COULD_NOT_CREATE_DIRECTORY", // $NON-NLS-1$
dir.getAbsolutePath()));
return null;
}
}
}
try {
SimpleContentItem content = new FileContentItem(file);
return content;
} catch (FileNotFoundException e) {
logger.error(Messages.getInstance().getErrorString("FileOutputHandler.ERROR_0002_COULD_NOT_CREATE_OUTPUT_FILE", file.getAbsolutePath()), // $NON-NLS-1$
e);
}
return null;
}
use of org.pentaho.platform.engine.core.output.FileContentItem in project pentaho-platform by pentaho.
the class XactionUtil method deleteContentItem.
static void deleteContentItem(IContentItem contentItem, IUnifiedRepository unifiedRepository) {
if (contentItem instanceof RepositoryFileContentItem) {
String path = contentItem.getPath();
RepositoryFile repositoryFile = unifiedRepository.getFile(path);
// repositoryFile can be null if we have not access or file does not exist
if (repositoryFile != null) {
unifiedRepository.deleteFile(repositoryFile.getId(), true, null);
}
} else if (contentItem instanceof FileContentItem) {
// Files in the file system must not be deleted here
String path = ((FileContentItem) contentItem).getFile().getName();
logger.warn(Messages.getInstance().getString("XactionUtil.SKIP_REMOVING_OUTPUT_FILE", path));
}
}
Aggregations