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);
}
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();
}
}
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;
}
Aggregations