Search in sources :

Example 6 with Vendor

use of org.eclipse.sw360.datahandler.thrift.vendors.Vendor in project sw360portal by sw360.

the class Sw360VendorService method deleteVendor.

public void deleteVendor(Vendor vendor, User sw360User) {
    try {
        VendorService.Iface sw360VendorClient = getThriftVendorClient();
        RequestStatus requestStatus = sw360VendorClient.deleteVendor(vendor.getId(), sw360User);
        if (requestStatus == RequestStatus.SUCCESS) {
            return;
        }
        throw new RuntimeException("sw360 vendor with name '" + vendor.getFullname() + " cannot be deleted.");
    } catch (TException e) {
        throw new RuntimeException(e);
    }
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TException(org.apache.thrift.TException) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 7 with Vendor

use of org.eclipse.sw360.datahandler.thrift.vendors.Vendor in project sw360portal by sw360.

the class Sw360VendorService method deleteAllVendors.

public void deleteAllVendors(User sw360User) {
    try {
        VendorService.Iface sw360VendorClient = getThriftVendorClient();
        List<Vendor> vendors = sw360VendorClient.getAllVendors();
        for (Vendor vendor : vendors) {
            sw360VendorClient.deleteVendor(vendor.getId(), sw360User);
        }
    } catch (TException e) {
        throw new RuntimeException(e);
    }
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TException(org.apache.thrift.TException) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor)

Example 8 with Vendor

use of org.eclipse.sw360.datahandler.thrift.vendors.Vendor in project sw360portal by sw360.

the class Sw360VendorService method updateVendor.

public void updateVendor(Vendor vendor, User sw360User) {
    try {
        VendorService.Iface sw360VendorClient = getThriftVendorClient();
        RequestStatus requestStatus = sw360VendorClient.updateVendor(vendor, sw360User);
        if (requestStatus == RequestStatus.SUCCESS) {
            return;
        }
        throw new RuntimeException("sw360 vendor with full name '" + vendor.getFullname() + " cannot be updated.");
    } catch (TException e) {
        throw new RuntimeException(e);
    }
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TException(org.apache.thrift.TException) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 9 with Vendor

use of org.eclipse.sw360.datahandler.thrift.vendors.Vendor in project sw360portal by sw360.

the class VendorResourceProcessor method process.

@Override
public Resource<Vendor> process(Resource<Vendor> resource) {
    Vendor project = resource.getContent();
    Link selfLink = linkTo(VendorController.class).slash("api" + VendorController.VENDORS_URL + "/" + project.getId()).withSelfRel();
    resource.add(selfLink);
    return resource;
}
Also used : Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor) Link(org.springframework.hateoas.Link)

Example 10 with Vendor

use of org.eclipse.sw360.datahandler.thrift.vendors.Vendor in project sw360portal by sw360.

the class BulkReleaseEdit method serveAddVendor.

private void serveAddVendor(ResourceRequest request, ResourceResponse response) throws IOException, PortletException {
    final Vendor vendor = new Vendor();
    ComponentPortletUtils.updateVendorFromRequest(request, vendor);
    try {
        VendorService.Iface client = thriftClients.makeVendorClient();
        String vendorId = client.addVendor(vendor);
        JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
        jsonObject.put("id", vendorId);
        try {
            writeJSON(request, response, jsonObject);
        } catch (IOException e) {
            log.error("Problem rendering VendorId", e);
        }
    } catch (TException e) {
        log.error("Error adding vendor", e);
    }
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TException(org.apache.thrift.TException) JSONObject(com.liferay.portal.kernel.json.JSONObject) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor) IOException(java.io.IOException)

Aggregations

Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)37 TException (org.apache.thrift.TException)14 VendorService (org.eclipse.sw360.datahandler.thrift.vendors.VendorService)12 Release (org.eclipse.sw360.datahandler.thrift.components.Release)8 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)5 User (org.eclipse.sw360.datahandler.thrift.users.User)5 DatabaseConnector (org.eclipse.sw360.datahandler.couchdb.DatabaseConnector)4 Before (org.junit.Before)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 Component (org.eclipse.sw360.datahandler.thrift.components.Component)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 JSONObject (com.liferay.portal.kernel.json.JSONObject)2 URI (java.net.URI)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 Collectors (java.util.stream.Collectors)2 ComponentDatabaseHandler (org.eclipse.sw360.datahandler.db.ComponentDatabaseHandler)2 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)2 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)2