use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class LicensesPortlet method delete.
@UsedAsLiferayAction
public void delete(ActionRequest request, ActionResponse response) throws PortletException, IOException {
RequestStatus requestStatus = deleteLicense(request);
setSessionMessage(request, requestStatus, "License", "remove");
}
use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class LicensesPortlet method update.
@UsedAsLiferayAction
public void update(ActionRequest request, ActionResponse response) throws PortletException, IOException {
LicenseService.Iface client = thriftClients.makeLicenseClient();
String licenseId = request.getParameter(LICENSE_ID);
User user = UserCacheHolder.getUserFromRequest(request);
License license = prepareLicenseForUpdate(request, client, licenseId, user);
boolean isNewLicense = isNullOrEmpty(licenseId);
boolean isAttemptToOverwriteExistingByNew = isAttemptToOverwriteExistingByNew(license, user, isNewLicense, client);
RequestStatus requestStatus = updateLicense(license, user, isAttemptToOverwriteExistingByNew, client);
if (isAttemptToOverwriteExistingByNew) {
response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
setSW360SessionError(request, ErrorMessages.LICENSE_SHORTNAME_TAKEN);
request.setAttribute(KEY_LICENSE_DETAIL, license);
} else if (isNewLicense) {
response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
setSessionMessage(request, requestStatus, "License", "adde");
} else {
response.setRenderParameter(LICENSE_ID, licenseId);
response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
response.setRenderParameter(SELECTED_TAB, "Details");
setSessionMessage(request, requestStatus, "License", "update");
}
}
use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class ComponentUploadPortlet method updateComponentAttachments.
@UsedAsLiferayAction
public void updateComponentAttachments(ActionRequest request, ActionResponse response) throws PortletException, IOException, TException {
List<CSVRecord> attachmentRecords = getCSVFromRequest(request, "file");
FluentIterable<ComponentAttachmentCSVRecord> compCSVRecords = convertCSVRecordsToComponentAttachmentCSVRecords(attachmentRecords);
log.trace("read records <" + Joiner.on("\n").join(compCSVRecords) + ">");
final ComponentService.Iface componentClient = thriftClients.makeComponentClient();
final AttachmentService.Iface attachmentClient = thriftClients.makeAttachmentClient();
User user = UserCacheHolder.getUserFromRequest(request);
final RequestSummary requestSummary = writeAttachmentsToDatabase(compCSVRecords, user, componentClient, attachmentClient);
renderRequestSummary(request, response, requestSummary);
}
use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class FossologyAdminPortlet method setFingerPrints.
@UsedAsLiferayAction
public void setFingerPrints(ActionRequest request, ActionResponse response) throws PortletException, IOException {
List<FossologyHostFingerPrint> fingerPrints;
FossologyService.Iface client;
try {
client = thriftClients.makeFossologyClient();
fingerPrints = client.getFingerPrints();
} catch (TException e) {
log.error("Error retrieving fingerprints when setting", e);
return;
}
for (FossologyHostFingerPrint fingerPrint : fingerPrints) {
String bool = request.getParameter(fingerPrint.fingerPrint);
fingerPrint.trusted = "on".equals(bool);
}
try {
client.setFingerPrints(fingerPrints);
} catch (TException e) {
log.error("Problems setting finger prints", e);
}
}
use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class ComponentPortlet method updateComponent.
// ! Actions
@UsedAsLiferayAction
public void updateComponent(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String id = request.getParameter(COMPONENT_ID);
final User user = UserCacheHolder.getUserFromRequest(request);
try {
ComponentService.Iface client = thriftClients.makeComponentClient();
if (id != null) {
Component component = client.getComponentByIdForEdit(id, user);
ComponentPortletUtils.updateComponentFromRequest(request, component);
String ModerationRequestCommentMsg = request.getParameter(MODERATION_REQUEST_COMMENT);
user.setCommentMadeDuringModerationRequest(ModerationRequestCommentMsg);
RequestStatus requestStatus = client.updateComponent(component, user);
setSessionMessage(request, requestStatus, "Component", "update", component.getName());
cleanUploadHistory(user.getEmail(), id);
response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
response.setRenderParameter(COMPONENT_ID, request.getParameter(COMPONENT_ID));
} else {
Component component = new Component();
ComponentPortletUtils.updateComponentFromRequest(request, component);
AddDocumentRequestSummary summary = client.addComponent(component, user);
AddDocumentRequestStatus status = summary.getRequestStatus();
switch(status) {
case SUCCESS:
String successMsg = "Component " + component.getName() + " added successfully";
SessionMessages.add(request, "request_processed", successMsg);
response.setRenderParameter(COMPONENT_ID, summary.getId());
response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
break;
case DUPLICATE:
setSW360SessionError(request, ErrorMessages.COMPONENT_DUPLICATE);
response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
prepareRequestForEditAfterDuplicateError(request, component);
break;
default:
setSW360SessionError(request, ErrorMessages.COMPONENT_NOT_ADDED);
response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
}
}
} catch (TException e) {
log.error("Error fetching component from backend!", e);
}
}
Aggregations