List of usage examples for org.apache.wicket.util.resource StringResourceStream setLastModified
public void setLastModified(final Time lastModified)
From source file:com.servoy.j2db.server.headlessclient.FormCssResource.java
License:Open Source License
/** * @see org.apache.wicket.Resource#getResourceStream() *//*ww w. j a v a 2s . c o m*/ @Override public IResourceStream getResourceStream() { String css = ""; ValueMap params = getParameters(); Long time = null; if (params.size() == 1) { Iterator iterator = params.entrySet().iterator(); if (iterator.hasNext()) { Map.Entry entry = (Entry) iterator.next(); String solutionName = (String) entry.getKey(); Pair<String, Long> filterTime = filterTime((String) entry.getValue()); String formInstanceName = filterTime.getLeft(); time = filterTime.getRight(); String solutionAndForm = solutionName + "/" + formInstanceName; //$NON-NLS-1$ String templateDir = "default"; //$NON-NLS-1$ IServiceProvider sp = null; Solution solution = null; Form form = null; if (Session.exists()) { sp = WebClientSession.get().getWebClient(); if (sp != null) { IForm fc = ((WebClient) sp).getFormManager().getForm(formInstanceName); if (fc instanceof FormController) { FlattenedSolution clientSolution = sp.getFlattenedSolution(); form = clientSolution.getForm(((FormController) fc).getForm().getName()); } } templateDir = WebClientSession.get().getTemplateDirectoryName(); } final String fullpath = "/servoy-webclient/templates/" + templateDir + "/" + solutionAndForm + ".css"; try { URL url = context.getResource(fullpath); if (url != null) { return new NullUrlResourceStream(url); } } catch (Exception e) { Debug.error(e); } try { IApplicationServerSingleton as = ApplicationServerRegistry.get(); RootObjectMetaData sd = as.getLocalRepository().getRootObjectMetaData(solutionName, IRepository.SOLUTIONS); if (sd != null) { solution = (Solution) as.getLocalRepository().getActiveRootObject(sd.getRootObjectId()); if (form == null) { form = solution.getForm(formInstanceName); } } if (form != null) { Pair<String, String> formHTMLAndCSS = TemplateGenerator.getFormHTMLAndCSS(solution, form, sp, formInstanceName); css = formHTMLAndCSS.getRight(); } } catch (Exception e) { Debug.error(e); } } } StringResourceStream stream = new StringResourceStream(css, "text/css"); //$NON-NLS-1$ stream.setLastModified(time != null ? Time.valueOf(time.longValue()) : null); return stream; }