use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectPortlet method getSourceCodeBundleName.
private String getSourceCodeBundleName(ResourceRequest request) throws TException {
User user = UserCacheHolder.getUserFromRequest(request);
ProjectService.Iface projectClient = thriftClients.makeProjectClient();
String projectId = request.getParameter(PROJECT_ID);
Project project = projectClient.getProjectById(projectId, user);
String timestamp = SW360Utils.getCreatedOn();
return "SourceCodeBundle-" + project.getName() + "-" + timestamp + ".zip";
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class FossologyAwarePortlet method serveProjectSendToFossology.
protected void serveProjectSendToFossology(ResourceRequest request, ResourceResponse response) {
String projectId = request.getParameter(PROJECT_ID);
String[] releaseIdArray = request.getParameterValues(RELEASE_ID);
if (projectId == null || releaseIdArray == null) {
renderRequestStatus(request, response, RequestStatus.FAILURE);
return;
}
String clearingTeam = request.getParameter(CLEARING_TEAM);
if (isNullOrEmpty(clearingTeam)) {
try {
User user = UserCacheHolder.getUserFromRequest(request);
ProjectService.Iface client = thriftClients.makeProjectClient();
Project project = client.getProjectById(projectId, user);
clearingTeam = project.getClearingTeam();
} catch (TException e) {
renderRequestStatus(request, response, RequestStatus.FAILURE);
log.error("Problem with project client", e);
}
}
if (!isNullOrEmpty(clearingTeam) && !CLEARING_TEAM_UNKNOWN.equals(clearingTeam)) {
List<String> releaseIds = Arrays.asList(releaseIdArray);
try {
FossologyService.Iface fossologyClient = thriftClients.makeFossologyClient();
renderRequestStatus(request, response, fossologyClient.sendReleasesToFossology(releaseIds, UserCacheHolder.getUserFromRequest(request), clearingTeam));
} catch (TException e) {
renderRequestStatus(request, response, RequestStatus.FAILURE);
log.error("Problem with fossology client", e);
}
} else {
renderRequestStatus(request, response, RequestStatus.FAILURE);
log.error("Cannot decide on a clearing team for project " + projectId);
}
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class RemoteAttachmentDownloaderTest method testWithBrokenURL.
@Test
public void testWithBrokenURL() throws Exception {
AttachmentContent attachmentContent = saveRemoteAttachment(TestUtils.BLACK_HOLE_ADDRESS);
AttachmentContent attachmentGood = saveRemoteAttachment(url);
assertThat(repository.getOnlyRemoteAttachments(), hasSize(2));
assertThat(retrieveRemoteAttachments(DatabaseSettings.getConfiguredHttpClient(), dbName, downloadTimeout), is(1));
assertThat(repository.getOnlyRemoteAttachments(), hasSize(1));
assertThat(attachmentConnector.getAttachmentStream(attachmentGood, dummyUser, new Project().setVisbility(Visibility.ME_AND_MODERATORS).setCreatedBy(dummyUser.getEmail()).setAttachments(Collections.singleton(new Attachment().setAttachmentContentId(attachmentGood.getId())))), hasLength(greaterThan(0l)));
assertThat(repository.getOnlyRemoteAttachments(), hasSize(1));
assertThat(retrieveRemoteAttachments(DatabaseSettings.getConfiguredHttpClient(), dbName, downloadTimeout), is(0));
assertThat(repository.getOnlyRemoteAttachments(), hasSize(1));
try {
assertThat(attachmentConnector.getAttachmentStream(attachmentContent, dummyUser, new Project().setVisbility(Visibility.ME_AND_MODERATORS).setCreatedBy(dummyUser.getEmail()).setAttachments(Collections.singleton(new Attachment().setAttachmentContentId(attachmentContent.getId())))), hasLength(greaterThan(0l)));
fail("expected exception not thrown");
} catch (SW360Exception e) {
assertThat(e.getWhy(), containsString(attachmentContent.getId()));
}
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class RemoteAttachmentDownloaderTest method testIntegration.
@Test
public void testIntegration() throws Exception {
AttachmentContent attachmentContent = saveRemoteAttachment(url);
assertThat(retrieveRemoteAttachments(DatabaseSettings.getConfiguredHttpClient(), dbName, downloadTimeout), is(1));
assertThat(attachmentConnector.getAttachmentStream(attachmentContent, dummyUser, new Project().setVisbility(Visibility.ME_AND_MODERATORS).setCreatedBy(dummyUser.getEmail()).setAttachments(Collections.singleton(new Attachment().setAttachmentContentId(attachmentContent.getId())))), hasLength(greaterThan(0l)));
assertThat(retrieveRemoteAttachments(DatabaseSettings.getConfiguredHttpClient(), dbName, downloadTimeout), is(0));
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class CombinedCLIParserTest method testIsApplicableToFailsOnIncorrectRootElement.
@Test
public void testIsApplicableToFailsOnIncorrectRootElement() throws Exception {
AttachmentContent content = new AttachmentContent().setId("A1").setFilename("a.xml").setContentType("application/xml");
when(connector.getAttachmentStream(content, new User(), new Project())).thenReturn(new ReaderInputStream(new StringReader("<wrong-root/>")));
assertFalse(parser.isApplicableTo(attachment, new User(), new Project()));
}
Aggregations