Example usage for org.apache.wicket RuntimeConfigurationType DEPLOYMENT

List of usage examples for org.apache.wicket RuntimeConfigurationType DEPLOYMENT

Introduction

In this page you can find the example usage for org.apache.wicket RuntimeConfigurationType DEPLOYMENT.

Prototype

RuntimeConfigurationType DEPLOYMENT

To view the source code for org.apache.wicket RuntimeConfigurationType DEPLOYMENT.

Click Source Link

Usage

From source file:cz.zcu.kiv.eegdatabase.wui.app.EEGDataBaseApplication.java

License:Apache License

@Override
public RuntimeConfigurationType getConfigurationType() {

    return development ? RuntimeConfigurationType.DEVELOPMENT : RuntimeConfigurationType.DEPLOYMENT;
}

From source file:de.alpharogroup.wicket.base.application.BaseWebApplication.java

License:Apache License

/**
 * Sets the application configurations.//from  w  w w.  j a  va  2 s. co m
 */
protected void onApplicationConfigurations() {
    // set configuration before the application configuration...
    onBeforeApplicationConfigurations();
    // set global configurations for both development and deployment mode...
    onGlobalSettings();
    // set configuration for development...
    if (RuntimeConfigurationType.DEVELOPMENT.equals(this.getConfigurationType())) {
        onDevelopmentModeSettings();
    }
    // set configuration for deployment...
    if (RuntimeConfigurationType.DEPLOYMENT.equals(this.getConfigurationType())) {
        onDeploymentModeSettings();
    }
}

From source file:edu.uci.ics.hyracks.control.cc.web.WebServer.java

License:Apache License

private Handler createAdminConsoleHandler() {
    FilterHolder filter = new FilterHolder(WicketFilter.class);
    filter.setInitParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
            HyracksAdminConsoleApplication.class.getName());
    filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
    filter.setInitParameter(Application.CONFIGURATION, RuntimeConfigurationType.DEPLOYMENT.toString());

    ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);
    handler.setContextPath("/adminconsole");
    handler.setAttribute(ClusterControllerService.class.getName(), ccs);
    handler.addFilter(filter, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR));
    handler.addServlet(DefaultServlet.class, "/");
    return handler;
}

From source file:fi.ilmoeuro.membertrack.ui.MtApplication.java

License:Open Source License

@Override
public RuntimeConfigurationType getConfigurationType() {
    if (appConfig.isDebug()) {
        return RuntimeConfigurationType.DEVELOPMENT;
    } else {/*from   w w w.j av  a2  s.c  o  m*/
        return RuntimeConfigurationType.DEPLOYMENT;
    }
}

From source file:fiftyfive.wicket.BaseWicketTest.java

License:Apache License

@Before
public void createTester() {
    this.tester = new WicketTester(new FoundationApplication() {
        public Class getHomePage() {
            return DummyHomePage.class;
        }//  w w w  .  j a v  a 2  s.  co  m

        @Override
        public RuntimeConfigurationType getConfigurationType() {
            return RuntimeConfigurationType.DEPLOYMENT;
        }

        @Override
        protected void init() {
            super.init();
            getResourceSettings().setCachingStrategy(NoOpResourceCachingStrategy.INSTANCE);
        }
    });
}

From source file:gr.abiss.calipso.wicket.CalipsoApplication.java

License:Open Source License

