eXo Platform 3.0

- Prev
- Next

## Chapter 4. Developer reference

## Extension points

There are some overridable components in eXo Collaboration so that you can control how these components work by implementing or extending default implementations and then reconfigure these new components in the file configuration.xml.

### ContentDAO

`ContentDAO` is an overridable component used in the Content application ( or called RSS reader) of eXo Collaboration.

You can find the configuration file at WEB-INF/cs-extension/cs/content/content-service-configuration.xml With the declaration as the below:

     <component>
        <key>org.exoplatform.content.service.ContentDAO</key>
        <type>org.exoplatform.content.service.impl.ContentDAOImpl</type>
      </component>

The example below is an example of plugin configuration:

    <external-component-plugins>
           <target-component>org.exoplatform.content.service.ContentDAO</target-component>
    	   <component-plugin>
    	      <name>rssreader.listener</name>
    	      <set-method>addPlugin</set-method>
    	      <type>org.exoplatform.content.service.RSSContentPlugin</type>
    	      <description>rss reader plugin</description>
    	    </component-plugin>

    	    <component-plugin>
    	      <name>description.listener</name>
    	      <set-method>addPlugin</set-method>
    	      <type>org.exoplatform.content.service.DescriptionPlugin</type>
    	      <description>Description plugin</description>
    	    </component-plugin>
        </external-component-plugins>

### ContactLifeCycle

`ContactLifeCycle` is an interface that you can implement to extend the capabilities of eXo. A `ContactLifeCycle` lets you be notified during the lifecycle of an address book's contact :

- when a contact is added

- when a contact is modified

An example of `ContactLifeCycle` has been implemented to integrate Address Book application in eXo Social's Spaces. See the following configuration at: ext/social-integration/src/main/resources/conf/portal/configuration.xml.

See the following example:

    <external-component-plugins>
        <target-component>org.exoplatform.contact.service.ContactService</target-component>
        <component-plugin>
          <name>ContactEventListener</name>
          <set-method>addListenerPlugin</set-method>
          <type>org.exoplatform.cs.ext.impl.ContactSpaceActivityPublisher</type>
        </component-plugin>
      </external-component-plugins>

Explanation: `ContactSpaceActivityPublisher` implements `ContactLifeCycle`. This implementation publishes activities in the space activity stream to notify of new and updated contacts in the space address book.

### Transport

`Transport` is an overridable component used in the Chat application of eXo Collaboration.

This overridable component is used to help users add the protocol to the Chat application such as: ICQ, YAHOO, MSN, XMPP, AIM, GTALk, etc.

The Chat application of eXo Collaboration only uses the XMPP protocol that is implemented in this object "`XMPPTransport`".

### EventLifeCycle

`EventLifeCycle` is an extension point used in the Calendar application of eXo Collaboration. You can find the configuration file of this component at: ext/social-integration/src/main/resources/conf/portal/configuration.xml.

See the following example:

     <external-component-plugins>
        <target-component>org.exoplatform.calendar.service.CalendarService</target-component>
        <component-plugin>
          <name>CalendarEventListener</name>
          <set-method>addEventListenerPlugin</set-method>
          <type>org.exoplatform.cs.ext.impl.CalendarSpaceActivityPublisher</type>
        </component-plugin>
      </external-component-plugins>

Explanation: `CalendarSpaceActivityPublisher` implements `EventLifeCycle`. It writes activities in the space activity stream when events or tasks are added/modified.

## Public REST APIs

eXo Collaboration implements and provides many public REST APIS to help built-in applications such as Calender, Chat and Mail to communicate and transfer data with the server. By using these public REST APIs, extended or 3rd party applications can make use of this to develop cool web applications faster without much implementation.

### Calendar application

Calendar application of eXo Collaboration use CalendarWebservice to provide all APIs for working with calendar such as create personal calendars, group calendars, share calendars, manage events / tasks, etc.

REST API of Calendar portlet is exposed by org.exoplatform.services.cs.calendar.CalendarWebservice class.

