use of org.eclipse.ceylon.cmr.spi.ContentStore 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.ContentStore in project ceylon by eclipse.
the class DefaultNode method getLastModified.
@Override
public long getLastModified() throws IOException {
synchronized (this) {
if (handle != null)
return handle.getLastModified();
}
final ContentStore cs = findService(ContentStore.class);
ContentHandle ch = cs.getContent(this);
if (ch == null) {
ch = HANDLE_MARKER;
}
synchronized (this) {
handle = ch;
}
return ch.getLastModified();
}
use of org.eclipse.ceylon.cmr.spi.ContentStore in project ceylon by eclipse.
the class DefaultNode method getSizedInputStream.
@Override
public SizedInputStream getSizedInputStream() throws IOException {
synchronized (this) {
if (handle != null)
return handle.getBinariesAsSizedStream();
}
final ContentStore cs = findService(ContentStore.class);
ContentHandle ch = cs.getContent(this);
if (ch == null) {
ch = HANDLE_MARKER;
}
synchronized (this) {
handle = ch;
}
return ch.getBinariesAsSizedStream();
}
use of org.eclipse.ceylon.cmr.spi.ContentStore in project ceylon by eclipse.
the class DefaultNode method addNode.
protected OpenNode addNode(final String label, final Object value, InputStream content, ContentOptions options, boolean allowNoContent) throws IOException {
if (label == null)
throw new IllegalArgumentException("Null label");
if (content == null && allowNoContent == false)
throw new IllegalArgumentException("Null content not allowed: " + label);
final DefaultNode node = new DefaultNode(label, value);
OpenNode previous = putChildIfAbsent(label, node);
if (previous == null) {
previous = node;
node.putParentIfAbsent(getLabel(), this);
if (content != null) {
final ContentStore contentStore = findService(ContentStore.class);
node.handle = contentStore.putContent(node, content, options);
}
} else if (content != null) {
if (options.forceOperation()) {
final ContentStore contentStore = findService(ContentStore.class);
ContentHandle ch = contentStore.putContent(previous, content, options);
if (previous instanceof DefaultNode) {
DefaultNode dn = (DefaultNode) previous;
dn.handle = ch;
}
} else {
throw new IllegalArgumentException("Content node already exists: " + label);
}
}
return previous;
}
use of org.eclipse.ceylon.cmr.spi.ContentStore in project ceylon by eclipse.
the class DefaultNode method hasBinaries.
@Override
public boolean hasBinaries() {
synchronized (this) {
if (handle != null)
return handle.hasBinaries();
}
final ContentStore cs = findService(ContentStore.class);
final ContentHandle ch = cs.peekContent(this);
synchronized (this) {
handle = (ch == null) ? HANDLE_MARKER : ch;
}
return (ch != null && ch.hasBinaries());
}
Aggregations