Project

General

Profile

« Previous | Next » 

Revision 5096

Added by daigle about 15 years ago

Removed some old commented out code

View differences:

src/edu/ucsb/nceas/metacat/Eml210SAXHandler.java
96 96

  
97 97
	private Vector<SubTree> subTreeList = new Vector<SubTree>();// store the
98 98
																// final subtree
99

  
100
	// MCD - Removed the following lines. They are used for node level access
101
	// control
102
	// which is not yet implemented in EML 2.1.0
103
	// private Hashtable<String,SubTree> unChangeableSubTreeHash = new
104
	// Hashtable<String,SubTree>();
105
	// private Stack<NodeRecord> currentUnChangeableSubtreeNodeStack = new
106
	// Stack<NodeRecord>();
107
	// private boolean startCriticalSubTree = false;
108
	// private boolean firstElementForCriticalSubTree = false;
109
	// private String firstElementNameForCriticalSubTree;
110 99
	
111 100
	private boolean needToCheckAccessModule = false;
112 101

  
......
231 220
		}
232 221
	}
233 222

  
234
	// MCD - Removed the following method. It is used for node level access
235
	// control
236
	// which is not yet implemented in EML 2.1.0
237
	// /* Pass a permission control and get the list of unchangable subtree */
238
	// private Hashtable getUnchangableSubTree(PermissionController controller,
239
	// String user, String[] groups) throws Exception
240
	// {
241
	// Hashtable list = null;
242
	// Hashtable result = new Hashtable();
243
	// // get unwritable sutree from controller
244
	// list = null;
245
	// // changed after old code removal
246
	// //controller.hasUnaccessableSubTree(user, groups,
247
	// // AccessControlInterface.WRITESTRING);
248
	// if (list != null) {
249
	//
250
	// Enumeration en = list.elements();
251
	// while (en.hasMoreElements()) {
252
	// // Get a subtree without node record list
253
	// SubTree treeWithoutStack = (SubTree) en.nextElement();
254
	// String subTreeId = treeWithoutStack.getSubTreeId();
255
	// logMetacat.info(
256
	// "unchangable subtree id: " + subTreeId);
257
	// long startNodeId = treeWithoutStack.getStartNodeId();
258
	// logMetacat.info("unchangable subtree startnodeid: "
259
	// + startNodeId);
260
	// long endNodeId = treeWithoutStack.getEndNodeId();
261
	// logMetacat.info("unchangable subtree endnodeid: "
262
	// + endNodeId);
263
	// // Get a subtree has the nodelist
264
	// SubTree tree = new SubTree(docid, subTreeId, startNodeId,
265
	// endNodeId);
266
	// // add this tree to the result
267
	// result.put(subTreeId, tree);
268
	//
269
	// }//while
270
	//
271
	// }//if
272
	//
273
	// return result;
274
	// }
275

  
276 223
	/*
277 224
	 * Get the subtree node info from xml_accesssubtree table
278 225
	 */
......
384 331
			// If hit a text node, we need write this text for current's parent
385 332
			// node This will happen if the element is mixed
386 333
			if (hitTextNode && parentNode != null) {
387
				// MCD - Removed the following method. It is used for node level
388
				// access control
389
				// which is not yet implemented in EML 2.1.0
390
				// //compare text node data for unchangeablesubtree
391
				// if (startCriticalSubTree) {
392
				// compareTextNode(currentUnChangeableSubtreeNodeStack,
393
				// textBuffer, PERMISSIONERROR);
394
				// }//if
395 334

  
396 335
				// compare top level access module
397 336
				if (processTopLevelAccess && needToCheckAccessModule) {
......
521 460
					resolver.resolveNameSpace();
522 461

  
523 462
				} else if (attributeName != null && attributeName.equals(ID)) {
524
					// MCD - Removed the following code. It is used for node
525
					// level access
526
					// control which is not yet implemented in EML 2.1.0
527
					// // check unchangeable subtree hash if contains this
528
					// // subtree id
529
					// if (unChangeableSubTreeHash.containsKey(attributeValue))
530
					// {
531
					// // this subtree couldn't be changed by the user and
532
					// // move it from hash
533
					// SubTree currentUnChangedableSubtree =
534
					// unChangeableSubTreeHash
535
					// .remove(attributeValue);
536
					// currentUnChangeableSubtreeNodeStack =
537
					// currentUnChangedableSubtree
538
					// .getSubTreeNodeStack();
539
					// startCriticalSubTree = true;
540
					// firstElementForCriticalSubTree = true;
541
					// }
463

  
542 464
				}
543 465
			}// for
544 466

  
......
614 536
			// Add the node to the vector used by thread for writing XML Index
615 537
			nodeIndex.addElement(currentNode);
616 538

  
617
			// MCD - Removed the following code. It is used for node level
618
			// access
619
			// control which is not yet implemented in EML 2.1.0
620
			// // handle critical subtree
621
			// if (startCriticalSubTree && firstElementForCriticalSubTree) {
622
			// //store the element name
623
			// firstElementNameForCriticalSubTree = qName;
624
			// firstElementForCriticalSubTree = false;
625
			// }//for first element
