Search in sources :

Example 6 with ContentHandle

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

the class URLContentStore method find.

public OpenNode find(Node parent, String child) {
    final String path = compatiblePath(getFullPath(parent, child));
    // enough
    if (hasContent(child) && !urlExists(path)) {
        return null;
    }
    final RemoteNode node = createNode(child);
    ContentHandle handle;
    if (hasContent(child))
        handle = createContentHandle(parent, child, path, node);
    else
        handle = DefaultNode.HANDLE_MARKER;
    node.setHandle(handle);
    return node;
}
Also used : ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle)

Example 7 with ContentHandle

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

Example 8 with ContentHandle

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

the class DefaultNode method getContent.

@Override
@SuppressWarnings("unchecked")
public <T> T getContent(Class<T> contentType) throws IOException {
    if (File.class.equals(contentType)) {
        synchronized (this) {
            if (handle != null)
                return (T) handle.getContentAsFile();
        }
        final ContentStore cs = findService(ContentStore.class);
        ContentHandle ch = cs.getContent(this);
        if (ch == null) {
            ch = HANDLE_MARKER;
        }
        synchronized (this) {
            handle = ch;
        }
        return (T) ch.getContentAsFile();
    } else {
        return super.getContent(contentType);
    }
}
Also used : ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle) ContentStore(org.eclipse.ceylon.cmr.spi.ContentStore)

Example 9 with ContentHandle

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

the class DefaultNode method getSize.

@Override
public long getSize() throws IOException {
    synchronized (this) {
        if (handle != null)
            return handle.getSize();
    }
    final ContentStore cs = findService(ContentStore.class);
    ContentHandle ch = cs.getContent(this);
    if (ch == null) {
        ch = HANDLE_MARKER;
    }
    synchronized (this) {
        handle = ch;
    }
    return ch.getSize();
}
Also used : ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle) 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