use of org.eclipse.vorto.repository.model.UploadResultView in project vorto by eclipse.
the class RestModelRepository method upload.
@Override
public UploadResult upload(String name, byte[] model) {
Objects.requireNonNull(model, "Model should not be null.");
Objects.requireNonNull(name, "Name should not be null.");
try {
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody(FILE_PARAMETER_NAME, model, ContentType.APPLICATION_OCTET_STREAM, name);
HttpEntity fileToUpload = builder.build();
UploadResultView uploadResult = httpClient.executePost("secure", fileToUpload, uploadResponseConverter);
return uploadResultConverter.apply(uploadResult);
} catch (RepositoryException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Error getting model info for resource", e);
}
}
use of org.eclipse.vorto.repository.model.UploadResultView in project vorto by eclipse.
the class StringToUploadResult method emptyUploadResult.
/**
* Return empty error view incase of invalid json or null values.
* @return Empty Upload result with error message.
*/
private UploadResultView emptyUploadResult() {
UploadResultView errorResult = new UploadResultView();
errorResult.setErrorMessage("Error while uploading to remote repository.");
errorResult.setValid(false);
return errorResult;
}
Aggregations