Skip to content

Commit

Permalink
Refactor plugins - Create Core and UI plugins for base and LSP functi…
Browse files Browse the repository at this point in the history
…onality. Fixes fabric8-analytics#143

Signed-off-by: Rastislav Wagner <[email protected]>
  • Loading branch information
rawagner committed Apr 10, 2018
1 parent 6fb8ca3 commit 9a5e885
Show file tree
Hide file tree
Showing 893 changed files with 123,630 additions and 428 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.redhat.fabric8analytics.lsp.eclipse.core;singleton:=true
Bundle-SymbolicName: com.redhat.fabric8analytics.eclipse.core;singleton:=true
Bundle-Version: 0.0.1.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.lsp4e;bundle-version="0.3.0",
org.eclipse.core.runtime,
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.12.0",
org.apache.httpcomponents.httpclient;bundle-version="4.5.2",
org.apache.httpcomponents.httpcore;bundle-version="4.4.6",
Expand All @@ -18,13 +17,13 @@ Require-Bundle: org.eclipse.lsp4e;bundle-version="0.3.0",
org.eclipse.m2e.core,
org.eclipse.m2e.maven.runtime,
org.jboss.tools.openshift.io.core
Eclipse-BundleShape: dir
Bundle-Activator: com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisLSCoreActivator
Bundle-Activator: com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Export-Package: com.redhat.fabric8analytics.lsp.eclipse.core,
com.redhat.fabric8analytics.lsp.eclipse.core.job,
com.redhat.fabric8analytics.lsp.eclipse.core.data,
com.redhat.fabric8analytics.lsp.eclipse.core.internal;x-friends:=com.redhat.fabric8analytics.lsp.eclipse.ui
Export-Package: com.redhat.fabric8analytics.eclipse.core,
com.redhat.fabric8analytics.eclipse.core.data,
com.redhat.fabric8analytics.eclipse.core.internal;x-friends:="com.redhat.fabric8analytics.eclipse.lsp.core, com.redhat.fabric8analytics.eclipse.ui, com.redhat.fabric8analytics.eclipse.lsp.ui",
com.redhat.fabric8analytics.eclipse.core.job,
com.redhat.fabric8analytics.eclipse.core.api


Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Bundle-Name=Fabric8Analytics Core Plugin
Bundle-Vendor=JBoss by Red Hat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>com.redhat.fabric8analytics.lsp.eclipse.core</artifactId>
<artifactId>com.redhat.fabric8analytics.eclipse.core</artifactId>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/

package com.redhat.fabric8analytics.lsp.eclipse.core;
package com.redhat.fabric8analytics.eclipse.core;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
Expand All @@ -19,17 +19,17 @@
/**
* The activator class controls the plug-in life cycle
*/
public class Fabric8AnalysisLSCoreActivator extends Plugin {
public class Fabric8AnalysisCoreActivator extends Plugin {

public static final String PLUGIN_ID = "com.redhat.fabric8analytics.lsp.eclipse.core";
public static final String PLUGIN_ID = "com.redhat.fabric8analytics.eclipse.core";

// The shared instance
private static Fabric8AnalysisLSCoreActivator plugin;
private static Fabric8AnalysisCoreActivator plugin;

/**
* The constructor
*/
public Fabric8AnalysisLSCoreActivator() {
public Fabric8AnalysisCoreActivator() {
}

@Override
Expand All @@ -49,7 +49,7 @@ public void stop(BundleContext context) throws Exception {
*
* @return the shared instance
*/
public static Fabric8AnalysisLSCoreActivator getDefault() {
public static Fabric8AnalysisCoreActivator getDefault() {
return plugin;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
* Contributors:
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/
package com.redhat.fabric8analytics.lsp.eclipse.core;
package com.redhat.fabric8analytics.eclipse.core;

import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.equinox.security.storage.ISecurePreferences;
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
import org.eclipse.equinox.security.storage.StorageException;

import com.redhat.fabric8analytics.lsp.eclipse.core.data.ThreeScaleData;
import com.redhat.fabric8analytics.eclipse.core.data.ThreeScaleData;

public class Fabric8AnalysisPreferences {

public static final String LSP_SERVER_ENABLED = "fabric8AnalysisPreferences.LSP_ENABLED";
public static final String PROD_URL = "fabric8AnalysisPreferences.PROD_URL";
public static final String STAGE_URL = "fabric8AnalysisPreferences.STAGE_URL";
public static final String USER_KEY = "fabric8AnalysisPreferences.USER_KEY";
Expand All @@ -39,28 +38,20 @@ public static Fabric8AnalysisPreferences getInstance() {
return instance;
}

public boolean isLSPServerEnabled() {
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).getBoolean(LSP_SERVER_ENABLED, false);
}

public void setLSPServerEnabled(boolean enabled) {
InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).putBoolean(LSP_SERVER_ENABLED, enabled);
}

public String getProdURL() {
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).get(PROD_URL, null);
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisCoreActivator.PLUGIN_ID).get(PROD_URL, null);
}

public void setProdURL(String prodURL) {
InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).put(PROD_URL, prodURL);
InstanceScope.INSTANCE.getNode(Fabric8AnalysisCoreActivator.PLUGIN_ID).put(PROD_URL, prodURL);
}

public String getStageURL() {
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).get(STAGE_URL, null);
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisCoreActivator.PLUGIN_ID).get(STAGE_URL, null);
}