Service name | Service URL | Description | Location |
CalendarWebservice | `$portalname/$restcontextname/private/cs/calendar` | This service is used to call extended services of Calendar application. | - Maven groupId: org.exoplatform.cs - ArtifactId: exo.cs.web.webservice |

### Note

- $portalname: It is the name of the portal

- $restcontextname: The context name of rest webapplication which is deployed to the "$portalname" portal.

- Private: is optional and used for protected access only. Such calls will require authentication

- APIs usage:

Use the following APIs to build all the functions of Calendar application:

Name | Description | Service URL endpoint | Parameters | Expected Values
--- | --- | --- | --- | ---
checkpermission | It checks the permission of a user to a calendar, aiming at defining if the user has the edit permission to the calendar or not. | /private/cs/calendar/checkPermission/{username}/{calendarId}/type} | username calendarid type | user id calendar id INVALID_TYPE = -1 / PRIVATE_TYPE = 0 / SHARED_TYPE = 1 / PUBLIC_TYPE = 2
event | It returns a feed rss that lists links to access a specific event. | /private/cs/calendar/event/{username}/{eventFeedName} | username eventFeedName | user id string
feed | It shows the content of a feed that is a list of events in the "filename" file. | /private/cs/calendar/feed/{username}/{feedname}/{filename} | username feedname filename | username string string
publicProcess | It processes the public calendar when having a remote access request. | /cs/calendar/subscribe/{username}/{calendarId}/{type} | username calendarId type | user id calendar id INVALID_TYPE = -1 / PRIVATE_TYPE = 0 / SHARED_TYPE = 1 / PUBLIC_TYPE = 2
privateProcess | It processes the public calendar when having a remote access request. User must enter username and password to access. | /private/cs/calendar/private/{username}/{calendarId}/{type} | username calendarID type | user id calendar id INVALID_TYPE = -1 / PRIVATE_TYPE = 0 / SHARED_TYPE = 1 / PUBLIC_TYPE = 2
upcomingEvent | It is a list of up coming events in a specific calendar. | /private/cs/calendar/getissues/{currentdatetime}/{type}/{limit} | currentdatatime type limit | valid time format INVALID_TYPE = -1 / PRIVATE_TYPE = 0 / SHARED_TYPE = 1 / PUBLIC_TYPE = 2 integer
updateStatus | To update the status of a task. | /private/cs/calendar/updatestatus/{taskid} | taskid | task id
getCalendars | It gets a list of calendars. | /private/cs/calendar/getcalendars | `no param` |

### Mail application

Mail application of eXo Collaboration use MailWebservice to provide all APIs for working with mail as send mail, check mail, store mail to JCR, etc.

REST API of Mail portlet is exposed by org.exoplatform.services.cs.mail.MailWebservice class.

Service name | Service URL | Description | Location
--- | --- | --- | ---
MailWebservice | `$portalname/$restcontextname/private/cs/mail` | This service is used to call extended services of Mail application. | - Maven groupId: org.exoplatform.cs - artifactId: exo.cs.web.webservice

- APIs Usage:

Use the following APIs to build all the functions of Mail application:

Name | Description | Service URL endpoint | Parameters | Expected Values
--- | --- | --- | --- | ---
checkMail | It executes to check mails when having a request. | /checkmail/{username}/{accountId}/{folderId/}/ | username accountID folderId | user id account id folder id
synchFolders | It synchronizes the mail folders in the clients and those in the mail server. | /synchfolders/{username}/{accountId}/ | username accountID | user id account id
stopCheckMail | to stop checking the mail | /stopcheckmail/{username}/{accountId}/ | username accountId | user id account id
getCheckMailJobInfo | It is the method to get information of mail-checking job. | /checkmailjobinfo/{username}/{accountId}/ | username accountId | user id account id
searchemail | It is used to search information from emails | /searchemail/{keywords} | keywords | string

### Chat application

Chat application use some APIs to help users to create a room, join a room, invite other users to room, send files, etc.

