use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class WhenComputeClearingState method the_release_is_sent_for_clearing_to.
public WhenComputeClearingState the_release_is_sent_for_clearing_to(@Quoted String clearingTeam) {
Release release = getFirstRelease();
Map<String, FossologyStatus> clearingTeamToFossologyStatus = release.getClearingTeamToFossologyStatus();
clearingTeamToFossologyStatus.put(clearingTeam, FossologyStatus.SENT);
the_clearing_state_is_computed_for(lastTestedClearingTeam);
return self();
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyAwarePortlet method serveFossologyStatus.
protected void serveFossologyStatus(ResourceRequest request, ResourceResponse response) throws IOException {
DataTablesParameters parameters = DataTablesParser.parametersFrom(request);
Release release = getReleaseForFossologyStatus(request);
Map<String, FossologyStatus> fossologyStatus = getFossologyStatus(release);
JSONObject jsonResponse = JSONFactoryUtil.createJSONObject();
JSONArray data = JSONFactoryUtil.createJSONArray();
for (Map.Entry<String, FossologyStatus> entry : fossologyStatus.entrySet()) {
JSONObject row = JSONFactoryUtil.createJSONObject();
row.put("0", entry.getKey());
row.put("1", ThriftEnumUtils.enumToString(entry.getValue()));
data.put(row);
}
jsonResponse.put("attachment", getFossologyUploadableAttachment(release));
jsonResponse.put("data", data);
jsonResponse.put("draw", parameters.getDraw());
jsonResponse.put("recordsTotal", fossologyStatus.size());
jsonResponse.put("recordsFiltered", fossologyStatus.size());
writeJSON(request, response, jsonResponse);
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyUploaderTest method testGetStatusInFossologyIsConnectionErrorForServerNotAvailable.
@Test
public void testGetStatusInFossologyIsConnectionErrorForServerNotAvailable() throws Exception {
int uploadId = 43;
String clearingTeam = "team d";
doReturn(1).when(sshConnector).runInFossologyViaSsh(anyString(), any(OutputStream.class));
FossologyStatus statusInFossology = fossologyUploader.getStatusInFossology(uploadId, clearingTeam);
assertThat(statusInFossology, is(FossologyStatus.CONNECTION_FAILED));
verify(sshConnector).runInFossologyViaSsh(anyString(), any(OutputStream.class));
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyUploaderFunctionalTest method testRealUpload.
@Ignore
@Test
public void testRealUpload() {
doFirstConnectionAndTrust();
String test = "this is the content\n";
InputStream inputStream = new ByteArrayInputStream(test.getBytes());
final CapturerOutputStream outputStream = new CapturerOutputStream();
final String command = String.format(FossologyUploader.FOSSOLOGY_COMMAND_UPLOAD, "id", GROUP, "project");
final int exitCode = fossologySshConnector.runInFossologyViaSsh(command, inputStream, outputStream);
final long uploadId = FossologyUploader.parseResultUploadId(outputStream.getContent());
System.out.println("uploaded as " + uploadId);
assertThat("Send to fossology failed: " + outputStream.getContent(), exitCode, is(0));
assertThat("bad uploadId received: " + outputStream.getContent(), uploadId, is(greaterThan(0L)));
int i = 0;
while (++i < 60) {
ByteArrayOutputStream osget = new ByteArrayOutputStream();
final String commandGet = String.format(FossologyUploader.FOSSOLOGY_COMMAND_GET_STATUS, uploadId, GROUP);
final int exitCodeGet = fossologySshConnector.runInFossologyViaSsh(commandGet, osget);
if (exitCodeGet != 0) {
fail("check status script is broken");
break;
}
final String outputget = new String(osget.toByteArray());
final FossologyStatus status = fossologyUploader.parseResultStatus(outputget);
System.out.println("status is " + status + ", try changing it from FOSSology");
if (status.equals(FossologyStatus.CLOSED)) {
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
fail("interrupted");
}
}
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyUploader method parseResultStatus.
protected FossologyStatus parseResultStatus(String output) {
final Pattern pattern = Pattern.compile("status=(\\w*)");
final Matcher matcher = pattern.matcher(output);
if (matcher.find()) {
try {
return FossologyStatus.valueOf(matcher.group(1));
} catch (Exception e) {
log.error("fossology output parser caught exception: " + e.getMessage(), e);
}
}
log.error("cannot parse output from fossology check status: '" + output + "'");
return FossologyStatus.CONNECTION_FAILED;
}
Aggregations