Crafter Social System Administration

This guide covers the basic configuration for Crafter Social, if you need to manage contexts and user generated content you can follow the Crafter Social Admin Console UI guides.

Note

This guide assumes that you have already installed and configured Crafter Profile. For details see Crafter Profile System Administration

All configuration for Crafter Social is managed using a properties file:

CRAFTER_HOME/bin/apache-tomcat/shared/classes/crafter/social/extension/server-config.properties

MongoDB Configuration

Using the following properties you can change the server and database used by Crafter Social. This will allow you to use advanced MongoDB features and also host multiple Crafter Social databases in the same MongoDB server.

Properties prefix: crafter.social.mongodb.

Property

Default Value

Description

connection.newConnectionStr

1

MongoDB URL used for all
connections

connection.dbName

craftersocial

Name of the MongoDB database

connection.scriptRunner.withClient

false

If enabled a native client will
be used to run all scripts

connection.scriptRunner.clientPath

/usr/local/bin/mongo

Absolute path of the native
client

connection.dbUsername

None

Username for MongoDB
authentication

connection.dbPassword

None

Password for MongoDB
authentication

scripts.runOnInit

true

If enabled all scripts for
creating the default context,
will run each time the
Crafter Social war is loaded

scripts.paths

2

List of all MongoDB scripts to
run

Crafter Profile Configuration

Using these properties you can control how Crafter Social interacts with Crafter Profile.

Properties prefix: crafter.profile.rest.client.

Property

Default Value

Description

url.base

http://localhost:8080/profile

URL where Crafter Profile is
deployed

accessToken.id

2ba3ac10-c43e-11e3-9c1a-0800200c9a66

Access Token included in all
requests made to the Crafter
Profile API

Web Configuration

Properties prefix: crafter.social.web.

Property

Default Value

Description

mapping.dateFormat

yyyy-MM-dd’T’HH:mm’Z’

Pattern used to format all dates

maxUpload

10485760

Maximum file size in bytes for attachments

defaultSortOrder

ASC

Default sort order used for queries

User Generated Content Configuration

Properties prefix: crafter.social.ugc.

Property

Default Value

Description

invalidQueryKeys

contextId:|$where:

MongoDB keywords not allowed in the
user provided queries

arraySortFields

flags, votesDown,
votesUp, attachments,
ancestors
MongoDB fields allowd to sort query
results

virusScanner


Class implementing the VirusScanner

Notifications Configuration

Using these configurations you can control how Crafter Social handles email notifications.

Properties prefix: studio.social.notification.

Property

Default Value

Description

dailyCron

0 0 0 * * ?

CRON Expressions used to control how often each type
of notification is sent.

weeklyCron

0 0 0 ? * SUN

instantCron

0 */2 * * * ?

startDelay

60

Time in seconds to wait after the application is
loaded to start sending notifications

instantInterval

120000

Time in milliseconds to wait between each instant
notification is sent

disable

false

If set to true notifications will not be sent

Other Configuration

Properties prefix: studio.social.system.

Property

Default Value

Description

ugcClass

Class implementing the
UgcFactory interface, will
be used to create all new user
generated contents

defaultLocale

EN
Locale used for notification
templates

ignoreAnonymousFlagRoles

SOCIAL_ADMIN,
SOCIAL_SUPERADMIN,
SOCIAL_MODERATOR
Roles not taken into account when
adding flags to user generated
content

Properties prefix: studio.social.system.profileAgg.

Property

Default
Value

Description

cache.ttl

3600

Total time in seconds that objects will be kept in
the cache

cache.tti

1800

Time in seconds that objects will be kept in the
cache wihout being used

cache.maxElementsInMemory

250

Maximum number of objects kept in memory
by the cache

attributesToReturn

5

List of fields used by MongoDB queries

Properties prefix: studio.social.system.emailConfig.

Property

Default
Value

Description

cache.ttl

3600

Total time in seconds that objects will be kept in
the cache

