use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class FossologyFileHandler method sendToFossology.
public RequestStatus sendToFossology(String releaseId, User user, String clearingTeam) throws TException {
Release release;
final ComponentService.Iface componentClient = thriftClients.makeComponentClient();
release = getReleaseAndUnlockIt(releaseId, user, componentClient);
Set<Attachment> sourceAttachments = getSourceAttachment(releaseId, user, componentClient);
if (sourceAttachments.size() != 1) {
log.error("release " + releaseId + " does not have a single source attachment");
// TODO return a summary and better fitting status
return RequestStatus.FAILURE;
}
final Attachment attachment = getFirst(sourceAttachments);
final FilledAttachment filledAttachment = fillAttachment(attachment);
if (!release.isSetFossologyId()) {
/* send the attachment as a new upload */
AttachmentContent attachmentContent = filledAttachment.getAttachmentContent();
return sendToFossologyNewUpload(release, user, clearingTeam, attachmentContent, componentClient);
} else {
if (!checkSourceAttachment(release, filledAttachment)) {
// TODO summary
return RequestStatus.FAILURE;
} else {
/* duplicate the old upload making it visible for clearingTeam */
return sendToFossologyExistingUpload(release, user, clearingTeam, componentClient);
}
}
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class TestComponentClient method main.
public static void main(String[] args) throws TException, IOException {
THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/components/thrift");
TProtocol protocol = new TCompactProtocol(thriftClient);
ComponentService.Iface client = new ComponentService.Client(protocol);
// List<Component> components = client.getComponentSummary(user);
// List<Component> recentComponents = client.getRecentComponents();
// List<Release> releases = client.getReleaseSummary(user);
//
// System.out.println("Fetched " + components.size() + " components from license service");
// System.out.println("Fetched " + releases.size() + " releases from license service");
// System.out.println("Fetched " + recentComponents.size() + " recent components from license service");
//
// String referenceId =null;
// for (Component component : recentComponents) {
// if(referenceId==null) referenceId=component.getId();
// System.out.println(component.getId() + ": " + component.getName());
// }
//
// if(referenceId!=null) {
// System.out.println(client.getComponentById(referenceId, user).toString());
// Component component = new ComponentHandler("http://localhost:5984", "sw360db", "sw360attachments").getComponentById(referenceId, user);
// System.out.println(component.toString());
// System.out.println(client.getComponentById(referenceId, user).toString());
// }
//
// for(Release release : releases) {
// System.out.println(release.toString());
// }
// // This fails with a thrift error... debug!
// if(releases.size()>0) {
// String releaseNameStart = releases.get(0).getName().substring(0,1);
// System.out.println("The following releases start with " + releaseNameStart );
//
// List<Release> releases1 = client.searchReleaseByName(releaseNameStart);
// for(Release release : releases1) {
// System.out.println(release.toString());
// }
//
// }
// final Component cpe = client.getComponentForReportFromCPEId("cpe");
// System.out.println(cpe.toString());
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class SearchLevels method guessForRelease.
private List<NeedleWithMeta> guessForRelease(CveSearchGuesser cveSearchGuesser, Release release, boolean useVersionInformation) throws IOException {
if (useVersionInformation && !release.isSetVersion()) {
return Collections.emptyList();
}
List<Match> vendorProductList;
String productHaystack = release.getName();
if (release.isSetVendor() && (release.getVendor().isSetShortname() || release.getVendor().isSetFullname())) {
String vendorHaystack = nullToEmptyString(release.getVendor().getShortname()) + " " + nullToEmptyString(release.getVendor().getFullname());
vendorProductList = cveSearchGuesser.guessVendorAndProducts(vendorHaystack, productHaystack);
} else {
vendorProductList = cveSearchGuesser.guessVendorAndProducts(productHaystack);
}
String cpeNeedlePostfix = ":" + (useVersionInformation ? release.getVersion() : "") + CPE_WILDCARD;
Function<String, String> cpeBuilder = cpeNeedle -> CPE_NEEDLE_PREFIX + cpeNeedle + cpeNeedlePostfix;
return vendorProductList.stream().map(match -> new NeedleWithMeta(cpeBuilder.apply(match.getNeedle()), "heuristic (dist. " + (useVersionInformation ? "0" : "1") + match.getDistance() + ")")).collect(Collectors.toList());
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ReleaseLinkCSVRecordBuilderTest method testFillRelease.
@Test
public void testFillRelease() throws Exception {
final String releaseName = "myRelease";
final String releaseVersion = "1.862b";
final Release release = new Release();
release.setName(releaseName).setVersion(releaseVersion);
final ReleaseLinkCSVRecordBuilder releaseLinkCSVRecordBuilder = new ReleaseLinkCSVRecordBuilder();
releaseLinkCSVRecordBuilder.fill(release);
final ReleaseLinkCSVRecord filledRecord = releaseLinkCSVRecordBuilder.build();
assertThat(filledRecord.getReleaseIdentifier(), is(SW360Utils.getVersionedName(releaseName, releaseVersion)));
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ReleaseLinkCSVRecordBuilderTest method testFillLinkedRelease.
@Test
public void testFillLinkedRelease() throws Exception {
final String releaseName = "myRelease";
final String releaseVersion = "1.862b";
final Release release = new Release();
release.setName(releaseName).setVersion(releaseVersion);
final ReleaseLinkCSVRecordBuilder releaseLinkCSVRecordBuilder = new ReleaseLinkCSVRecordBuilder();
releaseLinkCSVRecordBuilder.fillLinking(release);
final ReleaseLinkCSVRecord filledRecord = releaseLinkCSVRecordBuilder.build();
assertThat(filledRecord.getLinkedReleaseIdentifier(), is(SW360Utils.getVersionedName(releaseName, releaseVersion)));
}
Aggregations