use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectDatabaseHandler method updateProjectFromAdditionsAndDeletions.
public RequestStatus updateProjectFromAdditionsAndDeletions(Project projectAdditions, Project projectDeletions, User user) {
try {
Project project = getProjectById(projectAdditions.getId(), user);
project = moderator.updateProjectFromModerationRequest(project, projectAdditions, projectDeletions);
return updateProject(project, user);
} catch (SW360Exception e) {
log.error("Could not get original project when updating from moderation request.");
return RequestStatus.FAILURE;
}
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectImportPortlet method doView.
@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
List<Project> importables = new ArrayList<>();
Boolean loggedIn = false;
String loggedInServer = "";
RemoteCredentials reCred = getRemoteCredentialsFromSession(request.getPortletSession());
String projectName = request.getParameter(ProjectImportConstants.PROJECT_NAME);
if (!nullToEmpty(reCred.getServerUrl()).isEmpty()) {
importables = loadImportables(reCred, projectName);
loggedIn = true;
loggedInServer = reCred.getServerUrl();
}
String idName = getIdName();
request.setAttribute("idName", idName);
request.setAttribute("importables", importables);
request.setAttribute("loggedIn", loggedIn);
request.setAttribute("loggedInServer", loggedInServer);
super.doView(request, response);
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectPortlet method prepareSourceCodeBundle.
private void prepareSourceCodeBundle(RenderRequest request, RenderResponse response) throws IOException, PortletException {
User user = UserCacheHolder.getUserFromRequest(request);
String id = request.getParameter(PROJECT_ID);
request.setAttribute(PortalConstants.SW360_USER, user);
request.setAttribute(DOCUMENT_TYPE, SW360Constants.TYPE_PROJECT);
request.setAttribute(PROJECT_LINK_TABLE_MODE, PROJECT_LINK_TABLE_MODE_SOURCE_BUNDLE);
if (id != null) {
try {
ProjectService.Iface client = thriftClients.makeProjectClient();
Project project = client.getProjectById(id, user);
request.setAttribute(PROJECT, project);
request.setAttribute(DOCUMENT_ID, id);
List<ProjectLink> mappedProjectLinks = createLinkedProjects(project, filterAndSortAttachments(SW360Constants.SOURCE_CODE_ATTACHMENT_TYPES), true, user);
request.setAttribute(PROJECT_LIST, mappedProjectLinks);
addProjectBreadcrumb(request, response, project);
} catch (TException e) {
log.error("Error fetching project from backend!", e);
setSW360SessionError(request, ErrorMessages.ERROR_GETTING_PROJECT);
}
}
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectPortlet method updateVulnerabilitiesProject.
private void updateVulnerabilitiesProject(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
String projectId = request.getParameter(PortalConstants.PROJECT_ID);
CveSearchService.Iface cveClient = thriftClients.makeCvesearchClient();
try {
VulnerabilityUpdateStatus importStatus = cveClient.updateForProject(projectId);
JSONObject responseData = PortletUtils.importStatusToJSON(importStatus);
PrintWriter writer = response.getWriter();
writer.write(responseData.toString());
} catch (TException e) {
log.error("Error updating CVEs for project in backend.", e);
}
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectPortlet method exportReleasesSpreadsheet.
private void exportReleasesSpreadsheet(ResourceRequest request, ResourceResponse response) {
final User user = UserCacheHolder.getUserFromRequest(request);
try {
String id = request.getParameter(PROJECT_ID);
ProjectService.Iface client = thriftClients.makeProjectClient();
Project project = null;
if (!isNullOrEmpty(id)) {
project = client.getProjectById(id, user);
}
if (project != null) {
List<ReleaseClearingStatusData> releaseStringMap = client.getReleaseClearingStatuses(id, user);
List<Release> releases = releaseStringMap.stream().map(ReleaseClearingStatusData::getRelease).sorted(Comparator.comparing(SW360Utils::printFullname)).collect(Collectors.toList());
ReleaseExporter exporter = new ReleaseExporter(thriftClients.makeComponentClient(), releases, user, releaseStringMap);
PortletResponseUtil.sendFile(request, response, String.format("releases-%s-%s-%s.xlsx", project.getName(), project.getVersion(), SW360Utils.getCreatedOn()), exporter.makeExcelExport(releases), CONTENT_TYPE_OPENXML_SPREADSHEET);
}
} catch (IOException | TException e) {
log.error("An error occurred while generating the Excel export", e);
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
}
}
Aggregations