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 |
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, |
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 |
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);
Although media remains a standard object that can be manipulated via CTObject APIs standard, new APIs make it easy to simplify these manipulations.
Caution | 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 |
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 |
From a file
type | value = 3. |
Important | 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. |
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 |
Caution | 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). |
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);
Note | The duplicate button in the back-office and JSP clone.jsp have been customized for the media object in order to redirect to a project creation form of this type. |
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.
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.
// The assignment works in creation as well as in modification;
IObjectWritable project = CTObjects.JSPLoad("media", "42");
project.setProperty("users", "3,5,10,54");
project.JSPSave(surfer);
// note : the property will always be empty after saving
System.out.println("users : [" + project.getProperty("users") + "]"); // ==> user : []
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.
//the assignment works in creation as well as in modification;
IObjectWritable project = CTObjects.JSPLoad("media", "42");
project.setProperty("users", "3,5_10,10_4,54");
project.JSPSave(surfer);
// note : the property will always be empty after saving
System.out.println("users : [" + project.getProperty("users") + "]"); // ==> user : []
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
Tip | If you don’t want to touch the subpoenas, you can leave the empty users fields when making changes. |
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:
IWxmFactory wxmFactory = new WxmFactory(surfer);
IWxmProjectManager projectManager = wxmFactory.getProjectManager("42"); // project id 42
// Add the user 3 to the project
projectManager.registerUser("3");
// revoke user 10;
projectManager.unregisterUser("10");
Map<String, String> users = new HashMap<String, String>();
users.put("4", null); // add user 4 with its default role
users.put("56", "2"); // add user 56 with role 2
projectManager.registerUsers(users);
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 in the following form: <id_role>_<id_media>
separated by commas.
You will be able to use this information in security rules.
Note | For performance reasons this denormalization is not automatic and must be activated by the securityDenormalizeUserRightsInSurfer property in the configuration of the WXM_MediaCore plugin. |