Search in sources :

Example 6 with ModelControlException

use of com.iplanet.jato.model.ModelControlException in project OpenAM by OpenRock.

the class SubConfigAddViewBean method getAttributeValueMap.

@Override
protected Map<String, Set<String>> getAttributeValueMap() {
    try {
        SubConfigModel model = (SubConfigModel) getModel();
        AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
        String schemaName = (String) getPageSessionAttribute(AMServiceProfile.PG_SESSION_SUB_SCHEMA_NAME);
        return ps.getAttributeValues(model.getAttributeNames(schemaName));
    } catch (AMConsoleException | ModelControlException e) {
        debug.error("Could not retrieve attribute values", e);
    }
    return Collections.emptyMap();
}
Also used : SubConfigModel(com.sun.identity.console.service.model.SubConfigModel) AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) ModelControlException(com.iplanet.jato.model.ModelControlException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 7 with ModelControlException

use of com.iplanet.jato.model.ModelControlException in project OpenAM by OpenRock.

the class STSAddViewBeanBase method handleButton1Request.

/**
     * Handles save button request. Validates the rest sts configuration state, and invokes the model to publish a
     * rest sts instance corresponding to this state.
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    try {
        Map<String, Set<String>> configurationState = (Map<String, Set<String>>) getAttributeSettings();
        STSInstanceModel model = (STSInstanceModel) getModel();
        STSInstanceModelResponse validationResponse = model.validateConfigurationState(stsType, configurationState);
        if (validationResponse.isSuccessful()) {
            final String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
            try {
                STSInstanceModelResponse creationResponse = model.createInstance(stsType, configurationState, currentRealm);
                if (creationResponse.isSuccessful()) {
                    setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", creationResponse.getMessage());
                    forwardToAMViewBean();
                } else {
                    setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", creationResponse.getMessage());
                }
            } catch (AMConsoleException e) {
                throw new ModelControlException(e);
            }
        } else {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", validationResponse.getMessage());
        }
    } catch (AMConsoleException e) {
        //will be entered if getAttributeSettings throws a AMConsoleException because passwords are mis-matched.
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : Set(java.util.Set) STSInstanceModelResponse(com.sun.identity.console.sts.model.STSInstanceModelResponse) RestSTSInstanceModel(com.sun.identity.console.sts.model.RestSTSInstanceModel) SoapSTSInstanceModel(com.sun.identity.console.sts.model.SoapSTSInstanceModel) STSInstanceModel(com.sun.identity.console.sts.model.STSInstanceModel) ModelControlException(com.iplanet.jato.model.ModelControlException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 8 with ModelControlException

use of com.iplanet.jato.model.ModelControlException in project OpenAM by OpenRock.

the class STSEditViewBeanBase method handleButton1Request.

/**
     * Handles save button request. Validates the rest sts configuration state, and invokes the model to publish a
     * rest sts instance corresponding to this state.
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    final String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    final String instanceName = (String) getPageSessionAttribute(STSHomeViewBean.INSTANCE_NAME);
    try {
        Map<String, Set<String>> configurationState = getUpdatedConfigurationState(currentRealm, instanceName);
        if (configurationState.isEmpty()) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", getModel().getLocalizedString("rest.sts.view.no.updates"));
        } else {
            if (instanceNameUpdated(currentRealm, instanceName)) {
                setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", MessageFormat.format(getModel().getLocalizedString("rest.sts.view.no.edit.deployment.url"), instanceName));
            } else {
                STSInstanceModel model = (STSInstanceModel) getModel();
                STSInstanceModelResponse validationResponse = model.validateConfigurationState(stsType, configurationState);
                if (validationResponse.isSuccessful()) {
                    try {
                        STSInstanceModelResponse creationResponse = model.updateInstance(stsType, configurationState, currentRealm, instanceName);
                        if (creationResponse.isSuccessful()) {
                            forwardToSTSHomeViewBean();
                        } else {
                            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", creationResponse.getMessage());
                        }
                    } catch (AMConsoleException e) {
                        throw new ModelControlException(e);
                    }
                } else {
                    setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", validationResponse.getMessage());
                }
            }
        }
    } catch (AMConsoleException e) {
        //getUpdatedConfigurationState will throw this exception if passwords are mis-matched.
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : Set(java.util.Set) STSInstanceModelResponse(com.sun.identity.console.sts.model.STSInstanceModelResponse) RestSTSInstanceModel(com.sun.identity.console.sts.model.RestSTSInstanceModel) STSInstanceModel(com.sun.identity.console.sts.model.STSInstanceModel) SoapSTSInstanceModel(com.sun.identity.console.sts.model.SoapSTSInstanceModel) ModelControlException(com.iplanet.jato.model.ModelControlException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 9 with ModelControlException

use of com.iplanet.jato.model.ModelControlException in project OpenAM by OpenRock.

the class PWResetQuestionTiledView method getAnswers.

/**
     * Gets the answer to the secret question
     *
     * @return answer to the secret question
     */
public Map getAnswers() {
    Map map = Collections.EMPTY_MAP;
    PWResetQuestionModel model = getModel();
    try {
        DatasetModel dataModel = getPrimaryModel();
        int size = dataModel.getSize();
        if (size > 0) {
            dataModel.first();
            map = new HashMap(size);
        }
        for (int i = 0; i < size; i++) {
            HiddenField hf = (HiddenField) getChild(FLD_ATTR_NAME);
            String attrName = (String) hf.getValue();
            String answer = (String) getDisplayFieldValue(TF_ANSWER);
            if (answer != null) {
                answer = answer.trim();
            }
            if (answer == null || answer.length() == 0) {
                missingData = true;
            }
            map.put(attrName, answer);
            dataModel.next();
        }
    } catch (ModelControlException mce) {
        model.debugError("PWResetQuestionTiledView.getAnswers", mce);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) HiddenField(com.iplanet.jato.view.html.HiddenField) ModelControlException(com.iplanet.jato.model.ModelControlException) HashMap(java.util.HashMap) Map(java.util.Map) DatasetModel(com.iplanet.jato.model.DatasetModel) PWResetQuestionModel(com.sun.identity.password.ui.model.PWResetQuestionModel)

Example 10 with ModelControlException

use of com.iplanet.jato.model.ModelControlException in project OpenAM by OpenRock.

the class AuthExceptionViewBean method beginDisplay.

/**
     * Called as notification that the JSP has begun its display 
     * processing. In addition to performing the default behavior in the 
     * superclass's version, this method executes any auto-retrieving or auto-
     * executing models associated with this view unless auto-retrieval is
     * disabled.
     * @param event Display Event.
     * @throws ModelControlException if manipulation of a model fails during
     *         display preparation or execution of auto-retrieving models.
     */
public void beginDisplay(DisplayEvent event) throws ModelControlException {
    if (ad != null) {
        try {
            String cookieDomain = null;
            Set<String> cookieDomainSet = AuthClientUtils.getCookieDomainsForRequest(request);
            Cookie cookie;
            setPageEncoding(request, response);
            // No cookie domain specified in profile
            if (cookieDomainSet.isEmpty()) {
                cookie = AuthUtils.getLogoutCookie(ac, null);
                response.addCookie(cookie);
            } else {
                Iterator iter = cookieDomainSet.iterator();
                while (iter.hasNext()) {
                    cookieDomain = (String) iter.next();
                    cookie = AuthUtils.getLogoutCookie(ac, cookieDomain);
                    response.addCookie(cookie);
                }
            }
            AuthUtils.clearlbCookie(request, response);
            ResultVal = rb.getString("uncaught_exception");
        } catch (Exception e) {
            e.printStackTrace();
            if (exDebug.messageEnabled()) {
                exDebug.message("error in getting Exception : " + e.getMessage());
            }
            ResultVal = rb.getString("uncaught_exception") + " : " + e.getMessage();
        }
    }
}
Also used : Cookie(javax.servlet.http.Cookie) Iterator(java.util.Iterator) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ModelControlException(com.iplanet.jato.model.ModelControlException)

Aggregations

ModelControlException (com.iplanet.jato.model.ModelControlException)10 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)7 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)5 RestSTSInstanceModel (com.sun.identity.console.sts.model.RestSTSInstanceModel)5 STSInstanceModel (com.sun.identity.console.sts.model.STSInstanceModel)5 SoapSTSInstanceModel (com.sun.identity.console.sts.model.SoapSTSInstanceModel)5 Map (java.util.Map)4 Set (java.util.Set)4 SubConfigModel (com.sun.identity.console.service.model.SubConfigModel)2 STSInstanceModelResponse (com.sun.identity.console.sts.model.STSInstanceModelResponse)2 HashMap (java.util.HashMap)2 DatasetModel (com.iplanet.jato.model.DatasetModel)1 HiddenField (com.iplanet.jato.view.html.HiddenField)1 PWResetQuestionModel (com.sun.identity.password.ui.model.PWResetQuestionModel)1 CCActionTable (com.sun.web.ui.view.table.CCActionTable)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 ServletException (javax.servlet.ServletException)1 Cookie (javax.servlet.http.Cookie)1