2011-10-18 2 views
0

FatwireでREST APIを使用して新しいアセットを作成する際に問題が発生しました。私はアセットを読み込んで更新するために接続することができますが、私はエラーメッセージを受け取ります。Fatwire Rest API

お手伝いできますか?

エラーを受け取る - 私:

私のソースコードの下

"http://localfw.com.br:8080/cs/REST/sites/MySite/types/FD_Ajuda_C/assets/0?multiticket=ST-30-i3DZmlFcbbNNsdK0IwE0-cas-.com.br-1をPUTは、500の応答ステータスを返さ":

package com.fatwire.rest.samples.flex; 

import java.sql.Date; 

import javax.ws.rs.core.MediaType; 

import com.fatwire.rest.beans.AssetBean; 
import com.fatwire.rest.beans.Association; 
import com.fatwire.rest.beans.Associations; 
import com.fatwire.rest.beans.Attribute; 
import com.fatwire.rest.beans.Parent; 
import com.fatwire.rest.beans.Attribute.Data; 
import com.fatwire.rest.beans.Blob; 
import com.fatwire.wem.sso.SSO; 
import com.fatwire.wem.sso.SSOException; 
import com.fatwire.wem.sso.SSOSession; 
import com.sun.jersey.api.client.Client; 
import com.sun.jersey.api.client.UniformInterfaceException; 
import com.sun.jersey.api.client.WebResource; 
import com.sun.jersey.api.client.WebResource.Builder; 

public final class CreateAsset 
{ 

public static void main(String[] args) 
{ 
    // Step 1: Initiate Jersey client 
    Client client = Client.create(); 

    // Step 2: Create a WebResource with the base URL 
    WebResource webResource = 
     client.resource("http://localfw.com.br:8080/cs/REST/"); 

    // Step 3: Authenticate over SSO-CAS to acquire a ticket specific to a 
    // service or a multi-ticket over multiple services. 
    SSOSession ssoSession = null; 
    String multiticket = null; 
    try 
    { 
     ssoSession = SSO.getSSOSession("ExampleCASConfig.xml"); 
     multiticket = ssoSession.getMultiTicket("user", "pss"); 
    } 
    catch (SSOException e) 
    { 
     e.printStackTrace(); 
    } 

    // Step 4: Provide the ticket into the REST request 
    webResource = webResource.queryParam("multiticket", multiticket); 

    // Trying to create a Flex asset for the Flex asset type 
    String flexAssetSiteName = "FolhaDirigida"; 
    String flexAssetTypeName = "FD_Ajuda_C"; 

    // Step 5: Specify the REST Resource URL into the WebResource 
    // For creating assets of type {typename} in the CS site {sitename}, 
    // this is: {base_url}/sites/{sitename}/types/{typename}/assets/0 
    webResource = 
     webResource.path("sites").path(flexAssetSiteName).path("types") 
      .path(flexAssetTypeName).path("assets").path("0"); 

    // Step 6: Create a Builder and set the desired response type 
    // Supported response types are: 
    // MediaType.APPLICATION_XML, or, 
    // MediaType.APPLICATION_JSON 
    Builder builder = webResource.accept(MediaType.APPLICATION_XML); 

    // Step 7: Instantiate and define the AssetBean for the asset 
    AssetBean sourceAsset = new AssetBean(); 

    // Name - mandatory field 
    sourceAsset.setName("Test REST API FD_Ajuda_C"); 

    //sourceAsset.setId("1307037035763");   

    // Description - optional field 
    sourceAsset.setDescription("Test FD_Ajuda_C description"); 

    // Add attributes/associations/parents as in the Asset type 
    // definition 
    Attribute sourceAssetAttribute = new Attribute(); 
    Data sourceAssetAttributeData = new Data(); 
    sourceAssetAttribute.setName("titulo"); 
    sourceAssetAttributeData.setStringValue("Test Título FD_Ajuda_C"); 
    sourceAssetAttribute.setData(sourceAssetAttributeData); 
    sourceAsset.getAttributes().add(sourceAssetAttribute); 

    sourceAssetAttribute = new Attribute(); 
    sourceAssetAttributeData = new Data(); 
    sourceAssetAttribute.setName("conteudo"); 
    sourceAssetAttributeData.setStringValue("Test Long Description FD_Ajuda_C"); 
    sourceAssetAttribute.setData(sourceAssetAttributeData); 
    sourceAsset.getAttributes().add(sourceAssetAttribute); 

    sourceAssetAttribute = new Attribute(); 
    sourceAssetAttributeData = new Data(); 
    sourceAssetAttribute.setName("indAtivo"); 
    sourceAssetAttributeData.setStringValue("FD_IndAtivo_C:1307036912210"); 
    sourceAssetAttribute.setData(sourceAssetAttributeData); 
    sourceAsset.getAttributes().add(sourceAssetAttribute); 

    Parent parent = new Parent(); 
    parent.setParentDefName("CategoriaAjuda"); 
    parent.getAssets().add("FD_Conteudo_P:1307036837080"); 
    sourceAsset.getParents().add(parent); 

    // Required: Must specify the site(s) for the asset 
    sourceAsset.getPublists().add(flexAssetSiteName); 

    try{ 
     // Step 8: Invoke the REST request to create the asset 
     AssetBean resultAsset = builder.put(AssetBean.class, sourceAsset);   
    } 
    catch (UniformInterfaceException e) { 
     // TODO: handle exception    
     System.out.println("Teste" + e.getResponse()); 
     System.out.println(" || sourceAsset: " + sourceAsset.toString()); 
    } 


    // If the REST call encounter a server side exception, the client 
    // receives a UniformInterfaceException at runtime. 


    // Troubleshooting UniformInterfaceException 
    // ========================================= 
    // 
    // Cause: HTTP 403: User does not have permission to access the REST 
    // resource. 
    // Remedy: Use an authorized CAS user to use this REST resource. 
    // 
    // Cause: HTTP 404: Either site and/or asset type does not exist, or the 
    // asset type is not enabled in the site. 
    // Remedy: Verify existence of the site and/or asset type, if necessary 
    // create the site and/or type and make sure that the type is enabled in 
    // the site. 
    // 
    // Cause: HTTP 500: Generic server side exception. 
    // Remedy: Verify that the source AssetBean has been provided with all 
    // mandatory attributes, associations as per type definition, verify 
    // that at least one site has been provided in the publist attribute of 
    // the AssetBean. 
    // 
    // Cause: UnmarshalException. 
    // Remedy: Verify that the correct bean has been provided in the 
    // argument for put(). 
} 
} 
+0

今後のログから例外スタックトレースを投稿できますか? – Neel

答えて

0
  • は、ソースAssetBeanがされていることを確認しますすべて の必須属性、タイプ定義による関連付けを提供
  • 少なくとも1つのサイトで公開者属性 AssetBeanで提供されています