UGC 4

Submitter

Leran more about the submitter. The submitter is responsible to send the serialized JSON files in the json dump to the ugc-webapp.

<dependency>
  <groupId>com.subshell.sophora</groupId>
  <artifactId>ugc-submitter</artifactId>
  <version>X.X.X</version>
</dependency>

To perform these tasks it runs inside your delivery webapp. If the backend can not be reached, valid JSON files remain in the folder normal. The content will not be lost even if the Submitter is restarted and will be sent when the backend is reachable.

The json dump consists of the following folders:

  1. invalid: these files were marked invalid by the webapp
  2. noHandlersFound: these files couldn't be submitted as the application doesn't know how to handle them
  3. normal: user generated content that still has to be submitted
  4. priority: load information, which will be prioritized, when submitting
  5. skipped: these files were skipped because they are duplicates

Configuring the Submitter in a Webapp

In order for the submitter to be used in your webapp, you need to add a listener to the web.xml of your delivery webapp

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:spring-submitter.xml</param-value>
</context-param>
<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

If you want to use the load monitoring feature of the taglib as well, you need to use spring-usercontent.xml instead of spring-submitter.xml.

Your context.xml needs to be adapted as well. You need to configure the folder for the json dump with the parameter jsonDump. E.g.:

<?xml version='1.0' encoding='utf-8'?>
<Context>
	<Parameter name="jsonDump" value="/cms/webapps/sophora-demosite/json_dump"/>
	<Parameter name="localConfigDirectory" value="/cms/webapps/sophora-demosite/config"/>
	<Environment name="logPath" value="/cms/webapps/sophora-demosite/logs" type="java.lang.String"/>
</Context>

There is also a file called submitter.properties in either the classpath of your webapp or the config directory of the webapp. It allows to configure central aspects of the behaviour of the submitter.

It is important that you configure the right host and port of the ugc-webapp in sophora.ugc.submitter.webapp.url. As this is the URL the submissions get sent to.

submitter.properties
PropertyDescriptionDefault
sophora.ugc.submitter.checkintervalHow often should the json dump be checked for new files? Time in milliseconds.10000
sophora.ugc.submitter.submissionintervalHow often should the files be submitted? Time in milliseconds.10000
sophora.ugc.submitter.webapp.urlThe URL of the submission handler at the ugc-webapp. (Replace localhost and 9080 with the hostname and port of your ugc-webapp)http://localhost:9080/rest/submissions
sophora.ugc.submitter.webapp.usernameIf the URL of the submission handler is protected by HTTP basic authentication, you can configure a username for requests.
sophora.ugc.submitter.webapp.passwordIf the URL of the submission handler is protected by HTTP basic authentication, you can configure a password for requests.
sophora.ugc.submitter.webapp.maxNumberOfSubmissionAttemptsIf a submission attempt fails, how often should this attempt be retried?5
sophora.ugc.submitter.webapp.timeBetweenSubmissionAttemptsIf a submission attempt fails, how many milliseconds should the submitter wait to retry?50
sophora.ugc.submitter.webapp.cleanUpDelayInDaysRemove files from the invalid folder that are older than X days.30
sophora.ugc.submitter.webapp.removeUnsentLoadInformationAfterHoursRemove files from the priority folder that are older than X hours.1
sophora.ugc.submitter.webapp.maxNumberOfObjectsPerSubmissionHow many files should be submitted in each submission attempt?100
sophora.ugc.submitter.webapp.csrfTokenUrlThe URL of the endpoint to get a csrf token from the ugc-webapp.http://localhost:9080/rest/csrf

Configuring the Submitter in an Arbitrary Spring Context

If you don't want to start the submitter in a delivery webapp, it's also possible to use a Java configuration class. The important difference is, that you have to use the property sophora.ugc.submitter.jsonDump instead of the context parameter to specify the path of the jsonDump. All other parameters listed above can be set in the properties file of your Spring context.

The following example shows, how you could add the configuration class to your Spring java configuration.

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; 
import com.subshell.sophora.ugc.submitter.EmbeddedSpringConfig;

@Configuration
@Import(EmbeddedSpringConfig.class)
public class YourConfiguration {
 ...
}

Of course, you can use the @ComponentScan annotation to make your Spring context use the submitter configuration.

Last modified on 12/30/22

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.

Icon