]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/gss-lib-2.2/sample/SpreadSheet_Usage/src/com/prasanta/sample/ShareSample.java
Added gss-lib-2.2.
[Dictionary.git] / jars / gss-lib-2.2 / sample / SpreadSheet_Usage / src / com / prasanta / sample / ShareSample.java
1 package com.prasanta.sample;\r
2 \r
3 import java.util.ArrayList;\r
4 \r
5 import com.pras.Collaborator;\r
6 import com.pras.SpreadSheet;\r
7 import com.pras.SpreadSheetFactory;\r
8 \r
9 /**\r
10  * Demonstrates how to use SpreadSheet Share feature\r
11  * @author Prasanta Paul\r
12  *\r
13  */\r
14 public class ShareSample {\r
15 \r
16         public static void main(String[] args){\r
17                 \r
18                 SpreadSheetFactory spf = SpreadSheetFactory.getInstance(args[0], args[1]);\r
19                 \r
20                 // Get all SpreadSheets\r
21                 ArrayList<SpreadSheet> spreadSheets = spf.getAllSpreadSheets();\r
22                 \r
23                 if(spreadSheets == null || spreadSheets.size() == 0){\r
24                         System.out.println("No SpreadSheet exists");\r
25                 }\r
26                 \r
27                 SpreadSheet firstSP = spreadSheets.get(0);\r
28                 \r
29                 System.out.println("Read Collaborators of SpreadSheet: "+ firstSP.getEntry().getTitle());\r
30                 \r
31                 // Get the list of all people to whom this SpreadSheet is shared\r
32                 ArrayList<Collaborator> collaborators = spf.getAllCollaborators(firstSP);\r
33                 \r
34                 if(collaborators == null || collaborators.size() == 0){\r
35                         System.out.println("No Collaborators");\r
36                 }\r
37                 \r
38                 Collaborator c = null;\r
39                 \r
40                 for(int i=0; i<collaborators.size(); i++){\r
41                         c = collaborators.get(i);\r
42                         \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
47                 }\r
48                 \r
49                 System.out.println("<Change Access Rights: >"+ c.getScopeValue());\r
50                 spf.changeSharePermission(c, Collaborator.ROLE_READER);\r
51         }\r
52 }\r