Search in sources :

Example 31 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class Sw360ProjectService method createProject.

public Project createProject(Project project, User sw360User) throws TException {
    ProjectService.Iface sw360ProjectClient = getThriftProjectClient();
    AddDocumentRequestSummary documentRequestSummary = sw360ProjectClient.addProject(project, sw360User);
    if (documentRequestSummary.getRequestStatus() == AddDocumentRequestStatus.SUCCESS) {
        project.setId(documentRequestSummary.getId());
        return project;
    } else if (documentRequestSummary.getRequestStatus() == AddDocumentRequestStatus.DUPLICATE) {
        throw new DataIntegrityViolationException("sw360 project with name '" + project.getName() + "' already exists.");
    }
    return null;
}
Also used : AddDocumentRequestSummary(org.eclipse.sw360.datahandler.thrift.AddDocumentRequestSummary) ProjectService(org.eclipse.sw360.datahandler.thrift.projects.ProjectService) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException)

Example 32 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class UserController method getUser.

@RequestMapping(value = USERS_URL + "/{id:.+}", method = RequestMethod.GET)
public ResponseEntity<Resource<User>> getUser(@PathVariable("id") String id) {
    byte[] base64decodedBytes = Base64.getDecoder().decode(id);
    String decodedId;
    try {
        decodedId = new String(base64decodedBytes, "utf-8");
    } catch (UnsupportedEncodingException e) {
        throw (new RuntimeException(e));
    }
    User sw360User = userService.getUserByEmail(decodedId);
    HalResource<User> halResource = createHalUser(sw360User);
    return new ResponseEntity<>(halResource, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) User(org.eclipse.sw360.datahandler.thrift.users.User) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 33 with User

use of org.eclipse.sw360.datahandler.thrift.users.User 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 34 with User

use of org.eclipse.sw360.datahandler.thrift.users.User 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 35 with User

use of org.eclipse.sw360.datahandler.thrift.users.User 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)

Aggregations

User (org.eclipse.sw360.datahandler.thrift.users.User)169 TException (org.apache.thrift.TException)100 Release (org.eclipse.sw360.datahandler.thrift.components.Release)58 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)44 Test (org.junit.Test)30 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)27 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)26 Component (org.eclipse.sw360.datahandler.thrift.components.Component)20 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)20 ResponseEntity (org.springframework.http.ResponseEntity)20 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)19 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)18 IOException (java.io.IOException)17 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)16 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)16 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)13 RequestSummary (org.eclipse.sw360.datahandler.thrift.RequestSummary)12 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)12 Before (org.junit.Before)12 ArrayList (java.util.ArrayList)11