forked from SmartBear/soapui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOAPUIOS-268-Redirect-analytics-data
- Loading branch information
EkaterinaSorokina
authored and
EkaterinaSorokina
committed
Nov 17, 2017
1 parent
8f13914
commit 6b4aa42
Showing
5 changed files
with
64 additions
and
90 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
74 changes: 39 additions & 35 deletions
74
soapui/src/main/java/com/eviware/soapui/analytics/providers/OSUserProvider.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 |
---|---|---|
@@ -1,43 +1,47 @@ | ||
/* | ||
* SoapUI, Copyright (C) 2004-2017 SmartBear Software | ||
* | ||
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent | ||
* versions of the EUPL (the "Licence"); | ||
* You may not use this work except in compliance with the Licence. | ||
* You may obtain a copy of the Licence at: | ||
* | ||
* http://ec.europa.eu/idabc/eupl | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is | ||
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the Licence for the specific language governing permissions and limitations | ||
* under the Licence. | ||
*/ | ||
|
||
package com.eviware.soapui.analytics.providers; | ||
|
||
/** | ||
* Created by avdeev on 02.02.2015. | ||
*/ | ||
public class OSUserProvider { | ||
/* final private static String ANALYTICS_SERVER_URL = "https://analytics01.smartbear.com/open-source-analytics-server/analytics"; | ||
import com.eviware.soapui.SoapUI; | ||
import com.eviware.soapui.settings.ProxySettings; | ||
import com.smartbear.analytics.api.ProductInfo; | ||
import com.smartbear.analytics.impl.SoapUIOSUserProvider; | ||
|
||
@Override | ||
public void trackUserInfo(OSUserDescription osUserDescription) { | ||
String requestParams = prepareRequestParams(osUserDescription); | ||
sendRecord(ANALYTICS_SERVER_URL, requestParams); | ||
import java.net.*; | ||
|
||
public class OSUserProvider extends SoapUIOSUserProvider { | ||
|
||
public OSUserProvider(ProductInfo productInfo) { | ||
super(productInfo); | ||
} | ||
|
||
@Override | ||
public void trackAction(ActionDescription actionDescription) { | ||
} | ||
protected HttpURLConnection initializeConnection(String connectionURL) { | ||
HttpURLConnection connection; | ||
try { | ||
URL url = new URL(connectionURL); | ||
String host = SoapUI.getSettings().getString(ProxySettings.HOST, ""); | ||
int port = 0; | ||
|
||
private String prepareRequestParams (OSUserDescription osUserDescription){ | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("name="); | ||
sb.append(HttpUtils.urlEncodeWithUtf8(osUserDescription.getName())); | ||
sb.append("&email="); | ||
sb.append(HttpUtils.urlEncodeWithUtf8(osUserDescription.getEmail())); | ||
return sb.toString(); | ||
}*/ | ||
try { | ||
port = Integer.parseInt(SoapUI.getSettings().getString(ProxySettings.PORT, "0")); | ||
} catch (NumberFormatException ex) { | ||
} | ||
|
||
if (SoapUI.getSettings().getBoolean(ProxySettings.ENABLE_PROXY, false) && host.compareTo("") != 0 && port != 0) { | ||
SocketAddress sa = new InetSocketAddress(host, port); | ||
Proxy proxy = new Proxy(Proxy.Type.HTTP, sa); | ||
connection = (HttpURLConnection) url.openConnection(proxy); | ||
} else { | ||
connection = (HttpURLConnection) url.openConnection(); | ||
} | ||
|
||
connection.setRequestMethod("POST"); | ||
connection.setDoOutput(true); | ||
connection.setRequestProperty("Content-Type", "text/plain; charset=utf-8"); | ||
|
||
return connection; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
} |
55 changes: 9 additions & 46 deletions
55
soapui/src/main/java/com/eviware/soapui/analytics/providers/OSUserProviderFactory.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 |
---|---|---|
@@ -1,56 +1,19 @@ | ||
/* | ||
* SoapUI, Copyright (C) 2004-2017 SmartBear Software | ||
* | ||
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent | ||
* versions of the EUPL (the "Licence"); | ||
* You may not use this work except in compliance with the Licence. | ||
* You may obtain a copy of the Licence at: | ||
* | ||
* http://ec.europa.eu/idabc/eupl | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is | ||
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the Licence for the specific language governing permissions and limitations | ||
* under the Licence. | ||
*/ | ||
|
||
package com.eviware.soapui.analytics.providers; | ||
|
||
|
||
import com.smartbear.analytics.api.AnalyticsProvider; | ||
import com.smartbear.analytics.api.AnalyticsProviderFactory; | ||
import com.smartbear.analytics.api.ProductInfo; | ||
import com.smartbear.analytics.impl.SoapUIOSUserProviderFactory; | ||
|
||
/** | ||
* Created by avdeev on 02.02.2015. | ||
*/ | ||
public class OSUserProviderFactory implements AnalyticsProviderFactory { | ||
@Override | ||
public String getName() { | ||
return null; | ||
} | ||
public class OSUserProviderFactory extends SoapUIOSUserProviderFactory { | ||
private ProductInfo productInfo; | ||
|
||
@Override | ||
public String getDescription() { | ||
return null; | ||
public OSUserProviderFactory(ProductInfo productInfo) { | ||
super(productInfo); | ||
this.productInfo = productInfo; | ||
} | ||
|
||
@Override | ||
public AnalyticsProvider allocateProvider() { | ||
return null; | ||
} | ||
/* @Override | ||
public String getName() { | ||
return "OS User Contact Info Provider"; | ||
return new OSUserProvider(productInfo); | ||
} | ||
@Override | ||
public String getDescription() { | ||
return "Allow to track OS user contact information"; | ||
} | ||
@Override | ||
public AnalyticsProvider allocateProvider() { | ||
return new OSUserProvider(); | ||
}*/ | ||
|
||
} | ||
} |