Search in sources :

Example 71 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class DisplayReleaseChanges method doStartTag.

public int doStartTag() throws JspException {
    JspWriter jspWriter = pageContext.getOut();
    StringBuilder display = new StringBuilder();
    String namespace = getNamespace();
    if (additions == null || deletions == null) {
        return SKIP_BODY;
    }
    try {
        for (Release._Fields field : Release._Fields.values()) {
            switch(field) {
                // ignored Fields
                case ID:
                case REVISION:
                case TYPE:
                case CREATED_BY:
                case CREATED_ON:
                case PERMISSIONS:
                case DOCUMENT_STATE:
                case COMPONENT_ID:
                case VENDOR_ID:
                case CLEARING_TEAM_TO_FOSSOLOGY_STATUS:
                // Taken care of externally or in extra tables
                case ATTACHMENTS:
                case RELEASE_ID_TO_RELATIONSHIP:
                case CLEARING_INFORMATION:
                case COTS_DETAILS:
                case ECC_INFORMATION:
                    break;
                default:
                    FieldMetaData fieldMetaData = Release.metaDataMap.get(field);
                    displaySimpleFieldOrSet(display, actual, additions, deletions, field, fieldMetaData, "");
            }
        }
        String renderString = display.toString();
        if (Strings.isNullOrEmpty(renderString)) {
            renderString = "<h4> No changes in basic fields </h4>";
        } else {
            renderString = String.format("<table class=\"%s\" id=\"%schanges\" >", tableClasses, idPrefix) + "<thead><tr><th colspan=\"4\"> Changes for Basic fields</th></tr>" + String.format("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr></thead><tbody>", FIELD_NAME, CURRENT_VAL, DELETED_VAL, SUGGESTED_VAL) + renderString + "</tbody></table>";
        }
        StringBuilder releaseRelationshipDisplay = new StringBuilder();
        User user = getUserFromContext("Cannot render release changes without logged in user in request");
        renderReleaseIdToRelationship(releaseRelationshipDisplay, user);
        String clearingInformationDisplay = renderClearingInformation();
        String eccInformationDisplay = renderEccInformation();
        String cotsDetailDisplay = renderCOTSDetails();
        jspWriter.print(renderString + releaseRelationshipDisplay.toString() + clearingInformationDisplay + eccInformationDisplay + cotsDetailDisplay);
    } catch (Exception e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}
Also used : JspException(javax.servlet.jsp.JspException) FieldMetaData(org.apache.thrift.meta_data.FieldMetaData) User(org.eclipse.sw360.datahandler.thrift.users.User) JspWriter(javax.servlet.jsp.JspWriter) Release(org.eclipse.sw360.datahandler.thrift.components.Release) JspException(javax.servlet.jsp.JspException)

Example 72 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class SignupPortlet method createAccount.

@UsedAsLiferayAction
public void createAccount(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    Registrant registrant = new Registrant(request);
    SignupPortletUtils.updateUserFromRequest(request, registrant);
    User newUser = null;
    if (registrant.validateUserData(request)) {
        newUser = createUser(registrant, request);
    }
    if (null != newUser) {
        boolean success = createUserModerationRequest(newUser, request);
        if (success) {
            response.setRenderParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_SUCCESS);
        }
    } else {
        String message = (String) ((LinkedHashMap) request.getPortletSession().getAttributeMap().get("com.liferay.portal.kernel.servlet.SessionMessages")).get("requestProcessed");
        setSW360SessionError(request, message);
        request.setAttribute(PortalConstants.USER, registrant);
        log.info("Could not create user");
    }
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 73 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class LinkedReleaseRenderer method renderReleaseLinkList.

public <T> void renderReleaseLinkList(StringBuilder display, Map<String, T> releaseRelationshipMap, Set<String> releaseIds, String msg) {
    if (releaseIds.isEmpty())
        return;
    StringBuilder candidate = new StringBuilder();
    try {
        ComponentService.Iface componentClient = new ThriftClients().makeComponentClient();
        for (Release release : componentClient.getReleasesById(releaseIds, user)) {
            candidate.append(String.format("<tr><td>%s</td><td>%s</td></tr>", release.getName(), releaseRelationshipMap.get(release.getId())));
        }
    } catch (TException ignored) {
    }
    String tableContent = candidate.toString();
    if (!tableContent.isEmpty()) {
        display.append(String.format("<table class=\"%s\" id=\"%s%s\" >", tableClasses, idPrefix, msg));
        display.append(String.format("<thead><tr><th colspan=\"2\">%s</th></tr><tr><th>Release name</th><th>Release relationship</th></tr></thead><tbody>", msg));
        display.append(tableContent);
        display.append("</tbody></table>");
    }
}
Also used : TException(org.apache.thrift.TException) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Release(org.eclipse.sw360.datahandler.thrift.components.Release) ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients)

Example 74 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class UserAwareTag method getUserFromContext.

protected User getUserFromContext(String errorMessage) throws JspException, TException {
    Optional<String> userEmailOpt = UserCacheHolder.getUserEmailFromRequest(pageContext.getRequest());
    String userEmail = userEmailOpt.orElseThrow(() -> new JspException(errorMessage));
    UserService.Iface userClient = new ThriftClients().makeUserClient();
    return userClient.getByEmail(userEmail);
}
Also used : JspException(javax.servlet.jsp.JspException) UserService(org.eclipse.sw360.datahandler.thrift.users.UserService) ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients)

Example 75 with User

use of org.eclipse.sw360.datahandler.thrift.users.User 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;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) Joiner(com.google.common.base.Joiner) UserService(org.eclipse.sw360.datahandler.thrift.users.UserService) ArrayList(java.util.ArrayList) JspWriter(javax.servlet.jsp.JspWriter) JspException(javax.servlet.jsp.JspException) TException(org.apache.thrift.TException) JspException(javax.servlet.jsp.JspException) ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients)

Aggregations

User (org.eclipse.sw360.datahandler.thrift.users.User)169 TException (org.apache.thrift.TException)100 Release (org.eclipse.sw360.datahandler.thrift.components.Release)58 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)44 Test (org.junit.Test)30 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)27 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)26 Component (org.eclipse.sw360.datahandler.thrift.components.Component)20 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)20 ResponseEntity (org.springframework.http.ResponseEntity)20 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)19 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)18 IOException (java.io.IOException)17 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)16 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)16 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)13 RequestSummary (org.eclipse.sw360.datahandler.thrift.RequestSummary)12 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)12 Before (org.junit.Before)12 ArrayList (java.util.ArrayList)11