Search in sources :

Example 1 with BucketsApi

use of com.haleconnect.api.projectstore.v1.api.BucketsApi in project hale by halestudio.

the class HaleConnectInputSupplier method getLastModified.

/**
 * @return details on the hale connect project
 */
public Long getLastModified() {
    if (lastModified == null) {
        Owner owner = HaleConnectUrnBuilder.extractProjectOwner(getLocation());
        String projectId = HaleConnectUrnBuilder.extractProjectId(getLocation());
        final BucketsApi api = ProjectStoreHelper.getBucketsApi(basePathResolver, apiKey);
        final ApiResponse<BucketDetail> response;
        try {
            response = api.getBucketInfoWithHttpInfo(owner.getType().getJsonValue(), owner.getId(), projectId);
            lastModified = response.getData().getLastModified();
        } catch (ApiException e) {
        // Not fatal
        }
    }
    return lastModified;
}
Also used : BucketsApi(com.haleconnect.api.projectstore.v1.api.BucketsApi) BucketDetail(com.haleconnect.api.projectstore.v1.model.BucketDetail) ApiException(com.haleconnect.api.projectstore.v1.ApiException)

Example 2 with BucketsApi

use of com.haleconnect.api.projectstore.v1.api.BucketsApi 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;
}
Also used : Feedback(com.haleconnect.api.projectstore.v1.model.Feedback) BucketsApi(com.haleconnect.api.projectstore.v1.api.BucketsApi) HaleConnectException(eu.esdihumboldt.hale.io.haleconnect.HaleConnectException)

Example 3 with BucketsApi

use of com.haleconnect.api.projectstore.v1.api.BucketsApi 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();
}
Also used : BucketIdent(com.haleconnect.api.projectstore.v1.model.BucketIdent) Owner(eu.esdihumboldt.hale.io.haleconnect.Owner) BucketsApi(com.haleconnect.api.projectstore.v1.api.BucketsApi) HaleConnectException(eu.esdihumboldt.hale.io.haleconnect.HaleConnectException) NewBucket(com.haleconnect.api.projectstore.v1.model.NewBucket)

Aggregations

BucketsApi (com.haleconnect.api.projectstore.v1.api.BucketsApi)3 HaleConnectException (eu.esdihumboldt.hale.io.haleconnect.HaleConnectException)2 ApiException (com.haleconnect.api.projectstore.v1.ApiException)1 BucketDetail (com.haleconnect.api.projectstore.v1.model.BucketDetail)1 BucketIdent (com.haleconnect.api.projectstore.v1.model.BucketIdent)1 Feedback (com.haleconnect.api.projectstore.v1.model.Feedback)1 NewBucket (com.haleconnect.api.projectstore.v1.model.NewBucket)1 Owner (eu.esdihumboldt.hale.io.haleconnect.Owner)1