Search in sources :

Example 1 with GitData

use of org.eclipse.winery.repository.rest.datatypes.GitData in project winery by eclipse.

the class GitWebSocket method onMessage.

@OnMessage
public void onMessage(String message, Session session) {
    try {
        GitData data = JacksonProvider.mapper.readValue(message, GitData.class);
        Map<String, Map<DiffEntry, String>> repoEntryList = new HashMap<>();
        if (RepositoryFactory.getRepository() instanceof MultiRepository) {
            IRepository gitRepo;
            for (IRepository repo : ((MultiRepository) RepositoryFactory.getRepository()).getRepositories()) {
                gitRepo = repo;
                if (gitRepo instanceof GitBasedRepository) {
                    handleGitRepository((GitBasedRepository) gitRepo, data, repoEntryList);
                }
            }
            setGitDifferences(repoEntryList);
        } else if (RepositoryFactory.getRepository() instanceof GitBasedRepository) {
            handleGitRepository((GitBasedRepository) RepositoryFactory.getRepository(), data, repoEntryList);
            setGitDifferences(repoEntryList);
        }
    } catch (IOException e) {
        writeInSession(session, "{ \"error\": \"Could not parse message!\" }");
    }
}
Also used : MultiRepository(org.eclipse.winery.repository.filebased.MultiRepository) HashMap(java.util.HashMap) GitData(org.eclipse.winery.repository.rest.datatypes.GitData) IOException(java.io.IOException) IRepository(org.eclipse.winery.repository.backend.IRepository) HashMap(java.util.HashMap) Map(java.util.Map) GitBasedRepository(org.eclipse.winery.repository.backend.filebased.GitBasedRepository) OnMessage(javax.websocket.OnMessage)

Aggregations

IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 OnMessage (javax.websocket.OnMessage)1 IRepository (org.eclipse.winery.repository.backend.IRepository)1 GitBasedRepository (org.eclipse.winery.repository.backend.filebased.GitBasedRepository)1 MultiRepository (org.eclipse.winery.repository.filebased.MultiRepository)1 GitData (org.eclipse.winery.repository.rest.datatypes.GitData)1