Project APIs

Introduction

Wedia is distributed with a set of APIs that allow you to create and handle projects directly.

These apis are composed of TriggerBusinessService classes invoked on the media object as well as a class com.wedia.wxm.services.interfaces.IWxmProjectManager.

In this section we will describe the different processes called by the class and the triggers. For more information, please refer to the javadoc documentation of these classes.

Project management

Creating a project consists in inserting an object of the media type in the application. When this is saved with the method IObjectWritable#JSPSave(CTSurfer) triggers are executed by the class com.wedia.wxm.database.trigger.ProjectManager.

Some triggers validate the consistency of the object before insertion as:

  • declaration of project languages and default languages

  • the coherence of specific action statements

After basic integration, actions are carried out:

  • project assignment management

  • specific actions will be carried out

Triggering specific actions

When creating a project object instance (media), you can define a project type in the mediatype property. This type is used to inform the API that actions must be taken based on information also positioned on the media object.

If you do not specify any type, no support will be created and only generic actions will be executed.

From a template

The definition of support creation from a model requires to specify the following information:

type

value = 1
Indicates that project creation will result in export of a template to a medium

channel

The project must be assigned to a channel defining a medium. Without this information, it will not be possible to export the model in another dedicated collateral object.

model

Type of the model object to be exported; for example, monodocmodel or sitemodel. If the project channel defines a template type, it must match it.

modelid

Model object identifier of the model object to export

langs/defaultlang

The project must define at least one language of use in order to be able to create the media if it has the lang property.

Example of project creation with a medium created from a template:

final CTSurfer surfer = ... ; .... final IObjectReadOnly modelObject = .... ; ... final CTObjects factory = new CTObjects(); factory.JSPLoad("media", true); final IObjectWritable newProject = factory.create(); (1) newProject.setProperty("name", "test"); newProject.setProperty("type", "1"); // from model; newProject.setProperty("channel", "8"); // print / brochure; newProject.setProperty("model", modelObject.getObjectType().toString()); newProject.setProperty("modelid", modelObject.getIdentifiant().toString()); newProject.setProperty("mediagroup", "1"); // group id 1 newProject.setProperty("langs", "2,1"); // contribution languages 1 and 2; newProject.setProperty("defaultlang", "1"); // langue par défaut égale à 1; .... final String newProjectId = newProject.JSPSave(surfer);
  1. Although media remains a standard object that can be manipulated via CTObject APIs standard, new APIs make it easy to simplify these manipulations.

The media is created using the IObjectWritable#exportTo method with security activated.
You must therefore have the rights to insert the support object in order to be able to complete this type of action.

The media is created using the IObjectWritable#exportTo method with triggers: the behaviours implemented in an TriggerBusinessService when inserting a collateral with a project of this type are therefore common with those put in place for a single collateral in datanew mode.

Any specific behaviour in the case of creation at the same time that a project from a template will have to be implemented in an TriggerBusinessService of the media object.

From a brief

type

value = 2
Indicates that project creation will result in export of a model in a support

channel

(not obligatory) the application will assign by default the channel of this type if you don’t mention it. This type is present to simplify the use of the creative review channel, the search and ranking of a certain type of project, as well as the development of facets. It does not, by default, trigger any of the following additional processing than a project without mediatype.
The result will be similar to inserting a project without type on the channel creative review.

From a file

type

value = 3.
This type is reserved for a later version of the Wedia application.
It is not used today and is deactivated.

It is therefore strongly recommended that you do not exploit it or make any kind of developments with this type.

From a project

type

value = 4.
Indicates that creating a project will import all media and content from another project into it.

channel

Must match the source project channel.

project

Identifying the source project. After the insertion of the project, the system will decline all the objects with the media property in the new project (content as media).

This treatment requires multiple insertion and data changes, we have been forced to deactivate execution of triggers on insertion and updates of the imported objects.

If you want to process the imported objects, you must create triggers on the media object even on events after insertion (by testing the type and searching the database).

Example of creating a project from another project:

final CTSurfer surfer = ... ; .... final IObjectReadOnly sourceProject = .... ; ... final CTObjects factory = new CTObjects(); factory.JSPLoad("media", true); final IObjectWritable newProject = factory.create(); newProject.setProperty("name", "test"); newProject.setProperty("type", "4"); // from model; newProject.setProperty("channel", "8"); // print / brochure; newProject.setProperty("project", sourceProject.getIdentifiant().toString()); newProject.setProperty("mediagroup", "1"); .... final String newProjectId = newProject.JSPSave(surfer);

IWxmFactory and IWxmProjectManager

The IWxmFactory interface allows to get rid of the CTObject API for creating projects.

We distribute methods to help you create projects quickly.

Example of project creation from a model that produces the same result as the previous example

final CTSurfer surfer = ... ; final IWxmFactory wxmFactory = new WxmFactory(surfer); .... final IObjectReadOnly modelObject = .... ; ... final IWxmProjectManager newProject = wxmFactory.createNewProjectFromModel("test",          "2,1", // langs          "1",  // default lang          modelObject.getObjectType().toString(), // type de modèle          modelObject.getIdentifiant().toString(),  // id du modèle          "1", // groupe          Collections.emptyMap(), // pas de valeurs forcées sur le projet          null, // pas d'assignations spécifiques          Collections.emptyMap()); // pas de valeurs forcées sur le support

Assignments

When creating a project, by default, the user who creates the project sees itself as the only user assigned to its project. In concrete terms, a summons is expressed by the insertion of an object usermedia in the database.

To assign multiple users to the project when it is created or its modification, you must complete the property of denormalization users with the list of selected user IDs.

This action will update the set of assignments to the project:

  • Users 3,5,10 and 54 will be assigned to the project.

  • Previously assigned users will have their rights revoked.

It is possible to assign a specific role for a project to a user. To do this, you must use a specific pattern.

This action will update all assignments to the project:

  • Users 3 and 54 will be assigned to the project with their default roles.

  • user 5 will have role 10 on this project (regardless of its default role)

  • User 10 will have role 4 on this project (regardless of its default role)

  • previously assigned users will have their rights revoked

Manage rights finely

The standard API distributed in the IWxmProjectManager interface allows you to manipulate assignments more finely. You can add, modify or delete the right of a single user in the following ways or manipulate assignments in mass:

Cleaning assignments

When deleting a project, the API will delete automatically the referenced rights for each user.

Project Role Management

For each project, a user can be assigned a specific role.

This statement is informative: we do not modify the property roleid in surfing because it would cause undesirable effects with the taglib noheto:include.

The WXM_MediaCore plugin compiles, on the other hand, all user rights in a surfer property named wxm_roleByMedia in the following form: <id_role>_<id_media> separated by commas.

You will be able to use this information in security rules, for instance :