cache.tti

1800

Time in seconds that objects will be kept in the
cache wihout being used

cache.maxElementsInMemory

250

Maximum number of objects kept in memory
by the cache

Properties prefix: studio.social.system.tentanConfig.

Property

Default
Value

Description

cache.ttl

3600

Total time in seconds that objects will be kept in
the cache

cache.tti

1800

Time in seconds that objects will be kept in the
cache wihout being used

cache.maxElementsInMemory

250

Maximum number of objects kept in memory
by the cache

Properties prefix: studio.social.system.cors.

Using these properties you can control the Cross-Origin Resource Sharing settings to assure your sites and applications are able to access the Crafter Social API.

Property

Default Value

Description

disableCORS

false

If set to true CORS headers will
not be added to any response

accessControlAllowHeaders

x-requested-with

Value for the header
Access-Control-Allow-Headers

accessControlAllowMethods

POST,GET,PUT,DELETE

Value for the header
Access-Control-Allow-Methods

accessControlMaxAge

3600

Value for the header
Access-Control-Max-Age

accessControlAllowOrigin

Value for the header
Access-Control-Allow-Origin

accessControlAllowCredentials

false

Value for the header
Access-Control-Allow-Credentials

Virus Scanner Configuration

Since users of your site or application will be able to upload files into the Crafter Social database it is recommended to setup an antivirus for additional protection of both the server and the client machines. By default Crafter Social is configured to use an empty implementation of the VirusScanner, in a production environment you should follow these steps to enable it:

Enable ClamAV Virus Scanner

  1. Install ClamAV

  2. Edit the ClamAV configuration file to include the following properties:

clamd.conf
1
2
3
4
5
# The values provided are just an example, they are fine for a local test but you should
# use the appropriate values for production

TCPSocket 3310
TCPAddr 127.0.0.1
  1. Start the clamd daemon

  2. Add the following file:

Note

If you are going to use the default ClamAV values (localhost:3310) the only change needed is the property studio.social.ugc.virusScanner=org.craftercms.virusscanner.impl.ClamavVirusScannerImpl.

$TOMCAT/shared/classes/crafter/social/extension/virus-scanner-context.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<?xml version="1.0" encoding="UTF-8"?>
  <beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="social.ugc.virusScanner" class="org.craftercms.virusscanner.impl.ClamavVirusScannerImpl">
      <property name="host" value="localhost"/>
      <property name="port" value="3310"/>
      <property name="timeout" value="60000"/>
    </bean>

  </beans>
  1. Reload the Crafter Social WAR file or restart the Tomcat server

Using a Custom Virus Scanner

If you need to use a different antivirus software you can create a class that implements the org.craftercms.virusscanner.api.VirusScanner interface. Your custom class should:

  1. Define all configuration needed by the antivirus

  2. Execute the antivirus scan for individual files

  3. Throw a org.craftercms.virusscanner.impl.VirusScannerException if any threat is detected

Notes

1
  • Default Value: mongodb://localhost:27017/craftersocial?readPreference=primary&maxPoolSize=150&minPoolSize=50&maxIdleTimeMS=1000&waitQueueMultiple=200&waitQueueTimeoutMS=1000&w=1&journal=true

  • You can find more information about the format and parameters here: https://docs.mongodb.com/manual/reference/connection-string/

2
3
  • Default Value: org.craftercms.virusscanner.impl.NullVirusScannerImpl

  • You can extend Crafter Social to use a custom virus scanner or use the provided solution with ClamAV.

4
  • Default Value: org.craftercms.social.repositories.social.SocialUgcFactory

  • You can extend Crafter Social to include custom fields or logic when creating User Generated Content.

5
  • Default Value: displayName,avatarLink,socialContexts,notificationLocale,autoWatch,defaultFrequency,isAlwaysAnonymous

  • Crafter Social will expect those fields to be available in all profiles, you need to make sure they are included in all tenants that are needed by your site or application.