-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CODENVY-31: Replaced messages from git importer on error codes
Also added git checkout event which goes through by websocket connection
- Loading branch information
Showing
8 changed files
with
155 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...orm-api/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitWebSocketMessenger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.api.git; | ||
|
||
import org.eclipse.che.api.core.notification.EventService; | ||
import org.eclipse.che.api.core.notification.EventSubscriber; | ||
import org.eclipse.che.api.git.shared.GitCheckoutEvent; | ||
import org.eclipse.che.dto.server.DtoFactory; | ||
import org.everrest.websockets.WSConnectionContext; | ||
import org.everrest.websockets.message.ChannelBroadcastMessage; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.annotation.PreDestroy; | ||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
/** | ||
* @author Anton Korneta. | ||
*/ | ||
@Singleton | ||
public class GitWebSocketMessenger implements EventSubscriber<GitCheckoutEvent> { | ||
private static final Logger LOG = LoggerFactory.getLogger(GitWebSocketMessenger.class); | ||
private static final String CHANNEL = "git:events:channel"; | ||
|
||
private final EventService eventService; | ||
|
||
@Inject | ||
public GitWebSocketMessenger(EventService eventService) { | ||
this.eventService = eventService; | ||
} | ||
|
||
@PostConstruct | ||
private void subscribe() { | ||
eventService.subscribe(this); | ||
} | ||
|
||
@PreDestroy | ||
private void unsubscribe() { | ||
eventService.unsubscribe(this); | ||
} | ||
|
||
@Override | ||
public void onEvent(GitCheckoutEvent event) { | ||
try { | ||
final ChannelBroadcastMessage bm = new ChannelBroadcastMessage(); | ||
bm.setChannel(CHANNEL); | ||
bm.setBody(DtoFactory.getInstance().toJson(event)); | ||
WSConnectionContext.sendMessage(bm); | ||
} catch (Exception e) { | ||
LOG.error(e.getMessage(), e); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...m-api/che-core-api-git/src/main/java/org/eclipse/che/api/git/shared/GitCheckoutEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.api.git.shared; | ||
|
||
import org.eclipse.che.api.core.notification.EventOrigin; | ||
import org.eclipse.che.dto.shared.DTO; | ||
|
||
/** | ||
* @author Anton Korneta. | ||
*/ | ||
@EventOrigin("gitcheckout") | ||
@DTO | ||
public interface GitCheckoutEvent { | ||
|
||
boolean isCheckoutOnly(); | ||
|
||
void setCheckoutOnly(boolean checkoutOnly); | ||
|
||
GitCheckoutEvent withCheckoutOnly(boolean checkoutOnly); | ||
|
||
String getBranchRef(); | ||
|
||
void setBranchRef(String branchRef); | ||
|
||
GitCheckoutEvent withBranchRef(String branchRef); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters