Class CmsUgcSession

    • Method Detail

      • createUploadResource

        public CmsResource createUploadResource​(java.lang.String fieldName,
                                                java.lang.String rawFileName,
                                                byte[] content)
                                         throws CmsUgcException
        Creates a new resource from upload data.

        Parameters:
        fieldName - the name of the form field for the upload
        rawFileName - the file name
        content - the file content
        Returns:
        the newly created resource
        Throws:
        CmsUgcException - if creating the resource fails
      • disableCleanup

        public void disableCleanup()
        Disables auto-cleanup on session destruction.

      • finish

        public void finish()
                    throws CmsException
        Finishes the session and publishes the changed resources if necessary.

        Throws:
        CmsException - if something goes wrong
      • getCmsObject

        public CmsObject getCmsObject()
        Gets the CMS context used by this session.

        Returns:
        the CMS context used by this session
      • getId

        public CmsUUID getId()
        Returns the session id.

        Returns:
        the session id
      • getMessageLocale

        public java.util.Locale getMessageLocale()
        Returns the locale to use for messages generated by the form session which are intended to be displayed on the client.

        Returns:
        the locale to use for messages
      • getValues

        public java.util.Map<java.lang.String,​java.lang.String> getValues()
                                                                         throws CmsException
        Returns the content values.

        Returns:
        the content values
        Throws:
        CmsException - if reading the content fails
      • isFinished

        public boolean isFinished()
        Returns true if the session is finished.

        Returns:
        true if the session is finished
      • saveContent

        public CmsXmlContentErrorHandler saveContent​(java.util.Map<java.lang.String,​java.lang.String> contentValues)
                                              throws CmsUgcException
        Saves the content values to the sessions edit resource.

        Parameters:
        contentValues - the content values by XPath
        Returns:
        the validation handler
        Throws:
        CmsUgcException - if writing the content fails
      • addContentValue

        protected void addContentValue​(CmsXmlContent content,
                                       java.util.Locale locale,
                                       java.lang.String path,
                                       java.lang.String value)
        Adds the given value to the content document.

        Parameters:
        content - the content document
        locale - the content locale
        path - the value XPath
        value - the value
      • addContentValues

        protected CmsXmlContent addContentValues​(CmsFile file,
                                                 java.util.Map<java.lang.String,​java.lang.String> contentValues)
                                          throws CmsException
        Adds the given values to the content document.

        Parameters:
        file - the content file
        contentValues - the values to add
        Returns:
        the content document
        Throws:
        CmsException - if writing the XML fails
      • addContentValues

        protected void addContentValues​(CmsXmlContent content,
                                        java.util.Locale locale,
                                        java.util.Map<java.lang.String,​java.lang.String> contentValues)
                                 throws CmsXmlException
        Adds the given values to the content document.

        Parameters:
        content - the content document
        locale - the content locale
        contentValues - the values
        Throws:
        CmsXmlException - if writing the XML fails
      • deleteContentValue

        protected void deleteContentValue​(CmsXmlContent content,
                                          java.util.Locale locale,
                                          java.lang.String path)
        Deletes the given value path from the content document.

        Parameters:
        content - the content document
        locale - the content locale
        path - the value XPath
      • getContentValues

        protected java.util.Map<java.lang.String,​java.lang.String> getContentValues​(CmsXmlContent content,
                                                                                          java.util.Locale locale)
        Returns the content values of the requested locale.

        Parameters:
        content - the content document
        locale - the content locale
        Returns:
        the values