use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class IndexingEventListener method onApplicationEvent.
@Override
public void onApplicationEvent(AppEvent event) {
if (event.getEventType() == EventType.MODEL_CREATED) {
ModelInfo modelInfo = (ModelInfo) event.getSubject();
indexingService.indexModel(modelInfo, event.getUserContext().getWorkspaceId());
} else if (event.getEventType() == EventType.MODEL_UPDATED) {
ModelInfo modelInfo = (ModelInfo) event.getSubject();
indexingService.updateIndex(modelInfo);
} else if (event.getEventType() == EventType.MODEL_DELETED) {
ModelId modelId = (ModelId) event.getSubject();
indexingService.deleteIndex(modelId);
} else if (event.getEventType() == EventType.NAMESPACE_DELETED) {
indexingService.deleteIndexForWorkspace(event.getUserContext().getWorkspaceId());
}
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class IntegrationTestBase method addLink.
protected ResultActions addLink(String modelId, SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor user, ModelLink url) throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.put("/api/v1/attachments/" + modelId + "/links");
builder.content(ObjectMapperFactory.getInstance().writeValueAsString(url));
return repositoryServer.perform(builder.with(request -> {
request.setMethod("PUT");
return request;
}).contentType(MediaType.APPLICATION_JSON).with(user));
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class GeneratorUrlBuilderTest method getGeneratorUrl.
@Test
public void getGeneratorUrl() {
final String expected = "https://eclipse.vorto.org/api/v1/generators/eclipseditto/models/com.kolotu.test:SomeModel:1.0.0";
ModelId modelId = ModelId.fromPrettyFormat("com.kolotu.test:SomeModel:1.0.0");
String generatorKey = "eclipseditto";
String result = GeneratorUrlBuilder.getGeneratorUrl(BASE_URL, modelId, generatorKey, null);
assertEquals(expected, result);
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepository method getById.
@Override
public ModelInfo getById(ModelId modelId) {
final ModelId finalModelId = getLatestModelVersionIfLatestTagIsSet(modelId);
return doInSession(session -> {
try {
ModelIdHelper modelIdHelper = new ModelIdHelper(finalModelId);
Node folderNode = session.getNode(modelIdHelper.getFullPath());
return getModelResource(finalModelId, folderNode);
} catch (PathNotFoundException e) {
return null;
} catch (AccessDeniedException e) {
throw new NotAuthorizedException(finalModelId, e);
}
});
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepository method getFileContent.
@Override
public Optional<FileContent> getFileContent(ModelId modelId, Optional<String> fileName) {
return doInSession(session -> {
try {
ModelId finalModelId = getLatestModelVersionIfLatestTagIsSet(modelId);
ModelIdHelper modelIdHelper = new ModelIdHelper(finalModelId);
Node folderNode = session.getNode(modelIdHelper.getFullPath());
Node fileNode;
if (fileName.isPresent()) {
fileNode = folderNode.getNode(fileName.get());
} else {
if (!folderNode.getNodes(FILE_NODES).hasNext()) {
throw new NotAuthorizedException(finalModelId);
}
fileNode = (Node) folderNode.getNodes(FILE_NODES).next();
}
Node fileItem = (Node) fileNode.getPrimaryItem();
InputStream is = fileItem.getProperty(JCR_DATA).getBinary().getStream();
final String fileContent = IOUtils.toString(is);
return Optional.of(new FileContent(fileNode.getName(), fileContent.getBytes()));
} catch (PathNotFoundException e) {
return Optional.empty();
} catch (IOException e) {
throw new FatalModelRepositoryException("Something went wrong accessing the repository", e);
} catch (AccessDeniedException e) {
throw new NotAuthorizedException(modelId, e);
}
});
}
Aggregations