use of org.eclipse.ceylon.cmr.spi.OpenNode in project ceylon by eclipse.
the class RepoUsingTool method findCompiledVersions.
private Collection<ModuleVersionDetails> findCompiledVersions(RepositoryManager repoMgr, String name, Type type, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) throws IOException {
String outRepo = DefaultToolOptions.getCompilerOutputRepo();
if (outRepo != null) {
File outDir = new File(outRepo);
CmrRepository rep = null;
List<CmrRepository> repositories = repoMgr.getRepositories();
for (CmrRepository repository : repositories) {
OpenNode root = repository.getRoot();
// it has binaries if it is not a folder
if (root.isRemote() || root.hasBinaries())
continue;
ContentStore service = root.getService(ContentStore.class);
if (service == null)
continue;
ContentHandle content = service.peekContent(root);
// again skip binaries
if (content == null || content.hasBinaries())
continue;
File repoFile = content.getContentAsFile();
if (repoFile != null && FileUtil.sameFile(repoFile, outDir)) {
rep = repository;
break;
}
}
if (rep != null && rep.isSearchable()) {
ModuleVersionQuery query = getModuleVersionQuery(null, name, null, type, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
ModuleVersionResult result = new ModuleVersionResult(query.getName());
rep.completeVersions(query, result);
NavigableMap<String, ModuleVersionDetails> outRepoVersions = result.getVersions();
if (!outRepoVersions.isEmpty()) {
return outRepoVersions.values();
}
}
}
return null;
}
use of org.eclipse.ceylon.cmr.spi.OpenNode in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method putArtifact.
public void putArtifact(ArtifactContext context, InputStream content) throws RepositoryException {
try {
final Node parent = getOrCreateParent(context);
log.debug("Adding artifact " + context + " to cache " + cache.getDisplayString());
log.debug(" -> " + NodeUtils.getFullPath(parent));
final String[] names = cache.getArtifactNames(context);
if (names.length != 1) {
throw new RepositoryException("ArtifactContext should have a single suffix");
}
final String label = names[0];
try {
if (parent instanceof OpenNode) {
final OpenNode on = (OpenNode) parent;
if (on.addContent(label, content, context) == null)
addContent(context, parent, label, content);
} else {
addContent(context, parent, label, content);
}
} catch (IOException e) {
throw new RepositoryException(e);
}
log.debug(" -> [done]");
} finally {
IOUtils.safeClose(content);
}
}
use of org.eclipse.ceylon.cmr.spi.OpenNode in project ceylon by eclipse.
the class AbstractOpenNode method getChildren.
@Override
public Iterable<? extends Node> getChildren() {
if (!children.containsKey(NODE_MARKER)) {
// add marker
children.put(NODE_MARKER, new MarkerNode());
ConcurrentMap<String, OpenNode> tmp = new ConcurrentHashMap<>();
for (OpenNode on : findService(StructureBuilder.class).find(this)) put(tmp, on.getLabel(), on);
children.putAll(tmp);
return tmp.values();
} else {
List<Node> nodes = new ArrayList<>();
for (Node on : children.values()) {
if (on instanceof MarkerNode == false)
nodes.add(on);
}
return nodes;
}
}
use of org.eclipse.ceylon.cmr.spi.OpenNode in project ceylon by eclipse.
the class AbstractOpenNode method getChild.
@Override
public Node getChild(String label) {
OpenNode child = children.get(label);
if (child == null) {
final String markerLabel = label + NODE_MARKER;
final OpenNode marker = children.get(markerLabel);
if (marker == null) {
child = getNode(label, false);
children.put(markerLabel, new MarkerNode(label, child));
} else {
return marker.getValue(Node.class);
}
}
return child;
}
use of org.eclipse.ceylon.cmr.spi.OpenNode in project ceylon by eclipse.
the class AbstractOpenNode method getNode.
protected OpenNode getNode(String label, boolean create) {
final StructureBuilder builder = findService(StructureBuilder.class);
OpenNode child = create ? builder.create(this, label) : builder.find(this, label);
if (child != null) {
child = put(children, label, child);
}
return child;
}
Aggregations