本文整理汇总了Java中org.uberfire.backend.server.util.Paths类的典型用法代码示例。如果您正苦于以下问题:Java Paths类的具体用法?Java Paths怎么用?Java Paths使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Paths类属于org.uberfire.backend.server.util包,在下文中一共展示了Paths类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Override
public Path create(final Path context,
final String fileName,
final SolverConfigModel config,
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,
configPersistence.toXML(config),
commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
示例2: save
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Override
public Path save(final Path resource,
final SolverConfigModel config,
final Metadata metadata,
final String comment) {
try {
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource),
configPersistence.toXML(config),
metadataService.setUpAttributes(resource,
metadata),
commentedOptionFactory.makeCommentedOption(comment));
fireMetadataSocialEvents(resource,
currentMetadata,
metadata);
return resource;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
示例3: fillIndexBuilder
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Override
protected DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
final org.uberfire.backend.vfs.Path vfsPath = Paths.convert(path);
final KieProject project = kieProjectService.resolveProject(vfsPath);
if (project == null) {
logger.error("Unable to index " + path.toUri() + ", project could not be resolved.");
return null;
}
final Package _package = kieProjectService.resolvePackage(vfsPath);
if (_package == null) {
logger.error("Unable to index " + path.toUri() + ", package could not be resolved.");
return null;
}
return new DefaultIndexBuilder(vfsPath.getFileName(),
project,
_package);
}
示例4: save
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Override
@SuppressWarnings("unused")
public void save(final Path pathToPomXML,
final RepositoryStructureModel model,
final String comment) {
final FileSystem fs = Paths.convert(pathToPomXML).getFileSystem();
try {
pomService.save(pathToPomXML,
model.getPOM(),
model.getPOMMetaData(),
comment,
true);
} catch (final Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
示例5: getProjects
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
private List<Project> getProjects(final Path branchRoot) {
final List<Project> repositoryProjects = new ArrayList<Project>();
if (branchRoot == null) {
return repositoryProjects;
} else {
final DirectoryStream<org.uberfire.java.nio.file.Path> nioRepositoryPaths = ioService.newDirectoryStream(Paths.convert(branchRoot));
for (org.uberfire.java.nio.file.Path nioRepositoryPath : nioRepositoryPaths) {
if (Files.isDirectory(nioRepositoryPath)) {
final org.uberfire.backend.vfs.Path projectPath = Paths.convert(nioRepositoryPath);
final Project project = projectService.resolveProject(projectPath);
if (project != null) {
repositoryProjects.add(project);
}
}
}
return repositoryProjects;
}
}
示例6: validate
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Override
public Collection<ValidationMessage> validate(final Path path) {
if (path != null) {
String dataObjectSource = ioService.readAllString(Paths.convert(path));
GenerationResult generationResult = dataModelerService.loadDataObject(path,
dataObjectSource,
path);
if (generationResult.hasErrors()) {
return Collections.emptyList();
} else {
DataObject dataObject = generationResult.getDataObject();
if (dataObject.getAnnotation(PLANNING_SOLUTION_ANNOTATION) != null) {
return Arrays.asList(new PlanningSolutionToBeDuplicatedMessage(Level.ERROR));
}
}
}
return Collections.emptyList();
}
示例7: create
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Override
public Path create(final Path projectRoot,
final String repositoryWebBaseURL,
final POM pomModel) {
org.uberfire.java.nio.file.Path pathToPOMXML = null;
try {
pomModel.addRepository(getRepository(repositoryWebBaseURL));
final org.uberfire.java.nio.file.Path nioRoot = Paths.convert(projectRoot);
pathToPOMXML = nioRoot.resolve("pom.xml");
if (ioService.exists(pathToPOMXML)) {
throw new FileAlreadyExistsException(pathToPOMXML.toString());
}
ioService.write(pathToPOMXML,
pomContentHandler.toString(pomModel));
//Don't raise a NewResourceAdded event as this is handled at the Project level in ProjectServices
return Paths.convert(pathToPOMXML);
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
示例8: postProcess
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Override
public void postProcess(final Path path) {
String dataObjectSource = ioService.readAllString(Paths.convert(path));
GenerationResult generationResult = dataModelerService.loadDataObject(path,
dataObjectSource,
path);
if (generationResult.hasErrors()) {
LOGGER.warn("Path " + path + " parsing as a data object has failed. Score holder global generation will be skipped.");
} else {
DataObject dataObject = generationResult.getDataObject();
if (dataObject.getAnnotation(PLANNING_SOLUTION_ANNOTATION) != null) {
org.uberfire.java.nio.file.Path source = Paths.convert(kieProjectService.resolvePackage(path).getPackageMainResourcesPath());
org.uberfire.java.nio.file.Path sourcePackage = Files.isDirectory(source) ? source : source.getParent();
String dataObjectFileName = path.getFileName().substring(0,
path.getFileName().indexOf("."));
ioService.deleteIfExists(sourcePackage.resolve(dataObjectFileName + SCORE_HOLDER_GLOBAL_FILE_SUFFIX));
}
}
}
示例9: dataObjectToADataObject
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Test
public void dataObjectToADataObject() {
Path dataObjectPath = PathFactory.newPath("Test.java",
"file:///dataObjects");
when(ioService.readAllString(Paths.convert(dataObjectPath))).thenReturn("testResult");
DataObject originalDataObject = createDataObject(null);
GenerationResult generationResult = new GenerationResult();
generationResult.setDataObject(originalDataObject);
when(dataModelerService.loadDataObject(any(),
anyString(),
any())).thenReturn(generationResult);
DataObject updatedDataObject = createDataObject(null);
Collection<ValidationMessage> result = validator.validate(dataObjectPath,
updatedDataObject);
assertTrue(result.isEmpty());
}
示例10: scoreHolderTypeNotRecognized
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Test
public void scoreHolderTypeNotRecognized() {
Path dataObjectPath = PathFactory.newPath("Test.java",
"file:///dataObjects");
when(ioService.readAllString(Paths.convert(dataObjectPath))).thenReturn("testResult");
DataObject originalDataObject = createDataObject(HardSoftScore.class);
GenerationResult generationResult = new GenerationResult();
generationResult.setDataObject(originalDataObject);
when(dataModelerService.loadDataObject(any(),
anyString(),
any())).thenReturn(generationResult);
when(scoreHolderUtils.extractScoreTypeFqn(originalDataObject)).thenReturn(HardSoftScore.class.getName());
when(scoreHolderUtils.getScoreHolderTypeFqn(HardSoftScore.class.getName())).thenReturn(HardSoftScoreHolder.class.getName());
when(assetsUsageService.getAssetUsages(HardSoftScoreHolder.class.getName(),
ResourceType.JAVA, dataObjectPath)).thenReturn(Arrays.asList(mock(Path.class)));
DataObject updatedDataObject = createDataObject(SimpleScore.class);
when(scoreHolderUtils.extractScoreTypeFqn(updatedDataObject)).thenReturn("UnknownScoreClassName");
when(scoreHolderUtils.getScoreHolderTypeFqn("UnknownScoreClassName")).thenReturn(null);
}
示例11: notAPlanningSolution
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Test
public void notAPlanningSolution() {
Path dataObjectPath = PathFactory.newPath("Test.java",
"file:///dataObjects");
when(ioService.readAllString(Paths.convert(dataObjectPath))).thenReturn("testResult");
DataObject originalDataObject = new DataObjectImpl("test",
"Test");
GenerationResult generationResult = new GenerationResult();
generationResult.setDataObject(originalDataObject);
when(dataModelerService.loadDataObject(any(),
anyString(),
any())).thenReturn(generationResult);
DataObject updatedDataObject = new DataObjectImpl("test",
"Test");
Collection<ValidationMessage> result = validator.validate(dataObjectPath,
updatedDataObject);
assertTrue(result.isEmpty());
}
示例12: extractSolutionScoreTypeFqns
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
private Collection<String> extractSolutionScoreTypeFqns(final Path solutionObjectPath) {
org.uberfire.java.nio.file.Path source = Paths.convert(kieProjectService.resolvePackage(solutionObjectPath).getPackageMainResourcesPath());
org.uberfire.java.nio.file.Path sourcePackage = Files.isDirectory(source) ? source : source.getParent();
String sourceSolutionFileName = solutionObjectPath.getFileName().substring(0,
solutionObjectPath.getFileName().indexOf("."));
org.uberfire.java.nio.file.Path sourceScoreHolderGlobalPath = sourcePackage.resolve(sourceSolutionFileName + SCORE_HOLDER_GLOBAL_FILE_SUFFIX);
boolean scoreHolderGlobalFileExists = ioService.exists(sourceScoreHolderGlobalPath);
if (scoreHolderGlobalFileExists) {
GlobalsModel globalsModel = globalsEditorService.load(Paths.convert(sourceScoreHolderGlobalPath));
return globalsModel.getGlobals().stream()
.filter(global -> "scoreHolder".equals(global.getAlias()))
.map(Global::getClassName)
.collect(Collectors.toList());
}
return Collections.emptyList();
}
示例13: extractSolutionBendableScoreLevelsSize
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
public BendableScoreLevelsWrapper extractSolutionBendableScoreLevelsSize(final Path solutionPath) {
String solutionString = ioService.readAllString(Paths.convert(solutionPath));
GenerationResult generationResult = dataModelerService.loadDataObject(solutionPath,
solutionString,
solutionPath);
if (!generationResult.hasErrors()) {
DataObject dataObject = generationResult.getDataObject();
ObjectProperty scoreObjectProperty = dataObject.getProperty("score");
if (scoreObjectProperty != null) {
if (isBendableScore(scoreObjectProperty.getClassName())) {
Annotation annotation = scoreObjectProperty.getAnnotation(PlanningScore.class.getName());
if (annotation != null) {
Object hardLevelsSize = annotation.getValue("bendableHardLevelsSize");
Object softLevelsSize = annotation.getValue("bendableSoftLevelsSize");
return new BendableScoreLevelsWrapper(hardLevelsSize == null ? 0 : (int) hardLevelsSize,
softLevelsSize == null ? 0 : (int) softLevelsSize);
}
}
}
}
return new BendableScoreLevelsWrapper();
}
示例14: deletePath
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
void deletePath(final Path path,
final String comment) {
final org.uberfire.java.nio.file.Path _path = Paths.convert(path);
try {
ioService.startBatch(_path.getFileSystem());
// Delegate additional changes required for a deletion to applicable Helpers. Helpers are invoked before
// the deletion as Helpers may depend on the presence of the file; in particular when it is necessary to
// resolve a Package from a file name.
notifyDeleteHelpers(path);
ioService.delete(Paths.convert(path),
new CommentedOption(sessionInfo != null ? sessionInfo.getId() : "--",
identity.getIdentifier(),
null,
comment));
} catch (final Exception e) {
throw new RuntimeException(e);
} finally {
ioService.endBatch();
}
}
示例15: setUpAttributes
import org.uberfire.backend.server.util.Paths; //导入依赖的package包/类
@Override
public Map<String, Object> setUpAttributes(final Path path,
final Metadata metadata) {
try {
Map<String, Object> attributes;
try {
attributes = ioService.readAttributes(Paths.convert(path));
} catch (final NoSuchFileException ex) {
attributes = new HashMap<String, Object>();
}
if (metadata != null) {
attributes = configAttrs(attributes,
metadata);
}
return BasicFileAttributesUtil.cleanup(attributes);
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}