Revision 4861
Added by daigle over 15 years ago
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
66 | 66 |
private static final String FIRSTTIME = "replication.firsttimedreplication"; |
67 | 67 |
private static final int TIMEINTERVALLIMIT = 7200000; |
68 | 68 |
private static Logger logMetacat = Logger.getLogger(MetacatReplication.class); |
69 |
public static final String REPLICATIONUSER = "replication"; |
|
69 | 70 |
|
70 | 71 |
/** |
71 | 72 |
* Initialize the servlet by creating appropriate database connections |
... | ... | |
658 | 659 |
Hashtable<String,String> docinfoHash = dih.getDocInfo(); |
659 | 660 |
|
660 | 661 |
// Get user owner of this docid |
661 |
// String user = (String)docinfoHash.get("user_owner"); |
|
662 |
// replication user owns all docs from here on out. |
|
663 |
String user = SessionService.REPLICATION_USER_NAME; |
|
662 |
String user = (String)docinfoHash.get("user_owner"); |
|
664 | 663 |
// Get home server of this docid |
665 | 664 |
String homeServer=(String)docinfoHash.get("home_server"); |
666 | 665 |
String createdDate = (String)docinfoHash.get("date_created"); |
... | ... | |
724 | 723 |
|
725 | 724 |
MetacatReplication.replLog("document " + docid + " added to DB with " + |
726 | 725 |
"action " + dbaction); |
727 |
EventLog.getInstance().log(request.getRemoteAddr(), SessionService.REPLICATION_USER_NAME, docid, dbaction);
|
|
726 |
EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid, dbaction);
|
|
728 | 727 |
}//try |
729 | 728 |
catch(Exception e) |
730 | 729 |
{ |
... | ... | |
758 | 757 |
MetacatReplication.replLog("force replication delete docid " + docid); |
759 | 758 |
logMetacat.info("Force replication delete request from: "+ server); |
760 | 759 |
logMetacat.info("Force replication delete docid: "+docid); |
761 |
DocumentImpl.delete(docid, SessionService.REPLICATION_USER_NAME, null, server);
|
|
760 |
DocumentImpl.delete(docid, null, null, server);
|
|
762 | 761 |
MetacatReplication.replLog("document " + docid + " was successfully deleted "); |
763 |
EventLog.getInstance().log(request.getRemoteAddr(), SessionService.REPLICATION_USER_NAME, docid, "delete");
|
|
762 |
EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid, "delete");
|
|
764 | 763 |
logMetacat.info("document " + docid + " was successfully deleted "); |
765 | 764 |
} |
766 | 765 |
catch(Exception e) |
... | ... | |
835 | 834 |
XMLReader docinfoParser = ReplicationHandler.initParser(dih); |
836 | 835 |
docinfoParser.parse(new InputSource(new StringReader(docInfoStr))); |
837 | 836 |
Hashtable<String,String> docinfoHash = dih.getDocInfo(); |
838 |
//String user = (String)docinfoHash.get("user_owner"); |
|
839 |
String user = (String)docinfoHash.get(SessionService.REPLICATION_USER_NAME); |
|
837 |
String user = (String)docinfoHash.get("user_owner"); |
|
840 | 838 |
|
841 | 839 |
String docName = (String)docinfoHash.get("docname"); |
842 | 840 |
|
... | ... | |
899 | 897 |
//false means non-timed replication |
900 | 898 |
MetacatReplication.replLog("datafile " + docid + " added to DB with " + |
901 | 899 |
"action " + dbaction); |
902 |
EventLog.getInstance().log(request.getRemoteAddr(), SessionService.REPLICATION_USER_NAME, docid, dbaction);
|
|
900 |
EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid, dbaction);
|
|
903 | 901 |
} |
904 | 902 |
|
905 | 903 |
} |
... | ... | |
1025 | 1023 |
} |
1026 | 1024 |
catch (Exception e) |
1027 | 1025 |
{ |
1028 |
logMetacat.error("error in " + |
|
1029 |
"metacatReplication.handlegetdocumentinforequest: " + |
|
1030 |
e.getMessage()); |
|
1026 |
logMetacat.error("error in metacatReplication.handlegetdocumentinforequest " |
|
1027 |
+ "for doc: " + docid + " : " + e.getMessage()); |
|
1031 | 1028 |
} |
1032 | 1029 |
|
1033 | 1030 |
} |
... | ... | |
1175 | 1172 |
} |
1176 | 1173 |
|
1177 | 1174 |
String docid = params.get("docid")[0]; |
1175 |
logMetacat.debug("MetacatReplication.handleGetDocumentRequest for docid: " + docid); |
|
1178 | 1176 |
DocumentImpl di = new DocumentImpl(docid); |
1179 | 1177 |
|
1180 | 1178 |
String documentDir = PropertyService.getProperty("application.documentfilepath"); |
... | ... | |
1185 | 1183 |
if (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST |
1186 | 1184 |
|| FileUtil.getFileSize(documentPath) == 0) { |
1187 | 1185 |
FileWriter fileWriter = new FileWriter(documentPath); |
1188 |
di.toXml(fileWriter, SessionService.REPLICATION_USER_NAME, null, true);
|
|
1186 |
di.toXml(fileWriter, null, null, true);
|
|
1189 | 1187 |
} |
1190 | 1188 |
|
1191 | 1189 |
// read the file from disk and sent it to PrintWriter |
1192 | 1190 |
// PrintWriter out = new PrintWriter(streamOut); |
1193 |
di.readFromFileSystem(out, SessionService.REPLICATION_USER_NAME, null, documentPath);
|
|
1191 |
di.readFromFileSystem(out, null, null, documentPath);
|
|
1194 | 1192 |
|
1195 | 1193 |
// response.setContentType("text/xml"); |
1196 | 1194 |
// out.print(di.toString(null, null, true)); |
src/edu/ucsb/nceas/metacat/AccessControlInterface.java | ||
---|---|---|
47 | 47 |
public static final String DENY="deny"; |
48 | 48 |
public static final String PUBLIC="public"; |
49 | 49 |
public static final String ACLID="acl"; |
50 |
public static final String ACCESS="access"; |
|
50 |
|
|
51 | 51 |
public static final String PERMISSION="permission"; |
52 | 52 |
public static final String PRINCIPAL="principal"; |
53 | 53 |
|
src/edu/ucsb/nceas/metacat/PermissionController.java | ||
---|---|---|
30 | 30 |
import java.sql.*; |
31 | 31 |
import java.util.Enumeration; |
32 | 32 |
import java.util.Hashtable; |
33 |
import java.util.Stack; |
|
33 | 34 |
import java.util.Vector; |
35 |
import java.util.Iterator; |
|
34 | 36 |
|
35 | 37 |
import org.apache.log4j.Logger; |
36 | 38 |
|
37 | 39 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
38 |
import edu.ucsb.nceas.metacat.service.SessionService; |
|
39 | 40 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
40 | 41 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
41 | 42 |
|
... | ... | |
44 | 45 |
private String docId = null; |
45 | 46 |
private boolean hasSubTreeAccessControl = false; // flag if has a subtree |
46 | 47 |
// access for this docid |
47 |
private Vector<SubTree> subTreeList = new Vector<SubTree>();
|
|
48 |
private Vector subTreeList = new Vector();
|
|
48 | 49 |
|
49 | 50 |
private long TOPLEVELSTARTNODEID = 0; //if start node is 0, means it is top |
50 | 51 |
//level document |
... | ... | |
106 | 107 |
{ |
107 | 108 |
return true; |
108 | 109 |
} |
109 |
|
|
110 |
if (user.equals(SessionService.REPLICATION_USER_NAME)) { |
|
111 |
return true; |
|
112 |
} |
|
113 | 110 |
|
114 | 111 |
//create a userpackage including user, public and group member |
115 | 112 |
userPackage=createUsersPackage(user, groups); |
... | ... | |
245 | 242 |
{ |
246 | 243 |
boolean flag = true; |
247 | 244 |
// Get unaccessble subtree for this user |
248 |
Hashtable<Long, SubTree> unaccessableSubTree = hasUnaccessableSubTree(user, groups,
|
|
245 |
Hashtable unaccessableSubTree = hasUnaccessableSubTree(user, groups, |
|
249 | 246 |
myPermission); |
250 |
Enumeration<SubTree> en = unaccessableSubTree.elements();
|
|
247 |
Enumeration en = unaccessableSubTree.elements(); |
|
251 | 248 |
while (en.hasMoreElements()) |
252 | 249 |
{ |
253 | 250 |
SubTree tree = (SubTree)en.nextElement(); |
... | ... | |
269 | 266 |
* @param groups the groups which the use is in |
270 | 267 |
* @param myPermission permission type to check for |
271 | 268 |
*/ |
272 |
public Hashtable<Long, SubTree> hasUnaccessableSubTree(String user, String[] groups,
|
|
269 |
public Hashtable hasUnaccessableSubTree(String user, String[] groups, |
|
273 | 270 |
String myPermission) throws McdbException |
274 | 271 |
{ |
275 |
Hashtable<Long, SubTree> resultUnaccessableSubTree = new Hashtable<Long, SubTree>();
|
|
272 |
Hashtable resultUnaccessableSubTree = new Hashtable();
|
|
276 | 273 |
String [] principals=null; |
277 | 274 |
int permission =AccessControlList.intValue(myPermission); |
278 | 275 |
|
... | ... | |
372 | 369 |
* is a subtree of subtree a. And user doesn't have read permission for both |
373 | 370 |
* so we only use subtree a is enough. |
374 | 371 |
*/ |
375 |
private Hashtable<Long, SubTree> mergeEquivalentSubtree(Hashtable<Long, SubTree> unAccessSubTree)
|
|
372 |
private Hashtable mergeEquivalentSubtree(Hashtable unAccessSubTree)
|
|
376 | 373 |
{ |
377 |
Hashtable<Long, SubTree> newSubTreeHash = new Hashtable<Long, SubTree>();
|
|
374 |
Hashtable newSubTreeHash = new Hashtable();
|
|
378 | 375 |
boolean needDelete = false; |
379 | 376 |
// check the parameters |
380 | 377 |
if (unAccessSubTree == null || unAccessSubTree.isEmpty()) |
... | ... | |
386 | 383 |
// look every subtree start point and stop point, to see if it is embedded |
387 | 384 |
// in another one. If embedded, they are equavelent and we can use bigger |
388 | 385 |
// one to replace smaller one |
389 |
Enumeration<SubTree> en = unAccessSubTree.elements();
|
|
386 |
Enumeration en = unAccessSubTree.elements(); |
|
390 | 387 |
while (en.hasMoreElements()) |
391 | 388 |
{ |
392 | 389 |
SubTree tree = (SubTree)en.nextElement(); |
... | ... | |
394 | 391 |
long startId = tree.getStartNodeId(); |
395 | 392 |
long endId = tree.getEndNodeId(); |
396 | 393 |
|
397 |
Enumeration<SubTree> enu = unAccessSubTree.elements();
|
|
394 |
Enumeration enu = unAccessSubTree.elements(); |
|
398 | 395 |
while (enu.hasMoreElements()) |
399 | 396 |
{ |
400 | 397 |
SubTree subTree = (SubTree)enu.nextElement(); |
401 |
//String subTreeId= subTree.getSubTreeId();
|
|
398 |
String subTreeId= subTree.getSubTreeId(); |
|
402 | 399 |
long subTreeStartId = subTree.getStartNodeId(); |
403 | 400 |
long subTreeEndId = subTree.getEndNodeId(); |
404 | 401 |
//compare and if the first subtree is a subtree of the second |
... | ... | |
658 | 655 |
throws SQLException, Exception |
659 | 656 |
{ |
660 | 657 |
Vector<AccessControlForSingleFile> accessControl = new Vector<AccessControlForSingleFile>(); |
661 |
//boolean hasRow;
|
|
658 |
boolean hasRow; |
|
662 | 659 |
PreparedStatement pStmt = null; |
663 | 660 |
DBConnection conn = null; |
664 | 661 |
int serialNumber = -1; |
... | ... | |
757 | 754 |
PreparedStatement pStmt = null; |
758 | 755 |
int permissionValue=permission; |
759 | 756 |
int permissionValueInTable; |
760 |
//int ticketCount;
|
|
757 |
int ticketCount; |
|
761 | 758 |
DBConnection conn = null; |
762 | 759 |
int serialNumber = -1; |
763 | 760 |
boolean topLever = false; |
... | ... | |
1084 | 1081 |
boolean withRevision) |
1085 | 1082 |
throws SQLException,McdbException, Exception |
1086 | 1083 |
{ |
1087 |
Hashtable<String, String> unAccessibleIdList = new Hashtable<String, String>(); |
|
1088 |
Hashtable<String, String> allIdList = getAllInlineDataIdList(docid); |
|
1084 |
Hashtable<String, String> unAccessibleIdList = new Hashtable(); |
|
1085 |
if (user == null) { |
|
1086 |
return unAccessibleIdList; |
|
1087 |
} |
|
1088 |
|
|
1089 |
Hashtable allIdList = getAllInlineDataIdList(docid); |
|
1089 | 1090 |
Enumeration<String> en = allIdList.keys(); |
1090 | 1091 |
while (en.hasMoreElements()) |
1091 | 1092 |
{ |
... | ... | |
1127 | 1128 |
* about the inline data. The key is subtree id and data is a inline internal |
1128 | 1129 |
* file name |
1129 | 1130 |
*/ |
1130 |
private static Hashtable<String, String> getAllInlineDataIdList(String docid) throws SQLException
|
|
1131 |
private static Hashtable getAllInlineDataIdList(String docid) throws SQLException |
|
1131 | 1132 |
{ |
1132 |
Hashtable<String, String> inlineDataList = new Hashtable<String, String>();
|
|
1133 |
Hashtable inlineDataList = new Hashtable();
|
|
1133 | 1134 |
String sql = "SELECT subtreeid, docid FROM xml_access WHERE " + |
1134 | 1135 |
"accessfileid = ? AND subtreeid IS NOT NULL"; |
1135 | 1136 |
PreparedStatement pStmt=null; |
src/edu/ucsb/nceas/metacat/ReplicationHandler.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
import edu.ucsb.nceas.metacat.service.DatabaseService; |
30 | 30 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
31 |
import edu.ucsb.nceas.metacat.service.SessionService; |
|
32 | 31 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
33 | 32 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
34 | 33 |
|
35 | 34 |
import java.sql.*; |
36 | 35 |
import java.util.*; |
37 | 36 |
import java.util.Date; |
37 |
import java.lang.Thread; |
|
38 | 38 |
import java.io.*; |
39 | 39 |
import java.net.*; |
40 | 40 |
import java.text.*; |
... | ... | |
42 | 42 |
import org.apache.log4j.Logger; |
43 | 43 |
import org.xml.sax.AttributeList; |
44 | 44 |
import org.xml.sax.ContentHandler; |
45 |
import org.xml.sax.DTDHandler; |
|
46 |
import org.xml.sax.EntityResolver; |
|
45 | 47 |
import org.xml.sax.ErrorHandler; |
46 | 48 |
import org.xml.sax.InputSource; |
47 | 49 |
import org.xml.sax.XMLReader; |
50 |
import org.xml.sax.SAXException; |
|
51 |
import org.xml.sax.SAXParseException; |
|
48 | 52 |
import org.xml.sax.helpers.XMLReaderFactory; |
49 | 53 |
import org.xml.sax.helpers.DefaultHandler; |
50 | 54 |
|
... | ... | |
130 | 134 |
// ReplicationServer got from |
131 | 135 |
// Server list |
132 | 136 |
String server = null; // Variable to store server name |
133 |
// String update;
|
|
134 |
Vector<String> responses = new Vector<String>();
|
|
137 |
String update; |
|
138 |
Vector responses = new Vector();
|
|
135 | 139 |
URL u; |
136 | 140 |
|
137 | 141 |
|
... | ... | |
389 | 393 |
REVINSERTNUMBER++; |
390 | 394 |
} |
391 | 395 |
String ip = getIpFromURL(u); |
392 |
EventLog.getInstance().log(ip, SessionService.REPLICATION_USER_NAME, accNumber, actions);
|
|
396 |
EventLog.getInstance().log(ip, MetacatReplication.REPLICATIONUSER, accNumber, actions);
|
|
393 | 397 |
|
394 | 398 |
|
395 | 399 |
}//try |
... | ... | |
518 | 522 |
REVINSERTNUMBER++; |
519 | 523 |
} |
520 | 524 |
String ip = getIpFromURL(u); |
521 |
EventLog.getInstance().log(ip, SessionService.REPLICATION_USER_NAME, accNumber, actions);
|
|
525 |
EventLog.getInstance().log(ip, MetacatReplication.REPLICATIONUSER, accNumber, actions);
|
|
522 | 526 |
|
523 | 527 |
}//if |
524 | 528 |
else |
... | ... | |
584 | 588 |
MetacatReplication.replLog("Doc " + docId + " deleted"); |
585 | 589 |
URL u = new URL("https://"+notifyServer); |
586 | 590 |
String ip = getIpFromURL(u); |
587 |
EventLog.getInstance().log(ip, SessionService.REPLICATION_USER_NAME, docId, "delete");
|
|
591 |
EventLog.getInstance().log(ip, MetacatReplication.REPLICATIONUSER, docId, "delete");
|
|
588 | 592 |
} |
589 | 593 |
|
590 | 594 |
}//try |
... | ... | |
1061 | 1065 |
continue; |
1062 | 1066 |
} |
1063 | 1067 |
|
1064 |
} |
|
1065 |
|
|
1066 |
catch (Exception e) { |
|
1067 |
logMetacat.error("error handling update doc in " + tableName |
|
1068 |
+ " in timed replication: " + e.getMessage()); |
|
1068 |
} catch (Exception e) { |
|
1069 |
logMetacat.error("error to handle update doc in " + tableName |
|
1070 |
+ " in time replication" + e.getMessage()); |
|
1069 | 1071 |
continue; |
1070 | 1072 |
} |
1071 | 1073 |
|
src/edu/ucsb/nceas/metacat/service/SessionService.java | ||
---|---|---|
40 | 40 |
private static Hashtable<String, SessionData> sessionHash = null; |
41 | 41 |
|
42 | 42 |
private static final String PUBLIC_SESSION_ID = "0"; |
43 |
public static final String PUBLIC_USER_NAME = "public"; |
|
44 |
|
|
45 |
private static final String REPLICATION_SESSION_ID = "1"; |
|
46 |
public static final String REPLICATION_USER_NAME = "replication"; |
|
47 | 43 |
|
48 | 44 |
/** |
49 | 45 |
* private constructor since this is a singleton |
... | ... | |
51 | 47 |
private SessionService() throws ServiceException { |
52 | 48 |
sessionHash = new Hashtable<String, SessionData>(); |
53 | 49 |
logMetacat.debug("Registering public session id: " + PUBLIC_SESSION_ID); |
54 |
registerSession(PUBLIC_SESSION_ID, PUBLIC_USER_NAME, null, null); |
|
55 |
registerSession(REPLICATION_SESSION_ID, REPLICATION_USER_NAME, null, null); |
|
50 |
registerSession(PUBLIC_SESSION_ID, "public", null, null); |
|
56 | 51 |
} |
57 | 52 |
|
58 | 53 |
/** |
... | ... | |
164 | 159 |
} |
165 | 160 |
|
166 | 161 |
/** |
167 |
* Get the replication session from the session hash table. |
|
168 |
*/ |
|
169 |
public static SessionData getReplicationSession() { |
|
170 |
return sessionHash.get(REPLICATION_SESSION_ID); |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 | 162 |
* Keep a session active by updating its last accessed time. |
175 | 163 |
* |
176 | 164 |
* @param sessionId |
src/edu/ucsb/nceas/metacat/AccessControlForSingleFile.java | ||
---|---|---|
125 | 125 |
catch (Exception e) |
126 | 126 |
{ |
127 | 127 |
logMetacat.error("Error in construct of AccessControlForSingle" + |
128 |
"File: " + e.getMessage()); |
|
128 |
"File for docid: " + docId + " : " + e.getMessage());
|
|
129 | 129 |
throw e; |
130 | 130 |
} |
131 | 131 |
} |
src/edu/ucsb/nceas/metacat/AccessControlList.java | ||
---|---|---|
63 | 63 |
{ |
64 | 64 |
|
65 | 65 |
|
66 |
private static String sysdate = DatabaseService.getDBAdapter().getDateTimeFunction(); |
|
67 |
private static String isnull = DatabaseService.getDBAdapter().getIsNULLFunction(); |
|
66 |
// private static String sysdate = DatabaseService.getDBAdapter().getDateTimeFunction();
|
|
67 |
// private static String isnull = DatabaseService.getDBAdapter().getIsNULLFunction();
|
|
68 | 68 |
|
69 | 69 |
private DBConnection connection; |
70 | 70 |
private String parserName; |
... | ... | |
631 | 631 |
return 0; |
632 | 632 |
} |
633 | 633 |
|
634 |
/* Get the int value of READ, WRITE or ALL. */ |
|
635 |
public static int intValue ( String permission ) |
|
636 |
{ |
|
637 |
if ( permission.equalsIgnoreCase("READ") ) { |
|
638 |
return READ; |
|
639 |
} else if ( permission.equalsIgnoreCase("WRITE") ) { |
|
640 |
return WRITE; |
|
641 |
} else if ( permission.equalsIgnoreCase("ALL") ) { |
|
642 |
return ALL; |
|
643 |
} |
|
644 |
|
|
645 |
return -1; |
|
646 |
} |
|
634 |
/* Get the int value of READ, WRITE, CHMOD or ALL. */ |
|
635 |
public static int intValue(String permission) { |
|
636 |
int thisPermission = 0; |
|
637 |
if (permission.toUpperCase().contains(CHMODSTRING)) { |
|
638 |
thisPermission |= CHMOD; |
|
639 |
} |
|
640 |
if (permission.toUpperCase().contains(READSTRING)) { |
|
641 |
thisPermission |= READ; |
|
642 |
} |
|
643 |
if (permission.toUpperCase().contains(WRITESTRING)) { |
|
644 |
thisPermission |= WRITE; |
|
645 |
} |
|
646 |
if (permission.toUpperCase().contains(ALLSTRING)) { |
|
647 |
thisPermission |= ALL; |
|
648 |
} |
|
647 | 649 |
|
648 |
/* Get the text value of READ, WRITE or ALL. */ |
|
649 |
public static String txtValue ( int permission ) |
|
650 |
{ |
|
651 |
StringBuffer txtPerm = new StringBuffer(); |
|
652 |
if (permission == READ) { |
|
653 |
txtPerm.append("READ"); |
|
654 |
} |
|
655 |
if (permission == WRITE) { |
|
656 |
txtPerm.append("WRITE"); |
|
657 |
} |
|
658 |
if (permission == ALL) { |
|
659 |
txtPerm.append("ALL"); |
|
660 |
} |
|
650 |
if (thisPermission == 0) { |
|
651 |
return -1; |
|
652 |
} else { |
|
653 |
return thisPermission; |
|
654 |
} |
|
655 |
} |
|
656 |
|
|
657 |
/* Get the text value of READ, WRITE, CHMOD or ALL. */ |
|
658 |
public static String txtValue(int permission) { |
|
659 |
StringBuffer txtPerm = new StringBuffer(); |
|
660 |
|
|
661 |
if ((permission & ALL) == ALL) { |
|
662 |
return ALLSTRING; |
|
663 |
} |
|
664 |
if ((permission & CHMOD) == CHMOD) { |
|
665 |
txtPerm.append(CHMODSTRING); |
|
666 |
} |
|
667 |
if ((permission & READ) == READ) { |
|
668 |
if (txtPerm.length() > 0) |
|
669 |
txtPerm.append(","); |
|
670 |
txtPerm.append(READSTRING); |
|
671 |
} |
|
672 |
if ((permission & WRITE) == WRITE) { |
|
673 |
if (txtPerm.length() > 0) |
|
674 |
txtPerm.append(","); |
|
675 |
txtPerm.append(WRITESTRING); |
|
676 |
} |
|
661 | 677 |
|
662 |
return txtPerm.toString();
|
|
663 |
}
|
|
678 |
return txtPerm.toString();
|
|
679 |
}
|
|
664 | 680 |
|
681 |
// /* Get the text value of READ, WRITE or ALL. */ |
|
682 |
// public static String txtValue ( int permission ) |
|
683 |
// { |
|
684 |
// StringBuffer txtPerm = new StringBuffer(); |
|
685 |
// if (permission == READ) { |
|
686 |
// txtPerm.append("READ"); |
|
687 |
// } |
|
688 |
// if (permission == WRITE) { |
|
689 |
// txtPerm.append("WRITE"); |
|
690 |
// } |
|
691 |
// if (permission == ALL) { |
|
692 |
// txtPerm.append("ALL"); |
|
693 |
// } |
|
694 |
// |
|
695 |
// return txtPerm.toString(); |
|
696 |
// } |
|
697 |
|
|
665 | 698 |
/** |
666 | 699 |
* Get Access Control List information for document from db connetion. |
667 | 700 |
* User or Group should have permissions for reading |
... | ... | |
972 | 1005 |
} |
973 | 1006 |
}//finally |
974 | 1007 |
} |
1008 |
|
|
1009 |
public static void main(String[] args) { |
|
1010 |
System.out.println("text value for CHMOD (" + CHMOD + "): " + txtValue(CHMOD)); |
|
1011 |
System.out.println("text value for READ: (" + READ + "): " + txtValue(READ)); |
|
1012 |
System.out.println("text value for WRITE: (" + WRITE + "): " + txtValue(WRITE)); |
|
1013 |
System.out.println("text value for ALL: (" + ALL + "): " + txtValue(ALL)); |
|
1014 |
int chmod_read = CHMOD|READ; |
|
1015 |
System.out.println("text value for CHMOD|READ: (" + chmod_read + "): " + txtValue(CHMOD|READ)); |
|
1016 |
int chmod_write = CHMOD|WRITE; |
|
1017 |
System.out.println("text value for CHMOD|WRITE: (" + chmod_write + "): " + txtValue(CHMOD|WRITE)); |
|
1018 |
int chmod_all = CHMOD|ALL; |
|
1019 |
System.out.println("text value for CHMOD|ALL: (" + chmod_all + "): " + txtValue(CHMOD|ALL)); |
|
1020 |
int read_write = READ|WRITE; |
|
1021 |
System.out.println("text value for READ|WRITE: (" + read_write + "): " + txtValue(READ|WRITE)); |
|
1022 |
int read_all = READ|ALL; |
|
1023 |
System.out.println("text value for READ|ALL: (" + read_all + "): " + txtValue(READ|ALL)); |
|
1024 |
int write_all = WRITE|ALL; |
|
1025 |
System.out.println("text value for WRITE|ALL: (" + write_all + "): " + txtValue(WRITE|ALL)); |
|
1026 |
int chmod_read_write = CHMOD|READ|WRITE; |
|
1027 |
System.out.println("text value for CHMOD|READ|WRITE: (" + chmod_read_write + "): " + txtValue(CHMOD|READ|WRITE)); |
|
1028 |
int chmod_read_all = CHMOD|READ|ALL; |
|
1029 |
System.out.println("text value for CHMOD|READ|ALL: (" + chmod_read_all + "): " + txtValue(CHMOD|READ|ALL)); |
|
1030 |
int chmod_write_all = CHMOD|WRITE|ALL; |
|
1031 |
System.out.println("text value for CHMOD|WRITE|ALL: (" + chmod_write_all + "): " + txtValue(CHMOD|WRITE|ALL)); |
|
1032 |
int read_write_all = READ|WRITE|ALL; |
|
1033 |
System.out.println("text value for READ|WRITE|ALL: (" + read_write_all + "): " + txtValue(READ|WRITE|ALL)); |
|
1034 |
int chmod_read_write_all = CHMOD|READ|WRITE|ALL; |
|
1035 |
System.out.println("text value for CHMOD|READ|WRITE|ALL: (" + chmod_read_write_all + "): " + txtValue(CHMOD|READ|WRITE|ALL)); |
|
1036 |
System.out.println(); |
|
1037 |
System.out.println("int value for GOOBER: " + intValue("GOOBER")); |
|
1038 |
System.out.println("int value for CHANGEPERMISSION: " + intValue("CHANGEPERMISSION")); |
|
1039 |
System.out.println("int value for READ: " + intValue("READ")); |
|
1040 |
System.out.println("int value for WRITE: " + intValue("WRITE")); |
|
1041 |
System.out.println("int value for ALL: " + intValue("ALL")); |
|
1042 |
System.out.println("int value for CHANGEPERMISSION,READ: " + intValue("CHANGEPERMISSION,READ")); |
|
1043 |
System.out.println("int value for CHANGEPERMISSION,WRITE: " + intValue("CHANGEPERMISSION,WRITE")); |
|
1044 |
System.out.println("int value for CHANGEPERMISSION,ALL: " + intValue("CHANGEPERMISSION,ALL")); |
|
1045 |
System.out.println("int value for READ,WRITE: " + intValue("READ,WRITE")); |
|
1046 |
System.out.println("int value for READ,ALL: " + intValue("READ,ALL")); |
|
1047 |
System.out.println("int value for WRITE,ALL: " + intValue("WRITE,ALL")); |
|
1048 |
System.out.println("int value for CHANGEPERMISSION,READ,WRITE: " + intValue("CHANGEPERMISSION,READ,WRITE")); |
|
1049 |
System.out.println("int value for CHANGEPERMISSION,READ,ALL: " + intValue("CHANGEPERMISSION,READ,ALL")); |
|
1050 |
System.out.println("int value for CHANGEPERMISSION,READ,ALL: " + intValue("CHANGEPERMISSION,WRITE,ALL")); |
|
1051 |
System.out.println("int value for READ,WRITE,ALL: " + intValue("READ,WRITE,ALL")); |
|
1052 |
System.out.println("int value for CHANGEPERMISSION,READ,WRITE,ALL: " + intValue("CHANGEPERMISSION,READ,WRITE,ALL")); |
|
1053 |
} |
|
975 | 1054 |
|
976 | 1055 |
} |
Also available in: Unified diff
Roll back replication user changes. Fix code that converts access levels to integer and to text.