@Override
public void init() {

    super.init();
    // DEVELOPMENT or DEPLOYMENT
    RuntimeConfigurationType configurationType = this.getConfigurationType();
    if (RuntimeConfigurationType.DEVELOPMENT.equals(configurationType)) {
        logger.info("You are in DEVELOPMENT mode");
        // getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
        // getDebugSettings().setComponentUseCheck(true);
        getResourceSettings().setResourcePollFrequency(null);
        getDebugSettings().setComponentUseCheck(false);
        // getDebugSettings().setSerializeSessionAttributes(true);
        // getMarkupSettings().setStripWicketTags(false);
        // getExceptionSettings().setUnexpectedExceptionDisplay(
        // UnexpectedExceptionDisplay.SHOW_EXCEPTION_PAGE);
        // getAjaxSettings().setAjaxDebugModeEnabled(true);
    } else if (RuntimeConfigurationType.DEPLOYMENT.equals(configurationType)) {
        getResourceSettings().setResourcePollFrequency(null);
        getDebugSettings().setComponentUseCheck(false);
        // getDebugSettings().setSerializeSessionAttributes(false);
        // getMarkupSettings().setStripWicketTags(true);
        // getExceptionSettings().setUnexpectedExceptionDisplay(
        // UnexpectedExceptionDisplay.SHOW_INTERNAL_ERROR_PAGE);
        // getAjaxSettings().setAjaxDebugModeEnabled(false);
    }//  ww w  .  j  ava2s.  co m
    // initialize velocity
    try {
        Velocity.init();
        if (logger.isInfoEnabled()) {
            logger.info("Initialized Velocity engine");
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        logger.error("Failed to initialize velocity engine", e);
    }

    // Set custom page for internal errors
    getApplicationSettings().setInternalErrorPage(CalipsoErrorPage.class);

    // don't break down on missing resources
    getResourceSettings().setThrowExceptionOnMissingResource(false);

    // Redirect to PageExpiredError Page if current page is expired
    getApplicationSettings().setPageExpiredErrorPage(CalipsoPageExpiredErrorPage.class);

    // get hold of spring managed service layer (see BasePage, BasePanel etc
    // for how it is used)
    ServletContext sc = getServletContext();
    applicationContext = WebApplicationContextUtils.getWebApplicationContext(sc);
    calipsoService = (CalipsoService) applicationContext.getBean("calipsoService");

    calipsoPropertiesEditor = new CalipsoPropertiesEditor();

    // check if acegi-cas authentication is being used, get reference to
    // object to be used
    // by wicket authentication to redirect to right pages for login /
    // logout
    try {
        calipsoCasProxyTicketValidator = (CalipsoCasProxyTicketValidator) applicationContext
                .getBean("casProxyTicketValidator");
        logger.info("casProxyTicketValidator retrieved from application context: "
                + calipsoCasProxyTicketValidator);
    } catch (NoSuchBeanDefinitionException nsbde) {
        logger.info(
                "casProxyTicketValidator not found in application context, CAS single-sign-on is not being used");
    }
    // delegate wicket i18n support to spring i18n
    getResourceSettings().getStringResourceLoaders().add(new IStringResourceLoader() {

        @Override
        public String loadStringResource(Class<?> clazz, String key, Locale locale, String style,
                String variation) {
            return applicationContext.getMessage(key, null, null, locale);
        }

        @Override
        public String loadStringResource(Component component, String key, Locale locale, String style,
                String variation) {
            return applicationContext.getMessage(key, null, null, locale);
        }
    });

    // add DB i18n resources
    getResourceSettings().getStringResourceLoaders().add(new IStringResourceLoader() {
        @Override
        public String loadStringResource(Class<?> clazz, String key, Locale locale, String style,
                String variation) {
            if (StringUtils.isNotBlank(locale.getVariant())) {
                // always ignore the variant
                locale = new Locale(locale.getLanguage(), locale.getCountry());
            }
            String lang = locale.getLanguage();
            I18nStringResource resource = CalipsoApplication.this.calipsoService
                    .loadI18nStringResource(new I18nStringIdentifier(key, lang));
            if (resource == null && !lang.equalsIgnoreCase("en")) {
                resource = CalipsoApplication.this.calipsoService
                        .loadI18nStringResource(new I18nStringIdentifier(key, "en"));
            }
            return resource != null ? resource.getValue() : null;
        }

        @Override
        public String loadStringResource(Component component, String key, Locale locale, String style,
                String variation) {
            locale = component == null ? Session.get().getLocale() : component.getLocale();
            if (StringUtils.isNotBlank(locale.getVariant())) {
                // always ignore the variant
                locale = new Locale(locale.getLanguage(), locale.getCountry());
            }
            String lang = locale.getLanguage();
            I18nStringResource resource = CalipsoApplication.this.calipsoService
                    .loadI18nStringResource(new I18nStringIdentifier(key, lang));
            if (resource == null && !lang.equalsIgnoreCase("en")) {
                resource = CalipsoApplication.this.calipsoService
                        .loadI18nStringResource(new I18nStringIdentifier(key, "en"));
            }
            return resource != null ? resource.getValue() : null;
        }
    });
    // cache resources. resource cache is cleared when creating/updating a space
    getResourceSettings().getLocalizer().setEnableCache(true);
    getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy() {
        @Override
        public boolean isActionAuthorized(Component c, Action a) {
            return true;
        }

        @Override
        public boolean isInstantiationAuthorized(Class clazz) {
            if (BasePage.class.isAssignableFrom(clazz)) {
                if (((CalipsoSession) Session.get()).isAuthenticated()) {
                    return true;
                }
                if (calipsoCasProxyTicketValidator != null) {
                    // attempt CAS authentication
                    // ==========================
                    // logger.debug("checking if context contains CAS authentication");
                    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
                    if (authentication != null && authentication.isAuthenticated()) {
                        // logger.debug("security context contains CAS authentication, initializing session");
                        ((CalipsoSession) Session.get()).setUser((User) authentication.getPrincipal());
                        return true;
                    }
                }
                // attempt remember-me auto login
                // ==========================
                if (attemptRememberMeAutoLogin()) {
                    return true;
                }

                // attempt *anonymous* guest access if there are
                // spaces that allow it
                if (((CalipsoSession) Session.get()).getUser() == null) {
                    List<Space> anonymousSpaces = getCalipso().findSpacesWhereAnonymousAllowed();
                    if (anonymousSpaces.size() > 0) {
                        // logger.debug("Found "+anonymousSpaces.size()
                        // +
                        // " anonymousSpaces allowing ANONYMOUS access, initializing anonymous user");
                        User guestUser = new User();//getCalipso().loadUser(2);
                        guestUser.setLoginName("guest");
                        guestUser.setName("Anonymous");
                        guestUser.setLastname("Guest");
                        guestUser.setLocale(Session.get().getLocale().getLanguage());
                        getCalipso().initImplicitRoles(guestUser, anonymousSpaces, RoleType.ANONYMOUS);
                        // store user in session
                        ((CalipsoSession) Session.get()).setUser(guestUser);
                        return true;
                    } else {
                        if (logger.isDebugEnabled()) {
                            // logger.debug("Found no public spaces.");
                        }
                    }
                }

                // allow registration
                if (clazz.equals(RegisterUserFormPage.class)) {
                    return true;
                }
                // not authenticated, go to login page
                // logger.debug("not authenticated, forcing login, page requested was "
                // + clazz.getName());
                if (calipsoCasProxyTicketValidator != null) {
                    String serviceUrl = calipsoCasProxyTicketValidator.getLoginUrl();
                    //                              .getServiceProperties().getService();
                    String loginUrl = calipsoCasProxyTicketValidator.getLoginUrl();
                    // logger.debug("cas authentication: service URL: "
                    // + serviceUrl);
                    String redirectUrl = loginUrl + "?service=" + serviceUrl;
                    // logger.debug("attempting to redirect to: " +
                    // redirectUrl);
                    throw new RestartResponseAtInterceptPageException(new RedirectPage(redirectUrl));
                } else {
                    throw new RestartResponseAtInterceptPageException(LoginPage.class);
                }
            }
            return true;
        }
    });
    // TODO: create friendly URLs for all created pages
    // friendly URLs for selected pages
    if (calipsoCasProxyTicketValidator != null) {
        mountPage("/login", CasLoginPage.class);
    } else {
        mountPage("/login", LoginPage.class);
    }
    mountPage("/register", RegisterAnonymousUserFormPage.class);
    mountPage("/logout", LogoutPage.class);
    mountPage("/svn", SvnStatsPage.class);
    mountPage("/test", TestPage.class);
    mountPage("/casError", CasLoginErrorPage.class);
    mountPage("/item/", ItemViewPage.class);
    mountPage("/item/${itemId}", ItemViewPage.class);
    mountPage("/itemreport/", ItemTemplateViewPage.class);
    mountPage("/newItem/${spaceCode}", NewItemPage.class);
    //      MixedParamUrlCodingStrategy newItemUrls = new MixedParamUrlCodingStrategy(
    //                "/newItem",
    //                NewItemPage.class,
    //                new String[]{"spaceCode"}
    //        );
    //        mount(newItemUrls);

    //fix for tinyMCE bug, see https://github.com/wicketstuff/core/issues/113
    SecurePackageResourceGuard guard = (SecurePackageResourceGuard) getResourceSettings()
            .getPackageResourceGuard();
    guard.addPattern("+*.htm");

    this.getRequestCycleSettings().setTimeout(Duration.minutes(6));
    this.getPageSettings().setVersionPagesByDefault(true);
    this.getExceptionSettings().setThreadDumpStrategy(ThreadDumpStrategy.THREAD_HOLDING_LOCK);
}

