Giter Site home page Giter Site logo

dd4t-2-java's People

Contributors

alebastrov avatar dependabot[bot] avatar dretch avatar haraldhoffelinck avatar jhorsman avatar jonathanprimmer avatar jsalinaspolo avatar kieranshaw avatar mbilenko-sdl avatar nikondsl avatar quirijnslings avatar raimondkempees avatar rogieroudshoorn avatar rsleggett avatar themixed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dd4t-2-java's Issues

Rework the ComponentPresentationProvider for the version 2 TBBs

Now that the DD4T TBBS support publishing a full ComponentPresentation node in the Json, we can remove the ugly hacks in https://github.com/dd4t/dd4t-2-java/blob/develop/dd4t-providers/src/main/java/org/dd4t/providers/impl/BrokerComponentPresentationProvider.java.

This provider should have no dependency anymore on the org.dd4t.contentmodel.ComponentPresentation model, but should give back a String with the uncompressed Json content, just as in the other providers

Note: be sure to handle the Component Template metadata properly!

LastPublishDate in models

The DD4T JSON datamodel published by the Content Manager contains LastPublishedDate for pages, components, component links, etc. This LastPublishedDate is placeholder data since it cannot be published from the Content Manager, it has to be retrieved from the CD broker.

Currently the LastPublishedDate is not available in the DD4T models, or anywhere else in DD4T. It would be great to have this added.

Example: "RevisionDate":"2015-03-17T10:39:15.827","Filename":"index","LastPublishedDate":"0001-01-01T00:00:00","PageTemplate":

XPM path missing for Component Field(MULTIMEDIALINK/COMPONENTLINK) in View Model

We have view model content Java class as follows,

public class HomeHeader extends TridionViewModelBase {

    @ViewModelProperty(entityFieldName = "help_text")
    private String helpText;

    @ViewModelProperty(entityFieldName = "logo_image")
    private Component logoImage;

    @ViewModelProperty(entityFieldName = "banner_image")
    private Component bannerImage;
}

viewmodel bean class's FieldMap not having the XPath information for Component fields.(Even after changing Component type to MultiMediaImpl or ComponentImpl , could not find XPath info).

{help_text=org.dd4t.databind.viewmodel.base.TridionViewModelBase$XPMInfo@63869a2e }

JSON as follows,
json

Refactor Rich Text resolving

dd4t-2-java now has too many ways to do Rich Text resolving. Refactor the mechanism and align with the DD4T 2 .Net project.

Question: How to get Metadata of Multimedia Schema

Inside Tridion 2013 SP1 we have a:
Multimedia Schema "Image" with Metadata "attributes" type Embedded Schema

From Java application running DD4T 2.0.4
How to retrieve the values inside the Embedded Schema "attributes"

Sanitize the RenderUtils a bit more

In DD4T 2, the RenderUtils were sanitised, but some more work needs to be done on it to clean it up. This is now possible because the DD4T 2.0 TBBs give back ComponentPresentations in the published Json.

Question: AbstractPageController getPageViewName viewName?

Inside DD4T 2.0.4 and lower (checked till 2.0.2)
the class org.dd4t.mvc.controllers.AbstractPageController and method getPageViewName
There is a hardcode look for metadata viewName.

With the template: 2.0.8
There is no meta schema in there that provides this field and it's not documented.

Do I have to create this myself?

Refactor publication resolving

Publication resolving is in need of a bit of an overhaul. Design an implement a proper generic way of resolving Publication Ids based on incoming URL information.

This issue must have unit tests for all flows where this is used, as this is more complex than it seems.

dd4t core includes com.tridion.cache.CacheEvent class, leading to serialization issues

In the dd4t-core module a class is included which also exists in the standard Tridion product jar files: com.tridion.cache.CacheEvent (part of Tridion cd_cache.jar).

Even though both versions are the same on source level this still leads to issues in certain cases. As both versions do not define a serialVersionUID these are generated on compile time. And (depending on compiler, etc) are not the same.

In our scenario we are using JMS queues for cache invalidation. The CacheEvent is serialized and sent as a JMS message. This currently does not work because it throws java.io.InvalidClassException with two different serialVersionUID values (one that matches the compiled version in the DD4T jar and one that matches the compiled version in the Tridion jar). The sender (deployer) sends the original Tridion versoin and the receiver (webapp) uses the DD4T version.

Ideally the com.tridion.cache.CacheEvent class should not be included in the DD4T jars. So the best solution would be to remove this. If this is not possible then the alternative would be to include a serialVersionUID which matches the one that is in the Tridion provided jar (however, this could break very easily anytime an updated version of the Tridion jar is used).

Images looses quality when resizing

