use of org.eclipse.sw360.datahandler.thrift.SW360Exception in project sw360portal by sw360.
the class LicenseDatabaseHandler method getLicenseForOrganisationWithOwnModerationRequests.
public License getLicenseForOrganisationWithOwnModerationRequests(String id, String organisation, User user) throws SW360Exception {
List<ModerationRequest> moderationRequestsForDocumentId = moderator.getModerationRequestsForDocumentId(id);
License license = getLicenseForOrganisation(id, organisation);
DocumentState documentState;
if (moderationRequestsForDocumentId.isEmpty()) {
documentState = CommonUtils.getOriginalDocumentState();
} else {
final String email = user.getEmail();
Optional<ModerationRequest> moderationRequestOptional = CommonUtils.getFirstModerationRequestOfUser(moderationRequestsForDocumentId, email);
if (moderationRequestOptional.isPresent() && isInProgressOrPending(moderationRequestOptional.get())) {
ModerationRequest moderationRequest = moderationRequestOptional.get();
license = moderator.updateLicenseFromModerationRequest(license, moderationRequest.getLicenseAdditions(), moderationRequest.getLicenseDeletions(), organisation);
for (Todo todo : license.getTodos()) {
// remove other organisations from whitelist of todo
todo.setWhitelist(SW360Utils.filterBUSet(organisation, todo.whitelist));
}
documentState = CommonUtils.getModeratedDocumentState(moderationRequest);
} else {
documentState = new DocumentState().setIsOriginalDocument(true).setModerationState(moderationRequestsForDocumentId.get(0).getModerationState());
}
}
license.setPermissions(makePermission(license, user).getPermissionMap());
license.setDocumentState(documentState);
return license;
}
use of org.eclipse.sw360.datahandler.thrift.SW360Exception in project sw360portal by sw360.
the class CombinedCLIParser method getLicenseInfos.
@Override
public <T> List<LicenseInfoParsingResult> getLicenseInfos(Attachment attachment, User user, T context) throws TException {
AttachmentContent attachmentContent = attachmentContentProvider.getAttachmentContent(attachment);
InputStream attachmentStream = null;
List<LicenseInfoParsingResult> parsingResults = new ArrayList<>();
Map<String, Release> releasesByExternalId = prepareReleasesByExternalId(getCorrelationKey());
try {
attachmentStream = attachmentConnector.getAttachmentStream(attachmentContent, user, context);
Document doc = getDocument(attachmentStream);
Map<String, Set<String>> copyrightSetsByExternalId = getCopyrightSetsByExternalIdsMap(doc);
Map<String, Set<LicenseNameWithText>> licenseNamesWithTextsByExternalId = getLicenseNamesWithTextsByExternalIdsMap(doc);
Set<String> allExternalIds = Sets.union(copyrightSetsByExternalId.keySet(), licenseNamesWithTextsByExternalId.keySet());
allExternalIds.forEach(extId -> {
LicenseInfoParsingResult parsingResult = getLicenseInfoParsingResultForExternalId(attachmentContent, releasesByExternalId, copyrightSetsByExternalId, licenseNamesWithTextsByExternalId, extId);
parsingResults.add(parsingResult);
});
} catch (ParserConfigurationException | IOException | XPathExpressionException | SAXException | SW360Exception e) {
log.error(e);
parsingResults.add(new LicenseInfoParsingResult().setStatus(LicenseInfoRequestStatus.FAILURE).setMessage("Error while parsing combined CLI file: " + e.toString()));
} finally {
closeQuietly(attachmentStream, log);
}
return parsingResults;
}
use of org.eclipse.sw360.datahandler.thrift.SW360Exception in project sw360portal by sw360.
the class FossologySshConnector method runInFossologyViaSsh.
public int runInFossologyViaSsh(String command, InputStream stdin, OutputStream stdout) {
ChannelExec channel = null;
Session session = null;
int exitCode = -1;
try {
session = jSchSessionProvider.getSession(connectionTimeout);
channel = (ChannelExec) session.openChannel("exec");
channel.setOutputStream(stdout);
channel.setInputStream(stdin);
channel.setCommand(command);
channel.connect(connectionTimeout);
waitCompletion(channel, executionTimeout);
channel.disconnect();
exitCode = channel.getExitStatus();
} catch (JSchException | SW360Exception | NullPointerException | ClassCastException e) {
log.error("error executing remote command on Fossology Server " + jSchSessionProvider.getServerString(), e);
} finally {
if (channel != null && channel.isConnected()) {
channel.disconnect();
}
jSchSessionProvider.closeSession(session);
}
return exitCode;
}
use of org.eclipse.sw360.datahandler.thrift.SW360Exception in project sw360portal by sw360.
the class FossologyFileHandler method fillAttachment.
protected FilledAttachment fillAttachment(Attachment attachment) throws SW360Exception {
String attachmentContentId = attachment.getAttachmentContentId();
try {
AttachmentContent attachmentContent = attachmentConnector.getAttachmentContent(attachmentContentId);
assertNotNull(attachmentContent);
return new FilledAttachment().setAttachment(attachment).setAttachmentContent(attachmentContent);
} catch (SW360Exception e) {
log.error("cannot retrieve attachment " + attachmentContentId, e);
throw e;
}
}
use of org.eclipse.sw360.datahandler.thrift.SW360Exception in project sw360portal by sw360.
the class ProjectHelper method makeRowsWithReleases.
private SubTable makeRowsWithReleases(Project project) throws SW360Exception {
List<Release> releases = getReleases(project);
SubTable table = new SubTable();
if (releases.size() > 0) {
for (Release release : releases) {
List<String> currentRow = makeRowForProject(project);
currentRow.addAll(releaseHelper.makeRows(release).elements.get(0));
table.addRow(currentRow);
}
} else {
List<String> projectRowWithEmptyReleaseFields = makeRowForProject(project);
for (int i = 0; i < releaseHelper.getColumns(); i++) {
projectRowWithEmptyReleaseFields.add("");
}
table.addRow(projectRowWithEmptyReleaseFields);
}
return table;
}
Aggregations