/** * Persists a page to the file system. * @param pageInstance the live PageInstance containing the Page to save. * @return the file where the page was saved. * @throws Exception in case the save fails. */ public static File savePage(PageInstance pageInstance) throws Exception { return savePage(pageInstance.getDirectory(), pageInstance.getPage()); }
public Page getChildPage(String name) throws Exception { File childDirectory = getChildPageDirectory(name); return DispatcherLogic.getPage(childDirectory); }
@Override public ResourceResolver getResourceResolver() { return getParent().getResourceResolver(); }
protected void buildCopyPageForm() { PageInstance pageInstance = dispatch.getLastPageInstance(); SelectionProvider pagesSelectionProvider = DispatcherLogic.createPagesSelectionProvider (pagesDir, true, true, pageInstance.getDirectory()); copyForm = new FormBuilder(CopyPage.class) .configReflectiveFields() .configSelectionProvider(pagesSelectionProvider, "destinationPagePath") .build(); }
protected Object initSubResource(Object resource, FileObject location, String segment) { if(resource instanceof Resource) { Resource subResource = (Resource) resource; subResource.setParent(this); subResource.setLocation(location); subResource.setSegment(segment); initGenericResource(resource); initSubResource(subResource); return subResource.init(); } else { initGenericResource(resource); return resource; } }
/** * Reconstructs the URL path to this PageInstance from the root of the application (not including the * webapp's context path). */ public String getPath() { if(getParent() == null) { return ""; } else { return getParent().getPath() + "/" + getUrlFragment(); } }
public Class<? extends ActionBean> getActionBeanClass() { return getLastPageInstance().getActionClass(); }
public Root() { Page rootPage = DispatcherLogic.getPage(pagesDirectory); pageInstance = new PageInstance(null, pagesDirectory, rootPage, null); }
protected Dispatch getDispatch(String path) { HttpServletRequest request = ElementsThreadLocals.getHttpServletRequest(); Dispatcher dispatcher = DispatcherUtil.get(request); return dispatcher != null ? dispatcher.getDispatch(path) : null; }
public static Dispatch getDispatch(HttpServletRequest request) { Dispatcher dispatcher = get(request); return getDispatch(dispatcher, request); }
@Override public PageAction getParent() { return pageInstance.getParent().getActionBean(); }
public PageInstance getPageInstance(int index) { if(index >= 0) { return getPageInstancePath()[index]; } else { return getPageInstancePath()[getPageInstancePath().length + index]; } }
public static SelectionProvider createPagesSelectionProvider (File baseDir, File... excludes) { return createPagesSelectionProvider(baseDir, false, false, excludes); }
public Object getSubResource(FileObject resourceLocation, String segment, ResourceResolver resourceResolver) throws Exception { Class<?> subResourceClass = resourceResolver.resolve(resourceLocation, Class.class); if(subResourceClass == null) { logger.debug("Subresource could not be resolved"); return null; } else { return createSubResource(subResourceClass, resourceLocation, segment); } }
@Override public boolean supports(String extension) { for(ResourceResolver resourceResolver : resourceResolvers) { if(resourceResolver.supports(extension)) { return true; } } return false; }
@Override public void handleReset(CacheResetEvent e) { DispatcherLogic.clearConfigurationCache(); } }
@Override public FileObject resolve(FileObject location) throws FileSystemException { //TODO cache this too? return delegate.resolve(location); }
protected void buildMovePageForm() { PageInstance pageInstance = dispatch.getLastPageInstance(); SelectionProvider pagesSelectionProvider = DispatcherLogic.createPagesSelectionProvider (pagesDir, true, true, pageInstance.getDirectory()); moveForm = new FormBuilder(MovePage.class) .configReflectiveFields() .configSelectionProvider(pagesSelectionProvider, "destinationPagePath") .build(); }
@Override public boolean supports(Class<?> type) { for(ResourceResolver resourceResolver : resourceResolvers) { if(resourceResolver.supports(type)) { return true; } } return false; }