public void setStageURL(String stageURL) {
InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).put(STAGE_URL, stageURL);
InstanceScope.INSTANCE.getNode(Fabric8AnalysisCoreActivator.PLUGIN_ID).put(STAGE_URL, stageURL);
}

public String getUserKey() throws StorageException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/

package com.redhat.fabric8analytics.lsp.eclipse.core;
package com.redhat.fabric8analytics.eclipse.core.api;

import org.json.JSONObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/

package com.redhat.fabric8analytics.lsp.eclipse.core;
package com.redhat.fabric8analytics.eclipse.core.api;


import java.io.File;
Expand All @@ -31,8 +31,9 @@
import org.json.JSONException;
import org.json.JSONObject;

import com.redhat.fabric8analytics.lsp.eclipse.core.data.AnalyticsAuthData;
import com.redhat.fabric8analytics.lsp.eclipse.core.internal.PomContentBody;
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
import com.redhat.fabric8analytics.eclipse.core.data.AnalyticsAuthData;
import com.redhat.fabric8analytics.eclipse.core.internal.PomContentBody;

/**
* Provides access to Recommender API server
Expand Down Expand Up @@ -132,7 +133,7 @@ public boolean analysesFinished(String jobId) throws RecommenderAPIException {
int responseCode = response.getStatusLine().getStatusCode();

// TODO - for debug purposes - should be removed later
Fabric8AnalysisLSCoreActivator.getDefault().logInfo("F8 server response code: " + responseCode);
Fabric8AnalysisCoreActivator.getDefault().logInfo("F8 server response code: " + responseCode);

if (responseCode == HttpStatus.SC_OK) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/

package com.redhat.fabric8analytics.lsp.eclipse.core;
package com.redhat.fabric8analytics.eclipse.core.api;

import org.json.JSONObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/

package com.redhat.fabric8analytics.lsp.eclipse.core;
package com.redhat.fabric8analytics.eclipse.core.api;

import java.io.IOException;

Expand All @@ -22,7 +22,7 @@
import org.json.JSONException;
import org.json.JSONObject;

import com.redhat.fabric8analytics.lsp.eclipse.core.data.ThreeScaleData;
import com.redhat.fabric8analytics.eclipse.core.data.ThreeScaleData;

/**
* Provides access to 3scale service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/
package com.redhat.fabric8analytics.lsp.eclipse.core.data;
package com.redhat.fabric8analytics.eclipse.core.data;

public class AnalyticsAuthData {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redhat.fabric8analytics.lsp.eclipse.core.data;
package com.redhat.fabric8analytics.eclipse.core.data;

/**
* Stores 3scale data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/

package com.redhat.fabric8analytics.lsp.eclipse.core.internal;
package com.redhat.fabric8analytics.eclipse.core.internal;

import java.util.List;

Expand All @@ -21,12 +21,12 @@
import org.jboss.tools.openshift.io.core.AccountStatus;
import org.jboss.tools.openshift.io.core.model.IAccount;

import com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisLSCoreActivator;
import com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisPreferences;
import com.redhat.fabric8analytics.lsp.eclipse.core.ThreeScaleAPIException;
import com.redhat.fabric8analytics.lsp.eclipse.core.ThreeScaleAPIProvider;
import com.redhat.fabric8analytics.lsp.eclipse.core.data.AnalyticsAuthData;
import com.redhat.fabric8analytics.lsp.eclipse.core.data.ThreeScaleData;
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisPreferences;
import com.redhat.fabric8analytics.eclipse.core.api.ThreeScaleAPIException;
import com.redhat.fabric8analytics.eclipse.core.api.ThreeScaleAPIProvider;
import com.redhat.fabric8analytics.eclipse.core.data.AnalyticsAuthData;
import com.redhat.fabric8analytics.eclipse.core.data.ThreeScaleData;

public class AnalyticsAuthService {

Expand Down Expand Up @@ -78,7 +78,7 @@ public AnalyticsAuthData getAnalyticsAuthData(IProgressMonitor progressMonitor)
try {
threeScaleData = registerThreeScale(monitor, token);
} catch (ThreeScaleAPIException e) {
Fabric8AnalysisLSCoreActivator.getDefault().logError("Unable to get data from 3scale", e);
Fabric8AnalysisCoreActivator.getDefault().logError("Unable to get data from 3scale", e);
return null;
}
}
Expand All @@ -101,7 +101,7 @@ public AnalyticsAuthData login(IProgressMonitor progressMonitor) throws StorageE
try {
threeScaleData = registerThreeScale(monitor, token);
} catch (ThreeScaleAPIException e) {
Fabric8AnalysisLSCoreActivator.getDefault().logError("Unable to get data from 3scale", e);
Fabric8AnalysisCoreActivator.getDefault().logError("Unable to get data from 3scale", e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/
package com.redhat.fabric8analytics.lsp.eclipse.core.internal;
package com.redhat.fabric8analytics.eclipse.core.internal;

import java.io.IOException;
import java.io.OutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2018 Red Hat Inc..
* 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:
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/
package com.redhat.fabric8analytics.eclipse.core.job;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.security.storage.StorageException;

import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
import com.redhat.fabric8analytics.eclipse.core.data.AnalyticsAuthData;
import com.redhat.fabric8analytics.eclipse.core.internal.AnalyticsAuthService;

public class LoginToOSIOJob extends Job {

private AnalyticsAuthData analyticsAuthData;

public LoginToOSIOJob() {
super("Login to Openshift.io");
}

@Override
protected IStatus run(IProgressMonitor progressMonitor) {
try {
analyticsAuthData = AnalyticsAuthService.getInstance().login(progressMonitor);
} catch (StorageException e) {
return new Status(IStatus.ERROR, Fabric8AnalysisCoreActivator.PLUGIN_ID, "Error occured while storing Fabric8Analytics data", e);
}
return Status.OK_STATUS;
}

public AnalyticsAuthData getAnalyticsAuthData() {
return analyticsAuthData;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
* Contributors:
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/
package com.redhat.fabric8analytics.lsp.eclipse.core.job;
package com.redhat.fabric8analytics.eclipse.core.job;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

import com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisLSCoreActivator;
import com.redhat.fabric8analytics.lsp.eclipse.core.RecommenderAPIException;
import com.redhat.fabric8analytics.lsp.eclipse.core.RecommenderAPIProvider;
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
import com.redhat.fabric8analytics.eclipse.core.api.RecommenderAPIException;
import com.redhat.fabric8analytics.eclipse.core.api.RecommenderAPIProvider;

public class RetrieveResultsJob extends Job {

Expand All @@ -35,10 +35,10 @@ public RetrieveResultsJob(RecommenderAPIProvider provider, String jobID) {
protected IStatus run(IProgressMonitor monitor) {
try {
if (!provider.analysesFinished(jobID)) {
return new Status(IStatus.INFO, Fabric8AnalysisLSCoreActivator.PLUGIN_ID, "Analysis is not ready yet");
return new Status(IStatus.INFO, Fabric8AnalysisCoreActivator.PLUGIN_ID, "Analysis is not ready yet");
}
} catch (RecommenderAPIException e) {
return new Status(IStatus.ERROR, Fabric8AnalysisLSCoreActivator.PLUGIN_ID,
return new Status(IStatus.ERROR, Fabric8AnalysisCoreActivator.PLUGIN_ID,
"Error during communication with analytics server", e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/
package com.redhat.fabric8analytics.lsp.eclipse.core.job;
package com.redhat.fabric8analytics.eclipse.core.job;

import java.io.StringWriter;
import java.util.HashMap;
Expand All @@ -26,8 +26,8 @@
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;

import com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisLSCoreActivator;
import com.redhat.fabric8analytics.lsp.eclipse.core.RecommenderAPIProvider;
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
import com.redhat.fabric8analytics.eclipse.core.api.RecommenderAPIProvider;

public class SendToFabric8AnalysisJob extends Job {

Expand Down Expand Up @@ -61,7 +61,7 @@ protected IStatus run(IProgressMonitor monitor) {

jobID = provider.requestAnalyses(effectivePomFiles, license);
} catch (Exception e) {
return new Status(Status.ERROR, Fabric8AnalysisLSCoreActivator.PLUGIN_ID, "Error during communication with server", e);
return new Status(Status.ERROR, Fabric8AnalysisCoreActivator.PLUGIN_ID, "Error during communication with server", e);
}
return Status.OK_STATUS;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/bin/
/.settings/
/.project
/.classpath
target/
server*
**/.DS_Store
Loading

0 comments on commit 9a5e885

Please sign in to comment.