profile = _profileService.findProfile(req, profileName);
}
Repository repository = profile.getRepository();
if(action != null && action.equals(ACTION_CREATE_ASSET)) {
try {
AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text);
builder.content("")
.type(assetType)
.name(assetName)
.location(assetLocation);
String id = repository.createAsset(builder.getAsset());
if(id == null) {
_logger.error("Unable to create asset: " + assetLocation);
addError(errorsArray, "Unable to create asset: " + assetLocation);
}
returnObj.put("assetId", id);
} catch (Exception e) {
_logger.error("Error creating asset: " + e.getMessage());
addError(errorsArray, "Error creating asset: " + e.getMessage());
}
jsonResponse(returnObj, errorsArray, resp);
} else if(action != null && action.equals(ACTION_UPDATE_ASSET)) {
try {
if(assetContentTransform != null && assetContentTransform.equals(TRANSFORMATION_JSON_TO_BPMN2)) {
assetContent = profile.createMarshaller().parseModel(assetContent, preprocessingData);
}
Asset<String> currentAsset = repository.loadAsset(assetId);
AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(currentAsset);
builder.content(assetContent);
String id = repository.updateAsset(builder.getAsset(), commitMessage);
if(id == null) {
_logger.error("Unable to store asset: " + assetLocation);
addError(errorsArray, "Unable to store asset: " + assetLocation);
}