And the chat application of eXo Collaboration uses two services: RESTXMPPService and FileExchangeService to do these tasks.

#### RESTXMPPService

REST API RESTXMPPService of Chat portlet is exposed by org.exoplatform.services.xmpp.rest.RESTXMPPService class

Service name | Service URL | Description | Location |
RESTXMPPService | `$portalname/$restcontextname/xmpp` | It is the service to implement all the action sent to the chat server; | * Maven groupid: org.exoplatform.cs * exo.cs.eXoApplication.chat.service |

- APIs Usage:

Use the following APIs to build all the functions of Chat application:

Name | Description | Service URL endpoint | Parameters | Expected Values
--- | --- | --- | --- | ---
loadJsResourceBundle | To read the language files in the chat server. | /loadJsResourceBundle/{locale}/ | locale | locale id
createRoom | To create a chat room or a group chat | /muc/createroom/{username}/ | username room nickname | user id room name display name
configRoom | To establish the configuration of a chat room. | /muc/configroom/{username}/ | username room | user id room name
getRoomConfigForm | To get the configuration of a chat room created. | /muc/getroomconfig/{username}/ | username room | user id room name
getRoomInfo | To get the inforamtion of a chat room created | /muc/getroominfo/{username}/ | username room | user id string
getJoinedRooms | To list chat rooms that a user has been joined. | /muc/joinedrooms/{username}/ | username | user id
getRooms | To get a list of group chat or chat rooms created. | /muc/rooms/{username}/ | username | user id
declineToRoom | To refuse the invitation to join the chat room. | /muc/decline/{username}/{inviter}/ | username inviter room reason | user id user id room name string
destroyRoom | To delete a chat room created. | /muc/destroy/{username} | username room reason altroom | user id room name string room id
inviteToRoom | To invites other users to join a chat room. | /muc/invite/{username}/{invitee}/ | username invitee room reason | user id user id room name string
joinRoom | To join a chat room. | /muc/join/{username}/ | username room nickname password | user id room name display name room password
leftRoom | To leave a chat room. | /muc/leaveroom/{username}/ | username room | user id room name
changeNickname | To change the nickname of users | /muc/changenickname/{username}/{nickname}/ | username nickname | user id display name
changeAvailabilityStatusInRoom | To change the status of a user in the chat room. | /muc/changestatus/{username}/{mode}/ | username mood room status | user id presence type room name presence type
changeSubject | To change the subject of a chat room. | muc/changesubject/{username}/ | username room subject | user id room name string
manageRoleRoom | To change the role of each user in a chat room. | /muc/managerole/{username}/ | username room nickname role command | user id room name display name Participant / moderator grant/revoke
manageAffilationRoom | To change the ownership of a chat room. | /muc/manageaffiliation/{username}/ | username room nickname affiliation command | user id room name display name String affiliation grant / revoke
kickUserFromRoom | To remove a user from the chat room. | /muc/kick/{username}/ | username nickname room reason | user id display name room name string
banUserFromRoom | To ban a user in the chat room. | /muc/ban/{username}/ | username room name reason | user id room name user id string
addBoddyToRoster | To add a user into the contact list | /roster/add/{username}/{adduser} | username adduser nickname group | user id use id display name group id
updateBoddy | To update new users into the contact list | /roster/update/{username}/{upduser}/ | username upduser nickname group | user id user id display name group id
createGroup | To create a chat room. | /roster/group/{username}/{group}/ | username group | user id group id
askForSubscription | To change the presence type of a user into Subscription. | /askforsubscription/{username}/{askuser}/ | username askuser nickname | user id user id display name
cleanBuddylist | To remove a user from the contact list. | /rosterclean/{username}/ | username | user id
getAllHistory | To get all the chat history of two users. | /history/getmessages/{usernameto}/{isGroupChat}/ | usernameto isGroupChat usernamefrom | user id true / false user id
getHistoryBetweenDate | To get the chat history of two users in a specific period. | /history/getmessages/{usernameto}/{isGroupChat}/{from}/{to}/ | usernameto isgroupchat from to usernamefrom | user id true / false valid date format valid date format user id
getHistoryFromDateToNow | To get the chat history of two users from a specific date to the current time. | /history/getmessages/{usernameto}/{isGroupChat}/{from}/ | username isGroupChat from usernamefrom | user id true / false valid date format valid date format user id
getAllHistoryFile | To download all the chat history file of two users. | /history/file/getmessages/{usernameto}/{isGroupChat}/{clientTimezoneOffset}/ | uernameto isGroupChat clientTimezoneOffset usernamefrom | user id true / false Long user id
getHistoryFromDateToNowFile | To download the chat history file of two users from a specific date to the current time | /history/file/getmessages/{usernameto}/{isGroupChat}/{from}/{clientTimezoneOffset}/ | usernameto isGroupChat from clientTimezoneOffset usernamefrom | user id true / false valid date format Long user id
getHistoryBetweenDateFile | To download the chat history file of two users in the specific date. | /history/file/getmessages/{usernameto}/{isGroupChat}/{from}/{to}/{clientTimezoneOffset}/ | usernameto isGroupChat from to clientTimezoneOffset usernamefrom | user id true / false valid date format valid date format Long user id
getUserInfo | To get the information of a user | /getuserinfo/{username}/{needinfo}/ | username needinfo | user id string
login2 | To allow a user to log in the chat server. | /login2/{forcache}/ | forcache |
logout | To allow a user to log out the chat server | /logout/{username}/{presencestatus}/ | username presencestatus | user id presencestatus
messageReceive | To receive a message from other users | /history/messagereceive/{username}/{messageid}/ | username messageid | user id message id
removeBuddy | To delete a contact from the contact list. | /roster/del/{username}/{removeboddy}/ | username removeboddy | user id user id
removeTransport | To reset the presence type at the service that is being used. | /removetransport/{username}/{transport}/ | username transport | user id transport servive (e.g: Yahoo, XMPP)
searchUsers | To search users in the chat server | /searchuser/{username}/ | username search byUsername byName byEmail searchService | user id string true / false true /false true / false string
sendMessage | To send an message to other users. | /sendmessage/{username}/ | username messageBean | usesr id object
sendMUCMessage | To send a message to multile users or a group | /muc/sendmessage/{username}/ | username messageBean | user id object
setUserStatus | To change the status of a user. | /sendstatus/{username}/{status}/ | username status | user id available/ unavailabe / do not disturb / away / extend away
subscribeUser | To change presence type into Subcribed type | /subscribeuser/{username}/{subsuser}/ | username subsuser | user id user id
unsubscribeUser | To change presence type into the Unsubscribed type | /unsubscribeuser/{username}/{unsubsuser}/ | username unsubsuser | user id user id
acceptFile | To accept getting a file sent from another user. | /fileexchange/accept/{username}/{uuid}/ | username uuid | user id string
rejectFile | To refuse getting a file sent from another user. | /fileexchange/reject/{username}/{uuid}/ | username uuid | user id string
getPreviousStatus | To get the tatus of a user in the last log-in. | /getprevstatus/{username}/ | username | user id

#### FileExchangeService

REST API FileExchangeService for upload file is defined in org.exoplatform.services.xmpp.rest.FileExchangeService

Service name | Service URL | Description | Location
--- | --- | --- | ---
FileExchangeService | `$portalname/$restcontextname/fileexchange` | To upload a file to the server and inform the user that he can download it to his local computer. | - Maven groupid: org.exoplatform.cs - InterfactId: exo.cs.eXoApplication.chat.service

- APIs usage: Use the following APIs to upload and send files to other users:

Name | Description | Service URL endpoint | Parameters | Expected Values
--- | --- | --- | --- | ---
upload | To upload a file to the server. | $portalname/$restcontextname/fileexchange | description username requestor isroom | string user id user id true / false

- Prev
- Up
- Home
- Next