PolicyNormalEditViewBean.java revision 980c471e50c03bf708fca68a475d7c7206787173
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk/**
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk *
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk *
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * The contents of this file are subject to the terms
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * of the Common Development and Distribution License
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * (the License). You may not use this file except in
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * compliance with the License.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk *
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * You can obtain a copy of the License at
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * https://opensso.dev.java.net/public/CDDLv1.0.html or
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * opensso/legal/CDDLv1.0.txt
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * See the License for the specific language governing
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * permission and limitations under the License.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk *
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * When distributing Covered Code, include this CDDL
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * Header Notice in each file and include the License file
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * at opensso/legal/CDDLv1.0.txt.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * If applicable, add the following below the CDDL Header,
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * with the fields enclosed by brackets [] replaced by
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * your own identifying information:
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * "Portions Copyrighted [year] [name of copyright owner]"
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk *
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk * $Id: PolicyNormalEditViewBean.java,v 1.2 2008/06/25 05:43:03 qcheng Exp $
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk *
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * Portions Copyrighted 2015 ForgeRock AS.
4c0f084e476c05989eb702c500a763ef09ba044ejeff.schenk */
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Fosterpackage com.sun.identity.console.policy;
6e153e9671eb382c49354ab856404a71477cce58jeff.schenk
fb98811412f1a61efdc30b38091bf4708148a806Allan Fosterimport com.iplanet.jato.model.ModelControlException;
fb98811412f1a61efdc30b38091bf4708148a806Allan Fosterimport com.iplanet.jato.view.event.RequestInvocationEvent;
fb98811412f1a61efdc30b38091bf4708148a806Allan Fosterimport com.sun.identity.console.base.model.AMAdminConstants;
fb98811412f1a61efdc30b38091bf4708148a806Allan Fosterimport com.sun.identity.console.base.model.AMConsoleException;
fb98811412f1a61efdc30b38091bf4708148a806Allan Fosterimport com.sun.identity.console.policy.model.CachedPolicy;
6e153e9671eb382c49354ab856404a71477cce58jeff.schenkimport com.sun.identity.console.policy.model.PolicyModel;
6e153e9671eb382c49354ab856404a71477cce58jeff.schenkimport com.sun.web.ui.model.CCPageTitleModel;
6e153e9671eb382c49354ab856404a71477cce58jeff.schenkimport com.sun.web.ui.view.alert.CCAlert;
6e153e9671eb382c49354ab856404a71477cce58jeff.schenkimport java.text.MessageFormat;
6e153e9671eb382c49354ab856404a71477cce58jeff.schenk
fb98811412f1a61efdc30b38091bf4708148a806Allan Fosterpublic class PolicyNormalEditViewBean
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster extends PolicyNormalViewBeanBase
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster{
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster public static final String DEFAULT_DISPLAY_URL =
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster "/console/policy/PolicyNormalEdit.jsp";
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster private static final String PGTITLE_TWO_BTNS = "pgtitleTwoBtns";
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /**
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * Creates a policy creation view bean.
4c0f084e476c05989eb702c500a763ef09ba044ejeff.schenk */
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster public PolicyNormalEditViewBean() {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster super("PolicyNormalEdit", DEFAULT_DISPLAY_URL);
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster }
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster protected void createPageTitleModel() {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster ptModel = new CCPageTitleModel(
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster getClass().getClassLoader().getResourceAsStream(
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster "com/sun/identity/console/threeBtnsPageTitle.xml"));
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster ptModel.setValue("button1", "button.save");
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster ptModel.setValue("button2", "button.reset");
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster ptModel.setValue("button3", getBackButtonLabel());
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster ptModel.setPageTitleText("page.title.policy.edit");
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster }
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /**
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * Handles reset request.
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster *
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * @param event Request invocation event
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster */
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster public void handleButton2Request(RequestInvocationEvent event) {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster PolicyModel model = (PolicyModel) getModel();
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster String cacheID = (String) getPageSessionAttribute(ProfileViewBeanBase.PG_SESSION_POLICY_CACHE_ID);
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster try {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster CachedPolicy cachedPolicy = model.getCachedPolicy(cacheID);
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster try {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster model.updatePolicyCache(cacheID, cachedPolicy);
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster } catch (AMConsoleException e) {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster }
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster forwardTo();
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster } catch (AMConsoleException e) {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster debug.warning(
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster "PolicyNormalEditViewBean.handleButton2Request", e);
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster redirectToStartURL();
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster }
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster }
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /**
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * Handles create policy request.
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster *
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster * @param event Request invocation event
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster */
public void handleButton1Request(RequestInvocationEvent event)
throws ModelControlException
{
String currentRealm = (String)getPageSessionAttribute(
AMAdminConstants.CURRENT_REALM);
try {
if (reconstructPolicy()) {
// error message set in PolicyOpViewBeanBase
} else {
CachedPolicy cachedPolicy = getCachedPolicy();
PolicyModel model = (PolicyModel)getModel();
try {
model.replacePolicy(currentRealm, cachedPolicy.getPolicy());
setInlineAlertMessage(CCAlert.TYPE_INFO,
"message.information", "policy.modified.message");
cachedPolicy.setPolicyModified(false);
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error",
e.getMessage());
}
}
forwardTo();
} catch (AMConsoleException e) {
debug.warning(
"PolicyNormalEditViewBean.handleButton1Request", e);
redirectToStartURL();
}
}
protected String getBreadCrumbDisplayName() {
try {
PolicyModel model = (PolicyModel)getModel();
CachedPolicy cachedPolicy = getCachedPolicy();
String[] arg = {cachedPolicy.getTrackPolicyName()};
return MessageFormat.format(
model.getLocalizedString("breadcrumbs.editPolicy"),
(Object[])arg);
} catch (AMConsoleException e) {
debug.warning(
"PolicyNormalEditViewBean.getBreadCrumbDisplayName", e);
return "";
}
}
protected boolean startPageTrail() {
return false;
}
protected boolean isProfilePage() {
return true;
}
}