use of org.eclipse.vorto.repository.core.ModelResource in project vorto by eclipse.
the class ModelRepositoryController method createVersionOfModel.
@ApiOperation(value = "Creates a new version for the given model in the specified version")
@PreAuthorize("hasAuthority('sysadmin') or (hasAuthority('model_creator') and " + "hasPermission(T(org.eclipse.vorto.model.ModelId).fromPrettyFormat(#modelId)," + "T(org.eclipse.vorto.repository.core.PolicyEntry.Permission).READ))")
@PostMapping(value = "/{modelId:.+}/versions/{modelVersion:.+}", produces = "application/json")
public ResponseEntity<ModelInfo> createVersionOfModel(@ApiParam(value = "modelId", required = true) @PathVariable String modelId, @ApiParam(value = "modelVersion", required = true) @PathVariable String modelVersion) throws WorkflowException {
final ModelId modelID = ModelId.fromPrettyFormat(modelId);
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
try {
IUserContext userContext = UserContext.user(authentication, getWorkspaceId(modelId));
ModelResource resource = getModelRepository(modelID).createVersion(modelID, modelVersion, userContext);
this.workflowService.start(resource.getId(), userContext);
return new ResponseEntity<>(resource, HttpStatus.CREATED);
} catch (FatalModelRepositoryException e) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
use of org.eclipse.vorto.repository.core.ModelResource in project vorto by eclipse.
the class TargetPlatformUpgradeTask method doUpgrade.
@Override
public void doUpgrade() throws UpgradeProblem {
setAdminUserContext();
List<ModelInfo> searchResult = modelSearchService.search("type:Mapping");
for (ModelInfo modelInfo : searchResult) {
logger.info("Upgrading " + modelInfo.toString() + " for target platform key attribute....");
ModelRepository modelRepository = (ModelRepository) repositoryFactory.getRepositoryByModel(modelInfo.getId());
ModelResource mappingModel = modelRepository.getEMFResource(modelInfo.getId());
modelRepository.save(mappingModel, UserContext.user(modelInfo.getAuthor(), modelRepository.getWorkspaceId()));
}
}
Aggregations