ScriptsViewBean.java revision 1cbd8752ba5fabec320a628e3c2624a775b7d246
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/*
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * The contents of this file are subject to the terms of the Common Development and
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Distribution License (the License). You may not use this file except in compliance with the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * License.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * specific language governing permission and limitations under the License.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * When distributing Covered Software, include this CDDL Header Notice in each file and include
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Header, with the fields enclosed by brackets [] replaced by your own identifying
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * information: "Portions copyright [year] [name of copyright owner]".
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Copyright 2015 ForgeRock AS.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncpackage com.sun.identity.console.scripts;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncimport static com.sun.identity.console.XuiRedirectHelper.getRedirectRealm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncimport static com.sun.identity.console.XuiRedirectHelper.redirectToXui;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncimport com.iplanet.jato.RequestContext;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncimport com.iplanet.jato.RequestManager;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncimport com.iplanet.jato.view.event.DisplayEvent;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncimport com.sun.identity.console.base.model.AMModel;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncimport com.sun.identity.console.base.model.AMModelBase;
import com.sun.identity.console.realm.HasEntitiesTabs;
import com.sun.identity.console.realm.RealmPropertiesBase;
import javax.servlet.http.HttpServletRequest;
import java.text.MessageFormat;
/**
* Script management and editing.
* @since 13.0.0
*/
public class ScriptsViewBean extends RealmPropertiesBase implements HasEntitiesTabs {
public static final String DEFAULT_DISPLAY_URL = "/console/scripts/Scripts.jsp";
/**
* Creates a scripts view bean.
*/
public ScriptsViewBean() {
super("Scripts");
setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
}
@Override
protected void initialize() {
if (!initialized) {
super.initialize();
initialized = true;
}
}
/**
* This redirects to the script editor. This isn't a natural thing for JATO, and so the strategy used here is
* to set up a redirect and then throw a CompleteRequestException (thus pretending an error occurred) which causes
* the redirect to happen.
*
* @param event The display event.
*/
public void beginDisplay(DisplayEvent event) {
redirectToXui(getRequestContext().getRequest(), getRedirectRealm(this),
MessageFormat.format("realms/{0}/scripts", getCurrentRealmEncoded()));
}
@Override
protected AMModel getModelInternal() {
RequestContext rc = RequestManager.getRequestContext();
HttpServletRequest req = rc.getRequest();
return new AMModelBase(req, getPageSessionAttributes());
}
}