Commit 1a9701bf authored by Szabolcs Gyurko's avatar Szabolcs Gyurko
Browse files

Fixed POM defects and changed couple of logic part

parent 9acf2ddc
Pipeline #319 passed with stage
in 3 minutes and 51 seconds
......@@ -71,10 +71,6 @@
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!-- Lombok for generating getters/setters -->
<dependency>
......@@ -90,11 +86,6 @@
</dependency>
<!-- JAXB -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
......
......@@ -72,13 +72,6 @@
<artifactId>spring-security-oauth2</artifactId>
</dependency>
<!-- Lombok for generating getters/setters -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- Actuator for exposing management endpoints -->
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -52,14 +52,16 @@ public class ComponentToNodePropertiesConverter implements Converter<com.jeff_cm
styles.setName(componentPrefix + "styles");
styles.setValues(new ArrayList<>(component.getStyles()));
final List<NodeProperty> properties = component.getData().entrySet().stream().map(e -> {
final NodeProperty property = new NodeProperty();
final List<NodeProperty> properties = component.getData().entrySet().stream()
.map(e -> {
final NodeProperty property = new NodeProperty();
property.setName(componentPrefix + e.getKey());
property.setValues(e.getValue());
property.setName(componentPrefix + e.getKey());
property.setValues(e.getValue());
return property;
}).collect(Collectors.toList());
return property;
})
.collect(Collectors.toList());
properties.add(scripts);
properties.add(headScripts);
......
......@@ -25,12 +25,14 @@ package com.jeff_cms.jeff.web.converter;
*/
import com.jeff_cms.jeff.model.NodeProperty;
import com.jeff_cms.jeff.util.Pair;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
......@@ -38,6 +40,13 @@ import java.util.stream.Collectors;
*/
@Component
public class NodePropertiesToComponentConverter implements Converter<List<NodeProperty>, com.jeff_cms.jeff.web.model.Component> {
/* This predicate disallows the reserved property names to be returned as part of component data */
private static final Predicate<Pair<NodeProperty, String>> RESERVED_NODE_PROPERTY_PREDICATE = d ->
!d.getFirst().getName().equals(d.getSecond() + "styles")
&& !d.getFirst().getName().equals(d.getSecond() + "scripts")
&& !d.getFirst().getName().equals(d.getSecond() + "headScripts")
&& !d.getFirst().getName().equals(d.getSecond());
@Override
public com.jeff_cms.jeff.web.model.Component convert(final List<NodeProperty> properties) {
final com.jeff_cms.jeff.web.model.Component component = new com.jeff_cms.jeff.web.model.Component();
......@@ -54,7 +63,8 @@ public class NodePropertiesToComponentConverter implements Converter<List<NodePr
final NodeProperty nodeProperty = new NodeProperty();
nodeProperty.setValues(Collections.emptyList());
return nodeProperty;
}).getValues()
})
.getValues()
)
);
component.setScripts(new HashSet<>(
......@@ -65,7 +75,8 @@ public class NodePropertiesToComponentConverter implements Converter<List<NodePr
final NodeProperty nodeProperty = new NodeProperty();
nodeProperty.setValues(Collections.emptyList());
return nodeProperty;
}).getValues()
})
.getValues()
)
);
component.setStyles(new HashSet<>(
......@@ -76,14 +87,12 @@ public class NodePropertiesToComponentConverter implements Converter<List<NodePr
final NodeProperty nodeProperty = new NodeProperty();
nodeProperty.setValues(Collections.emptyList());
return nodeProperty;
}).getValues()
})
.getValues()
)
);
component.setData(properties.stream().filter(p ->
!p.getName().equals(componentPrefix + "styles")
&& !p.getName().equals(componentPrefix + "scripts")
&& !p.getName().equals(componentPrefix + "headScripts")
&& !p.getName().equals(componentPrefix))
component.setData(properties.stream()
.filter(p -> RESERVED_NODE_PROPERTY_PREDICATE.test(Pair.of(p, componentPrefix)))
.map(np -> {
final NodeProperty nodeProperty = new NodeProperty();
nodeProperty.setName(np.getName().replaceAll("jc_[0-9a-z\\-]+_(.+)", "$1"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment