Example usage for org.apache.thrift.protocol TCompactProtocol TCompactProtocol

List of usage examples for org.apache.thrift.protocol TCompactProtocol TCompactProtocol

Introduction

In this page you can find the example usage for org.apache.thrift.protocol TCompactProtocol TCompactProtocol.

Prototype

public TCompactProtocol(TTransport transport) 

Source Link

Document

Create a TCompactProtocol.

Usage

From source file:com.siemens.sw360.components.TestComponentClient.java

License:Open Source License

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);
    ////w  w  w. j ava  2 s .  c o  m
    //        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());

}

From source file:com.siemens.sw360.datahandler.thrift.ThriftClients.java

License:Open Source License

/**
 * Creates a Thrift Compact Protocol object linked to the given address
 *//*from  www  . j  a va 2 s  .  c o m*/
private static TProtocol makeProtocol(String url, String service) {
    THttpClient thriftClient = null;
    final String destinationAddress = url + service;
    try {
        thriftClient = new THttpClient(destinationAddress);
    } catch (TTransportException e) {
        log.error("cannot connect to backend on " + destinationAddress, e);
    }
    return new TCompactProtocol(thriftClient);
}

From source file:com.siemens.sw360.licenses.TestLicenseClient.java

License:Open Source License

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());

}

From source file:com.siemens.sw360.moderation.TestModerationClient.java

License:Open Source License

public static void main(String[] args) throws TException, IOException {
    THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080//moderation/thrift");
    TProtocol protocol = new TCompactProtocol(thriftClient);
    ModerationService.Iface client = new ModerationService.Client(protocol);

    List<ModerationRequest> requestsByModerator = client.getRequestsByModerator(
            new User().setId("").setEmail("cedric.bodet@tngtech.com").setDepartment("BB"));

    System.out//from  w w  w  .j ava 2  s  .  com
            .println("Fetched " + requestsByModerator.size() + " moderation requests from moderation service");

}

From source file:com.siemens.sw360.projects.TestProjectClient.java

License:Open Source License

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());
    //        }/*from   w w w  .  j  a v a2 s  .  c o m*/
}

From source file:com.siemens.sw360.search.TestSearchClient.java

License:Open Source License

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() + ")");
    }//from w w  w . jav  a  2s.  c  om
}

From source file:com.siemens.sw360.users.TestUserClient.java

License:Open Source License

public static void main(String[] args) throws TException, IOException {
    THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/users/thrift");
    TProtocol protocol = new TCompactProtocol(thriftClient);
    UserService.Iface client = new UserService.Client(protocol);

    System.out.println(client.getByEmail("cedric.bodet@tngtech.com"));
}

From source file:com.siemens.sw360.vendors.TestVendorClient.java

License:Open Source License

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);/*  w w w.ja  v  a2  s. co  m*/

    System.out.println("Now looking for matches starting with 'm' from vendor service");

    reportFindings(client.searchVendors("m"));
}

From source file:com.sleepycat.client.BdbServerConnection.java

License:Open Source License

/**
 * For unit test only./*w  ww . j  a v  a2  s  .  c o  m*/
 *
 * @param clientIn the input stream
 * @param clientOut the out stream
 */
BdbServerConnection(InputStream clientIn, OutputStream clientOut) {
    this.host = "test";
    this.port = 0;
    TProtocol protocol = new TCompactProtocol(new TIOStreamTransport(clientIn, clientOut));
    this.client = new BdbService.Client(protocol);
}

From source file:com.sleepycat.client.BdbServerConnection.java

License:Open Source License

private void open(SslConfig sslConfig, int timeout) throws TTransportException {
    TTransport transport;//from w w w .  j  av  a  2s  . c om
    if (sslConfig == null) {
        TSocket socket = new TSocket(this.host, this.port);
        transport = new TFramedTransport(socket);
        transport.open();
    } else {
        transport = TSSLTransportFactory.getClientSocket(this.host, this.port, timeout,
                sslConfig.getParameters());
    }

    TProtocol protocol = new TCompactProtocol(transport);
    this.client = new BdbService.Client(protocol);

    TProtocolVersionTestResult testResult = remoteCall(
            () -> this.client.isProtocolVersionSupported(dbConstants.PROTOCOL_VERSION));
    if (!testResult.isSupported()) {
        throw new BdbConnectionException(
                "Driver is not compatible with the server. The "
                        + "server requires drivers with protocol version: " + testResult.serverProtocolVersion,
                null);
    }
}