Package com.ibm.sbt.util

Examples of com.ibm.sbt.util.DataNavigator


                    Map<String, String> p = Collections.singletonMap(key, lcid);
                    HandlerXml xml = new HandlerXml();
                    Document doc = (Document)svc.get("/profiles/atom/profile.do",p,xml).getData();
                    XmlNavigator nav = new XmlNavigator(doc);
                    ProfilesData data = new ProfilesData();
                    DataNavigator entry = nav.get("feed/entry/content/div/span/div");
                    data.privateData = privateData;
                    data.lcname = nav.get("feed/entry/contributor/name").stringValue(".");
                    data.lcid = entry.selectEq("@class","x-lconn-userid").stringValue(".");
                    data.lckey = entry.selectEq("@class","x-profile-key").stringValue(".");
                    data.thumbnailUrl = entry.get("img").selectEq("@class","photo").stringValue("@src");
                    data.email = entry.get("a").selectEq("@class","email").stringValue(".");                   
                    data.groupwareMail = entry.selectEq("@class","x-groupwareMail").stringValue(".");
                    data.role = entry.selectEq("@class","role").stringValue(".");
                    data.title = entry.selectEq("@class","TITLE").stringValue(".");
                    return data;
                }
            } catch(ClientServicesException ex) {
                // Ok, leave the profile empty...
                // But we return a profile withe an error in it
View Full Code Here


    //Utilities
    //TODO - Add utility methods for all profile attributes
    public static String getURL(Object json){
        JsonNavigator nav = new JsonNavigator(json);
        DataNavigator entry = nav.get("entry");
        entry = entry.get("photos");
        entry = entry.selectEq("type", "Photo");
        return entry.stringValue("value");
    }
View Full Code Here

        return entry.stringValue("value");
    }

    public static String getEMail(Object json){
        JsonNavigator nav = new JsonNavigator(json);
        DataNavigator entry = nav.get("entry");
        return entry.stringValue("emailAddress");
    }
View Full Code Here

        return entry.stringValue("emailAddress");
    }

    public static String getPrimaryAddress(Object json){
        JsonNavigator nav = new JsonNavigator(json);
        DataNavigator entry = nav.get("entry");
        entry = entry.get("addresses");
        entry = entry.selectEq("title", "Primary Address");
        return entry.stringValue("address");
    }
View Full Code Here

        return entry.stringValue("address");
    }

    public static String getPrimaryPhone(Object json){
        JsonNavigator nav = new JsonNavigator(json);
        DataNavigator entry = nav.get("entry");
        entry = entry.get("phoneNumbers");
        entry = entry.selectEq("title", "Primary Telephone");
        return entry.stringValue("phone");
    }
