Search in sources :

Example 1 with BasePathResolver

use of eu.esdihumboldt.hale.io.haleconnect.BasePathResolver in project hale by halestudio.

the class HaleConnectProjectWriter method prettifyTarget.

private URI prettifyTarget(URI targetUri) {
    try {
        BasePathResolver resolver = (BasePathResolver) haleConnect;
        Owner owner = HaleConnectUrnBuilder.extractProjectOwner(targetUri);
        String projectId = HaleConnectUrnBuilder.extractProjectId(targetUri);
        String clientBasePath = resolver.getBasePath(HaleConnectServices.WEB_CLIENT);
        return HaleConnectUrnBuilder.buildClientAccessUrl(clientBasePath, owner, projectId);
    } catch (Throwable t) {
        return targetUri;
    }
}
Also used : Owner(eu.esdihumboldt.hale.io.haleconnect.Owner) BasePathResolver(eu.esdihumboldt.hale.io.haleconnect.BasePathResolver)

Example 2 with BasePathResolver

use of eu.esdihumboldt.hale.io.haleconnect.BasePathResolver in project hale by halestudio.

the class HaleConnectProjectWriter method createReporter.

/**
 * @see IOProvider#createReporter()
 */
@Override
public IOReporter createReporter() {
    if (!(haleConnect instanceof BasePathResolver) || !HaleConnectUrnBuilder.isValidProjectUrn(getTarget().getLocation())) {
        return super.createReporter();
    }
    try {
        URI targetUri = getTarget().getLocation();
        Locatable prettifiedTarget = new LocatableURI(prettifyTarget(targetUri));
        return new DefaultIOReporter(prettifiedTarget, MessageFormat.format("{0} export", getTypeName()), getActionId(), true);
    } catch (Throwable t) {
        return super.createReporter();
    }
}
Also used : LocatableURI(eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) URI(java.net.URI) LocatableURI(eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI) BasePathResolver(eu.esdihumboldt.hale.io.haleconnect.BasePathResolver) Locatable(eu.esdihumboldt.hale.common.core.io.supplier.Locatable)

Example 3 with BasePathResolver

use of eu.esdihumboldt.hale.io.haleconnect.BasePathResolver in project hale by halestudio.

the class HaleConnectProjectReader method createReporter.

/**
 * @see eu.esdihumboldt.hale.common.core.io.impl.AbstractImportProvider#createReporter()
 */
@Override
public IOReporter createReporter() {
    if (!(getSource() instanceof HaleConnectInputSupplier) || !HaleConnectUrnBuilder.isValidProjectUrn(getSource().getLocation())) {
        return super.createReporter();
    }
    try {
        BasePathResolver resolver = ((HaleConnectInputSupplier) getSource()).getBasePathResolver();
        URI sourceUri = getSource().getLocation();
        Owner owner = HaleConnectUrnBuilder.extractProjectOwner(sourceUri);
        String projectId = HaleConnectUrnBuilder.extractProjectId(sourceUri);
        String clientBasePath = resolver.getBasePath(HaleConnectServices.WEB_CLIENT);
        Locatable prettifiedTarget = new LocatableURI(HaleConnectUrnBuilder.buildClientAccessUrl(clientBasePath, owner, projectId));
        return new DefaultIOReporter(prettifiedTarget, MessageFormat.format("{0} import", getTypeName()), getActionId(), true);
    } catch (Throwable t) {
        return super.createReporter();
    }
}
Also used : Owner(eu.esdihumboldt.hale.io.haleconnect.Owner) LocatableURI(eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) HaleConnectInputSupplier(eu.esdihumboldt.hale.io.haleconnect.HaleConnectInputSupplier) URI(java.net.URI) LocatableURI(eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI) BasePathResolver(eu.esdihumboldt.hale.io.haleconnect.BasePathResolver) Locatable(eu.esdihumboldt.hale.common.core.io.supplier.Locatable)

Aggregations

BasePathResolver (eu.esdihumboldt.hale.io.haleconnect.BasePathResolver)3 DefaultIOReporter (eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter)2 Locatable (eu.esdihumboldt.hale.common.core.io.supplier.Locatable)2 LocatableURI (eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI)2 Owner (eu.esdihumboldt.hale.io.haleconnect.Owner)2 URI (java.net.URI)2 HaleConnectInputSupplier (eu.esdihumboldt.hale.io.haleconnect.HaleConnectInputSupplier)1