Skip to content

Commit

Permalink
Factory migration (#4413)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshaposhnik authored Apr 3, 2017
1 parent 2fcb0fb commit 62d3268
Show file tree
Hide file tree
Showing 266 changed files with 21,375 additions and 207 deletions.
12 changes: 12 additions & 0 deletions assembly/assembly-ide-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-github-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-github-pullrequest</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-github-shared</artifactId>
Expand Down Expand Up @@ -243,6 +247,14 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-product-info</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-pullrequest-ide</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-pullrequest-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-python-lang-ide</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@

RewriteRule ^/api/(.*)$ /wsmaster/api/$1 [L]
RewriteRule ^/factory\\?(.*)$ /dashboard/#/load-factory/$1 [R,NE]
RewriteRule ^/factory/(.*)$ /dashboard/#/load-factory/$1 [R,NE]
RewriteRule ^/f/?(.*)$ /dashboard/#/load-factory/$1 [R,NE]
RewriteRule ^/f\\?(.*)$ /dashboard/#/load-factory/$1 [R,NE]
21 changes: 16 additions & 5 deletions assembly/assembly-wsmaster-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-machine</artifactId>
Expand Down Expand Up @@ -178,6 +182,10 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-docker-machine</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-github-factory-resolver</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-github-oauth2</artifactId>
Expand All @@ -198,10 +206,18 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-openshift-client</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-pullrequest-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ssh-machine</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-url-factory</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
Expand Down Expand Up @@ -237,11 +253,6 @@
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@
import org.eclipse.che.api.core.rest.CheJsonProvider;
import org.eclipse.che.api.core.rest.MessageBodyAdapter;
import org.eclipse.che.api.core.rest.MessageBodyAdapterInterceptor;
import org.eclipse.che.api.factory.server.FactoryAcceptValidator;
import org.eclipse.che.api.factory.server.FactoryCreateValidator;
import org.eclipse.che.api.factory.server.FactoryEditValidator;
import org.eclipse.che.api.factory.server.FactoryParametersResolver;
import org.eclipse.che.api.machine.shared.Constants;
import org.eclipse.che.api.user.server.TokenValidator;
import org.eclipse.che.api.workspace.server.WorkspaceConfigMessageBodyAdapter;
import org.eclipse.che.api.workspace.server.WorkspaceMessageBodyAdapter;
import org.eclipse.che.api.workspace.server.stack.StackMessageBodyAdapter;
import org.eclipse.che.core.db.schema.SchemaInitializer;
import org.eclipse.che.inject.DynaModule;
import org.eclipse.che.plugin.github.factory.resolver.GithubFactoryParametersResolver;
import org.flywaydb.core.internal.util.PlaceholderReplacer;

import javax.sql.DataSource;
Expand All @@ -62,6 +67,18 @@ protected void configure() {
bind(org.eclipse.che.core.db.DBInitializer.class).asEagerSingleton();
bind(PlaceholderReplacer.class).toProvider(org.eclipse.che.core.db.schema.impl.flyway.PlaceholderReplacerProvider.class);

//factory
bind(FactoryAcceptValidator.class).to(org.eclipse.che.api.factory.server.impl.FactoryAcceptValidatorImpl.class);
bind(FactoryCreateValidator.class).to(org.eclipse.che.api.factory.server.impl.FactoryCreateValidatorImpl.class);
bind(FactoryEditValidator.class).to(org.eclipse.che.api.factory.server.impl.FactoryEditValidatorImpl.class);
bind(org.eclipse.che.api.factory.server.FactoryService.class);
install(new org.eclipse.che.api.factory.server.jpa.FactoryJpaModule());

Multibinder<FactoryParametersResolver> factoryParametersResolverMultibinder =
Multibinder.newSetBinder(binder(), FactoryParametersResolver.class);
factoryParametersResolverMultibinder.addBinding()
.to(GithubFactoryParametersResolver.class);

install(new org.eclipse.che.plugin.docker.compose.ComposeModule());

bind(org.eclipse.che.api.user.server.CheUserCreator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
<class>org.eclipse.che.api.machine.server.model.impl.SnapshotImpl</class>
<class>org.eclipse.che.api.machine.server.recipe.RecipeImpl</class>

<class>org.eclipse.che.api.factory.server.model.impl.FactoryImpl</class>
<class>org.eclipse.che.api.factory.server.model.impl.OnAppClosedImpl</class>
<class>org.eclipse.che.api.factory.server.model.impl.OnProjectsLoadedImpl</class>
<class>org.eclipse.che.api.factory.server.model.impl.OnAppLoadedImpl</class>
<class>org.eclipse.che.api.factory.server.model.impl.PoliciesImpl</class>
<class>org.eclipse.che.api.factory.server.model.impl.ActionImpl</class>
<class>org.eclipse.che.api.factory.server.model.impl.AuthorImpl</class>
<class>org.eclipse.che.api.factory.server.model.impl.ButtonAttributesImpl</class>
<class>org.eclipse.che.api.factory.server.model.impl.ButtonImpl</class>
<class>org.eclipse.che.api.factory.server.model.impl.IdeImpl</class>
<class>org.eclipse.che.api.factory.server.FactoryImage</class>

<class>org.eclipse.che.api.ssh.server.model.impl.SshPairImpl</class>

<exclude-unlisted-classes>true</exclude-unlisted-classes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public interface Policies {
*/
Long getUntil();

/**
* Re-open projects on factory 2-nd click
*/
String getMatch();

/**
* Workspace creation strategy
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class CheCacheDisablingFilter extends CacheDisablingFilter {

private Set<Pattern> actionPatterns = new HashSet<>();

@Override
public void init(FilterConfig filterConfig) {
Enumeration<String> names = filterConfig.getInitParameterNames();
while (names.hasMoreElements()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class CheCacheForcingFilter extends CacheForcingFilter {

private Set<Pattern> actionPatterns = new HashSet<>();

@Override
public void init(FilterConfig filterConfig) {
Enumeration<String> names = filterConfig.getInitParameterNames();
while (names.hasMoreElements()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,27 @@ public Object[][] cachedPathProvider() {
private class MockFilterConfig implements FilterConfig {
private final Map<String, String> filterParams = new HashMap<>();

public MockFilterConfig() {
MockFilterConfig() {
this.filterParams.put("pattern1", "^.*\\.nocache\\..*$");
this.filterParams.put("pattern2", "^.*/_app/.*$");
}

@Override
public String getFilterName() {
return this.getClass().getName();
}

@Override
public ServletContext getServletContext() {
throw new UnsupportedOperationException("The method does not supported in " + this.getClass());
}

@Override
public String getInitParameter(String key) {
return this.filterParams.get(key);
}

@Override
public Enumeration<String> getInitParameterNames() {
return Collections.enumeration(filterParams.keySet());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,27 @@ public Object[][] nonCachedPathProvider() {
private class MockFilterConfig implements FilterConfig {
private final Map<String, String> filterParams = new HashMap<>();

public MockFilterConfig() {
MockFilterConfig() {
this.filterParams.put("pattern1", "^.*\\.cache\\..*$");
this.filterParams.put("pattern2", "^.*/_app/.*$");
}

@Override
public String getFilterName() {
return this.getClass().getName();
}

@Override
public ServletContext getServletContext() {
throw new UnsupportedOperationException("The method does not supported in " + this.getClass());
}

@Override
public String getInitParameter(String key) {
return this.filterParams.get(key);
}

@Override
public Enumeration<String> getInitParameterNames() {
return Collections.enumeration(filterParams.keySet());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Copyright (c) 2015-2017 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
*/
'use strict';

/**
* Defines controller of directive for displaying action box.
* @ngdoc controller
* @name factory.directive:FactoryActionBoxController
* @author Florent Benoit
*/
export class FactoryActionBoxController {
private $mdDialog: ng.material.IDialogService;
private actions: Array<any>;
private selectedAction: string;
private factoryObject: any;
private lifecycle: any;
private onChange: Function;

/**
* Default constructor that is using resource injection
* @ngInject for Dependency injection
*/
constructor($mdDialog: ng.material.IDialogService) {
this.$mdDialog = $mdDialog;

this.actions = [];
this.actions.push({name : 'RunCommand', id: 'runcommand'});
this.actions.push({name : 'openFile', id: 'openfile'});
this.selectedAction = this.actions[0].id;
}

/**
* Edit the action based on the provided index
* @param $event the mouse event
* @param index the index in the array of factory actions
*/
editAction($event: any, index: number): void {
let action = this.factoryObject.ide[this.lifecycle].actions[index];
this.$mdDialog.show({
targetEvent: $event,
controller: 'FactoryActionDialogEditController',
controllerAs: 'factoryActionDialogEditCtrl',
bindToController: true,
clickOutsideToClose: true,
locals: {
callbackController: this,
index: index,
// selectedAction: action
selectedValue: action.properties
},
templateUrl: 'app/factories/create-factory/action/factory-action-edit.html'
});
}

/**
* Edit action callback.
*
* @param index the index in the array of factory actions
* @param newValue new value
*/
callbackEditAction(index: number, newValue: any): void {
this.factoryObject.ide[this.lifecycle].actions[index].properties = newValue;

this.onChange();
}

addAction(): void {
if (!this.factoryObject.ide) {
this.factoryObject.ide = {};
}
if (!this.factoryObject.ide[this.lifecycle]) {
this.factoryObject.ide[this.lifecycle] = {};
this.factoryObject.ide[this.lifecycle].actions = [];
}

let actionToAdd;
if ('openfile' === this.selectedAction) {
actionToAdd = {
"properties": {
"file": this.selectedParam
},
"id": "openFile"
};
} else if ('runcommand' === this.selectedAction) {
actionToAdd = {
"properties": {
"name": this.selectedParam
},
"id": "runCommand"
};
}
if (actionToAdd) {
this.factoryObject.ide[this.lifecycle].actions.push(actionToAdd);
}

this.onChange();
}

/**
* Remove action based on the provided index
* @param index the index in the array of factory actions
*/
removeAction(index: number): void {
this.factoryObject.ide[this.lifecycle].actions.splice(index, 1);

this.onChange();
}
}
Loading

0 comments on commit 62d3268

Please sign in to comment.