예제 #1
0
  public static ArrayList<ContentTreeItem> addDocFolders(
      ApplicationManager appManager,
      Application app,
      DataSourceBase dataSource,
      ContentTreeItem dataSourceItem,
      ContentTree destinationTree,
      long flags) {
    if (dataSource == null) {
      return null;
    }
    ContentTree tree = null;
    try {
      tree = GoogleTreeFactory.createDocFolderTree(appManager, app, dataSource.uid, flags);
    } catch (ParserConfigurationException e) {
      e.printStackTrace();
    } catch (SAXException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ParseException e) {
      e.printStackTrace();
    }

    if (tree == null) {
      return null;
    }

    /// add it to items :
    ContentTreeItem rootItem = new ContentTreeItem();
    rootItem.name = "Document Folders";
    String uuid = UUID.randomUUID().toString();
    rootItem.id = uuid;
    // rootItem.id = "55e969d6-c588-4268-a8b7-45240999d1cc";
    rootItem.children = new ArrayList<Reference>();
    destinationTree.items.add(rootItem);
    rootItem.type = "leaf";
    rootItem.contentType =
        "" + ECMContentSourceTypeTools.TypeToInteger(ECMContentSourceType.Unknown);

    Reference articleRef = new Reference();
    articleRef._reference = "" + rootItem.id;
    dataSourceItem.addChild(articleRef);

    for (int i = 0; i < tree.items.size(); i++) {
      ContentTreeItem item = tree.items.get(i);
      if (item.contentType != null
          && item.contentType.equals(
              ""
                  + ECMContentSourceTypeTools.TypeToInteger(
                      ECMContentSourceType.GoogleDocumentFolder))) {
        Reference ref = new Reference();
        ref._reference = "" + item.id;
        rootItem.addChild(ref);
        item.type = "leaf";
        item.contentType =
            "" + ECMContentSourceTypeTools.TypeToInteger(ECMContentSourceType.GoogleDocumentFolder);
      }
    }
    return tree.items;
  }
예제 #2
0
  public static ContentTree createDocFolderTree(
      ApplicationManager appManager, Application app, String dataSourceUid, long flags)
      throws ParserConfigurationException, SAXException, IOException, ParseException {
    ContentTree tree = new ContentTree();
    tree.id = "1";
    DataSourceBase dataSource = app.getDataSource(dataSourceUid);

    DataSourceCache dsc = ServerCache.getDSC(appManager, app, dataSource);
    ArrayList<CContent> calendars = dsc.getByType(ECMContentSourceType.GoogleDocumentFolder);
    if (calendars != null) {
      // addTreeItemsByParent(CList albums,ArrayList<CListItem>photos,ContentTree
      // tree,DataSourceBase dataSource)
      // addTreeItemsByParentCalendars(ArrayList<CContent>calendars,ContentTree tree,DataSourceBase
      // dataSource)
      GoogleTreeFactory.addTreeItemsByParentDocFolders(calendars, tree, dataSource);
    }

    return tree;
  }
예제 #3
0
  public static ContentTree createAlbumTree(
      ApplicationManager appManager, Application app, String dataSourceUid, long flags)
      throws ParserConfigurationException, SAXException, IOException, ParseException {
    ContentTree tree = new ContentTree();
    tree.id = "1";
    DataSourceBase dataSource = app.getDataSource(dataSourceUid);

    DataSourceCache dsc = ServerCache.getDSC(appManager, app, dataSource);
    ArrayList<CList> albums = dsc.getByType(ECMContentSourceType.GooglePicassaAlbum);
    ArrayList<CListItem> entries = dsc.getByType(ECMContentSourceType.GooglePicassaItem);
    if (albums != null && entries != null) {
      CList cAlbums = albums.get(0);
      if (cAlbums != null) {
        // addTreeItemsByParent(CList albums,ArrayList<CListItem>photos,ContentTree
        // tree,DataSourceBase dataSource)

        GoogleTreeFactory.addTreeItemsByParent(cAlbums, entries, tree, dataSource);
      }
    }

    return tree;
  }
예제 #4
0
  public static ContentTree createDataSourceTree(
      ApplicationManager appManager, Application app, long flags)
      throws ParserConfigurationException, SAXException, IOException, ParseException {
    ContentTree tree = new ContentTree();
    tree.id = "1";
    ArrayList<ContentTreeItem> result = new ArrayList<ContentTreeItem>();
    tree.setItems(result);

    ArrayList<DataSourceBase> datasources = app.getDataSources();

    ContentTreeItem rootItem = new ContentTreeItem();
    rootItem.name = "Data Sources";
    rootItem.label = "Data Sources";
    rootItem.id = "9898989";
    rootItem.children = new ArrayList<Reference>();
    // result.add(rootItem);
    tree.items.add(rootItem);
    rootItem.type = "top";
    rootItem.contentType =
        "" + ECMContentSourceTypeTools.TypeToInteger(ECMContentSourceType.Unknown);

    for (int i = 0; i < datasources.size(); i++) {
      DataSourceBase ds = datasources.get(i);
      String dsType = ds.getType();
      Boolean isValid =
          dsType.equals("Youtube")
              || dsType.equals("Picassa")
              || dsType.equals("Calendar")
              || dsType.equals("Documents");
      if (!isValid) continue;

      ContentTreeItem item = new ContentTreeItem();
      item.name = GoogleTreeFactory.getDataSourceLabel(ds);
      item.id = "" + ds.getUid();
      item.dataSourceUID = ds.uid;
      item.contentType =
          "" + ECMContentSourceTypeTools.TypeToInteger(ECMContentSourceType.DataSourceItem);
      /*
      item.children = new ArrayList<Reference>();
      Reference ref0 = new Reference();
      ref0._reference="" + "asdasd";
      item.addChild(ref0);
      */
      Reference ref = new Reference();
      ref._reference = "" + item.id;
      rootItem.addChild(ref);
      result.add(item);
      item.type = ds.getType();

      if (dsType.equals("Picassa")
          && BitUtils.hasFlag(
              flags,
              ECMContentSourceTypeTools.TypeToInteger(ECMContentSourceType.GooglePicassaAlbum))) {
        ArrayList<ContentTreeItem> albumItems =
            GoogleTreeFactory.addAlbums(appManager, app, ds, item, tree, flags);
        if (albumItems != null) {
          tree.items.addAll(albumItems);
        }
      }

      if (dsType.equals("Calendar")
          && BitUtils.hasFlag(
              flags,
              ECMContentSourceTypeTools.TypeToInteger(ECMContentSourceType.GoogleCalendar))) {
        ArrayList<ContentTreeItem> albumItems =
            GoogleTreeFactory.addCalendars(appManager, app, ds, item, tree, flags);
        if (albumItems != null) {
          tree.items.addAll(albumItems);
        }
      }

      Boolean docs =
          BitUtils.hasFlag(
              flags,
              ECMContentSourceTypeTools.TypeToInteger(ECMContentSourceType.GoogleDocumentFolder));
      if (dsType.equals("Documents")
          && BitUtils.hasFlag(
              flags,
              ECMContentSourceTypeTools.TypeToInteger(ECMContentSourceType.GoogleDocumentFolder))) {
        ArrayList<ContentTreeItem> albumItems =
            GoogleTreeFactory.addDocFolders(appManager, app, ds, item, tree, flags);
        if (albumItems != null) {
          tree.items.addAll(albumItems);
        }
      }
    }
    // tree.setItems(result);

    return tree;
  }