Example usage for javax.xml.bind ValidationException printStackTrace

List of usage examples for javax.xml.bind ValidationException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.bind ValidationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this JAXBException and its stack trace (including the stack trace of the linkedException if it is non-null) to System.err .

Usage

From source file:org.gnenc.yams.portlet.AccountManagement.java

public void addAccount(ActionRequest actionRequest, ActionResponse actionResponse) {
    Account account = ActionUtil.accountFromRequest(actionRequest);
    String backURL = ParamUtil.getString(actionRequest, "backURL");
    Account newAccount = null;//from   w  w  w.j a  va2  s.  c  om
    String jspPage = null;

    AccountManagementService ams = AccountManagementServiceImpl.getInstance();
    List<SubSystem> subsystems = new ArrayList<SubSystem>();

    List<String> responses = new ArrayList<String>();
    String password = DAOParamUtil.getString(actionRequest, "password");
    String verify = DAOParamUtil.getString(actionRequest, "verify");
    String emailAddress = DAOParamUtil.getString(actionRequest, "emailAddress") + StringPool.AT
            + DAOParamUtil.getString(actionRequest, "domain");

    actionRequest.setAttribute("selAccount", account);
    actionResponse.setRenderParameter("backURL", backURL);

    boolean valid = PortletUtil.validatePasswordFields(password, verify, account.getGivenName(),
            account.getSn(), responses);

    if (valid) {
        valid = PortletUtil.validateEmailAddressField(emailAddress, responses);
    }

    if (!valid && responses.size() > 0) {
        for (String response : responses) {
            SessionErrors.add(actionRequest, response);
        }

        jspPage = PortletUtil.ACCT_MGMT_ACCOUNT_ADD_WIZARD_JSP;
    } else {
        account.setPassword(password);
        subsystems.add(SubSystem.LDAP);
        try {
            if (ams.checkAccountExists(account.getMail().get(0)).isEmpty()) {
                newAccount = ams.createAccount(account, subsystems);
                jspPage = PortletUtil.SEARCH_VIEW_JSP;
            } else {
                SessionErrors.add(actionRequest, "This account already exists");
                jspPage = PortletUtil.ACCT_MGMT_ACCOUNT_ADD_WIZARD_JSP;
            }
        } catch (ValidationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    writeActionLog(actionRequest, account.getMail().get(0), account.getDisplayName(),
            account.getAttribute("esuccEntity"), "Add account");
    actionResponse.setRenderParameter("jspPage", jspPage);
}

From source file:org.gnenc.yams.portlet.AccountManagement.java

public void editAccount(ActionRequest actionRequest, ActionResponse actionResponse) {
    Account account = ActionUtil.accountFromRequest(actionRequest);
    String backURL = ParamUtil.getString(actionRequest, "backURL");
    Account newAccount = null;//from   ww  w.  j  av a2s  .  c  o  m
    String jspPage = null;

    AccountManagementService ams = AccountManagementServiceImpl.getInstance();
    List<SubSystem> subsystems = new ArrayList<SubSystem>();

    List<String> responses = new ArrayList<String>();
    String password = DAOParamUtil.getString(actionRequest, "password_field");
    String verify = DAOParamUtil.getString(actionRequest, "verify");
    boolean valid = false;

    // If the password fields aren't populated, don't change the user's password
    if (Validator.isNotNull(password) && Validator.isNotNull(verify)) {
        valid = PortletUtil.validatePasswordFields(password, verify, account.getGivenName(), account.getSn(),
                responses);
        account.setPassword(password);
    } else {
        valid = true;
    }

    actionResponse.setRenderParameter("uidNumber", account.getAttribute("uidNumber"));
    actionResponse.setRenderParameter("backURL", backURL);

    if (!valid && responses.size() > 0) {
        for (String response : responses) {
            SessionErrors.add(actionRequest, response);
        }

        jspPage = PortletUtil.ACCT_MGMT_ACCOUNT_EDIT_ACCOUNT_JSP;
    } else {
        subsystems.add(SubSystem.LDAP);
        try {
            newAccount = ams.modifyAccount(account, subsystems);
        } catch (ValidationException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            // That's Ok
        }
        jspPage = PortletUtil.SEARCH_VIEW_JSP;
    }

    writeActionLog(actionRequest, account.getMail().get(0), account.getDisplayName(),
            account.getAttribute("esuccEntity"), "Edit account");
    actionResponse.setRenderParameter("jspPage", jspPage);
}

From source file:org.gnenc.yams.portlet.AccountManagement.java

public static boolean importAccount(ActionRequest actionRequest, Account account, List<String> responses) {
    String emailAddress = account.getMail().get(0);
    Account newAccount = null;//from  w  w w.  j  a va  2 s.  c o m

    AccountManagementService ams = AccountManagementServiceImpl.getInstance();
    List<SubSystem> subsystems = new ArrayList<SubSystem>();

    List<SearchFilter> filters = new ArrayList<SearchFilter>();
    filters.add(new SearchFilter(Filter.esuccEntity, account.getAttribute("esuccEntity"), false));

    List<Domain> domains = Search.getDomains(filters, null, StringPool.BLANK, StringPool.BLANK, false);

    boolean valid = PortletUtil.validatePasswordFields(account.getPassword(), account.getPassword(),
            account.getGivenName(), account.getSn(), responses);

    if (valid) {
        valid = PortletUtil.validateEmailAddressField(emailAddress, responses);
    }

    if (valid) {
        boolean matched = false;
        for (Domain domain : domains) {

            if (domain.getOrganization().equals(account.getAttribute("esuccMailPrimaryDomain"))) {
                matched = true;
                break;
            }
        }
        if (!matched) {
            valid = false;
            responses.add("Invalid domain");
        }
    }

    if (!valid && responses.size() > 0) {
        return false;
    } else {
        subsystems.add(SubSystem.LDAP);
        try {
            if (ams.checkAccountExists(account.getMail().get(0)).isEmpty()) {
                newAccount = ams.createAccount(account, subsystems);
            } else {
                return false;
            }
        } catch (ValidationException e) {
            e.printStackTrace();
            return false;
        }
    }

    writeActionLog(actionRequest, account.getMail().get(0), account.getDisplayName(),
            account.getAttribute("esuccEntity"), "Add account (Import)");

    return true;
}

From source file:org.gnenc.yams.portlet.AccountManagement.java

public static void removeAccount(ActionRequest actionRequest, ActionResponse actionResponse) {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    Account callingAccount = null;//from  w  w  w  .  ja  va2s  .  c om
    try {
        callingAccount = ActionUtil.accountFromEmailAddress(themeDisplay.getUser().getEmailAddress());
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    AccountManagementService ams = AccountManagementServiceImpl.getInstance();
    String jspPage = null;
    List<SubSystem> subsystems = new ArrayList<SubSystem>();
    String backURL = DAOParamUtil.getString(actionRequest, "backURL");
    boolean remove = DAOParamUtil.getBoolean(actionRequest, "remove");
    Account account = ActionUtil.accountFromUidNumber(DAOParamUtil.getString(actionRequest, "uidNumber"));

    actionResponse.setRenderParameter("uidNumber", account.getAttribute("uidNumber"));
    actionResponse.setRenderParameter("backURL", backURL);

    if (PermissionsChecker.hasPermission(callingAccount, account,
            PermissionsChecker.PERMISSION_ACCOUNT_REMOVE_FORCE)) {
        subsystems.add(SubSystem.LDAP);
        if (remove) {
            try {
                account.setAttribute("removeAccount", "TRUE");
                ams.modifyAccount(account, subsystems);
            } catch (ValidationException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                // That's Ok
            }
        }
        jspPage = PortletUtil.SEARCH_VIEW_JSP;
    } else {
        SessionErrors.add(actionRequest, "insufficient-privileges");

        jspPage = PortletUtil.ACCT_MGMT_ACCOUNT_REMOVE_JSP;
    }

    writeActionLog(actionRequest, account.getMail().get(0), account.getDisplayName(),
            account.getAttribute("esuccEntity"), "Immediate account removal");
    actionResponse.setRenderParameter("jspPage", jspPage);
}