626
			//
627
			// // handle critical subtree
628
			// if (startCriticalSubTree) {
629
			// compareElementNameSpaceAttributes(
630
			// currentUnChangeableSubtreeNodeStack, namespaces, atts,
631
			// localName, PERMISSIONERROR);
632
			// 
633
			// }
634

  
635 539
			// compare top access level module
636 540
			if (processTopLevelAccess && needToCheckAccessModule) {
637 541
				compareElementNameSpaceAttributes(
......
880 784
			} catch (IOException ioe) {
881 785
				throw new SAXException(ioe.getMessage());
882 786
			}
883
			// MCD - Removed the following code. It is used for node level
884
			// access
885
			// control which is not yet implemented in EML 2.1.0
886
			// //check if user changed inline data or not if user doesn't have
887
			// // write permission
888
			// if (startCriticalSubTree) {
889
			// NodeRecord node = null;
890
			// try {
891
			// node = currentUnChangeableSubtreeNodeStack.pop();
892
			// // get file name from db
893
			// String fileName = node.getNodeData();
894
			// logMetacat.info("in handle inline data");
895
			// logMetacat.info(
896
			// "the inline data file name from node is: "
897
			// + fileName);
898
			// if (!compareInlineDataFiles(fileName, inlineDataFileName)) {
899
			// logMetacat.info(
900
			// "inline data was changed by a user"
901
			// + " who doesn't have permission");
902
			// throw new SAXException(PERMISSIONERROR);
903
			// }
904
			// } catch (EmptyStackException ee) {
905
			// logMetacat.error(
906
			// "the stack is empty for text data");
907
			// throw new SAXException(PERMISSIONERROR);
908
			// } catch (McdbException eee) {
909
			// throw new SAXException(eee.getMessage());
910
			// } finally {
911
			// // delete the inline data file already in file system
912
			// deleteInlineDataFile(inlineDataFileName);
913
			// }
914
			// }//if
915 787

  
916 788
			// write put inline data file name into text buffer (without path)
917 789
			textBuffer = new StringBuffer(inlineDataFileName);
......
985 857
				// if (!localName.equals(INLINE))
986 858
				{
987 859
					logMetacat.debug("Write text into DB in End Element");
988
					// MCD - Removed the following code. It is used for node
989
					// level access
990
					// control which is not yet implemented in EML 2.1.0
991
					// //compare text node if need
992
					// if (startCriticalSubTree) {
993
					// compareTextNode(currentUnChangeableSubtreeNodeStack,
994
					// textBuffer, PERMISSIONERROR);
995
					// }//if
996 860

  
997 861
					// compare top level access module
998 862
					if (processTopLevelAccess && needToCheckAccessModule) {
......
1012 876
				}
1013 877
			}// if
1014 878

  
1015
			// MCD - Removed the following code. It is used for node level
1016
			// access
1017
			// control which is not yet implemented in EML 2.1.0
1018
			// //end critical subtree(user doesn't have permission to write)
1019
			// //When reach the first element and stack is empty
1020
			// if (localName.equals(firstElementNameForCriticalSubTree)
1021
			// && currentUnChangeableSubtreeNodeStack.isEmpty()) {
1022
			// startCriticalSubTree = false;
1023
			// }
1024

  
1025 879
			// set hitText false
1026 880
			hitTextNode = false;
1027 881
			// reset textbuff
......
1175 1029
				DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
1176 1030
				String str = new String(ch, start, length);
1177 1031

  
1178
				// MCD - Removed the following code. It is used for node level
1179
				// access
1180
				// control which is not yet implemented in EML 2.1.0
1181
				// //compare comment if need
1182
				// if (startCriticalSubTree) {
1183
				// compareCommentNode(currentUnChangeableSubtreeNodeStack,
1184
				// str, PERMISSIONERROR);
1185
				// }//if
1186

  
1187 1032
				// compare top level access module
1188 1033
				if (processTopLevelAccess && needToCheckAccessModule) {
1189 1034
					compareCommentNode(currentUnchangeableAccessModuleNodeStack, str,
......
1299 1144
					moredata = false;
1300 1145
				}
1301 1146

  
1302
				// MCD - Removed the following code. It is used for node level
1303
				// access
1304
				// control which is not yet implemented in EML 2.1.0
1305
				// //compare whitespace if need
1306
				// if (startCriticalSubTree) {
1307
				// compareWhiteSpace(currentUnChangeableSubtreeNodeStack,
1308
				// data, PERMISSIONERROR);
1309
				// }//if
1310

  
1311 1147
				// compare whitespace in access top module
1312 1148
				if (processTopLevelAccess && needToCheckAccessModule) {
1313 1149
					compareWhiteSpace(currentUnchangeableAccessModuleNodeStack, data,
......
1358 1194
		logMetacat.debug("end Document");
1359 1195
		// There are some unchangable subtree didn't be compare
1360 1196
		// This maybe cause user change the subtree id
1361
		// MCD - Removed the following code. It is used for node level access
1362
		// control which is not yet implemented in EML 2.1.0
1363
		// if (!unChangeableSubTreeHash.isEmpty()) {
1364
		// logMetacat.info("The unChangealbe subtree is not empty");
1365
		// throw new SAXException(PERMISSIONERROR);
1366
		// }
1367 1197
		if (!super.getIsRevisionDoc()) {
1368 1198
			// write access rule to db
1369 1199
			writeAccessRuleToDB();
......
1611 1441
		
1612 1442
	}
1613 1443

  
1614
	// /* The method to write addtional access rule into db. */
1615
	// private void writeAdditionalAccessRuleToDB() throws SAXException
1616
	// {
1617
	//
1618
	// boolean topLevel = false;
1619
	// // go through the vector which contains the additional access control
1620
	// // hashtable. Each hashtable has info for one additonalmetadata
1621
	// // container
1622
	// for (Hashtable<String, AccessSection> accessControlMap :
1623
	// additionalAccessMapList) {
1624
	// // additional access rule
1625
	// Enumeration<String> en = accessControlMap.keys();
1626
	//
1627
	// while (en.hasMoreElements()) {
1628
	// try {
1629
	// // Get subsection id
1630
	// String subSectionId = en.nextElement();
1631
	// logMetacat.debug("sub section id in additional access mapping"
1632
	// + "(go through): " + subSectionId);
1633
	//
1634
	// if (subSectionId == null) {
1635
	// // if id is null, terminate the program
1636
	// throw new SAXException("subtree id is null"); }
1637
	// // Get AccessSection Object
1638
	// AccessSection accessSectionObj =
1639
	// accessControlMap.get(subSectionId);
1640
	// if (accessSectionObj == null) {
1641
	// // if accesssection is null, terminate the program
1642
	// throw new SAXException("access subtree is null");
1643
	// } else if (accessSectionObj.getDataFileName() == null) {
1644
	// // if there is no data file name, continue with the next record
1645
	// continue;
1646
	// } else {
1647
	// AccessSection accessControlObj = accessSectionObj;
1648
	// // if the access section is not references, write it to
1649
	// // db
1650
	// if (accessControlObj.getReferences() == null) {
1651
	// writeGivenAccessRuleIntoDB(accessControlObj,
1652
	// topLevel, subSectionId);
1653
	// } else {
1654
	// // this is a reference and go trough the vector
1655
	// // which contains all access object
1656
	// String referenceId = accessControlObj
1657
	// .getReferences();
1658
	//
1659
	// boolean findAccessObject = false;
1660
	// logMetacat.debug("referered id for additional access "
1661
	// + "mapping(go through): " + referenceId);
1662
	// for (AccessSection accessObj : accessObjectList) {
1663
	// String accessObjId = accessObj.getSubTreeId();
1664
	// logMetacat.debug("access obj id in the list(go through): "
1665
	// + accessObjId);
1666
	// if (referenceId != null && accessObj != null
1667
	// && referenceId.equals(accessObjId)) {
1668
	// writeGivenAccessRuleIntoDB(accessObj,
1669
	// topLevel, subSectionId);
1670
	// findAccessObject = true;
1671
	// }//if
1672
	// }//for
1673
	// // if we couldn't find an access subtree id for
1674
	// // this reference id
1675
	// if (!findAccessObject) {
1676
	// throw new SAXException("The referenceid: " + referenceId
1677
	// + " is not access subtree");
1678
	// }//if
1679
	// }//else
1680
	// }//else
1681
	// }//try
1682
	// catch (Exception e) {
1683
	//
1684
	// logMetacat.error(
1685
	// "error in EmlSAXHandler.writeAddtionalAccess"
1686
	// + ": " + e.getMessage());
1687
	// throw new SAXException(e.getMessage());
1688
	// }
1689
	// }//while
1690
	// }//for
1691
	// }//writeAccessRuletoDB
1692

  
1693 1444
	/* Write a given access rule into db */
1694 1445
	private void writeGivenAccessRuleIntoDB(AccessSection accessSection,
1695 1446
			boolean topLevel, String subSectionId) throws SAXException {
......
1732 1483
				if (subSectionId == null) {
1733 1484
					throw new SAXException("The subsection is null");
1734 1485
				}
1735
				// MCD - Removed the following code. It is used for node level
1736
				// access
1737
				// control which is not yet implemented in EML 2.1.0
1738
				// // go through the substree list vector and found the start
1739
				// node
1740
				// // id and stop node id for this subtree id
1741
				// for (int i = 0; i < subTreeList.size(); i++) {
1742
				// SubTree tree = subTreeList.elementAt(i);
1743
				// String subTreeId = tree.getSubTreeId();
1744
				// if (subSectionId.equals(subTreeId)) {
1745
				// startNodeId = tree.getStartNodeId();
1746
				// endNodeId = tree.getEndNodeId();
1747
				// }//if
1748
				// }//for
1749
				// if (startNodeId == 0 || endNodeId == 0) {
1750
				// throw new SAXException("Could not find the subtree for this
1751
				// id: "
1752
				// + subSectionId);
1753
				// }
1754 1486

  
1755 1487
				pstmt.setString(7, subSectionId);
1756 1488
				logMetacat.debug("SubSectionId in accesstable: " + subSectionId);

Also available in: Unified diff