Search in sources :

Example 1 with HaleConnectInputSupplier

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

the class HaleConnectServiceImpl method loadProject.

/**
 * @see eu.esdihumboldt.hale.io.haleconnect.HaleConnectService#loadProject(Owner,
 *      String)
 */
@Override
public LocatableInputSupplier<InputStream> loadProject(Owner owner, String projectId) throws HaleConnectException {
    if (!isLoggedIn()) {
        throw new IllegalStateException("Not logged in.");
    }
    URI location = HaleConnectUrnBuilder.buildProjectUrn(owner, projectId);
    HaleConnectProjectInfo projectInfo = getProject(owner, projectId);
    if (projectInfo == null) {
        throw new HaleConnectException(MessageFormat.format("Project does not exist: {0}", location.toString()));
    }
    return new HaleConnectInputSupplier(location, this.getSession().getToken(), this);
}
Also used : HaleConnectInputSupplier(eu.esdihumboldt.hale.io.haleconnect.HaleConnectInputSupplier) HaleConnectProjectInfo(eu.esdihumboldt.hale.io.haleconnect.HaleConnectProjectInfo) HaleConnectException(eu.esdihumboldt.hale.io.haleconnect.HaleConnectException) URI(java.net.URI)

Example 2 with HaleConnectInputSupplier

use of eu.esdihumboldt.hale.io.haleconnect.HaleConnectInputSupplier 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)

Example 3 with HaleConnectInputSupplier

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

the class HaleConnectProjectReader method execute.

/**
 * @see eu.esdihumboldt.hale.common.core.io.project.impl.ArchiveProjectReader#execute(eu.esdihumboldt.hale.common.core.io.ProgressIndicator,
 *      eu.esdihumboldt.hale.common.core.io.report.IOReporter)
 */
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
    IOReport result = super.execute(progress, reporter);
    if (getSource() instanceof HaleConnectInputSupplier) {
        HaleConnectInputSupplier source = (HaleConnectInputSupplier) getSource();
        getProject().getProperties().put(HALECONNECT_LAST_MODIFIED_PROPERTY, Value.of(source.getLastModified()));
        getProject().getProperties().put(HALECONNECT_URN_PROPERTY, Value.of(source.getLocation()));
        IOConfiguration saveConfig = getProject().getSaveConfiguration();
        saveConfig.setProviderId(HaleConnectProjectWriter.ID);
        saveConfig.getProviderConfiguration().put(ExportProvider.PARAM_CONTENT_TYPE, Value.of(HaleConnectProjectWriter.HALECONNECT_CONTENT_TYPE_ID));
        /*
			 * Don't overwrite the target of the save configuration which is, at
			 * this point, set to the temporary location of the extracted
			 * project archive. The reason for this is to make sure that
			 * PathUpdate can correctly resolve all relative resource paths.
			 * (https://github.com/halestudio/hale/issues/506)
			 */
        // saveConfig.getProviderConfiguration().put(ExportProvider.PARAM_TARGET,
        // Value.of(source.getLocation()));
        getProject().setSaveConfiguration(saveConfig);
    }
    return result;
}
Also used : IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) HaleConnectInputSupplier(eu.esdihumboldt.hale.io.haleconnect.HaleConnectInputSupplier) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Aggregations

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