Search in sources :

Example 36 with User

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

the class WhenComputePermissions method the_highest_allowed_action_is_computed_for_user_$_with_user_group_$_and_department_$.

public WhenComputePermissions the_highest_allowed_action_is_computed_for_user_$_with_user_group_$_and_department_$(@Quoted String userEmail, @TEnumToString UserGroup userGroup, @Quoted String userDept) {
    final User user = new User(DUMMY_ID, userEmail, userDept).setUserGroup(userGroup);
    final DocumentPermissions<Project> projectDocumentPermissions = PermissionUtils.makePermission(project, user);
    allowedActions = projectDocumentPermissions.getAllAllowedActions();
    return self();
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 37 with User

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

the class TestServiceHandler method test.

@Override
public TestObject test(TestObject user) throws TException {
    TestObject copy = new TestObject(user);
    copy.setText(testText);
    return copy;
}
Also used : TestObject(org.eclipse.sw360.testthrift.TestObject)

Example 38 with User

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

the class Sw360AttachmentService method getAttachmentByIdForUser.

public AttachmentInfo getAttachmentByIdForUser(String id, User sw360User) throws TException {
    ComponentService.Iface sw360ComponentClient = getThriftComponentClient();
    List<Release> releases = sw360ComponentClient.getReleaseSummary(sw360User);
    for (Release release : releases) {
        final Set<Attachment> attachments = release.getAttachments();
        if (attachments != null && attachments.size() > 0) {
            for (Attachment attachment : attachments) {
                if (id.equals(attachment.getAttachmentContentId())) {
                    return new AttachmentInfo(attachment, release);
                }
            }
        }
    }
    return null;
}
Also used : ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 39 with User

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

the class AttachmentSpecTest method before.

@Before
public void before() throws TException {
    List<Attachment> attachmentList = new ArrayList<>();
    attachment = new Attachment();
    attachment.setAttachmentContentId("76537653");
    attachment.setFilename("spring-core-4.3.4.RELEASE.jar");
    attachment.setSha1("da373e491d3863477568896089ee9457bc316783");
    attachment.setAttachmentType(AttachmentType.BINARY_SELF);
    attachment.setCreatedTeam("Clearing Team 1");
    attachment.setCreatedComment("please check before Christmas :)");
    attachment.setCreatedOn("2016-12-18");
    attachment.setCreatedBy("admin@sw360.org");
    attachment.setCheckedTeam("Clearing Team 2");
    attachment.setCheckedComment("everything looks good");
    attachment.setCheckedOn("2016-12-18");
    attachment.setCheckStatus(CheckStatus.ACCEPTED);
    attachmentList.add(attachment);
    Release release = new Release();
    release.setId("874687");
    release.setName("Spring Core 4.3.4");
    release.setCpeid("cpe:/a:pivotal:spring-core:4.3.4:");
    release.setReleaseDate("2016-12-07");
    release.setVersion("4.3.4");
    release.setCreatedOn("2016-12-18");
    release.setCreatedBy("admin@sw360.org");
    release.setModerators(new HashSet<>(Arrays.asList(testUserId, testUserPassword)));
    release.setComponentId("678dstzd8");
    release.setClearingState(ClearingState.APPROVED);
    AttachmentInfo attachmentInfo = new AttachmentInfo(attachment, release);
    given(this.attachmentServiceMock.getAttachmentByIdForUser(eq(attachment.getAttachmentContentId()), anyObject())).willReturn(attachmentInfo);
    User user = new User();
    user.setId("admin@sw360.org");
    user.setEmail("admin@sw360.org");
    user.setFullname("John Doe");
    given(this.userServiceMock.getUserByEmail("admin@sw360.org")).willReturn(user);
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) ArrayList(java.util.ArrayList) AttachmentInfo(org.eclipse.sw360.rest.resourceserver.attachment.AttachmentInfo) Attachment(org.eclipse.sw360.datahandler.thrift.attachments.Attachment) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Before(org.junit.Before)

Example 40 with User

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

the class TestUtils method getAdminUser.

public static User getAdminUser(Class caller) {
    User user = failingMock(User.class);
    doReturn(true).when(user).isSetUserGroup();
    doReturn(UserGroup.ADMIN).when(user).getUserGroup();
    doReturn(true).when(user).isSetEmail();
    doReturn(caller.getSimpleName() + "@tngtech.com").when(user).getEmail();
    doReturn(true).when(user).isSetDepartment();
    doReturn(caller.getPackage().getName()).when(user).getDepartment();
    return user;
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User)

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