/******************************************************************************************************************* * * * ******************************************************************************************************************/ private void appendTitle (final @Nonnull StringBuilder builder, final @Nonnull ResourceProperties siteNodeProperties) throws IOException { try { builder.append(String.format("<h2>%s</h2>%n", siteNodeProperties.getProperty(PROPERTY_TITLE))); } catch (NotFoundException e) { // ok, no title } }
@Override public <Type> void setDynamicNodeProperty (final @Nonnull Key<Type> key, final @Nonnull Type value) { ResourceProperties properties = dynamicNodePropertiesHolder.get(); dynamicNodePropertiesHolder.set(properties.withProperty(key, value)); }
/******************************************************************************************************************* * * FIXME: move to ResourceProperties! * ******************************************************************************************************************/ private void logProperties (final @Nonnull String indent, final @Nonnull ResourceProperties properties) { log.debug("{} property items:", indent); for (final Key<?> key : properties.getKeys()) { try { log.debug("{}>>>> {} = {}", indent, key, properties.getProperty(key)); } catch (NotFoundException | IOException e) { log.error("", e); } } log.debug("{} property groups: {}", indent, properties.getGroupIds()); for (final Id groupId : properties.getGroupIds()) { log.debug("{}>>>> group: {}", indent, groupId); logProperties(indent + ">>>>", properties.getGroup(groupId)); } } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public ResourceProperties merged (@Nonnull ResourceProperties properties) { final DefaultResourceProperties otherProperties = (DefaultResourceProperties)properties; if (!id.equals(otherProperties.id)) { throw new IllegalArgumentException("Id mismatch " + id + " vs " + otherProperties.id); } ResourceProperties result = new DefaultResourceProperties(this); for (final Entry<Key<?>, Object> entry : otherProperties.propertyMap.entrySet()) { result = result.withProperty((Key<Object>)entry.getKey(), entry.getValue()); } for (final Entry<Id, DefaultResourceProperties> entry : otherProperties.groupMap.entrySet()) { final Id groupId = entry.getKey(); final ResourceProperties propertyGroup = entry.getValue(); result = (!groupMap.containsKey(groupId)) ? result.withProperties(propertyGroup) : result.withProperties(groupMap.get(groupId).merged(propertyGroup)); } return result; }
/******************************************************************************************************************* * ******************************************************************************************************************/ @BeforeMethod public void setup() throws Exception { context = new ClassPathXmlApplicationContext("DefaultMetadataTestBeans.xml"); context.getBean(MetadataInterpolatorFactory.class); // initialize it properties = mock(ResourceProperties.class); final ResourceProperties resourceProperties = mock(ResourceProperties.class); when(resourceProperties.getProperty(PROPERTY_LENS_IDS)).thenReturn(Arrays.asList("1:Lens1", "2:Lens2")); when(properties.getGroup(PROPERTY_GROUP_ID)).thenReturn(resourceProperties); }
@Cleanup final InputStream is = propertyFile.getInputStream(); final ResourceProperties tempProperties = modelFactory.createProperties().build().as(Unmarshallable).unmarshal(is); properties = properties.merged(tempProperties); tmpPlaceHolder &= !propertyFile.getParent().equals(file); placeHolder = properties.getBooleanProperty(PROPERTY_PLACE_HOLDER, tmpPlaceHolder);
/******************************************************************************************************************* * ******************************************************************************************************************/ @BeforeMethod public void setup() { ContextManager.Locator.set(null); context = new ClassPathXmlApplicationContext("DefaultStructureEditorPresentationControlTestBeans.xml"); underTest = context.getBean(DefaultStructureEditorPresentationControl.class); presentation = context.getBean(StructureEditorPresentation.class); siteNode = mock(SiteNode.class); properties = mock(ResourceProperties.class); presentable = mock(Presentable.class); pm = mock(PresentationModel.class); when(siteNode.getProperties()).thenReturn(properties); when(presentable.createPresentationModel(anyVararg())).thenReturn(pm); when(properties.as(eq(Presentable))).thenReturn(presentable); }
final int maxFullItems = componentProperties.getIntProperty(PROPERTY_MAX_FULL_ITEMS, 99); final int maxLeadinItems = componentProperties.getIntProperty(PROPERTY_MAX_LEADIN_ITEMS, 99); final int maxItems = componentProperties.getIntProperty(PROPERTY_MAX_ITEMS, 99); post.getProperties().getProperty(PROPERTY_TITLE); // Skip folders used for categories - this throws exception
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull private ResourceProperties loadProperties() throws IOException { final ResourceFile file = getFile(); log.debug("loadProperties() for {}", file.getPath().asString()); ResourceProperties properties = modelFactory.createProperties().withPropertyResolver(propertyResolver).build(); try { final ResourceFile propertyFile = file.findChildren().withName("Properties.xml").result(); // FIXME reuse the inheritance helper // log.trace(">>>> reading properties from {} ({})...", propertyFile.getPath().asString(), locale); @Cleanup final InputStream is = propertyFile.getInputStream(); final ResourceProperties tempProperties = // modelFactory.createProperties().build().as(Unmarshallable).unmarshal(is); modelFactory.createProperties().withPropertyResolver(propertyResolver).build().as(Unmarshallable).unmarshal(is); // log.trace(">>>>>>>> read properties: {} ({})", tempProperties, locale); properties = properties.merged(tempProperties); } catch (NotFoundException e) { // ok, no properties } return properties; } }
final boolean index = siteNodeProperties.getBooleanProperty(PROPERTY_INDEX, false); final List<Content> allPosts = findAllPosts(siteNodeProperties); final List<Content> posts = new ArrayList<>();
@Override @Nonnull public ResourceProperties getNodeProperties() { if (contentHolder.get() == null) // FIXME: should never occur { log.warn("NO CONTENT IN CONTEXT"); // Thread.dumpStack(); // FIXME return dynamicNodePropertiesHolder.get(); } return nodeHolder.get().getProperties().merged(dynamicNodePropertiesHolder.get()); }
final SiteNode rootSiteNode = site.find(SiteNode).withRelativeUri("/").result(); final ResourceProperties rootSiteNodeProperties = rootSiteNode.getProperties(); final ResourceProperties properties = rootSiteNodeProperties.getGroup(PROPERTY_GROUP_ID); for (final String permanentRedirectConfig : properties.getProperty(PROPERTY_PERMANENT_REDIRECTS))
/* visible for testing */ void onSiteNodeSelected (final @ListensTo @Nonnull SiteNodeSelectedEvent selectionEvent) { log.debug("onSiteNodeSelected({})", selectionEvent); if (!selectionEvent.getSiteNode().isPresent()) { presentation.clear(); } else { final SiteNode siteNode = selectionEvent.getSiteNode().get(); final ResourceProperties properties = siteNode.getProperties(); log.debug(">>>> properties: {}", properties); presentation.populate("Viewer not implemented for " + siteNode.getFile()); presentation.populateProperties(properties.as(Presentable).createPresentationModel()); presentation.showUp(); } } }
final String entries = siteNodeProperties.getProperty(PROPERTY_ENTRIES); final StringBuilder builder = new StringBuilder(); final int selectedYear = viewProperties.getIntProperty(PROPERTY_SELECTED_YEAR, currentYear); final int firstYear = viewProperties.getIntProperty(PROPERTY_FIRST_YEAR, Math.min(selectedYear, currentYear)); final int lastYear = viewProperties.getIntProperty(PROPERTY_LAST_YEAR, Math.max(selectedYear, currentYear)); final int columns = 4;
final boolean tagCloud = siteNodeProperties.getBooleanProperty(PROPERTY_TAG_CLOUD, false);
/******************************************************************************************************************* * * Appends the title. * ******************************************************************************************************************/ private void appendTitle (final @Nonnull ResourceProperties contentProperties, final @Nonnull StringBuilder htmlBuilder, final @Nonnull String titleMarkup) throws IOException { try { final String title = contentProperties.getProperty(PROPERTY_TITLE); htmlBuilder.append(String.format("<%s>%s</%s>%n", titleMarkup, title, titleMarkup)); } catch (NotFoundException e) { // ok, no title } }
/******************************************************************************************************************* * ******************************************************************************************************************/ @BeforeMethod public void setup() { ContextManager.Locator.set(null); context = (ClassPathXmlApplicationContext)helper.createSpringContext(); underTest = context.getBean(DefaultContentEditorPresentationControl.class); embeddedServer = context.getBean(EmbeddedServer.class); presentation = context.getBean(ContentEditorPresentation.class); content = mock(Content.class); properties = mock(ResourceProperties.class); presentable = mock(Presentable.class); pm = mock(PresentationModel.class); propertyBinder = mock(PropertyBinder.class); when(embeddedServer.putDocument(anyString(), any(Document.class))).thenReturn(registeredUrl); when(content.getProperties()).thenReturn(properties); when(presentable.createPresentationModel(anyVararg())).thenReturn(pm); when(properties.as(eq(Presentable))).thenReturn(presentable); when(properties.as(eq(PropertyBinder))).thenReturn(propertyBinder); document = new Document().withContent("proxy for: full text") .withMimeType("text/html"); when(propertyBinder.createBoundDocument(any(Key.class), any(PropertyBinder.UpdateCallback.class))) .thenAnswer(invocation -> document); underTest.initialize(); }
@BeforeClass public void prepareProperties() { factory = new AdminModelFactory(); properties = factory.createProperties().build() .withProperty(Properties.PROPERTY_CREATION_TIME2, new DateTime(1342536534636L)) .withProperty(Properties.PROPERTY_TITLE, "the title"); PropertyUtilities.setLocale(Locale.UK); PropertyUtilities.setZone(DateTimeZone.forID("CET")); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull private DateTime getSiteNodeDateTime (final @Nonnull ResourceProperties properties) { final DateTimeFormatter isoFormatter = ISODateTimeFormat.dateTime(); try { return isoFormatter.parseDateTime(properties.getProperty(Properties.PROPERTY_LATEST_MODIFICATION_DATE)); } catch (NotFoundException e) { } catch (IOException e) { log.warn("", e); } return new DateTime(0); } }
/******************************************************************************************************************* * ******************************************************************************************************************/ @BeforeMethod public void setup() throws IOException { ContextManager.Locator.set(new DefaultContextManagerProvider()); modelFactory = new ModelFactorySupport() { @Override @Nonnull public ResourceProperties build (final @Nonnull ResourceProperties.Builder builder) { return new DefaultResourceProperties(builder); } }; properties = modelFactory.createProperties().build().withProperty(PROPERTY_1, ORIGINAL_PROPERTY_1_VALUE) .withProperty(PROPERTY_2, ORIGINAL_PROPERTY_2_VALUE); callback = mock(UpdateCallback.class); underTest = new ResourcePropertiesBinder(properties); }