From source file:guru.mmp.application.web.WebApplication.java

License:Apache License

/**
 * Returns the runtime configuration type for the Wicket web application.
 *
 * @return the runtime configuration type for the Wicket web application
 *//*w w w .j  a  va 2s .  co  m*/
@Override
public RuntimeConfigurationType getConfigurationType() {
    if (Debug.inDebugMode()) {
        return RuntimeConfigurationType.DEVELOPMENT;
    } else {
        return RuntimeConfigurationType.DEPLOYMENT;
    }
}

From source file:it.av.es.web.BasePageSimple.java

License:Apache License

/**
 * Construct.// ww  w  . j av  a2s .co  m
 */
public BasePageSimple() {
    HtmlUtil.fixInitialHtml(this);
    titlePage = new Label("pageTitle", ":: EasyTrack - Eurocargo ::");
    add(titlePage);

    WebMarkupContainer googleCode = new WebMarkupContainer("googleCode");
    add(googleCode);
    googleCode.setVisible(
            getApplication().getConfigurationType().compareTo(RuntimeConfigurationType.DEPLOYMENT) >= 0);

    feedbackPanel = new CustomFeedbackPanel("feedBackPanel");
    feedbackPanel.add(new AbstractDefaultAjaxBehavior() {

        //            @Override
        //            public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target) {
        //            }
        //            
        //            @Override
        //            public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) {
        //                response.addJavaScript("jQuery('#" + electionContainer.getMarkupId() + "').fadeTo(300, 0.5, function() {})");
        //                response.addJavaScript("jQuery('#" + electionContainer.getMarkupId() + "').fadeTo(300, 1.0, function() {})");
        //            }
        //            
        @Override
        protected void respond(AjaxRequestTarget target) {
            target.appendJavaScript(
                    "jQuery('#" + feedbackPanel.getMarkupId() + "').fadeTo(300, 0.5, function() {})");

            // register the onSuccess listener that will execute Handlebars logic
            target.addListener(new IListener() {

                @Override
                public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target) {
                    System.out.println("");
                }

                @Override
                public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) {
                    response.addJavaScript(
                            "jQuery('#" + feedbackPanel.getMarkupId() + "').fadeTo(300, 0.5, function() {})");
                    response.addJavaScript(
                            "jQuery('#" + feedbackPanel.getMarkupId() + "').fadeTo(300, 1.0, function() {})");
                }
            });
        }
    });
    ;

    feedbackPanel.setOutputMarkupId(true);
    feedbackPanel.setOutputMarkupPlaceholderTag(true);
    add(feedbackPanel);

    session = ((SecuritySession) getSession());

    loggedInUser = session.getLoggedInUser();
    if (new CookieUtils().load(CookieUtil.LANGUAGE) != null) {
        getSession().setLocale(new Locale(new CookieUtils().load(CookieUtil.LANGUAGE)));
    } else {
        if (loggedInUser != null) {
            ((WebResponse) RequestCycle.get().getResponse())
                    .addCookie((new Cookie(CookieUtil.LANGUAGE, loggedInUser.getLanguage().getLanguage())));
            getSession().setLocale(new Locale(loggedInUser.getLanguage().getLanguage()));
        }
    }

    //BookmarkablePageLink goAccount = new BookmarkablePageLink<String>("goAccount", UserAccountPage.class, goAccountParameters);

    //        Label name = new Label("loggedInUser", loggedInUser != null ? loggedInUser.getFirstname() + " " +loggedInUser.getLastname() : "");
    //        add(name);

    add(new BookmarkablePageLink<String>("goUserManagerPage", UserManagerPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy()
                    .isInstantiationAuthorized(UserManagerPage.class)));
        }
    });
    add(new BookmarkablePageLink<String>("goProjectManagerPage", ProjectManagerPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy()
                    .isInstantiationAuthorized(ProjectManagerPage.class)));
        }
    });
    //        add(new BookmarkablePageLink<String>("goProductManagerPage", ProductManagerPage.class) {
    //            @Override
    //            protected void onBeforeRender() {
    //                super.onBeforeRender();
    //                setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy()
    //                        .isInstantiationAuthorized(ProductManagerPage.class)));
    //            }
    //        });
    add(new BookmarkablePageLink<String>("goOrderManagerPage", OrderManagerPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy()
                    .isInstantiationAuthorized(OrderManagerPage.class)));
        }
    });
    add(new BookmarkablePageLink<String>("goPlaceNewOrderPage", PlaceNewOrderPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy()
                    .isInstantiationAuthorized(PlaceNewOrderPage.class)));
        }
    });
    add(new BookmarkablePageLink<String>("goCustomerManagerPage", CustomerManagerPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy()
                    .isInstantiationAuthorized(CustomerManagerPage.class)));
        }
    });
    add(new BookmarkablePageLink<String>("goCustomerNewPage", CustomerPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy()
                    .isInstantiationAuthorized(CustomerPage.class)));
        }
    });
    add(new BookmarkablePageLink<String>("goSignOut", SignOut.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy()
                    .isInstantiationAuthorized(SignOut.class)));
        }
    });
    add(new BookmarkablePageLink<String>("goUserAccountPage", UserAccountPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible(loggedInUser != null && (getApplication().getSecuritySettings()
                    .getAuthorizationStrategy().isInstantiationAuthorized(UserAccountPage.class)));
            if (loggedInUser != null) {
                add(AttributeModifier.replace("value",
                        loggedInUser.getFirstname() + " " + loggedInUser.getLastname()));
            }
        }
    });
    add(new BookmarkablePageLink<String>("goGroupManagerPage", GroupManagerPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible(loggedInUser != null && (getApplication().getSecuritySettings()
                    .getAuthorizationStrategy().isInstantiationAuthorized(GroupManagerPage.class)));
        }
    });

    add(new BookmarkablePageLink<String>("goGroupMembersManagerPage", GroupMembersManagerPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible(loggedInUser != null && (getApplication().getSecuritySettings()
                    .getAuthorizationStrategy().isInstantiationAuthorized(GroupMembersManagerPage.class)));
        }
    });

    add(new BookmarkablePageLink<String>("goProductFamilyManagerPage", ProductFamilyManagerPage.class) {
        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible(loggedInUser != null && (getApplication().getSecuritySettings()
                    .getAuthorizationStrategy().isInstantiationAuthorized(ProductFamilyManagerPage.class)));
        }
    });

    //        BookmarkablePageLink goInfo = new BookmarkablePageLink("goInfo", AboutPage.class);
    //        add(goInfo);
    //        
    //        BookmarkablePageLink goPrivacy = new BookmarkablePageLink("goPrivacy", PrivacyPage.class);
    //        add(goPrivacy);
}

From source file:it.av.youeat.web.YoueatApplication.java

License:Apache License

/**
 * @return true when running in deployment configuration, false for development configuration
 *///from  w w  w.ja v  a2  s.c  om
public boolean inDeployment() {
    return getConfigurationType().equals(RuntimeConfigurationType.DEPLOYMENT);
}

From source file:net.rrm.ehour.ui.EhourWebApplication.java

License:Open Source License

@Override
public RuntimeConfigurationType getConfigurationType() {
    String development = RuntimeConfigurationType.DEVELOPMENT.name();
    String deployment = RuntimeConfigurationType.DEPLOYMENT.name();

    String configurationType = ehourSystemConfig.getConfigurationType();

    if (configurationType == null || (!configurationType.equalsIgnoreCase(deployment)
            && !configurationType.equalsIgnoreCase(development))) {
        LOGGER.warn("Invalid configuration type defined in ehour.properties. Valid values are " + deployment
                + " or " + development);
        return RuntimeConfigurationType.DEVELOPMENT;
    }/*www.j  a  va 2s .  c om*/

    return RuntimeConfigurationType.valueOf(configurationType.toUpperCase());
}