use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentPortlet method prepareReleaseDuplicate.
private void prepareReleaseDuplicate(RenderRequest request, RenderResponse response) throws PortletException {
String id = request.getParameter(COMPONENT_ID);
String releaseId = request.getParameter(RELEASE_ID);
request.setAttribute(DOCUMENT_TYPE, SW360Constants.TYPE_RELEASE);
final User user = UserCacheHolder.getUserFromRequest(request);
if (isNullOrEmpty(releaseId)) {
throw new PortletException("Release ID not set!");
}
try {
ComponentService.Iface client = thriftClients.makeComponentClient();
String emailFromRequest = LifeRayUserSession.getEmailFromRequest(request);
Release release = PortletUtils.cloneRelease(emailFromRequest, client.getReleaseById(releaseId, user));
if (isNullOrEmpty(id)) {
id = release.getComponentId();
}
Component component = client.getComponentById(id, user);
addComponentBreadcrumb(request, response, component);
request.setAttribute(COMPONENT, component);
request.setAttribute(RELEASE_LIST, Collections.emptyList());
setUsingDocs(request, null, user, client);
request.setAttribute(RELEASE, release);
request.setAttribute(PortalConstants.ATTACHMENTS, Collections.emptySet());
} catch (TException e) {
log.error("Error fetching release from backend!", e);
}
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentPortlet method updateVulnerabilitiesComponent.
private void updateVulnerabilitiesComponent(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
String componentId = request.getParameter(PortalConstants.COMPONENT_ID);
CveSearchService.Iface cveClient = thriftClients.makeCvesearchClient();
try {
VulnerabilityUpdateStatus importStatus = cveClient.updateForComponent(componentId);
JSONObject responseData = PortletUtils.importStatusToJSON(importStatus);
PrintWriter writer = response.getWriter();
writer.write(responseData.toString());
} catch (TException e) {
log.error("Error updating CVEs for component in backend.", e);
}
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentPortletUtils method unsubscribeComponent.
public static RequestStatus unsubscribeComponent(ResourceRequest request, Logger log) {
String id = request.getParameter(PortalConstants.COMPONENT_ID);
if (id != null) {
try {
ComponentService.Iface client = new ThriftClients().makeComponentClient();
User user = UserCacheHolder.getUserFromRequest(request);
return client.unsubscribeComponent(id, user);
} catch (TException e) {
log.error("Could not unsubscribe to component", e);
}
}
return RequestStatus.FAILURE;
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentPortletUtils method subscribeComponent.
public static RequestStatus subscribeComponent(ResourceRequest request, Logger log) {
String id = request.getParameter(PortalConstants.COMPONENT_ID);
if (id != null) {
try {
ComponentService.Iface client = new ThriftClients().makeComponentClient();
User user = UserCacheHolder.getUserFromRequest(request);
return client.subscribeComponent(id, user);
} catch (TException e) {
log.error("Could not subscribe to component", e);
}
}
return RequestStatus.FAILURE;
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class MyComponentsPortlet method doView.
@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
List<Component> components;
try {
final User user = UserCacheHolder.getUserFromRequest(request);
components = thriftClients.makeComponentClient().getMyComponents(user);
} catch (TException e) {
log.error("Could not fetch your components from backend", e);
components = new ArrayList<>();
}
request.setAttribute("components", CommonUtils.nullToEmptyList(components));
super.doView(request, response);
}
Aggregations