View Full Code Here

    public SmartCLoudContactsService(Endpoint endpoint, String serviceUrl) {
        super(endpoint.getLabel());
    }
   
    public static LLContact[] parseContacts(Object json){
        DataNavigator navigator  = new JsonNavigator(json).get("entry");
        List<LLContact> contacts = new ArrayList<LLContact>();
        if(navigator != null){
            for(int i = 0; i < navigator.getCount(); i++){
                DataNavigator nav = navigator.get(i);
                DataNavigator photo = nav.get("photos").selectEq("type", "Photo");
                String val = photo.stringValue("value");
                LLContact contact = new LLContact();
                contact.setPhoto(val);
                val = nav.stringValue("displayName");
                contact.setName(val);
                val = nav.stringValue("emailAddress");
View Full Code Here

      HandlerJson json= new HandlerJson();   
      Object jsonObject = (Object) svc.get(serviceUrl,params, json).getData();
        ArrayList<FileEntry> entries = new ArrayList<FileEntry>();
        String epName = accessor.findEndpointName();
        JsonNavigator navigator = new JsonNavigator(jsonObject);
        DataNavigator contentsNav = navigator.get("contents");
        for (int i = 0; i < contentsNav.getCount(); ++i) {
            FileEntry entry = new FileEntry();
            DataNavigator nav = contentsNav.get(i);
            try {
                String title = nav.stringValue("path");
                String[] result = title.split("/");
                entry.setTitle(result[result.length - 1]);
                entry.setUpdated(nav.dateValue("modified"));
                entry.setBytes(nav.intValue("bytes"));
                entry.setSize(nav.stringValue("size"));
                entry.setAuthorName(params.get("subscriberId"));
                entry.setVersion(String.valueOf( nav.doubleValue("revision")));
                boolean isDir = nav.booleanValue("is_dir");
                entry.setIsDirectory(isDir);
                if(!isDir){
                    entry.setMimeType(nav.stringValue("mime_type"));
                }
                else{
                    entry.setMimeType("undefined");
                }
                entry.setIcon(MimeIconRegistry.getInstance().get(entry.getMimeType()));
                entry.setPath(nav.stringValue("path"));
                String proxyUrl = "xsp/.proxy/files/" + title + "?" + PARAM_TYPE + "=" + TYPE + "&path=" + entry.getPath() + "&mimeType=" + entry.getMimeType() + "&" + PARAM_ENDPOINT_NAME + "=";
                if(StringUtil.isNotEmpty(epName)){
                    proxyUrl = proxyUrl + epName;
                }
                else{
View Full Code Here

          HandlerXml xml = new HandlerXml();
          Object result = svc.get("/files/basic/api/introspection",params, xml).getData();
           
            if (result instanceof Document) {
                XmlNavigator workspacesNavigator = new XmlNavigator((Document) result);
                DataNavigator filesNavigator = workspacesNavigator.get(TAG_SERVICE + "/" + TAG_WORKSPACE).selectEq(TAG_TITLE, ATTR_VAL_FILES);
                String href = filesNavigator.get(TAG_COLLECTION).selectEq(TAG_TITLE, ATTR_VAL_MY_FILES).stringValue(ATTR_HREF);
                if (StringUtil.isNotEmpty(href)) {
                    String start = svc.getEndpoint().getUrl();
                    if (href.indexOf(start) > -1) {
                        href = href.substring(href.indexOf(start) + start.length());
                    }
                    ClientService filesService = createClientService(svc.getEndpoint(), href);
                    result = filesService.get(href, ClientService.FORMAT_XML).getData();
                    if (result instanceof Document) {
                        Document entriesDocument = (Document) result;
                        XmlNavigator entriesNavigator = new XmlNavigator(entriesDocument);
                        DataNavigator entries = entriesNavigator.get(TAG_FEED + "/" + TAG_ENTRY);
                        String repId = entriesNavigator.stringValue(TAG_FEED + "/" + TAG_ID);
                        if (StringUtil.isNotEmpty(repId)) {
                            repId = repId.substring(repId.lastIndexOf(':') + 1);
                        }
                        if (entries != null) {
                            String epName = accessor.findEndpointName();
                            for (int i = 0; i < entries.getCount(); i++) {
                                DataNavigator navigator = entries.get(i);
                                FileEntry fe = new FileEntry();
                                fe.setRepository(repId);
                                fe.setTitle(navigator.stringValue(TAG_LABEL));
                                fe.setUpdated(navigator.dateValue(TAG_MODIFIED));
                                fe.setAuthorName(navigator.stringValue(TAG_AUTHOR + "/" + TAG_NAME));
                                fe.setDescription(navigator.stringValue(TAG_SUMMARY));
                                fe.setFileId(navigator.stringValue(TAG_UUID));
                                fe.setUniqueId(fe.getFileId());
                                fe.setMimeType(getMimeType(navigator.stringValue(TAG_LABEL)));
                                fe.setIcon(MimeIconRegistry.getInstance().get(fe.getMimeType()));
                                String proxyUrl = "xsp/.proxy/files/"+accessor.findEndpointName()+"/connections/" + fe.getTitle() + "?" + PARAM_TYPE + "=" + TYPE + "&" + PARAM_ID
                                        + "=" + fe.getUniqueId() + "&" + PARAM_REPOSITORY_ID + "=" + repId + "&"+"fileName="+fe.getTitle()+"&" + PARAM_ENDPOINT_NAME
                                        + "=";
                                if (StringUtil.isNotEmpty(epName)) {
                                    proxyUrl = proxyUrl + epName;
                                }
                                else {
                                    proxyUrl = proxyUrl + TYPE;
                                }
                                fe.setProxyURL(proxyUrl);

                                fe.setPublished(navigator.dateValue(TAG_PUBLISHED));
                                fe.setVersion(navigator.stringValue(TAG_VERSION));
                                fe.setVisibility(navigator.stringValue(TAG_VISIBILITY));
                                fileEntries.add(fe);
                            }
                        }
                    }
                }
View Full Code Here

        ArrayList<FileEntry> entries = new ArrayList<FileEntry>();
        // Extract the content from the ATOM feed...
        XmlNavigator navigator = new XmlNavigator(document);
        //TODO Externalize these constants
        DataNavigator mynav = navigator.get("feed/entry");

        if (mynav != null) {
            String epName = accessor.findEndpointName();
            for (int i = 0; i < mynav.getCount(); i++) {
                FileEntry entry = new FileEntry();
                DataNavigator nav = mynav.get(i);
                entry.setUserId((String) UserBean.get().getPerson().getField(LOTUS_LIVE_SUBSCRIBER_ID));
                entry.setTitle(nav.stringValue("title"));
                entry.setUpdated(nav.dateValue("updated"));
                entry.setPublished(nav.dateValue("published"));
                entry.setAuthorName(nav.stringValue("author/name"));
               
                String id = nav.stringValue("id");
                if (StringUtil.isNotEmpty(id)) {
                    int index = id.indexOf("snx:file!");
                    if (index != -1) {
                        index = index + "snx:file!".length();
                        id = id.substring(index);
                    }
                }
                //hack
                id=id.replace("http://www.ibm.com/xmlns/prod/sn/cmis/00000000-0000-0000-0001-000000000000!", "");
                entry.setFileId(id);
                entry.setUniqueId(id);
                DataNavigator propsNavigator = nav.get("object/properties");

                String description = propsNavigator.get("propertyString").selectEq("@displayName", "Description").stringValue("value");
                entry.setDescription(StringUtil.getNonNullString(description));
                String size = propsNavigator.get("propertyInteger").selectEq("@propertyDefinitionId", "cmis:contentStreamLength").stringValue("value");
                entry.setSize(calculateBytes(size));
                String version = propsNavigator.get("propertyString").selectEq("@propertyDefinitionId", "cmis:versionLabel").stringValue("value");
                entry.setVersion(StringUtil.getNonNullString(version));
                String visibility = propsNavigator.get("propertyString").selectEq("@propertyDefinitionId", "snx:visibilityComputed").stringValue("value");
                entry.setVisibility(StringUtil.getNonNullString(visibility));
                String mimeType = propsNavigator.get("propertyString").selectEq("@propertyDefinitionId", "cmis:contentStreamMimeType").stringValue("value");
                entry.setMimeType(mimeType);
                entry.setIcon(MimeIconRegistry.getInstance().get(mimeType));
               
                String proxyUrl = "xsp/.proxy/files/" + entry.getTitle() + "?" + PARAM_TYPE + "=" + TYPE + "&" + PARAM_ID + "="
                        + entry.getFileId() + "&" + PARAM_REPOSITORY_ID + "=" + composeRepositoryID(entry) + "&"+"fileName="+entry.getTitle()+ "&" + PARAM_ENDPOINT_NAME
View Full Code Here

                ActivityStreamService svc = createService(findEndpointBean(),getServiceUrl());
                Map<String,String> parameters = getParameters(index, blockSize);

                //TODO Padraic Is this correct?
                DataNavigator.Json nav = new DataNavigator.Json(svc.getAllUpdates(parameters)); // this.data has the response feed.
          DataNavigator entry = nav.get("list");
               
                Object[] data = new Object[entry.getCount()];
                for(int i=0; i<data.length; i++) {
                    data[i] = entry.get(i);
                }
                return new ArrayBlock(index,data);
            } catch(Exception ex) {
                throw new FacesExceptionEx(ex,"Error while reading the Activity Streams");
            }
View Full Code Here

TOP

Related Classes of com.ibm.sbt.util.DataNavigator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.