use of com.haleconnect.api.projectstore.v1.ApiException in project hale by halestudio.
the class HaleConnectServiceImpl method setProjectSharingOptions.
@Override
public boolean setProjectSharingOptions(String projectId, Owner owner, SharingOptions options) throws HaleConnectException {
BucketsApi bucketsApi = ProjectStoreHelper.getBucketsApi(this, this.getSession().getToken());
Feedback feedback;
try {
feedback = bucketsApi.setBucketProperty(owner.getType().getJsonValue(), owner.getId(), projectId, "sharingOptions", options);
} catch (com.haleconnect.api.projectstore.v1.ApiException e) {
throw new HaleConnectException(e.getMessage(), e);
}
if (feedback.getError()) {
log.error(MessageFormat.format("Error setting sharing options for hale connect project {0}", projectId));
return false;
}
return true;
}
use of com.haleconnect.api.projectstore.v1.ApiException in project hale by halestudio.
the class HaleConnectInputSupplier method getInput.
@Override
public InputStream getInput() throws IOException {
Owner owner = HaleConnectUrnBuilder.extractProjectOwner(getLocation());
String projectId = HaleConnectUrnBuilder.extractProjectId(getLocation());
FilesApi api = ProjectStoreHelper.getFilesApi(basePathResolver, apiKey);
final ApiResponse<File> response;
try {
response = api.getProjectFilesAsZipWithHttpInfo(owner.getType().getJsonValue(), owner.getId(), projectId);
} catch (com.haleconnect.api.projectstore.v1.ApiException e) {
throw new IOException(e.getMessage(), e);
}
// Cache lastModified timestamp at the time of import
getLastModified();
return new BufferedInputStream(new FileInputStream(response.getData()));
}
use of com.haleconnect.api.projectstore.v1.ApiException in project hale by halestudio.
the class HaleConnectServiceImpl method uploadProjectFileAsync.
@Override
public ListenableFuture<Boolean> uploadProjectFileAsync(String projectId, Owner owner, File file, ProgressIndicator progress) throws HaleConnectException {
if (!this.isLoggedIn()) {
throw new HaleConnectException("Not logged in");
}
String apiKey = this.getSession().getToken();
// PUT /buckets/{ownerType}/{ownerId}/{bucketID}/name
FilesApi filesApi = ProjectStoreHelper.getFilesApi(this, apiKey);
// refactor to reuse code in both sync and async methods
SettableFuture<Boolean> future = SettableFuture.create();
try {
// POST /raw
int totalWork = computeTotalWork(file);
progress.begin("Uploading project archive", totalWork);
filesApi.addFilesAsync(owner.getType().getJsonValue(), owner.getId(), projectId, file, createUploadFileCallback(future, progress, file, totalWork));
} catch (com.haleconnect.api.projectstore.v1.ApiException e) {
throw new HaleConnectException(e.getMessage(), e);
}
return future;
}
use of com.haleconnect.api.projectstore.v1.ApiException in project hale by halestudio.
the class HaleConnectServiceImpl method uploadProjectFile.
/**
* @see eu.esdihumboldt.hale.io.haleconnect.HaleConnectService#uploadProjectFile(java.lang.String,
* eu.esdihumboldt.hale.io.haleconnect.Owner, java.io.File,
* eu.esdihumboldt.hale.common.core.io.ProgressIndicator)
*/
@Override
public boolean uploadProjectFile(String projectId, Owner owner, File file, ProgressIndicator progress) throws HaleConnectException {
if (!this.isLoggedIn()) {
throw new HaleConnectException("Not logged in");
}
String apiKey = this.getSession().getToken();
SettableFuture<Boolean> future = SettableFuture.create();
try {
FilesApi filesApi = ProjectStoreHelper.getFilesApi(this, apiKey);
// POST /raw
int totalWork = computeTotalWork(file);
ApiCallback<Feedback> apiCallback = createUploadFileCallback(future, progress, file, totalWork);
progress.begin("Uploading project archive", totalWork);
filesApi.addFilesAsync(owner.getType().getJsonValue(), owner.getId(), projectId, file, apiCallback);
return future.get();
} catch (com.haleconnect.api.projectstore.v1.ApiException e1) {
throw new HaleConnectException(e1.getMessage(), e1, e1.getCode(), e1.getResponseHeaders());
} catch (ExecutionException e2) {
Throwable t = e2.getCause();
if (t instanceof HaleConnectException) {
throw (HaleConnectException) t;
} else {
throw new HaleConnectException(t.getMessage(), t);
}
} catch (InterruptedException e3) {
throw new HaleConnectException(e3.getMessage(), e3);
}
}
use of com.haleconnect.api.projectstore.v1.ApiException in project hale by halestudio.
the class HaleConnectServiceImpl method createProject.
/**
* @see eu.esdihumboldt.hale.io.haleconnect.HaleConnectService#createProject(java.lang.String,
* java.lang.String, eu.esdihumboldt.hale.io.haleconnect.Owner,
* boolean)
*/
@Override
public String createProject(String name, String author, Owner owner, boolean versionControl) throws HaleConnectException {
if (!this.isLoggedIn()) {
throw new HaleConnectException("Not logged in");
}
String apiKey = this.getSession().getToken();
NewBucket newBucket = new NewBucket();
newBucket.setName(name);
newBucket.setVersionControl(versionControl);
final BucketIdent id;
try {
BucketsApi bucketsApi = ProjectStoreHelper.getBucketsApi(this, apiKey);
// POST /buckets
id = bucketsApi.createBucketWithOwner(owner.getType().getJsonValue(), owner.getId(), newBucket);
Owner bucketOwner = UserServiceHelper.toOwner(id.getUserId(), id.getOrgId());
// PUT /buckets/{ownerType}/{ownerId}/{bucketID}/p/author
bucketsApi.setBucketProperty(bucketOwner.getType().getJsonValue(), bucketOwner.getId(), id.getTransformationproject(), "author", author);
} catch (com.haleconnect.api.projectstore.v1.ApiException e) {
throw new HaleConnectException(e.getMessage(), e);
}
return id.getTransformationproject();
}
Aggregations