Change identifier for import project channel
parent
664bbf82ef
commit
ca82851bd3
|
|
@ -64,7 +64,7 @@ public class RequestDispatcher {
|
|||
LOG.debug("Extracted request method: " + method);
|
||||
|
||||
final RequestHandler handler = handlers.get(method);
|
||||
if(handler == null) {
|
||||
if (handler == null) {
|
||||
LOG.error("Handler not found: " + method);
|
||||
// TODO make a centralized standard errors structure
|
||||
transmitter.transmit(endpointId, error(-32601, "Method not found: " + method));
|
||||
|
|
@ -100,24 +100,24 @@ public class RequestDispatcher {
|
|||
Class<P> paramClass,
|
||||
Class<R> resultClass) {
|
||||
|
||||
R result;
|
||||
final R result;
|
||||
|
||||
if(paramClass != null) {
|
||||
if (paramClass != null) {
|
||||
final P param = DtoFactory.getInstance().createDtoFromJson(params.toString(), paramClass);
|
||||
result = handler.handleRequest(endpointId, param);
|
||||
} else {
|
||||
result = handler.handleRequest(endpointId);
|
||||
}
|
||||
|
||||
LOG.debug("Dispatch response: " + result);
|
||||
LOG.debug("Dispatch response: ", result);
|
||||
|
||||
if(result instanceof Void)
|
||||
if (result instanceof Void)
|
||||
return new JsonObject();
|
||||
else if(result instanceof String) {
|
||||
else if (result instanceof String) {
|
||||
JsonObject response = new JsonObject();
|
||||
response.addProperty("text", (String)result);
|
||||
return response;
|
||||
} else if(result instanceof Collection) { // list of DTO objects
|
||||
} else if (result instanceof Collection) { // list of DTO objects
|
||||
JsonArray valueArray = new JsonArray();
|
||||
((Collection)result).stream().filter(r -> r instanceof JsonSerializable).forEach(r -> {
|
||||
String resultString = DtoFactory.getInstance().toJson(r);
|
||||
|
|
|
|||
|
|
@ -561,7 +561,7 @@ export class CreateProjectController {
|
|||
this.createProjectSvc.setCurrentProgressStep(3);
|
||||
|
||||
var promise;
|
||||
var channel = null;
|
||||
let channel: string = null;
|
||||
// select mode (create or import)
|
||||
if (this.selectSourceOption === 'select-source-new' && this.templatesChoice === 'templates-wizard') {
|
||||
|
||||
|
|
@ -578,7 +578,7 @@ export class CreateProjectController {
|
|||
}
|
||||
|
||||
// websocket channel
|
||||
channel = 'importProject:output:' + workspaceId + ':' + projectName;
|
||||
channel = 'importProject:output';
|
||||
|
||||
// on import
|
||||
bus.subscribe(channel, (message: any) => {
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ public interface CoreLocalizationConstant extends Messages {
|
|||
String importProjectButton();
|
||||
|
||||
@Key("importProject.importing")
|
||||
String importingProject();
|
||||
String importingProject(String projectName);
|
||||
|
||||
@Key("importProject.uriFieldTitle")
|
||||
String importProjectUriFieldTitle();
|
||||
|
|
|
|||
|
|
@ -10,8 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.projectimport.wizard;
|
||||
|
||||
import com.google.gwt.json.client.JSONObject;
|
||||
import com.google.gwt.json.client.JSONParser;
|
||||
import elemental.json.Json;
|
||||
import elemental.json.JsonObject;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
|
@ -19,16 +20,14 @@ import org.eclipse.che.api.promises.client.Operation;
|
|||
import org.eclipse.che.api.promises.client.OperationException;
|
||||
import org.eclipse.che.api.promises.client.PromiseError;
|
||||
import org.eclipse.che.ide.CoreLocalizationConstant;
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.machine.WsAgentStateController;
|
||||
import org.eclipse.che.ide.api.notification.NotificationManager;
|
||||
import org.eclipse.che.ide.api.notification.StatusNotification;
|
||||
import org.eclipse.che.ide.api.project.wizard.ProjectNotificationSubscriber;
|
||||
import org.eclipse.che.ide.commons.exception.UnmarshallerException;
|
||||
import org.eclipse.che.ide.util.loging.Log;
|
||||
import org.eclipse.che.ide.websocket.Message;
|
||||
import org.eclipse.che.ide.websocket.MessageBus;
|
||||
import org.eclipse.che.ide.websocket.WebSocketException;
|
||||
import org.eclipse.che.ide.websocket.rest.StringUnmarshallerWS;
|
||||
import org.eclipse.che.ide.websocket.rest.SubscriptionHandler;
|
||||
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE;
|
||||
|
|
@ -48,7 +47,6 @@ public class ProjectNotificationSubscriberImpl implements ProjectNotificationSub
|
|||
private final Operation<PromiseError> logErrorHandler;
|
||||
private final CoreLocalizationConstant locale;
|
||||
private final NotificationManager notificationManager;
|
||||
private final String workspaceId;
|
||||
private final WsAgentStateController wsAgentStateController;
|
||||
|
||||
private String wsChannel;
|
||||
|
|
@ -58,12 +56,10 @@ public class ProjectNotificationSubscriberImpl implements ProjectNotificationSub
|
|||
|
||||
@Inject
|
||||
public ProjectNotificationSubscriberImpl(CoreLocalizationConstant locale,
|
||||
AppContext appContext,
|
||||
NotificationManager notificationManager,
|
||||
WsAgentStateController wsAgentStateController) {
|
||||
this.locale = locale;
|
||||
this.notificationManager = notificationManager;
|
||||
this.workspaceId = appContext.getWorkspace().getId();
|
||||
this.wsAgentStateController = wsAgentStateController;
|
||||
this.logErrorHandler = new Operation<PromiseError>() {
|
||||
@Override
|
||||
|
|
@ -75,19 +71,32 @@ public class ProjectNotificationSubscriberImpl implements ProjectNotificationSub
|
|||
|
||||
@Override
|
||||
public void subscribe(final String projectName) {
|
||||
notification = notificationManager.notify(locale.importingProject(), PROGRESS, FLOAT_MODE);
|
||||
notification = notificationManager.notify(locale.importingProject(projectName), PROGRESS, FLOAT_MODE);
|
||||
subscribe(projectName, notification);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(final String projectName, final StatusNotification existingNotification) {
|
||||
this.projectName = projectName;
|
||||
this.wsChannel = "importProject:output:" + workspaceId + ":" + projectName;
|
||||
public void subscribe(final String name, final StatusNotification existingNotification) {
|
||||
this.projectName = name;
|
||||
this.wsChannel = "importProject:output";
|
||||
this.notification = existingNotification;
|
||||
this.subscriptionHandler = new SubscriptionHandler<String>(new LineUnmarshaller()) {
|
||||
this.subscriptionHandler = new SubscriptionHandler<String>(new StringUnmarshallerWS()) {
|
||||
@Override
|
||||
protected void onMessageReceived(String result) {
|
||||
notification.setContent(result);
|
||||
JsonObject jsonObject = Json.parse(result);
|
||||
|
||||
if (jsonObject == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (jsonObject.hasKey("project")) {
|
||||
projectName = jsonObject.getString("project");
|
||||
notification.setTitle(locale.importingProject(projectName));
|
||||
}
|
||||
|
||||
if (jsonObject.hasKey("line")) {
|
||||
notification.setContent(jsonObject.getString("line"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -153,25 +162,4 @@ public class ProjectNotificationSubscriberImpl implements ProjectNotificationSub
|
|||
}
|
||||
}).catchError(logErrorHandler);
|
||||
}
|
||||
|
||||
static class LineUnmarshaller implements org.eclipse.che.ide.websocket.rest.Unmarshallable<String> {
|
||||
private String line;
|
||||
|
||||
@Override
|
||||
public void unmarshal(Message response) throws UnmarshallerException {
|
||||
JSONObject jsonObject = JSONParser.parseStrict(response.getBody()).isObject();
|
||||
if (jsonObject == null) {
|
||||
return;
|
||||
}
|
||||
if (jsonObject.containsKey("line")) {
|
||||
line = jsonObject.get("line").isString().stringValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPayload() {
|
||||
return line;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ importLocalProject.openZipTitle = Select Zip archive to import:
|
|||
importProject.importButton = Import
|
||||
importProject.uriFieldTitle = URL:
|
||||
importProject.viewTitle = Import project
|
||||
importProject.importing = Importing project(s)
|
||||
importProject.importing = Importing project {0}
|
||||
importProject.message.success = Project {0} imported
|
||||
importProject.message.failure = Failed to import project {0}
|
||||
importProject.message.startWithWhiteSpace = The url can not start with a whitespace.
|
||||
|
|
|
|||
|
|
@ -493,10 +493,6 @@ public final class ProjectManager {
|
|||
sourceStorage.getLocation(), sourceStorage.getType()));
|
||||
}
|
||||
|
||||
// Preparing websocket output publisher to broadcast output of import process to the ide clients while importing
|
||||
// final LineConsumerFactory outputOutputConsumerFactory =
|
||||
// () -> new ProjectImportOutputWSLineConsumer(path, workspaceProjectsHolder.getWorkspaceId(), 300);
|
||||
|
||||
String normalizePath = (path.startsWith("/")) ? path : "/".concat(path);
|
||||
FolderEntry folder = asFolder(normalizePath);
|
||||
if (folder != null && !rewrite) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import org.eclipse.che.api.core.util.LineConsumerFactory;
|
|||
import org.eclipse.che.api.project.server.importer.ProjectImportOutputWSLineConsumer;
|
||||
|
||||
/**
|
||||
* LineConsumerFactory dedicated to project related operations long output
|
||||
* {@link LineConsumerFactory} dedicated to project related operations long output
|
||||
* extended standard factory with setProjectName method to make it possible
|
||||
* change it runtime inside ProjectManager
|
||||
*
|
||||
|
|
@ -23,9 +23,9 @@ import org.eclipse.che.api.project.server.importer.ProjectImportOutputWSLineCons
|
|||
*/
|
||||
public class ProjectOutputLineConsumerFactory implements LineConsumerFactory {
|
||||
|
||||
private String projectName;
|
||||
private String projectName;
|
||||
private final String workspaceId;
|
||||
private final int delay;
|
||||
private final int delay;
|
||||
|
||||
public ProjectOutputLineConsumerFactory(String projectName, String workspaceId, int delay) {
|
||||
this.projectName = projectName;
|
||||
|
|
|
|||
|
|
@ -232,7 +232,6 @@ public class ProjectService extends Service {
|
|||
|
||||
List<ProjectConfigDto> result = new ArrayList<>(projectConfigList.size());
|
||||
final ProjectOutputLineConsumerFactory outputOutputConsumerFactory = new ProjectOutputLineConsumerFactory(workspace, 300);
|
||||
// () -> new ProjectImportOutputWSLineConsumer("BATCH", workspace, 300);
|
||||
|
||||
for (RegisteredProject registeredProject : projectManager.createBatchProjects(projectConfigList, rewrite, outputOutputConsumerFactory)) {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue