Search in sources :

Example 1 with BucketIdent

use of com.haleconnect.api.projectstore.v1.model.BucketIdent 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)1 BucketIdent (com.haleconnect.api.projectstore.v1.model.BucketIdent)1 NewBucket (com.haleconnect.api.projectstore.v1.model.NewBucket)1 HaleConnectException (eu.esdihumboldt.hale.io.haleconnect.HaleConnectException)1 Owner (eu.esdihumboldt.hale.io.haleconnect.Owner)1