We have noticed that the picture loses quality when resizing. The reason for this disparity in quality is due to the different filtering algorithms in use. If downscaling by more than two times, the BILINEAR and BICUBIC algorithms tend to lose information due to the way pixels are sampled from the source image; the older AreaAveragingFilter algorithm used by Image.getScaledInstance() is quite different and does not suffer from this problem as much, but it requires much more processing time in general.

To combat this issue, you can use a multi-step approach when downscaling by more than two times; this helps prevent the information loss issue and produces a much higher quality result.

You need to use several resizing steps in order to get a good image. The helper method for scaling image is below.

public static BufferedImage getScaledInstance(BufferedImage img,
        int targetWidth, int targetHeight, int type, boolean higherQuality) {
    BufferedImage ret = (BufferedImage) img;
    int w, h;
    if (higherQuality) {
        // Use multi-step technique: start with original size, then
        // scale down in multiple passes with drawImage()
        // until the target size is reached
        w = img.getWidth();
        h = img.getHeight();
    } else {
        // Use one-step technique: scale directly from original
        // size to target size with a single drawImage() call
        w = targetWidth;
        h = targetHeight;
    }
    do {
        if (higherQuality && w > targetWidth) {
            w /= 2;
            if (w < targetWidth) {
                w = targetWidth;
            }
        }
        if (higherQuality && h > targetHeight) {
            h /= 2;
            if (h < targetHeight) {
                h = targetHeight;
            }
        }

        BufferedImage tmp = new BufferedImage(w, h, type);
        Graphics2D g2 = tmp.createGraphics();
        g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        g2.setRenderingHint(RenderingHints.KEY_RENDERING,
                RenderingHints.VALUE_RENDER_QUALITY);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        g2.drawImage(ret, 0, 0, w, h, null);
        g2.dispose();

        ret = tmp;
    } while (w != targetWidth || h != targetHeight);

    return ret;
 }

Attached images showing original image resized using single shot and new improved iterative method. The image quality is improved visually.
highquality
lowquality

Custom Component MetaData deserialization failure during JSON binding

We are having component metadata field called 'session' which is dropdown in Tridion CMS. we are upgrading to DD4T 2.0.4 version(Earlier version 2.0.1-beta) and got below exception,

java.io.IOException: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.dd4t.contentmodel.Keyword, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information at [Source: N/A; line: -1, column: -1] (through reference chain: org.dd4t.contentmodel.impl.ComponentImpl["MetadataFields"]->java.util.LinkedHashMap["session"]->org.dd4t.contentmodel.impl.KeywordField["Keywords"]->java.util.ArrayList[0]) at org.dd4t.databind.serializers.json.ComponentPresentationDeserializer.renderComponentData(ComponentPresentationDeserializer.java:129) ~[ComponentPresentationDeserializer.class:na] at org.dd4t.databind.serializers.json.ComponentPresentationDeserializer.deserialize(ComponentPresentationDeserializer.java:113) ~[ComponentPresentationDeserializer.class:na] at org.dd4t.databind.serializers.json.ComponentPresentationDeserializer.deserialize(ComponentPresentationDeserializer.java:46) ~[ComponentPresentationDeserializer.class:na] at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3736) ~[ObjectMapper.class:2.6.4] at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2726) ~[ObjectMapper.class:2.6.4] at org.dd4t.databind.builder.json.JsonDataBinder.buildComponentPresentation(JsonDataBinder.java:94) ~[JsonDataBinder.class:na] at org.dd4t.databind.DataBindFactory.buildDynamicComponentPresentation(DataBindFactory.java:60) [DataBindFactory.class:na]

Session Type Schema Definition:
image

Published JSON content for session Type:

"session": { "Name": "session", "Value": "MORNING", "Values": [ "MORNING" ], "NumericValues": [], "DateTimeValues": [], "LinkedComponentValues": [], "FieldType": 3, "CategoryName": "Session Type", "CategoryId": "tcm:123-1234-512", "XPath": "tcm:Metadata/custom:Metadata/custom:session", "Keywords": [ { "Description": "", "Key": "", "TaxonomyId": "tcm:123-1234-512", "Path": "\\Session\\MORNING", "ParentKeywords": [], "MetadataFields": { "order": { "Name": "order", "Value": "1", "Values": [ "1" ], "NumericValues": [ 1 ], "DateTimeValues": [], "LinkedComponentValues": [], "FieldType": 8, "Keywords": [], "KeywordValues": [] } }, "Id": "tcm:123-1234-1024", "Title": "MORNING" } ], "KeywordValues": [ { "Description": "", "Key": "", "TaxonomyId": "tcm:123-1234-512", "Path": "\\Session\\Morning", "ParentKeywords": [], "MetadataFields": { "order": { "Name": "order", "Value": "1", "Values": [ "1" ], "NumericValues": [ 1 ], "DateTimeValues": [], "LinkedComponentValues": [], "FieldType": 8, "Keywords": [], "KeywordValues": [] } }, "Id": "tcm:123-1234-1024", "Title": "MORNING" } ] }

