1 package com.prasanta.sample;
\r
3 import java.util.ArrayList;
\r
5 import com.pras.Collaborator;
\r
6 import com.pras.SpreadSheet;
\r
7 import com.pras.SpreadSheetFactory;
\r
10 * Demonstrates how to use SpreadSheet Share feature
\r
11 * @author Prasanta Paul
\r
14 public class ShareSample {
\r
16 public static void main(String[] args){
\r
18 SpreadSheetFactory spf = SpreadSheetFactory.getInstance(args[0], args[1]);
\r
20 // Get all SpreadSheets
\r
21 ArrayList<SpreadSheet> spreadSheets = spf.getAllSpreadSheets();
\r
23 if(spreadSheets == null || spreadSheets.size() == 0){
\r
24 System.out.println("No SpreadSheet exists");
\r
27 SpreadSheet firstSP = spreadSheets.get(0);
\r
29 System.out.println("Read Collaborators of SpreadSheet: "+ firstSP.getEntry().getTitle());
\r
31 // Get the list of all people to whom this SpreadSheet is shared
\r
32 ArrayList<Collaborator> collaborators = spf.getAllCollaborators(firstSP);
\r
34 if(collaborators == null || collaborators.size() == 0){
\r
35 System.out.println("No Collaborators");
\r
38 Collaborator c = null;
\r
40 for(int i=0; i<collaborators.size(); i++){
\r
41 c = collaborators.get(i);
\r
43 System.out.println("EditLink: "+ c.getEditLink());
\r
44 System.out.println("Role: "+ c.getRole());
\r
45 System.out.println("Scope Type: "+ c.getScopeType());
\r
46 System.out.println("Scope Value: "+ c.getScopeValue());
\r
49 System.out.println("<Change Access Rights: >"+ c.getScopeValue());
\r
50 spf.changeSharePermission(c, Collaborator.ROLE_READER);
\r