use of org.eclipse.sw360.datahandler.thrift.ThriftClients in project sw360portal by sw360.
the class DisplayUserEdit method doStartTag.
public int doStartTag() throws JspException {
JspWriter jspWriter = pageContext.getOut();
StringBuilder display = new StringBuilder();
List<String> userList = new ArrayList<>();
List<String> emailList = new ArrayList<>();
List<String> emailInput;
if (multiUsers) {
emailInput = emails;
} else {
emailInput = new ArrayList<>();
emailInput.add(email);
}
String namespace = getNamespace();
try {
UserService.Iface client = new ThriftClients().makeUserClient();
for (String email : emailInput) {
User user = null;
try {
if (!Strings.isNullOrEmpty(email))
user = client.getByEmail(email);
} catch (TException e) {
log.info("User with email=" + email + " not found in DB");
}
emailList.add(email);
if (user != null) {
userList.add(user.getFullname());
} else {
userList.add(email);
}
}
Joiner commaJoiner = Joiner.on(", ");
String mails = getString(commaJoiner.join(emailList));
String userNames = getString(commaJoiner.join(userList));
display.append(String.format("<label class=\"textlabel stackedLabel\" for=\"%sDisplay\">%s</label>", id, description)).append(String.format("<input type=\"hidden\" readonly=\"\" value=\"%s\" id=\"%s\" name=\"%s%s\"/>", mails, id, namespace, id)).append(String.format("<input type=\"text\" readonly=\"\" value=\"%s\" id=\"%sDisplay\" ", userNames, id));
if (!readonly) {
display.append(String.format(" placeholder=\"Click to edit\" class=\"clickable userSearchDialogInteractive\" data-id=\"%s\" data-multi-user=\"%s\"", id, multiUsers ? "true" : "false"));
} else {
display.append(" placeholder=\"Will be set automatically\" ");
}
display.append("/>");
jspWriter.print(display.toString());
} catch (Exception e) {
throw new JspException(e);
}
return SKIP_BODY;
}
use of org.eclipse.sw360.datahandler.thrift.ThriftClients in project sw360portal by sw360.
the class ScheduleHandler method scheduleService.
@Override
public RequestSummary scheduleService(String serviceName) throws TException {
if (ScheduleConstants.invalidConfiguredServices.contains(serviceName)) {
log.info("Could not schedule " + serviceName + " because of invalid configuration.");
return new RequestSummary(RequestStatus.FAILURE);
}
Scheduler.cancelSyncJobOfService(serviceName);
boolean successSync = false;
switch(serviceName) {
case ThriftClients.CVESEARCH_SERVICE:
successSync = wrapSupplierException(() -> thriftClients.makeCvesearchClient().update(), serviceName);
break;
default:
log.error("Could not schedule service: " + serviceName + ". Reason: service is not registered in ThriftClients.");
}
if (successSync) {
RequestSummary summary = new RequestSummary(RequestStatus.SUCCESS);
summary.setMessage(SW360Utils.getDateTimeString(Scheduler.getNextSync()));
return summary;
} else {
return new RequestSummary(RequestStatus.FAILURE);
}
}
use of org.eclipse.sw360.datahandler.thrift.ThriftClients in project sw360portal by sw360.
the class ComponentAndAttachmentAwareDBTest method setUp.
@Before
public void setUp() throws Exception {
deleteDatabases();
ThriftClients thriftClients = getThriftClients();
componentClient = thriftClients.makeComponentClient();
vendorClient = thriftClients.makeVendorClient();
attachmentClient = thriftClients.makeAttachmentClient();
attachmentRepository = getAttachmentRepository();
user = getAdminUser(getClass());
}
use of org.eclipse.sw360.datahandler.thrift.ThriftClients in project sw360portal by sw360.
the class ScheduleAdminPortlet method unscheduleCveSearch.
@UsedAsLiferayAction
public void unscheduleCveSearch(ActionRequest request, ActionResponse response) throws PortletException, IOException {
try {
User user = UserCacheHolder.getUserFromRequest(request);
RequestStatus requestStatus = new ThriftClients().makeScheduleClient().unscheduleService(ThriftClients.CVESEARCH_SERVICE, user);
setSessionMessage(request, requestStatus, "Task", "unschedule");
} catch (TException e) {
log.error(e);
}
}
use of org.eclipse.sw360.datahandler.thrift.ThriftClients in project sw360portal by sw360.
the class ComponentPortletUtils method deleteRelease.
public static RequestStatus deleteRelease(PortletRequest request, Logger log) {
String releaseId = request.getParameter(PortalConstants.RELEASE_ID);
if (releaseId != null) {
try {
String deleteCommentEncoded = request.getParameter(PortalConstants.MODERATION_REQUEST_COMMENT);
User user = UserCacheHolder.getUserFromRequest(request);
if (deleteCommentEncoded != null) {
String deleteComment = new String(Base64.getDecoder().decode(deleteCommentEncoded));
user.setCommentMadeDuringModerationRequest(deleteComment);
}
ComponentService.Iface client = new ThriftClients().makeComponentClient();
return client.deleteRelease(releaseId, UserCacheHolder.getUserFromRequest(request));
} catch (TException e) {
log.error("Could not delete release from DB", e);
}
}
return RequestStatus.FAILURE;
}
Aggregations