TBB version 2.0.8

I am guessing this issue occurs because of @JsonSetter ("Keywords") at line 231 points to interface instead of class, may be we need to add @JsonDeserialize (contentAs = KeywordImpl.class) (I am yet to customize and test it whether it works or not)

https://github.com/dd4t/dd4t-2-java/blob/develop/dd4t-core/src/main/java/org/dd4t/contentmodel/impl/BaseField.java

ViewModels are not created for DCPs

If a DCP is retrieved through the ComponentFactory, ViewModels are never correctly created. They are either missing altogether, or they have only empty properties (which contain 'null').
The problem becomes apparent in the JsonModelConverter. This class checks for the ComponentType of the JSON object, to find out if it should look at the content AND metadata (for regular components) or the metadata only (for multimedia components). If the content comes from a DCP, there is no ComponentType property at all. As a result, the JsonModelConverter has no 'field list' at its disposal to look for the values for the specified properties.
Why the ComponentType property is missing, is unclear to me.

Embedded field in embdded field is not mapped to view model on DD4T 2 Java version

This issues is posted to StackExchange too.
http://tridion.stackexchange.com/questions/12859/embedded-field-in-embdded-field-is-not-mapped-to-view-model-on-dd4t-2-java-versi

Summary is following.
On DD4T 2 Java version environment, I created view model class. But, when there is a embedded field in another embedded field, 2nd embedded field values are not mapped to view model instance, and I got following error. (1st embedded field's value is mapped to view model instance normally.)

Create JSTL tags for XPM support

While dd4t-core and dd4t-databind fully support XPM, there's no proper exposure in the form of a JSTL tag. Therefore, a tag function or class needs to be created in the dd4t.tld tag library

Need access to link resolving logic

As a developer I need access to a class in the framework which allows me to resolve dynamic links. For example: my ViewModel needs a resolved link to A. the underlying component itself, and B. another component to which the underlying component links.

AbstractBinaryController : After image re-sizing .tmp files are not getting deleted

fillResponse() method creates ".tmp" file during image re-sizing which is not deleted afterwards.

We can try something similar to delete the tmp file.

                   if (resizeToWidth == -1) {
                        saveBinary(binary, binaryFile);
                    } else {
                        File tempBinary = new File(path + ".tmp");
                        saveBinary(binary, tempBinary);
                        try (InputStream tempBinaryInputStream = new FileInputStream(tempBinary)) {
                            BufferedImage before = ImageIO.read(tempBinaryInputStream);

                            // other steps

                            ImageIO.write(after, getImageType(path), binaryFile);
                    }
                        Files.deleteIfExists(tempBinary.toPath());

image

SerializerFactory.java serializer is null

Inside the dispatcher-serlet:
<bean id="serializerFactory" class="org.dd4t.core.serializers.impl.SerializerFactory"> <constructor-arg name="serializerInstance" ref="serializer"/> </bean>

Inside SerializerFactory:
public SerializerFactory (final JSONSerializer serializerInstance) {}

The serializer = null when called

Archetype won't run on Tomcat in Eclipse

The dd4t archetype cannot be run on Tomcat combined with Eclipse Mars. The error shows that the dispatcher-servlet cannot be found. Root cause is that the WEB-INF\classes folder that contains the dispatcher-servlet.xml and other property/config files, is not part of the classpath.

Tested with Tomcat 7 in Eclipse Mars.

Multimedia missing properties

When getting a image from Tridion 2013 SP1
With DD4T 2.0.4 inside the ViewModel with the property Multimedia
It fields: height, width and alt are empty.

Expected:
Tridion - Java

Description - alt
NA - height (property of original image)
NA - width (property of original image)
NA - binaryData (raw binary data)

Rework the caching mechanism

In order to prevent serialisation issues, a better caching mechanism should be devised. In addition, the classes containing caching functionality are a candidate to be moved to the DD4T Providers project.

BrokerBinaryProvider does not return binaries

There are 2 major bugs in this class:

  1. The method "private Binary getBinary" contains the following line:

binaryDataBytes.setBytes(getBinaryContentById(binaryUri.getPublicationId(), binaryUri.getItemId()));

However, the signature of the getBinaryContentById method puts the ITEM id first and the PUBLICATION id second. No binaries are ever retrieved.

2.The method "public byte[] getBinaryContentById" contains the following code:

if (binaryData == null || binaryData.getDataSize() > 0 ) {
throw new ItemNotFoundException("Unable to find binary content by id: tcm:" + publication+"-"+id);
}

This means that an exception is thrown for binaries with a data size of MORE than 0. In other words: valid binaries always lead to an item not found exception.

How do I get the resolved URL for a component link?

org.dd4t.core.processors.impl.LinkingProcessor.resolveComponent(Component component) method does not set the resolved url for the component anywhere.
protected void resolveComponent (Component component) throws TransformerException {
try {
if (component != null) {
resolveMap(component.getContent());
resolveMap(component.getMetadata());
linkResolver.resolve(component);
}
} catch (ItemNotFoundException | SerializationException e) {
throw new TransformerException(e);
}
}

Binary.getLastPublishedDate always returns 'now'

The following code returns 2 different values for 'millis'. The values always represent 'now'.

Binary binary = brokerBinaryProvider.getBinaryByURL (binaryurl, 1);
System.out.println(binary.getLastPublishedDate().getMillis());
// wait for a second
binary = brokerBinaryProvider.getBinaryByURL (binaryurl, 1);
System.out.println(binary.getLastPublishedDate().getMillis());

In our implementation, we never get the real last published date. Could it be that this only works for multimedia components that are published as a DCP?

DataBindFactory.buildPage argument must extend Page

Currently, the DataBindFactory.buildPage requires a type argument which extends Item. See this snippet:

public static T buildPage(final String source,final Class aClass) throws SerializationException {
return INSTANCE.dataBinder.buildPage(source,aClass);
}

This is inconsistent with for example DataBindFactory.buildComponent, where the type argument extends Component.
Suggest to change this to:

public static T buildPage(final String source,final Class aClass) throws SerializationException {
return INSTANCE.dataBinder.buildPage(source,aClass);
}

Totally rework handling of Binary content

At the moment, the Binary provider and BinaryFactory is a bit of a mess. Design and refactor this functionality and keep in mind possible integration with XPM, SDL Mobile and SDL Media Manager.

Write Unit Tests

The following modules absolutely need unit tests:

  • dd4t-core (to be subdivided)
  • dd4t-providers
  • dd4t-databind
  • dd4t-compatibility

Context root is duplicated

When you run dd4t in a context path, an incorrect url is passed to the PageFactory. The context root path is duplicated.
So if your context root is /text:
/test/index.html
becomes:
/test/test/index.html

Setup Jenkins for CI

We need a Jenkins (or another CI tool) instance to do the following:

  • Perform QA against SonarQube
  • Build releases and snapshot build
  • Run tests

<dd4t:componentpresentations view="XXX" /> not working

We have component template with metadata field "view". BY using dd4t Tag components are not getting resolved.

Rootcause :
In BaseComponentPresentationsTag view attribute value converted to lower case.

 public String getView () {
        return view;
    }

    public void setView (final String view) {
        this.view = view.toLowerCase(Locale.getDefault());
    }

In RenderUtils we are comparing whatever value we received from metadata without converting to lowercase.

 String view = getViewName(cp);

                if (match(componentSchema.toLowerCase(), schemaName) &&
                        match(componentRootElement, rootElementName) &&
                        match(view, viewName) && isComponentPresentationInRegion(region, regionIsSet, cp)) {
                    componentPresentationsToRender.add(cp);
                }

.
.
//Get View name not doing the lowercase conversion.

 public static String getViewName (final ComponentPresentation cp) {
        ComponentTemplate componentTemplate = cp.getComponentTemplate();
        String viewNameKey = DataBindFactory.findComponentTemplateViewName(componentTemplate);

        if (StringUtils.isNotEmpty(viewNameKey)) {
            return viewNameKey;
        }

        return componentTemplate.getTitle().toLowerCase();
    }

To fix the issue we need to convert viewNameKey to LowerCase as well.

 if (StringUtils.isNotEmpty(viewNameKey)) {
            return viewNameKey.toLowerCase();
        }

Move the Spring @RequestMapping annotations out of the dd4t-mvc-support module

In order to give developers more control over path mappings and other Spring MVC controller annotations, these should be removed form the dd4t-mvc-support module and be set on concrete implementing classes. This will mean a bit of extra configuration in an actual web application, but gives a lot more flexibility. The dd4t-2-archetype already does this for you, so it should not be much of a change.

AbstractPageController seBlank() method

Do we require seBlank() method in AbstractPageController class ?

We have scenario where we extend AbstractPageController and override show method in all controllers(To populate custom attributes in model and call super class show method to retrieve the page content).

When we extend AbstractPageController more than one controller, we are getting URL mapping issue, because /se_blank.html url inherited in both controllers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.