Esempio n. 1
0
 private void updateProject(final ProjectConfigDto projectToUpdate) {
   Promise<ProjectConfigDto> updateProjectPromise =
       projectService.updateProject(workspaceId, projectToUpdate.getPath(), projectToUpdate);
   updateProjectPromise
       .then(
           new Operation<ProjectConfigDto>() {
             @Override
             public void apply(ProjectConfigDto arg) throws OperationException {
               updateOpenedFiles();
               eventBus.fireEvent(new ProjectUpdatedEvent(arg.getPath(), arg));
             }
           })
       .catchError(
           new Operation<PromiseError>() {
             @Override
             public void apply(PromiseError arg) throws OperationException {
               notificationManager.notify(arg.getMessage(), FAIL, true, projectToUpdate);
             }
           });
 }
  private void setupMixin(Project project) {
    final ProjectConfigDto projectConfig = appContext.getCurrentProject().getRootProject();

    List<String> mixins = projectConfig.getMixins();
    if (!mixins.contains(OPENSHIFT_PROJECT_TYPE_ID)) {
      mixins.add(OPENSHIFT_PROJECT_TYPE_ID);
    }

    Map<String, List<String>> attributes = projectConfig.getAttributes();
    attributes.put(OPENSHIFT_APPLICATION_VARIABLE_NAME, newArrayList(osAppName));
    attributes.put(
        OPENSHIFT_NAMESPACE_VARIABLE_NAME, newArrayList(project.getMetadata().getName()));

    projectService
        .updateProject(appContext.getWorkspaceId(), projectConfig.getPath(), projectConfig)
        .then(
            new Operation<ProjectConfigDto>() {
              @Override
              public void apply(ProjectConfigDto project) throws OperationException {
                eventBus.fireEvent(new ProjectUpdatedEvent(projectConfig.getPath(), project));
                notificationManager.notify(
                    locale.linkProjectWithExistingSuccess(projectConfig.getName(), osAppName),
                    SUCCESS,
                    true);
              }
            })
        .catchError(
            new Operation<PromiseError>() {
              @Override
              public void apply(PromiseError arg) throws OperationException {
                final ServiceError serviceError =
                    dtoFactory.createDtoFromJson(arg.getMessage(), ServiceError.class);
                notificationManager.notify(serviceError.getMessage(), FAIL, true);
              }
            });
  }