Search in sources :

Example 1 with ContentHandle

use of org.eclipse.ceylon.cmr.spi.ContentHandle 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;
}
Also used : ModuleVersionResult(org.eclipse.ceylon.cmr.api.ModuleVersionResult) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle) ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) OpenNode(org.eclipse.ceylon.cmr.spi.OpenNode) ContentStore(org.eclipse.ceylon.cmr.spi.ContentStore)

Example 2 with ContentHandle

use of org.eclipse.ceylon.cmr.spi.ContentHandle 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();
}
Also used : ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle) ContentStore(org.eclipse.ceylon.cmr.spi.ContentStore)

Example 3 with ContentHandle

use of org.eclipse.ceylon.cmr.spi.ContentHandle in project ceylon by eclipse.

the class DefaultNode method removeNode.

@Override
public Node removeNode(String label) {
    final Node node = super.removeNode(label);
    if (node instanceof DefaultNode) {
        DefaultNode dn = (DefaultNode) node;
        ContentHandle ch = dn.handle;
        dn.handle = null;
        if (ch != null) {
            ch.clean();
        }
    }
    return node;
}
Also used : OpenNode(org.eclipse.ceylon.cmr.spi.OpenNode) Node(org.eclipse.ceylon.cmr.spi.Node) ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle)

Example 4 with ContentHandle

use of org.eclipse.ceylon.cmr.spi.ContentHandle 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();
}
Also used : ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle) ContentStore(org.eclipse.ceylon.cmr.spi.ContentStore)

Example 5 with ContentHandle

use of org.eclipse.ceylon.cmr.spi.ContentHandle 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;
}
Also used : ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle) OpenNode(org.eclipse.ceylon.cmr.spi.OpenNode) ContentStore(org.eclipse.ceylon.cmr.spi.ContentStore)

Aggregations

ContentHandle (org.eclipse.ceylon.cmr.spi.ContentHandle)9 ContentStore (org.eclipse.ceylon.cmr.spi.ContentStore)7 OpenNode (org.eclipse.ceylon.cmr.spi.OpenNode)3 File (java.io.File)1 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)1 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)1 ModuleVersionQuery (org.eclipse.ceylon.cmr.api.ModuleVersionQuery)1 ModuleVersionResult (org.eclipse.ceylon.cmr.api.ModuleVersionResult)1 Node (org.eclipse.ceylon.cmr.spi.Node)1