HH Soap - EntityType

nicoesiea's Avatar

nicoesiea

14 May, 2012 03:26 PM

hello,
I used the soap API 6.7 on the old version of cascadeServer.
To use the soap API 6.10 I have to understand how the EntityType attribute is now managed . It is completely removed and it makes my code wrong.

How can I find this attribute from the new class PublishableAsset?
If this is not possible is there a simple solution to implement it?

Thx,
Nicolas

  1. 2 Posted by jenkshaw on 14 May, 2012 04:19 PM

    jenkshaw's Avatar

    Hello,

    I will be away from the office until May 22nd. Please contact [email blocked] with any problems or questions.

    Thanks,
    Shawn

    >>> "nicoesiea" <[email blocked]> 05/14/12 09:26 >>>

  2. Support Staff 3 Posted by Bradley Wagner on 14 May, 2012 05:07 PM

    Bradley Wagner's Avatar

    Can you please include a sample of your script that you're having issues with?

  3. 4 Posted by nicoesiea on 15 May, 2012 07:18 AM

    nicoesiea's Avatar

    This is a very short sample :

    List assets = ....
    for (PublishableAsset asset : assets) {
    if (asset.getEntityType().getName().equals(EntityTypeString.page)) {...

    And here, the methode getEntityType does not exist since the new version API 6.10.
    Is there a way to do this without getEntityType methdoe?

  4. Support Staff 5 Posted by Bradley Wagner on 16 May, 2012 03:50 PM

    Bradley Wagner's Avatar

    Hi,

    Given that you are using Java, you should be able to replace your type checks with an "instanceof" check like the following:

    if (asset instanceof com.hannonhill.www.ws.ns.AssetOperationService.Page)
    

    Can you tell me where you're getting the list of PublishableAssets? Most API operations that return collections of assets of mixed-types specify the explicit type of the assets being returned. I'd be curious to see where you were getting a set of PublishableAssets from.

    Thanks!

  5. Bradley Wagner closed this discussion on 16 May, 2012 11:48 PM.

  6. nicoesiea re-opened this discussion on 21 May, 2012 08:28 AM

  7. 6 Posted by nicoesiea on 21 May, 2012 08:28 AM

    nicoesiea's Avatar

    Hello Bradley,

    Use the instanceOf operator is great, thx.
    In fact I find the PublishableAssets from :

    List<PublishableAsset> assets;
    try {
         assets = cs1.listFolder(path);
    } catch (RemoteException e) {
         e.printStackTrace();
         return;
    }
    

    The listFolder methode is in the CascadeServer class, it's :

    public List<PublishableAsset> listFolder(String path) throws RemoteException {
    
            List<PublishableAsset> assets = new ArrayList<PublishableAsset>();
    
            // === Parse all the assets contained inside this folder :
            Folder f = handler.read( authentication, new Identifier(null, new Path(path, null, site),EntityTypeString.folder, false)).getAsset().getFolder();
    
            // Indicates a folder.
            Identifier[] ids = f.getChildren();
            for (int i = 0; i < ids.length; i++) {
    
                if (ids[i].getType().equals(EntityTypeString.page)) {
                    Asset a = handler.read( authentication, new Identifier(ids[i].getId(), null, ids[i].getType(), false)).getAsset();
                    assets.add(a.getPage());
                }
    
                if (ids[i].getType().equals(EntityTypeString.folder)) {
                    Asset a = handler.read(
                            authentication,
                            new Identifier(ids[i].getId(), null, ids[i].getType(),
                                    false)).getAsset();
                    assets.add(a.getFolder());
                }
    
            }
    
            return assets;
        }
    

    Is it not a good solution ???

  8. 7 Posted by nicoesiea on 21 May, 2012 01:41 PM

    nicoesiea's Avatar

    But now, with 6.10.9 version I want try my Java code on the example but there are lot of errors.
    On my listFolder method I have a new NullPointerException exception with the following code :

    List<PublishableAsset> assets = new ArrayList<PublishableAsset>();
            //Path
            Path pat = new Path(path, null, site);
           
            // === Parse all the assets contained inside this folder :
            Identifier iden = new Identifier(null, pat,EntityTypeString.folder, false);
           
            if (authentication == null){
                System.out.println("auth null");
            }
            if (iden == null){
                System.out.println("iden null");
            }
           
            //Folder f = handler.read( authentication, iden).getAsset().getFolder();
            Folder f = handler.read( authentication, iden).getAsset().getFolder();
    

    on my script I asked assets = cs1.listFolder("_compagny"); with the site : private String site = "example.com";

    Can you explain to me the raison of my bug ??

  9. Support Staff 8 Posted by Bradley Wagner on 22 May, 2012 03:04 PM

    Bradley Wagner's Avatar

    Your code to read the contents of a Folder and create a collection of all the Folder's children looks fine.

    Your NullPointerException is likely happening around here:

            //Folder f = handler.read( authentication, iden).getAsset().getFolder();
            Folder f = handler.read( authentication, iden).getAsset().getFolder();
    

    You need to make sure that the getAsset is not null before trying to invoke getFolder on it. Can you include some actual values that you're using to build the Path object?

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.