How to edit content

[tab:Actions]

Requirements

In order to be able to perform editing operations on a content it is necessary that the following conditions are complied:

  • You must use a business user and therefore possess its credentials (username and password or token). Some applications have the right to edit content, in this case you can authenticate through its appId.

  • The user must be the owner of the content or must have the write access over the content.

 

Updating basic information

Each content within THRON is enriched by a series of additional information. Typically this information is subject to change, especially if the source file is dynamic and is updated frequently. To retrieve basic content information you have to know their xcontentId and then you can use the web service getContentDetail, in the response you can view all the information and content metadata: title (for each language), author, owner, prettyID (for each language), creation date, last update, version number (the version number is incremental and corresponds to how many times you replaced the original file), address (URL) of the thumbnail, tags and metadata and all other information related to the content.

There are also specific web services that allow you to update content’s basic information, those services are included in JContent and JMetadata.

  • To change title and description (in a specific language) use the service UpdateContent4Locale.

  • To link a new metadata to a specific tag you can use the insert web service of imetadatadefinition while in order to set its value on a specific entity (content or contact) use the insert web service of imetadata. Further information can be found in this article.

  • There is a set of specific services for content’s prettyId: addContentPrettyId, updateContentPrettyId and removeContentPrettyId respectively for creating, updating and removal of a content prettyId in a specific language that must be included in the parameters of the request.

  • There is a set of specific services for the management of content’s rating: getContentScore allows to view the average vote received by the content; it consists of a number between 0 and 1; insertRating allows you to add a vote to a content, while removeRatings allows you to reset all the votes of a specific content; if you properly parameterize this specific request you can also revoke the vote posted by a specific user or in a specific time interval. 

 

Updating content’s version

THRON content are characterized by the fact that can be updated in time. The update status of a content is identified by its version number. To update a content you need to go replace the original file inside THRON repository, and this action will trigger the republishing of the content in all available channels, thumbnail included; if the content has been published to external projects such as websites or applications, there might be a period of time during which it will not be available: as long as the first available channel has been transcoded if you are using THRON player. To start the process of a content replacement you can use the service updateSource. Source file can be withdrawn from the platform where it can be uploaded using the same methods described for content creation. In order to perform this action you need the permission to create new content and the write access over the content you want to replace. 

Besides uploading a new file in order to create a new content version, you can even restore a previous one. In order to do so you will have to provide the specific versionId, which can be retrieved with a listversions request.

 

Tagging a content

THRON content might be enriched with tags in order to leverage intelligence and analytics collection. Along with the automatic assignation performed by the semantic and behavior engine, tags can be added to content by administrative users. The web service to be used in order to add a specific tag to your content is insert, which can is included within the itag package of xintelligence. Once a tag is linked to a content, this will inherit all metadata included within the tag. If that specific tag has one or more childs, such tags will be linked to the content too, along with their metadatas. Further information on tags an metadatas can be found here and here.[/tab]

 

[tab:Code Samples][dropdown: REST - UPDATING BASIC INFORMATION]

The function updateContent4Locale, used to add basic information of a content in a specific locale, is located within xcontents , within the “content” package.
In order to use it you must have a valid platform token, which ican be obtained by logging in to the platform.

In the body of the request, the minimum information to be included are :

  • clientId: compiled using the service code name (usually company name)
  • contentid: compiled with the xcontentId of the content to be updated
  • detail: an object containing the new data to be included in the content
  • name: the new title
  • description: the new description
  • locale: the language for which data must be updated

The headers that should be used for the request, which must be in POST are:

  • Content-Type : application / json
  • X-TokenId : XXXXX (using the token obtained through the login)

The url of the request is formatted according to the structure:

//[clientId]-view.thron.com/api/xcontents/resources/content/updateContent4Locale

Where [clientId] is the name of the service code as used for the body of the request.

You can test this functionality in the Developer Center here.

In the body of the request you can paste the following JSON, replacing the required values​​:

