List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:org.hippoecm.frontend.plugins.jquery.upload.behaviors.AjaxFileUploadBehavior.java
License:Apache License
/** * Create a multi-part request containing uploading files that supports disk caching. * * @param request//from w w w . j av a2 s . c o m * @return the multi-part request or exception thrown if there's any error. * @throws FileUploadException */ private MultipartServletWebRequest createMultipartWebRequest(final ServletWebRequest request) throws FileUploadException { DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory( Application.get().getResourceSettings().getFileCleaner()) { @Override public FileItem createItem(String fieldName, String contentType, boolean isFormField, String fileName) { FileItem item = super.createItem(fieldName, contentType, isFormField, fileName); return new TemporaryFileItem(item); } }; try { long contentLength = Long.valueOf(request.getHeader("Content-Length")); if (contentLength > 0) { return request.newMultipartWebRequest(Bytes.bytes(contentLength), container.getPage().getId(), diskFileItemFactory); } else { throw new FileUploadException("Invalid file upload content length"); } } catch (NumberFormatException e) { throw new FileUploadException("Invalid file upload content length", e); } }
From source file:org.hippoecm.frontend.plugins.jquery.upload.behaviors.AjaxFileUploadBehavior.java
License:Apache License
private void setResponse(final ServletWebRequest request, final String responseContent) { final Application app = Application.get(); final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding(); final String contentType; if (wantsHtml(request)) { contentType = "text/html; charset=" + encoding; } else {//ww w. j av a2 s.com contentType = APPLICATION_JSON; } TextRequestHandler textRequestHandler = new TextRequestHandler(contentType, encoding, responseContent); RequestCycle.get().scheduleRequestHandlerAfterCurrent(textRequestHandler); }
From source file:org.hippoecm.frontend.plugins.login.LoginPanel.java
License:Apache License
protected void loginFailed(final Cause cause) { Main main = (Main) Application.get(); main.resetConnection(); info(getReason(cause)); }
From source file:org.hippoecm.frontend.plugins.standards.ClassResourceModel.java
License:Apache License
@Override protected String load() { Iterator<IStringResourceLoader> iter = Application.get().getResourceSettings().getStringResourceLoaders() .iterator();/*from w ww . j a va 2s . c om*/ String value = null; while (iter.hasNext()) { IStringResourceLoader loader = iter.next(); value = loader.loadStringResource(clazz, key, locale, style, null); if (value != null) { break; } } if (value != null) { if (parameters != null) { final MessageFormat format = new MessageFormat(value, locale); value = format.format(parameters); } return value; } if (RuntimeConfigurationType.DEVELOPMENT.equals(Application.get().getConfigurationType())) { throw new RuntimeException("No translation found for " + this); } else { return key; } }
From source file:org.hippoecm.frontend.plugins.yui.header.CachedYuiDependencyResolver.java
License:Apache License
public static Set<YuiDependency> getDependencies(YuiNamespace ns, String module) { Application application = Application.get(); synchronized (cache) { if (!cache.containsKey(application)) { cache.put(application, new CacheEntry(application)); }//from w ww .j a v a 2 s . co m return cache.get(application).getDependencies(ns, module); } }
From source file:org.hippoecm.frontend.plugins.yui.header.YuiHeaderCache.java
License:Apache License
private static boolean isCacheEnabled() { return Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEPLOYMENT); }
From source file:org.hippoecm.frontend.plugins.yui.header.YuiHeaderCache.java
License:Apache License
private static boolean isDebugEnabled() { return Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT); }
From source file:org.hippoecm.frontend.plugins.yui.header.YuiHeaderCache.java
License:Apache License
public void renderHead(IHeaderResponse response) { if (loadWicketAjax) { CoreLibrariesContributor.contributeAjax(Application.get(), response); }//from w ww . ja va2 s . co m ; final WebRequest req = (WebRequest) RequestCycle.get().getRequest(); if (!req.isAjax()) { for (CachedHeaderItem contrib : referencesCache.values()) { contrib.rendered = false; } for (ModuleSet set : moduleSetsCache.values()) { set.rendered = false; } for (Module mod : moduleCache.values()) { mod.rendered = false; } } localContext.renderHead(response); }
From source file:org.hippoecm.frontend.plugins.yui.upload.validation.DefaultUploadValidationService.java
License:Apache License
/** * Check if the defaultMaximumUploadSize stored in the IApplicationSettings is set explicitly and only * then used it, otherwise use DEFAULT_MAX_FILE_SIZE. This is because it is set to Bytes.MAX * by default which is a bit overkill (8388608T). * * @return The String value of the default maximum file size for an upload */// w w w.ja v a 2s .co m protected String getDefaultMaxFileSize() { IApplicationSettings settings = Application.get().getApplicationSettings(); Bytes defaultSize = settings.getDefaultMaximumUploadSize(); return Bytes.MAX.equals(defaultSize) ? DEFAULT_MAX_FILE_SIZE : defaultSize.toString(); }
From source file:org.hippoecm.frontend.session.PluginUserSession.java
License:Apache License
/** * Retrieve the JCR {@link javax.jcr.Session} that is bound to the Wicket {@link org.apache.wicket.Session}. This * method will throw a RestartResponseException when no JCR session is available. *//* w ww . j ava2s . c o m*/ public Session getJcrSession() { Session session = getJcrSessionInternal(); if (session == null) { Main main = (Main) Application.get(); if (fallbackCredentials == null) { try { main.getRepository(); // side effect of reinitializing fallback credentials } catch (RepositoryException ignored) { } } if (fallbackSession == null) { try { fallbackSession = JcrSessionModel.login(fallbackCredentials); } catch (RepositoryException e) { log.warn("Cannot login fallback session: " + e.getMessage()); } } session = fallbackSession; if (session == null) { main.resetConnection(); throw new RepositoryUnavailableException("Repository is not available."); } } else if (fallbackSession != null) { fallbackSession.logout(); fallbackSession = null; } return session; }