Interface ImageEntityManagementService


  • public interface ImageEntityManagementService
    This service provides utility methods to set and get image entities in panels, elements, media items and page metadata. For more information, see https://wiki.gxsoftware.com/wiki/display/GX/Image+API+using+Utility+Services
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addImage​(Website website, javax.jcr.Node node, String propertyName, ImageEntity imageBean)
      In the multi value case, this method appends an image entity to the existing set of assigned image entities.
      ImageEntity createImageEntity()
      Factory method for creating a new empty image entity.
      ImageEntity createImageEntity​(int imageMediaItemId)
      Factory method for creating a new image entity from a image media item.
      ImageEntity createImageEntity​(org.springframework.web.multipart.MultipartFile imageFile, long focusPointX, long focusPointY)
      Factory method for creating a new image entity from a physical file.
      ImageEntity getImage​(javax.jcr.Node node, String propertyName)
      Retrieves an image that is stored as property of type image entity in the JCR.
      ImageEntity[] getImages​(javax.jcr.Node node, String propertyName)
      Retrieves an array of images that are stored as property of type image entity array in the JCR.
      boolean setImage​(Website website, javax.jcr.Node node, String propertyName, int index, ImageEntity imageBean)
      Stores the properties contained by the Image entity passed in the JCR.
      void setImage​(Website website, javax.jcr.Node node, String propertyName, ImageEntity imageBean)
      Stores the properties contained by the Image entity passed in the JCR.
    • Method Detail

      • getImage

        ImageEntity getImage​(javax.jcr.Node node,
                             String propertyName)
        Retrieves an image that is stored as property of type image entity in the JCR. An image entity is stored as child element of a private node with primary type WCBConstants.NODETYPE_IMAGEENTITY.
        Parameters:
        node - The private node that holds the property containing the image entity.
        propertyName - The name of the property of the private node that holds the image entity
        Returns:
        The image entity assigned to the property. Note that if no image entity is assigned yet, this method returns an empty instance, not null. Furthermore, the object returned is a Java bean. This means that invoking setters on this object will not effect the entity stored in the JCR. Invoke the setter with the modified bean in this service to persist the changes.
      • setImage

        void setImage​(Website website,
                      javax.jcr.Node node,
                      String propertyName,
                      ImageEntity imageBean)
        Stores the properties contained by the Image entity passed in the JCR.
        Parameters:
        website - The website that holds the panel, element, media item or page metadata to which the image entity is assigned
        node - The private node that holds the property containing the image entity.
        propertyName - The name of the property of the private node that holds the image entity
        imageBean - The image entity bean holding all properties to set on the entity
      • getImages

        ImageEntity[] getImages​(javax.jcr.Node node,
                                String propertyName)
        Retrieves an array of images that are stored as property of type image entity array in the JCR. An image entity is stored as child element of a private node with primary type WCBConstants.NODETYPE_IMAGEENTITY. Since all node types in XC are orderableChildNodes, the array of images returned by this method always has the same order.
        Parameters:
        node - The private node that holds the property containing the image entities.
        propertyName - The name of the property of the private node that holds the image entities
        Returns:
        The image entities assigned to the property. Note that if no image entity is assigned yet, this method returns an empty array, not null. Furthermore, the objects returned are Java beans. This means that invoking setters on this object will not effect the entity stored in the JCR. Invoke the setter with the modified beans in this service to persist the changes.
      • setImage

        boolean setImage​(Website website,
                         javax.jcr.Node node,
                         String propertyName,
                         int index,
                         ImageEntity imageBean)
        Stores the properties contained by the Image entity passed in the JCR. This method has an option index parameter for the multi value case; if an array of image entities are stored the index determines which node to update. This method returns true if the image has been updated, false if the image could not be found or has been removed
        Parameters:
        website - The website that holds the panel, element, media item or page metadata to which the image entity is assigned
        node - The private node that holds the property containing the image entity.
        propertyName - The name of the property of the private node that holds the image entity
        index - The index of the node to update
        imageBean - The image entity bean holding all properties to set on the entity
        Returns:
      • addImage

        void addImage​(Website website,
                      javax.jcr.Node node,
                      String propertyName,
                      ImageEntity imageBean)
        In the multi value case, this method appends an image entity to the existing set of assigned image entities.
        Parameters:
        website - The website that holds the panel, element, media item or page metadata to which the image entity is assigned
        node - The private node that holds the property containing the image entity.
        propertyName - The name of the property of the private node that holds the image entity
        imageBean - The image entity bean holding all properties to set on the entity
      • createImageEntity

        ImageEntity createImageEntity()
        Factory method for creating a new empty image entity.
        Returns:
        a new empty image entity
      • createImageEntity

        ImageEntity createImageEntity​(org.springframework.web.multipart.MultipartFile imageFile,
                                      long focusPointX,
                                      long focusPointY)
                               throws ImagingException
        Factory method for creating a new image entity from a physical file.
        Parameters:
        imageFile - The physical image file to associated with the entity. This can be used to assign images uploaded directly from disk instead of selecting it from the content repository.
        focusPointX - The X coordinate of the focus point to set. Use -1 to not set a X coordinate.
        focusPointY - The Y coordinate of the focus point to set. Use -1 to not set a Y coordinate.
        Returns:
        A new image entity representing a physical image stored on disk
        Throws:
        ImagingException - In case an error occurred while creating the image entity or the provided parameters are invalid for some reason
      • createImageEntity

        ImageEntity createImageEntity​(int imageMediaItemId)
                               throws ImagingException
        Factory method for creating a new image entity from a image media item.
        Parameters:
        imageMediaItemId - The id of image media item to associate with the entity. This can be used to assign images by selecting it from the content repository.
        Returns:
        A new image entity representing an image media item selected from the content repository
        Throws:
        ImagingException - In case an error occurred while creating the image entity or the provided parameters are invalid for some reason