use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelIdTest method testValidModelId.
@Test
public void testValidModelId() {
String modelId = "com.bosch:Test:1.0.0";
assertEquals(new ModelId("Test", "com.bosch", "1.0.0"), ModelId.fromPrettyFormat(modelId));
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class DefaultPayloadMappingService method getModelWithAllDependencies.
private List<ModelInfo> getModelWithAllDependencies(ModelId modelId) {
List<ModelInfo> modelInfos = new ArrayList<>();
ModelInfo modelResource = this.modelRepositoryFactory.getRepositoryByModel(modelId).getById(modelId);
modelInfos.add(modelResource);
for (ModelId reference : modelResource.getReferences()) {
modelInfos.addAll(getModelWithAllDependencies(reference));
}
return modelInfos;
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class DefaultPayloadMappingService method saveSpecification.
@Override
public void saveSpecification(IMappingSpecification specification, IUserContext user) {
MappingSpecificationSerializer.create(specification).iterator().forEachRemaining(serializer -> {
final ModelId createdModelId = serializer.getModelId();
String serializedMapping = serializer.serialize();
LOGGER.trace(String.format("Saving mapping: %s", serializedMapping));
this.modelRepositoryFactory.getRepositoryByModel(createdModelId).save(createdModelId, serializedMapping.getBytes(), createdModelId.getName() + ".mapping", user, false);
try {
workflowService.start(createdModelId, user);
} catch (WorkflowException e) {
throw new RuntimeException("Could not start workflow for mapping model", e);
}
});
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class DefaultBulkOperationsService method revertToPrivate.
private void revertToPrivate(List<ModelId> accumulator) {
for (ModelId modelId : accumulator) {
IModelRepository repo = this.repositoryFactory.getRepositoryByModel(modelId);
String tenantId = repo.getWorkspaceId();
// changed back visibility property
repo.updateVisibility(modelId, IModelRepository.VISIBILITY_PRIVATE);
// remove added policy
IModelPolicyManager policyManager = this.repositoryFactory.getPolicyManager(tenantId, getAuthenticationToken());
Collection<PolicyEntry> policies = policyManager.getPolicyEntries(modelId);
for (PolicyEntry policy : policies) {
if (policy.getPrincipalId().equals(IModelPolicyManager.ANONYMOUS_ACCESS_POLICY)) {
policyManager.removePolicyEntry(modelId, policy);
break;
}
}
}
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class DefaultBulkOperationsService method makeModelPublicRecursively.
private void makeModelPublicRecursively(ModelId modelId, List<ModelId> modelsMadePublicAcc) throws ExecutionException {
if (hasPrivateNamespace(modelId)) {
throw new ModelNamespaceNotOfficialException(modelId);
}
IModelRepository repository = repositoryFactory.getRepositoryByModel(modelId);
ModelInfo modelInfo = repository.getById(modelId);
if (!modelInfo.isReleased()) {
throw new ModelNotReleasedException(modelId);
}
if (isPrivate(modelInfo)) {
LOGGER.info("Changing visibility of model " + modelId.getPrettyFormat() + " to public.");
// Add public visibility property
repository.updateVisibility(modelId, IModelRepository.VISIBILITY_PUBLIC);
// Add corresponding policy to model
IModelPolicyManager policyMgr = this.repositoryFactory.getPolicyManager(repository.getWorkspaceId(), getAuthenticationToken());
policyMgr.addPolicyEntry(modelId, PolicyEntry.of(IModelPolicyManager.ANONYMOUS_ACCESS_POLICY, PrincipalType.User, Permission.READ));
modelsMadePublicAcc.add(modelId);
// Make references public
for (ModelId referencedModelId : modelInfo.getReferences()) {
makeModelPublicRecursively(referencedModelId, modelsMadePublicAcc);
}
}
}
Aggregations