[/dropdown] [dropdown:REST - UDPATING CONTENT'S VERSION]

The function updateSource, used to update the version of a specific content, is located within xadmin in the content package. To use it you must own a valid platform token, obtainable by logging in to platform. Minimum information to be included in the body of the request are:

  • contentid: filled with the xcontentId of the specific content to be updated
  • sources: the origin of the new source file. It can be repository, FTP, S3, web or RAW data.

Headers that should be used for the request, which must be a POST are:

  • Content-Type : application / json
  • X - TokenId : XXXXX (using the token obtained through the login)

The url of the service is formatted according to this structure:

//[clientId]-view.thron.com/api/xadmin/resources/content/updateSource/[clientId] 

Where [clientId] is the name of the service code as used in the body of the request.

You can test this functionality in the Developer Center here.

In the body of the request you can paste the following JSON, replacing the required values​​:

{
    "xcontentId": "",
    "param": {
        "profileId": "",
        "sources": [{
            "repo": {
                "repositoryFileId": ""
            },
            "ftp": {
                "fileName": ""
            },
            "s3": {
                "bucket": "",
                "filePath": "",
                "newFileName": "",
                "removeSourceFile": false
            },
            "web": {
                "url": "",
                "newFileName": ""
            },
            "raw": {
                "buffer": [
                    ""
                ],
                "mimeType": ""
            }
        }],
        "preserveThumb": false
    },
    "silentMode": false
}

[/dropdown][dropdown: REST - RESTORING A PREVIOUS VERSION]

First thing to do is to retrieve the specific versionId. This can be done by invoking a listversions, which is a POST request included in the content package of xadmin.

Headers that should be used for the request, which must be a POST are:

  • Content-Type : application / json
  • X - TokenId : XXXXX (using the token obtained through the login)

The URL of the request is structured as follows: 

//[clientId]-view.thron.com/api/xadmin/resources/content/listVersions/[clientId]/[xcontentId]

In the body of the request, you can paste the following JSON:

{
  "offset": 0,
  "numberOfResults": 0
}

In the response of this request you will find the "id" of each specific version (the first id for each object in the response body).

Once you have copied this Id you will have to include it in the updateSource request.  

[/dropdown][dropdown:REST - TAGGING A CONTENT]

The function insert, used to add a tag to a specific content, is located within xintelligence in the itag package. To use it you must own a valid platform token, obtainable by logging in to platform. Minimum information to be included in the body of the request are:

  • entityType: filled with the type of entity of the target, in this case "CONTENT"
  • xcontentId: the ID of the content

Headers that should be used for the request, which must be a POST are:

  • Content-Type : application / json
  • X - TokenId : XXXXX (using the token obtained through the login)
  • classificationId: filled with the ID of the class which includes the specific tag to be added
  • tagId: the ID of the tag to be added

The url of the service is formatted according to this structure:

//[clientId]-view.thron.com/api/xintelligence/resources/itag/insert/[clientId]/[classificationId]/[tagId]

 

Where [clientId] is the name of the service code as used in the body of the request.

You can test this functionality in the Developer Center here.

In the body of the request you can paste the following JSON, replacing the required values​​: 

{
    "target": {
        "id": "",
        "entityType": ""
    },
    "suggested": false
}

[/dropdown] [dropdown:PHP - UPDATING CONTENT'S VERSION]

<?php

// #########################################
// CONFIG
// #########################################
// token

$tokenTHRON = 'TOKEN';

// client

$client_idTHRON = 'CLIENTID';

//  content  id

$xcontentIdTHRON = "CONTENT ID";

// id repository id new source file

$repositoryIdTHRON = "ID FILE REPOSITORY THRON "; //  id content repository THRON...file use for original replace
$removeOriginalFiles = false; //remove original file

// #########################################
// MAIN
// #########################################

$url = "http://" . $client_idTHRON . "-view.thron.com/api/xadmin/resources/dashboard/replaceSourceFiles";
$header = array(
    'X-TOKENID: ' . $tokenTHRON,
    "Content-Type: application/json"
);

// echo $url;

$request = array(
    "clientId" => $client_idTHRON,
    "xcontentId" => $xcontentIdTHRON,
    "sourceFiles" => array(
        "repositoryFileIds" => array(
            $repositoryIdTHRON
        )
    ) ,
    "removeOriginalFiles" => $removeOriginalFiles
);
$request = json_encode($request);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
$curlRes = curl_exec($curl);

// var_dump($curlRes);

$curlResInfo = curl_getinfo($curl);
curl_close($curl);
$resHeadersString = substr($curlRes, 0, $curlResInfo['header_size']);
$resBody = substr($curlRes, $curlResInfo['header_size']);
$response = json_decode($resBody, true);

// #########################################
// output

echo ("<br />UPDATE CONTENT VERSION <br />");

// print_r($request);

print_r($resBody);
?>

[/dropdown] [dropdown:JAVA - UPDATING BASIC INFORMATION]

/**

* Created by THRON S.p.A. on 06/11/14.

*/

import it.newvision.nvp.xcontents.model.MContent4Locale;

import it.newvision.nvp.xcontents.services.model.common.MCredential;

import it.newvision.nvp.xcontents.services.model.content.MResponseContentUpdateLocale;

import it.newvision.nvp.xcontents.services.model.request.MContentupdateContent4LocaleReq;

import it.newvision.nvp.xcontents.services.rest.JContentClient;



import org.codehaus.jackson.map.ObjectMapper;






public class updateContent {



 public static void main(String[] args)

 {

  /*SETUP FILE*/

  String clientId = "CLIENTID"; // client THRON

  String token = "TOKENID"; // token  THRON

  String xcontentId = "XCONTENIT"; //xcontentId

  String locale = "IT"; //locale (ex IT or EN)

  String titleContent = "New Demo title THRON"; //text title

  String descriptionContent = "New Demo description "; //text description



  //init object output

  ObjectMapper mapper = new ObjectMapper();

  // UPDATE CONTENT API THRON

  JContentClient Content = new JContentClient("http://" + clientId + "-view.thron.com/api/xcontents/resources");



  try {



   //--------------------------

   // UPDATE  Content

   //--------------------------

   // content data update

   MContent4Locale modLocale = new MContent4Locale();

   modLocale.setLocale(locale);

   modLocale.setDescription(descriptionContent);

   modLocale.setName(titleContent);

   MCredential clienTHRON = new MCredential();

   clienTHRON.setClientId(clientId);

   // init for update

   MContentupdateContent4LocaleReq updateContentReq = new MContentupdateContent4LocaleReq();

   updateContentReq.setClient(clienTHRON);

   updateContentReq.setContentId(xcontentId);

   updateContentReq.setDetail(modLocale);

   // update

   MResponseContentUpdateLocale risUpdate = Content.updateContent4Locale(token, updateContentReq, null);

   //result publish  content THRON

   System.out.println("THRON update content:");

   System.out.println(mapper.writeValueAsString(risUpdate));



  } catch (Exception e)

  {

   //error file THRON

   System.out.println(e);

  }



 }

}

[/dropdown] [dropdown:JAVA - UPDATING CONTENT'S VERSION]

import it.newvision.nvp.xadmin.services.model.request.MDashboardreplaceSourceFilesReq;
import it.newvision.nvp.xadmin.services.model.utils.MFiles;
import it.newvision.nvp.xadmin.services.model.utils.MResponseDashboard;
import it.newvision.nvp.xadmin.services.rest.JDashboardClient;
import org.codehaus.jackson.map.ObjectMapper;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by stefano.bisello on 18/12/14.
 */
public class updateContentVersion {

 public static void main(String[] args) {

  /*SETUP FILE*/
  String clientId = "CLIENTID";
  String tokenID = "TOKEN";
  String xcontentIdTHRON = "CONTENT ID";
  //id repository id new source file
  String repositoryIdTHRON = "ID FILE REPOSITORY THRON "; // id content repository THRON...file use for original replace
  // remove original file
  boolean removeOriginalFiles = true; //remove original file
  //MAIN
  //init object
  List < String > listIdRepository = new ArrayList < String > ();
  listIdRepository.add(repositoryIdTHRON);
  ObjectMapper mapper = new ObjectMapper();
  try {

   JDashboardClient replaceManager = new JDashboardClient("http://" + clientId + "-view.thron.com/api/xadmin/resources");
   // param
   MDashboardreplaceSourceFilesReq param = new MDashboardreplaceSourceFilesReq();
   MFiles replaceFileId = new MFiles();
   replaceFileId.setRepositoryFileIds(listIdRepository);

   //set param
   param.setClientId(clientId);
   param.setXcontentId(xcontentIdTHRON);
   param.setSourceFiles(replaceFileId);
   param.setRemoveOriginalFiles(removeOriginalFiles);
   //execute
   MResponseDashboard ris = replaceManager.replaceSourceFiles(tokenID, param, null);
   //RESULT THRON
   System.out.println(mapper.writeValueAsString(param));
   System.out.println(mapper.writeValueAsString(ris));

  } catch (Exception e) {
   //error file THRON
   System.out.println(e);
  }

 }
}

[/dropdown] [/tab]

Was this article helpful?
0 out of 0 found this helpful

Have more questions?

SUBMIT A REQUEST

Hai altre domande?

INOLTRA UNA RICHIESTA

Comments