Search in sources :

Example 21 with HalResource

use of org.eclipse.sw360.rest.resourceserver.core.HalResource in project sw360portal by sw360.

the class RestControllerHelper method addEmbeddedAttachments.

private void addEmbeddedAttachments(HalResource halResource, Set<Attachment> attachments) {
    for (Attachment attachment : attachments) {
        Attachment embeddedAttachment = convertToEmbeddedAttachment(attachment);
        HalResource<Attachment> halAttachmentResource = new HalResource<>(embeddedAttachment);
        Link attachmentLink = linkTo(AttachmentController.class).slash("api/attachments/" + attachment.getAttachmentContentId()).withSelfRel();
        halAttachmentResource.add(attachmentLink);
        halResource.addEmbeddedResource("sw360:attachments", halAttachmentResource);
    }
}
Also used : Attachment(org.eclipse.sw360.datahandler.thrift.attachments.Attachment) Link(org.springframework.hateoas.Link)

Example 22 with HalResource

use of org.eclipse.sw360.rest.resourceserver.core.HalResource in project sw360portal by sw360.

the class RestControllerHelper method addEmbeddedReleases.

public void addEmbeddedReleases(HalResource halResource, Set<String> releases, Sw360ReleaseService sw360ReleaseService, User user) throws TException {
    for (String releaseId : releases) {
        final Release release = sw360ReleaseService.getReleaseForUserById(releaseId, user);
        addEmbeddedRelease(halResource, release);
    }
}
Also used : Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 23 with HalResource

use of org.eclipse.sw360.rest.resourceserver.core.HalResource in project sw360portal by sw360.

the class RestControllerHelper method addEmbeddedModerators.

public void addEmbeddedModerators(HalResource halResource, Set<String> moderators) {
    for (String moderatorEmail : moderators) {
        User user = new User();
        user.setEmail(moderatorEmail);
        addEmbeddedUser(halResource, user, "sw360:moderators");
    }
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 24 with HalResource

use of org.eclipse.sw360.rest.resourceserver.core.HalResource in project sw360portal by sw360.

the class RestControllerHelper method addEmbeddedRelease.

public void addEmbeddedRelease(HalResource halResource, Release release) {
    Release embeddedRelease = convertToEmbeddedRelease(release);
    HalResource<Release> halRelease = new HalResource<>(embeddedRelease);
    Link releaseLink = linkTo(ReleaseController.class).slash("api/releases/" + release.getId()).withSelfRel();
    halRelease.add(releaseLink);
    halResource.addEmbeddedResource("sw360:releases", halRelease);
}
Also used : Release(org.eclipse.sw360.datahandler.thrift.components.Release) Link(org.springframework.hateoas.Link)

Example 25 with HalResource

use of org.eclipse.sw360.rest.resourceserver.core.HalResource in project sw360portal by sw360.

the class RestControllerHelper method addEmbeddedProject.

public void addEmbeddedProject(HalResource<Project> halProject, Set<String> projectIds, Sw360ProjectService sw360ProjectService, User user) throws TException {
    for (String projectId : projectIds) {
        final Project project = sw360ProjectService.getProjectForUserById(projectId, user);
        addEmbeddedProject(halProject, project);
    }
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project)

Aggregations

User (org.eclipse.sw360.datahandler.thrift.users.User)16 ResponseEntity (org.springframework.http.ResponseEntity)12 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)8 Link (org.springframework.hateoas.Link)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 Release (org.eclipse.sw360.datahandler.thrift.components.Release)6 URI (java.net.URI)5 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)5 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)5 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)5 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)4 IOException (java.io.IOException)3 TException (org.apache.thrift.TException)3 Component (org.eclipse.sw360.datahandler.thrift.components.Component)3 License (org.eclipse.sw360.datahandler.thrift.licenses.License)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ProjectReleaseRelationship (org.eclipse.sw360.datahandler.thrift.ProjectReleaseRelationship)1 Vulnerability (org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability)1 Resource (org.springframework.hateoas.Resource)1