use of org.uberfire.java.nio.file.FileAlreadyExistsException in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImpl method create.
@Override
public Path create(final Path context, final String fileName, final Scenario content, final String comment) {
try {
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
ioService.write(nioPath, ScenarioXMLPersistence.getInstance().marshal(content), commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.uberfire.java.nio.file.FileAlreadyExistsException in project drools-wb by kiegroup.
the class GlobalsEditorServiceImpl method createInternal.
private Path createInternal(final Path context, final String fileName, final GlobalsModel content, final String comment, final boolean generate) {
try {
final Package pkg = moduleService.resolvePackage(context);
final String packageName = (pkg == null ? null : pkg.getPackageName());
content.setPackageName(packageName);
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
if (generate) {
Metadata metadata = MetadataBuilder.newMetadata().withGenerated(true).build();
ioService.write(nioPath, GlobalsPersistence.getInstance().marshal(content), metadataService.configAttrs(new HashMap<>(), metadata), commentedOptionFactory.makeCommentedOption(comment));
} else {
ioService.write(nioPath, GlobalsPersistence.getInstance().marshal(content), commentedOptionFactory.makeCommentedOption(comment));
}
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.uberfire.java.nio.file.FileAlreadyExistsException in project drools-wb by kiegroup.
the class DSLTextEditorServiceImpl method create.
@Override
public Path create(final Path context, final String fileName, final String content, final String comment) {
try {
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
ioService.write(nioPath, content, commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
Aggregations