private ResourceFile getDeviceClassResolverResourceFile(SiteEntity site) { ResourceKey deviceClassResolverResourceKey = site.getDeviceClassResolver(); if (deviceClassResolverResourceKey == null) { return null; } return getResolverScript(deviceClassResolverResourceKey); }
public void addCommonParameters( AdminService admin, User user, HttpServletRequest request, Map<String, Object> parameters, int unitKey, int menuKey) { if (user != null) { UserEntity userEntity = securityService.getUser(user); parameters.put("currentuser_key", userEntity.getKey().toString()); parameters.put("current_uid", userEntity.getName()); parameters.put("currentuser_uid", userEntity.getName()); parameters.put("currentuser_fullname", userEntity.getDisplayName()); parameters.put("currentuser_qualifiedname", userEntity.getQualifiedName()); parameters.put( "currentuser_email", userEntity.getEmail() != null ? userEntity.getEmail() : ""); parameters.put("currentuser_has_photo", userEntity.hasPhoto()); } if (unitKey != -1) { UnitEntity unit = unitDao.findByKey(unitKey); parameters.put("unitname", unit.getName()); parameters.put("selectedunitkey", String.valueOf(unitKey)); } if (menuKey != -1) { SiteEntity site = siteDao.findByKey(menuKey); if (site != null) { parameters.put("menuname", site.getName()); parameters.put("menukey", String.valueOf(menuKey)); } } if (!parameters.containsKey("referer") && request.getHeader("referer") != null) { parameters.put("referer", request.getHeader("referer")); } }
@Before public void before() { fixture = new DomainFixture(hibernateTemplate); factory = new DomainFactory(fixture); fixture.initSystemData(); fixture.createAndStoreUserAndUserGroup( "testuser", "testuser fullname", UserType.NORMAL, "testuserstore"); httpServletRequest.setCharacterEncoding("UTF-8"); ServletRequestAccessor.setRequest(httpServletRequest); loginUserInPortal(fixture.findUserByName("testuser").getKey()); previewService = Mockito.mock(PreviewService.class); Mockito.when(previewService.isInPreview()).thenReturn(false); Mockito.when(previewService.getPreviewContext()).thenReturn(PreviewContext.NO_PREVIEW); imageController.setPreviewService(previewService); MockTimeService timeService = new MockTimeService(new DateTime(2011, 6, 27, 12, 0, 0, 0)); imageController.setTimeService(timeService); site1 = factory.createSite("MySite", new Date(), null, "en"); fixture.save(site1); MenuItemEntity firstPage = createPage("Firstpage", null, "MySite"); fixture.save(firstPage); site1.setFirstPage(firstPage); fixture.flushAndClearHibernateSesssion(); fixture.save( factory.createContentHandler( "Image content", ContentHandlerName.IMAGE.getHandlerClassShortName())); fixture.save( factory.createContentType( "ImageContentType", ContentHandlerName.IMAGE.getHandlerClassShortName())); fixture.save(factory.createUnit("ImageUnit")); fixture.save( factory.createCategory( "ImageCategory", "ImageContentType", "ImageUnit", "testuser", "testuser")); fixture.save( factory.createCategoryAccessForUser("ImageCategory", "testuser", "read, create, approve")); fixture.flushAndClearHibernateSesssion(); }
private void injectMenuItemToSiteEntityResolver(String localPath, MenuItemEntity menuItem) { when(site.resolveMenuItemByPath(new Path(localPath))).thenReturn(menuItem); }
private void injectRootPageOnSite(MenuItemEntity rootMenuItem) { when(site.getFrontPage()).thenReturn(rootMenuItem); }
private void setPathInfoAndRequestURI( MockHttpServletRequest httpServletRequest, String imageRequestPath) { httpServletRequest.setRequestURI("/site/" + site1.getKey() + "/" + imageRequestPath); httpServletRequest.setPathInfo("/" + site1.getKey() + "/" + imageRequestPath); }
protected String createForcedValueKey(SiteEntity site) { return DEVICE_CLASS_FORCED_BASE_NAME + site.getKey(); }
private String createSiteSessionBaseName(SiteEntity site) { return DEVICE_CLASS_CACHE_BASE_NAME + site.getKey().toInt(); }
private String createForcedDeviceClassKey(SiteEntity site) { return DEVICE_CLASS_FORCED_BASE_NAME + site.getKey(); }