Search in sources :

Example 16 with TCompactProtocol

use of org.apache.thrift.protocol.TCompactProtocol in project sw360portal by sw360.

the class TestLicenseClient method main.

public static void main(String[] args) throws TException, IOException {
    THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/licenses/thrift");
    TProtocol protocol = new TCompactProtocol(thriftClient);
    LicenseService.Iface client = new LicenseService.Client(protocol);
    List<License> licenses = client.getLicenseSummary();
    List<Obligation> obligations = client.getObligations();
    System.out.println("Fetched " + licenses.size() + " licenses from license service");
    System.out.println("Fetched " + obligations.size() + " obligations from license service");
    // final List<License> licenseList = client.getDetailedLicenseSummaryForExport("");
    final List<License> licenseList = client.getDetailedLicenseSummary("", ImmutableList.of("AFL-2.1", "Artistic-1.0"));
    System.out.println(licenseList.toString());
}
Also used : Obligation(org.eclipse.sw360.datahandler.thrift.licenses.Obligation) TProtocol(org.apache.thrift.protocol.TProtocol) LicenseService(org.eclipse.sw360.datahandler.thrift.licenses.LicenseService) License(org.eclipse.sw360.datahandler.thrift.licenses.License) THttpClient(org.apache.thrift.transport.THttpClient) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 17 with TCompactProtocol

use of org.apache.thrift.protocol.TCompactProtocol in project sw360portal by sw360.

the class TestVendorClient method main.

public static void main(String[] args) throws TException, IOException {
    THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/vendorservice/thrift");
    TProtocol protocol = new TCompactProtocol(thriftClient);
    VendorService.Iface client = new VendorService.Client(protocol);
    List<Vendor> vendors = client.getAllVendors();
    reportFindings(vendors);
    System.out.println("Now looking for matches starting with 'm' from vendor service");
    reportFindings(client.searchVendors("m"));
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 18 with TCompactProtocol

use of org.apache.thrift.protocol.TCompactProtocol in project sw360portal by sw360.

the class TestSearchClient method main.

public static void main(String[] args) throws TException, IOException {
    THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/search/thrift");
    TProtocol protocol = new TCompactProtocol(thriftClient);
    SearchService.Iface client = new SearchService.Client(protocol);
    List<SearchResult> results = client.search(searchtext, null);
    // List<SearchResult> results = new SearchHandler().search(searchtext);
    // http://localhost:5984/_fti/local/sw360db/_design/lucene/all?q=type:project%20AND%20P1*
    System.out.println("Fetched " + results.size() + " from search service");
    for (SearchResult result : results) {
        System.out.println(result.getId() + "(" + result.getType() + "): " + result.getName() + " (" + result.getScore() + ")");
    }
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) SearchService(org.eclipse.sw360.datahandler.thrift.search.SearchService) THttpClient(org.apache.thrift.transport.THttpClient) SearchResult(org.eclipse.sw360.datahandler.thrift.search.SearchResult) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 19 with TCompactProtocol

use of org.apache.thrift.protocol.TCompactProtocol in project sw360portal by sw360.

the class TestProjectClient method main.

public static void main(String[] args) throws TException, IOException {
    THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/projects/thrift");
    TProtocol protocol = new TCompactProtocol(thriftClient);
    ProjectService.Iface client = new ProjectService.Client(protocol);
// User cedric = new User().setEmail("cedric.bodet@tngtech.com").setDepartment("CT BE OSS TNG CB");
// Project myProject = new Project().setName("First project").setDescription("My first project");
// client.addProject(myProject, cedric);
// List<Project> projects = client.getBUProjectsSummary("CT BE OSS");
// System.out.println("Fetched " + projects.size() + " from project service");
// for (Project project : projects) {
// System.out.println(project.toString());
// }
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) ProjectService(org.eclipse.sw360.datahandler.thrift.projects.ProjectService) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 20 with TCompactProtocol

use of org.apache.thrift.protocol.TCompactProtocol in project sw360portal by sw360.

the class TestComponentClient method main.

public static void main(String[] args) throws TException, IOException {
    THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/components/thrift");
    TProtocol protocol = new TCompactProtocol(thriftClient);
    ComponentService.Iface client = new ComponentService.Client(protocol);
// List<Component> components = client.getComponentSummary(user);
// List<Component> recentComponents = client.getRecentComponents();
// List<Release> releases = client.getReleaseSummary(user);
// 
// System.out.println("Fetched " + components.size() + " components from license service");
// System.out.println("Fetched " + releases.size() + " releases from license service");
// System.out.println("Fetched " + recentComponents.size() + " recent components from license service");
// 
// String referenceId =null;
// for (Component component : recentComponents) {
// if(referenceId==null) referenceId=component.getId();
// System.out.println(component.getId() + ": " + component.getName());
// }
// 
// if(referenceId!=null) {
// System.out.println(client.getComponentById(referenceId, user).toString());
// Component component = new ComponentHandler("http://localhost:5984", "sw360db", "sw360attachments").getComponentById(referenceId, user);
// System.out.println(component.toString());
// System.out.println(client.getComponentById(referenceId, user).toString());
// }
// 
// for(Release release : releases) {
// System.out.println(release.toString());
// }
// // This fails with a thrift error... debug!
// if(releases.size()>0) {
// String releaseNameStart = releases.get(0).getName().substring(0,1);
// System.out.println("The following releases start with " + releaseNameStart );
// 
// List<Release> releases1 = client.searchReleaseByName(releaseNameStart);
// for(Release release : releases1) {
// System.out.println(release.toString());
// }
// 
// }
// final Component cpe = client.getComponentForReportFromCPEId("cpe");
// System.out.println(cpe.toString());
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Aggregations

TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)54 TProtocol (org.apache.thrift.protocol.TProtocol)38 THttpClient (org.apache.thrift.transport.THttpClient)18 TSocket (org.apache.thrift.transport.TSocket)18 TException (org.apache.thrift.TException)15 TTransport (org.apache.thrift.transport.TTransport)11 TFramedTransport (org.apache.thrift.transport.TFramedTransport)9 IOException (java.io.IOException)8 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)7 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)7 TIOStreamTransport (org.apache.thrift.transport.TIOStreamTransport)7 TTransportException (org.apache.thrift.transport.TTransportException)5 TFramedTransport (org.apache.thrift.transport.layered.TFramedTransport)5 Test (org.junit.Test)5 LoginException (javax.security.auth.login.LoginException)4 Hello (org.tech.model.Hello)4 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 UGIAssumingTransport (org.apache.accumulo.core.rpc.UGIAssumingTransport)3 AccumuloProxy (org.apache.accumulo.proxy.thrift.AccumuloProxy)3