1 22 23 package org.cofax.cms; 24 25 import java.io.BufferedReader ; 26 import java.io.File ; 27 import java.io.FileReader ; 28 import java.io.FileWriter ; 29 import java.io.IOException ; 30 import java.io.PrintWriter ; 31 import java.text.Collator ; 32 import java.util.ArrayList ; 33 import java.util.Calendar ; 34 import java.util.Enumeration ; 35 import java.util.HashMap ; 36 import java.util.Iterator ; 37 import java.util.List ; 38 import java.util.Locale ; 39 import java.util.ResourceBundle ; 40 import java.util.Set ; 41 import java.util.SortedMap ; 42 import java.util.TreeMap ; 43 import java.util.Vector ; 44 45 import javax.servlet.http.HttpServletRequest ; 46 import javax.servlet.http.HttpSession ; 47 48 import org.cofax.CofaxUtil; 49 import org.cofax.DataStore; 50 51 52 58 59 public class CofaxToolsUtil { 60 61 62 69 public static String readFile(String fileLocation) { 70 return readFile(fileLocation, false); 71 } 72 73 74 83 public static String readFile(String fileLocation, boolean delete) { 84 StringBuffer s = new StringBuffer (); 85 String thisLine; 86 try { 87 FileReader fr = new FileReader (fileLocation); 88 BufferedReader br = new BufferedReader (fr); 89 90 while ((thisLine = br.readLine()) != null) { 91 s.append(thisLine + "\n"); 92 } 93 File file = new File (fileLocation); 94 if (delete == true) { 95 if (!file.delete()) { 96 log("CofaxToolsUtil readFile ERROR: Cannot delete file on local drive: " + fileLocation + "."); 97 } 98 } 99 } catch (IOException e) { 100 log("CofaxToolsUtil readFile ERROR: " + e.toString()); 101 } 102 String nb = s.toString(); 103 return (nb); 104 } 105 106 107 115 public static String createCheckBoxTable(HashMap nameValue, String name) { 116 Vector v = new Vector (); 117 return (createCheckBoxTable(nameValue, v, name)); 118 } 119 120 121 122 132 public static String createCheckBoxTable(HashMap nameValueIn, Vector checked, String name) { 133 HashMap nameValueReverse = new HashMap (); 134 Iterator it = nameValueIn.keySet().iterator(); 135 while (it.hasNext()) { 136 String keyName = (String ) it.next(); 137 String keyVal = (String ) nameValueIn.get(keyName); 138 nameValueReverse.put(keyVal, keyName); 139 } 140 StringBuffer s = new StringBuffer (); 141 s.append("\n\n<TABLE BORDER=0>\n"); 142 SortedMap nameValue = new TreeMap (); 143 144 Iterator nameValIt = nameValueReverse.keySet().iterator(); 146 while (nameValIt.hasNext()) { 147 try { 148 String key = (String ) nameValIt.next(); 149 String val = (String ) nameValueReverse.get(key); 150 if ((key != null) && (val != null)) { 151 nameValue.put(key, val); 152 } 153 } catch (Exception e) { 154 log("Null key in HashMap nameValueReverse sub createCheckBoxTable class CofaxToolsUtil - likely Oracle error " + e); 155 } 156 } 157 158 Set set = nameValue.keySet(); 159 Iterator keys = set.iterator(); 160 161 String isChecked; 162 int i = 0; 163 while (keys.hasNext()) { 164 String key = (String ) keys.next(); 165 String checkCheck = (String ) nameValue.get(key); 166 if (checked.contains(checkCheck)) { 167 isChecked = "checked"; 168 } else { 169 isChecked = ""; 170 } 171 172 s.append("<TD><INPUT TYPE=CHECKBOX " + isChecked + " NAME=\"" + i + "\" VALUE=\"" + nameValue.get(key) + "\"><INPUT TYPE=HIDDEN NAME=PARAMNAME" + i + " VALUE=" + nameValue.get(key) + "></TD><TD>" + key + "</TD><TR>\n"); 173 i++; 174 } 175 s.append("<INPUT TYPE=HIDDEN NAME=checkBoxTableLength VALUE=" + (i) + ">"); 176 s.append("</TABLE>\n\n"); 177 return (s.toString()); 178 } 179 180 181 188 public static String createSelect(String selectName, HashMap nameValue) { 189 String sb = createSelect(selectName, nameValue, ""); 190 return (sb); 191 } 192 193 194 203 public static String createSelect(String selectName, HashMap nameValue, String selected) { 204 String sb = createSelect(selectName, nameValue, selected, ""); 205 return (sb); 206 } 207 208 209 220 public static String createSelect(String selectName, HashMap nameValue, String selected, String javaScript) { 221 222 SortedMap sortedMap = new TreeMap (); 224 sortedMap.putAll(nameValue); 225 Set set = sortedMap.keySet(); 226 Iterator iterator = set.iterator(); 227 StringBuffer s = new StringBuffer (); 228 229 try { 231 String [] a = new String [nameValue.size()]; 232 s.append("\n\n<SELECT NAME =\"" + selectName + "\" " + javaScript + ">\n"); 233 String i; 234 int ii = 0; 235 while (iterator.hasNext()) { 236 String key = (String ) iterator.next(); 237 String value = (String ) sortedMap.get(key); 238 if (value == selected || value.equals(selected)) { 239 i = " selected"; 240 } else { 241 i = ""; 242 } 243 a[ii] = ("<OPTION VALUE=\"" + value + "\"" + i + ">" + key + "\n"); 244 ii++; 245 } 246 StringBuffer sb = arrayToStringBuffer(a); 247 s.append(sb.toString()); 248 s.append("\n</SELECT>\n\n"); 249 } catch (ArrayIndexOutOfBoundsException e) { 250 log("CofaxToolsUtil createSelect ERROR: " + e.toString()); 251 } finally { 252 253 } 254 return (s.toString()); 255 } 256 257 258 267 public static String createMultipleSelect(String selectName, HashMap nameValue, int size) { 268 Vector selected = new Vector (); 269 return createMultipleSelect(selectName, nameValue, size, selected); 270 } 271 272 273 284 public static String createMultipleSelect(String selectName, HashMap nameValue, int size, Vector selected) { 285 286 Iterator en = nameValue.keySet().iterator(); 287 StringBuffer s = new StringBuffer (); 288 s.append("\n\n<SELECT NAME =\"" + selectName + "\" MULTIPLE SIZE=" + size + ">\n"); 289 290 while (en.hasNext()) { 291 String key = (String ) en.next(); 292 String value = (String ) nameValue.get(key); 293 if (selected.contains(value)) { 294 s.append("<OPTION VALUE=\"" + value + "\" SELECTED>" + key + "\n"); 295 } else { 296 s.append("<OPTION VALUE=\"" + value + "\">" + key + "\n"); 297 } 298 299 } 300 s.append("</SELECT>"); 301 return (s.toString()); 302 } 303 304 310 public static String [] bubbleSort(String [] toBeSorted) { 311 312 boolean sorted = false; 313 while (!sorted) { 315 sorted = true; 316 for (int i = 0; i < toBeSorted.length - 1; i++) { 317 Collator myCollator = Collator.getInstance(); 318 int iPlus = i + 1; 319 320 if (myCollator.compare((String ) toBeSorted[i], (String ) toBeSorted[iPlus]) > 0) { 321 String temp = toBeSorted[i]; 322 toBeSorted[i] = toBeSorted[iPlus]; 323 toBeSorted[iPlus] = temp; 324 sorted = false; 325 } 326 } 327 } 328 329 return (toBeSorted); 330 } 331 332 333 334 340 public static StringBuffer arrayToStringBuffer(String [] input) { 341 StringBuffer sb = new StringBuffer (); 342 for (int i = 0; i < input.length; i++) { 343 sb.append(input[i]); 344 } 345 346 return (sb); 347 } 348 349 350 351 357 public static String getGroupTypesSelectID(DataStore db) { 358 String s = getGroupTypesSelectID(db, "noPub"); 359 return (s); 360 } 361 362 363 364 372 public static String getGroupTypesSelectID(DataStore db, String selected) { 373 HashMap htGroupTypes = getGroupTypes(db); 374 String s = createSelect("GROUPTYPE", htGroupTypes, selected); 375 return (s); 376 } 377 378 379 386 public static String getGroupsSelectID(DataStore db, HttpSession session) { 387 String s = getGroupsSelectID(db, "noPub", session); 388 return (s); 389 } 390 391 392 393 402 public static String getGroupsSelectID(DataStore db, String selected, HttpSession session) { 403 HashMap htGroups = new HashMap (); 404 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 405 htGroups = getGroupsConverse(db); 406 String s = createSelect("selectGroup", htGroups, selected); 407 return (s); 408 } 409 410 411 412 422 public static String getPublicationSelectID(DataStore db, HttpSession session, String name) { 423 String s = getPublicationSelectID(db, session, name, "PUBLICATION"); 424 return (s); 425 } 426 427 428 429 441 public static String getPublicationSelectID(DataStore db, HttpSession session, String selected, String name) { 442 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 443 HashMap results = new HashMap (); 444 boolean nationalAdmin = false; 445 446 Iterator groupTypeIt = user.userPubsVectorOHash.iterator(); 448 while (groupTypeIt.hasNext()) { 449 HashMap pubIdGroupType = (HashMap ) groupTypeIt.next(); 450 if (pubIdGroupType.containsValue(CofaxToolsServlet.adminGroupID)) { 451 nationalAdmin = true; 452 } 453 } 454 455 if (nationalAdmin == true) { 456 String tag = CofaxToolsDbUtils.fillTag(db, "getPubDescPubIDFromTblPubs"); 457 results = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "PUBDESC", "PUBID"); 458 } else { 459 results = user.userPubDescPubIDHash; 460 } 461 String s = createSelect(name, results, selected); 462 return (s); 463 } 464 465 466 467 474 public static HashMap getPubNamePubDescFromID(DataStore db, String pubID) { 475 HashMap fillReq = new HashMap (); 476 fillReq.put("PUBID", pubID); 477 String tag = CofaxToolsDbUtils.fillTag(db, "getPubDescPubNameFromTblPubsByPubID"); 478 HashMap results = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 479 return (results); 480 } 481 482 483 484 491 public static String getUsersSelect(DataStore db, HttpSession session) { 492 String s = getUsersSelect(db, session, ""); 493 return (s); 494 } 495 496 497 508 public static String getUsersSelect(DataStore db, HttpSession session, String selected) { 509 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 510 511 String tag = CofaxToolsDbUtils.fillTag(db, "getUserNameUserIdFromPermUsers"); 513 HashMap userIDUserName = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "USERNAME", "USERID"); 514 Iterator enu = userIDUserName.keySet().iterator(); 515 516 tag = CofaxToolsDbUtils.fillTag(db, "getAllFromPermUserToGroup"); 518 ArrayList users = (ArrayList ) CofaxToolsDbUtils.getPackageData(db, tag); 519 520 HashMap userIDUserNameTwo = new HashMap (); 522 524 while (enu.hasNext()) { 526 String checkUserIDKey = (String ) enu.next(); 528 String checkUserID = (String ) userIDUserName.get(checkUserIDKey); 529 for (int i = 0; i < users.size(); i++) { 530 HashMap hm = (HashMap ) users.get(i); 531 String checkUserTwo = (String ) hm.get("USERID"); 532 if (checkUserTwo.equals(checkUserID)) { 533 boolean delete = true; 534 Iterator it = hm.keySet().iterator(); 535 while (it.hasNext()) { 536 String userGroupKey = (String ) it.next(); 537 if (userGroupKey.indexOf("USERID") < 0) { 538 String userGroup = (String ) hm.get(userGroupKey); 539 if (!userGroup.equals("")) { 540 if (user.userGroupNameGroupIDHash.containsKey(userGroup)) { 541 delete = false; 542 } 543 } 544 } 545 } 546 if (delete == false) { 547 userIDUserNameTwo.put(checkUserIDKey, checkUserID); 548 } 549 } 550 } 551 } 552 boolean nationalAdmin = false; 553 if (user.userGroupVector.contains((String )CofaxToolsServlet.adminGroupID)) { 555 nationalAdmin = true; 556 } 557 558 if (nationalAdmin == true) { 559 userIDUserNameTwo = userIDUserName; 560 } 561 562 String s = createSelect("selectUser", userIDUserNameTwo, selected); 563 return (s); 564 } 565 566 567 574 public static HashMap getUserInfo(DataStore db, String userID) { 575 HashMap fillReq = new HashMap (); 576 fillReq.put("USERID", userID); 577 String tag = CofaxToolsDbUtils.fillTag(db, "getUserInfoByUserID"); 578 HashMap results = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 579 return (results); 580 } 581 582 583 590 public static Vector getUserGroups(DataStore db, String userID) { 591 HashMap fillReq = new HashMap (); 592 fillReq.put("USERID", userID); 593 String tag = CofaxToolsDbUtils.fillTag(db, "getVectorOfGroupsByUserID"); 594 Vector results = CofaxToolsDbUtils.getPackageVector(db, fillReq, tag); 595 return (results); 596 } 597 598 599 606 public static HashMap getGroups(DataStore db, HttpSession session) { 607 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 608 HashMap results = new HashMap (); 609 boolean nationalAdmin = false; 610 611 if (user.userGroupVector.contains((String )CofaxToolsServlet.adminGroupID)) { 613 nationalAdmin = true; 614 } 615 616 if (nationalAdmin != true) { 617 results = user.userGroupNameGroupIDHash; 618 } else { 619 String tag = CofaxToolsDbUtils.fillTag(db, "getGroupNameGroupIDFromPermGroups"); 620 results = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "GROUPID", "GROUPNAME"); 621 } 622 return (results); 623 } 624 625 626 632 public static HashMap getGroupsConverse(DataStore db) { 633 String tag = CofaxToolsDbUtils.fillTag(db, "getGroupNameGroupIDFromPermGroups"); 634 HashMap results = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "GROUPNAME", "GROUPID"); 635 return (results); 636 } 637 638 639 645 public static HashMap getGroupTypes(DataStore db) { 646 String tag = CofaxToolsDbUtils.fillTag(db, "getGroupNameGroupIDFromPermGroupType"); 647 HashMap results = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "GROUPTYPENAME", "GROUPTYPEID"); 648 return (results); 649 } 650 651 652 653 660 public static HashMap getGroupInfo(DataStore db, String groupID) { 661 HashMap fillReq = new HashMap (); 662 fillReq.put("pubNameKey", groupID); 663 String tag = CofaxToolsDbUtils.fillTag(db, "getAllFromPermGroupsByGroupID"); 664 HashMap results = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 665 return (results); 666 } 667 668 669 670 676 public static void log(String input) { 677 input = new java.util.Date ().toString()+" - "+input; 678 if (CofaxToolsServlet.log.equals("1")) { 679 if (!CofaxToolsServlet.logLocation.equals("")) { 680 try { 681 if (CofaxToolsServlet.logMaxSize > 0) { 682 File file = new File (CofaxToolsServlet.logLocation); 683 long fileSize = file.length(); 684 if (fileSize > CofaxToolsServlet.logMaxSize) { 685 file.delete(); 686 } 687 } 688 PrintWriter fileOutputStream = new PrintWriter (new FileWriter (CofaxToolsServlet.logLocation, true)); 689 fileOutputStream.println(input); 690 fileOutputStream.close(); 691 } catch (IOException e) { 692 System.err.println("CofaxToolsUtil log ERROR: " + e.toString()); 693 } 694 } else { 695 System.out.println("CT log: " + input); 696 } 697 } 698 } 699 700 701 707 public static HashMap getPublications(DataStore db) { 708 String tag = CofaxToolsDbUtils.fillTag(db, "getPubDescPubIDFromTblPubs"); 709 HashMap results = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "PUBDESC", "PUBID"); 710 return (results); 711 } 712 713 714 721 public static HashMap getGroupsPublications(DataStore db, String groupID) { 722 HashMap fillReq = new HashMap (); 723 fillReq.put("pubNameKey", groupID); 724 String tag = CofaxToolsDbUtils.fillTag(db, "getAllFromGroupToPubByGroupID"); 725 ArrayList results = (ArrayList ) CofaxToolsDbUtils.getPackageData(db, fillReq, tag); 727 728 tag = CofaxToolsDbUtils.fillTag(db, "getPubDescPubIDFromTblPubs"); 729 HashMap pubNames = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "PUBID", "PUBDESC"); 730 HashMap newHash = new HashMap (); 731 Iterator en = results.iterator(); 733 while (en.hasNext()) { 734 HashMap groupIDpubID = (HashMap ) en.next(); 735 String resultValue = (String ) groupIDpubID.get("PUBID"); 736 newHash.put(pubNames.get(resultValue), resultValue); 737 } 738 return (newHash); 739 } 740 741 742 743 750 public static HashMap getGroupsNonPublications(DataStore db, String groupID) { 751 HashMap fillReq = new HashMap (); 752 fillReq.put("pubNameKey", groupID); 753 String tag = CofaxToolsDbUtils.fillTag(db, "getAllFromGroupToPubByGroupID"); 754 ArrayList results = (ArrayList ) CofaxToolsDbUtils.getPackageData(db, fillReq, tag); 756 Iterator enu = results.iterator(); 758 Vector vec = new Vector (); 759 while (enu.hasNext()) { 760 HashMap groupIDpubID = (HashMap ) enu.next(); 762 String resultValue = (String ) groupIDpubID.get("PUBID"); 763 vec.add(resultValue); 764 } 765 766 tag = CofaxToolsDbUtils.fillTag(db, "getPubDescPubIDFromTblPubs"); 767 HashMap pubNames = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "PUBID", "PUBDESC"); 768 HashMap newHash = new HashMap (); 769 Iterator en = pubNames.keySet().iterator(); 770 while (en.hasNext()) { 771 String pubNamesKey = (String ) en.next(); 772 String pubNamesValue = (String ) pubNames.get(pubNamesKey); 773 774 if (vec.indexOf(pubNamesKey) == -1) { 775 newHash.put(pubNamesValue, pubNamesKey); 776 } 777 } 778 return (newHash); 779 } 780 781 782 783 790 public static String getPubDescFromID(DataStore db, String pubID) { 791 HashMap fillReq = new HashMap (); 792 fillReq.put("PUBID", pubID); 793 String tag = CofaxToolsDbUtils.fillTag(db, "getPubDescFromPublicationsByPubID"); 794 HashMap pubNames = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 795 return ((String ) pubNames.get("PUBDESC")); 796 } 797 798 799 806 807 public static String getPubNameFromID(DataStore db, String pubID) { 808 HashMap fillReq = new HashMap (); 809 fillReq.put("PUBID", pubID); 810 String tag = CofaxToolsDbUtils.fillTag(db, "getPubNameFromPublicationsByPubID"); 811 HashMap pubNames = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 812 return ((String ) pubNames.get("PUBNAME")); 813 } 814 815 816 823 824 public static String getPubIDFromName(DataStore db, String pubName) { 825 HashMap fillReq = new HashMap (); 826 fillReq.put("PUBNAME", pubName); 827 String tag = CofaxToolsDbUtils.fillTag(db, "getPubIDByPubName"); 828 HashMap pubNames = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 829 return ((String ) pubNames.get("PUBID")); 830 } 831 832 833 834 841 public static void showVector(String name, Vector vec) { 842 String key = ""; 843 String value = ""; 844 Iterator it = vec.iterator(); 845 while (it.hasNext()) { 846 log(name + " contents: -" + it.next()); 847 } 848 } 849 850 851 858 public static void showHash(String name, HashMap hm) { 859 String key = ""; 860 String value = ""; 861 Iterator it = hm.keySet().iterator(); 862 while (it.hasNext()) { 863 try { 864 key = (String ) it.next(); 865 value = (String ) hm.get(key); 866 log(name + " name/ value: -" + key + "-" + value + "-"); 867 } catch (java.lang.ClassCastException e) { 868 log("name/ " + key + " cannot be cast to a string, sorry!"); 869 } 870 } 871 } 872 873 874 881 public static void showListOfHashes(String name, List list) { 882 Iterator it = list.iterator(); 883 884 while (it.hasNext()) { 885 Object o = it.next(); 886 HashMap hm = (HashMap ) o; 887 Iterator ite = hm.keySet().iterator(); 888 889 while (ite.hasNext()) { 890 String key = (String ) ite.next(); 891 String s = (String ) hm.get(key); 892 log(name + " name/ value : " + key + " " + s + ""); 893 } 894 } 895 } 896 897 898 904 public static Vector getGroupTypeIDs(DataStore db) { 905 String tag = CofaxToolsDbUtils.fillTag(db, "getGroupTypeIDFromGroupType"); 906 Vector v = CofaxToolsDbUtils.getPackageVector(db, tag); 907 return (v); 908 } 909 910 911 917 public static Vector getGroupTypeNames(DataStore db) { 918 String tag = CofaxToolsDbUtils.fillTag(db, "getGroupTypeNameFromGroupType"); 919 Vector v = CofaxToolsDbUtils.getPackageVector(db, tag); 920 return (v); 921 } 922 923 924 930 public static ArrayList getModes(DataStore db) { 931 String tag = CofaxToolsDbUtils.fillTag(db, "getModeAndTypeFromPermModes"); 932 ArrayList l = (ArrayList ) CofaxToolsDbUtils.getPackageData(db, tag); 933 return (l); 934 } 935 936 937 938 944 945 public static void showVectorOfHashes(String s, Vector v) { 946 Iterator it = v.iterator(); 947 int i = 0; 948 while (it.hasNext()) { 949 i++; 950 Object o = it.next(); 951 HashMap ht = (HashMap ) o; 952 Iterator en = ht.keySet().iterator(); 953 while (en.hasNext()) { 954 String key = (String ) en.next(); 955 String value = (String ) ht.get(key); 956 log(s + " table " + i + " : " + key + " \\ " + value + ""); 957 958 } 959 } 960 } 961 962 963 970 971 public static HashMap getPublicationInfo(DataStore db, String pubID) { 972 HashMap fillReq = new HashMap (); 973 fillReq.put("PUBID", pubID); 974 String tag = CofaxToolsDbUtils.fillTag(db, "getAllFromConfigByPubID"); 975 HashMap pubInfo = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 976 tag = CofaxToolsDbUtils.fillTag(db, "getAllFromPublicationsByPubID"); 977 HashMap pubInfo2 = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 978 pubInfo.putAll(pubInfo2); 979 return (pubInfo); 980 } 981 982 983 989 public static String getSelectGroupType(DataStore db) { 990 String tag = CofaxToolsDbUtils.fillTag(db, "getGroupNameGroupIDFromPermGroupType"); 991 HashMap typeInfo = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "GROUPTYPENAME", "GROUPTYPEID"); 992 String select = createSelect("selectGroupType", typeInfo, ""); 993 return (select); 994 } 995 996 997 1004 public static String getSelectGroupType(DataStore db, String groupID) { 1005 String tag = CofaxToolsDbUtils.fillTag(db, "getGroupNameGroupIDFromPermGroupType"); 1006 HashMap typeInfo = CofaxToolsDbUtils.getValueValuePackageHash(db, tag, "GROUPTYPENAME", "GROUPTYPEID"); 1007 String select = createSelect("selectGroupType", typeInfo, groupID); 1008 return (select); 1009 } 1010 1011 1012 1019 public static HashMap getGroupTypeInfo(DataStore db, String groupTypeID) { 1020 HashMap fillReq = new HashMap (); 1021 fillReq.put("GROUPTYPEID", groupTypeID); 1022 String tag = CofaxToolsDbUtils.fillTag(db, "getAlltblpermgrouptypeByGroupTypeID"); 1023 HashMap typeInfo = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 1024 return (typeInfo); 1025 } 1026 1027 1028 1037 public static String replace(String originalText, String subStringToFind, String subStringToReplaceWith) { 1038 int s = 0; 1039 int e = 0; 1040 StringBuffer newText = new StringBuffer (); 1041 while ((e = originalText.indexOf(subStringToFind, s)) >= 0) { 1042 newText.append(originalText.substring(s, e)); 1043 newText.append(subStringToReplaceWith); 1044 s = e + subStringToFind.length(); 1045 } 1046 1047 newText.append(originalText.substring(s)); 1048 return newText.toString(); 1049 } 1050 1051 1052 1053 1059 1060 public static String getSelectDate(String label) { 1061 String sb = getSelectDate(label, 0, 0, 0); 1062 return (sb); 1063 } 1064 1065 1066 1075 1076 public static String getSelectDate(String label, int year, int month, int day) { 1077 StringBuffer select = new StringBuffer (); 1078 StringBuffer select1 = new StringBuffer (); 1079 StringBuffer select2 = new StringBuffer (); 1080 StringBuffer select3 = new StringBuffer (); 1081 String selected; 1082 select1.append("<SELECT name=" + label + "month>\n"); 1083 for (int i = 1; i <= 12; i++) { 1084 if (month == i) { 1085 selected = "selected"; 1086 } else { 1087 selected = ""; 1088 } 1089 select1.append("<OPTION VALUE=" + i + " " + selected + ">" + i + "\n"); 1090 } 1091 select1.append("</SELECT>\n"); 1092 1093 select2.append("<SELECT name=" + label + "day>\n"); 1094 for (int i = 1; i <= 31; i++) { 1095 if (day == i) { 1096 selected = "selected"; 1097 } else { 1098 selected = ""; 1099 } 1100 select2.append("<OPTION VALUE=" + i + " " + selected + ">" + i + "\n"); 1101 } 1102 select2.append("</SELECT>\n"); 1103 1104 select3.append("<SELECT name=" + label + "year>\n"); 1105 for (int i = 1990; i <= 2010; i++) { 1106 if (year == i) { 1107 selected = "selected"; 1108 } else { 1109 selected = ""; 1110 } 1111 select3.append("<OPTION VALUE=" + i + " " + selected + ">" + i + "\n"); 1112 } 1113 select3.append("</SELECT>\n"); 1114 1115 if (CofaxToolsServlet.lcl.toString().equals("fr")) { 1117 select.append(select2.toString()); 1118 select.append(select1.toString()); 1119 select.append(select3.toString()); 1120 } else { 1121 select.append(select1.toString()); 1122 select.append(select2.toString()); 1123 select.append(select3.toString()); 1124 } 1125 return select.toString(); 1126 } 1127 1128 1129 1130 1139 public static String getSelectArticleSection(DataStore db, String currentPubName, String name, String userID) { 1140 String select = getSelectArticleSection(db, currentPubName, name, userID, "" ); 1141 return (select); 1142 } 1143 1144 1145 1155 1156 public static String getSelectArticleSection(DataStore db, String currentPubName, String name, String userID, String selected) { 1157 HashMap fillReq = new HashMap (); 1158 fillReq.put("currentPubName", currentPubName); 1159 fillReq.put("currentUserID", userID); 1160 String tag = CofaxToolsDbUtils.fillTag(db, "getSectionDescAndSectionFromSectionsByPubNameUser"); 1161 HashMap nameValue = CofaxToolsDbUtils.getValueValuePackageHash(db, fillReq, tag, "SECTIONDESC", "SECTION"); 1162 String select = createSelect(name, nameValue, selected); 1163 return (select); 1164 } 1165 1166 1167 1176 1177 public static String getMappingCodesRankComboTable(DataStore db, int howManyRows, HttpSession session) { 1178 HashMap ht = new HashMap (); 1179 String combo = getMappingCodesRankComboTable(db, howManyRows, session, ht); 1180 return (combo); 1181 } 1182 1183 1184 1194 1195 public static String getMappingCodesRankComboTable(DataStore db, int howManyRows, HttpSession session, HashMap sectionSelectRank) { 1196 1197 StringBuffer combo = new StringBuffer (); 1198 combo.append("<TABLE>"); 1199 combo.append("<TR><TD><B>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_map") + "</B></TD>\n"); 1200 combo.append("<TD><B>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_rank") + "</B></TD>\n"); 1201 combo.append("<TD><B>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_removefrommap") + "</B></TD></TR>\n"); 1202 combo.append("<TR>"); 1203 1204 ArrayList tempSelectStatement = (ArrayList ) getSelectMappingsMultiplePublicationsArrayList(db, CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"mapping_code"), session); 1205 1206 Iterator en = sectionSelectRank.keySet().iterator(); 1207 int i = 1; 1208 while (en.hasNext()) { 1209 String selectedSection = (String ) en.next(); 1210 String rank = (String ) sectionSelectRank.get(selectedSection); 1211 String selectStatement = createSelect("MAPPINGCODE" + i, tempSelectStatement, selectedSection); 1212 combo.append("<TD>" + selectStatement + "</TD>\n"); 1213 combo.append("<TD><input name=RANK" + i + " value=\"" + rank + "\" size=4></TD>\n"); 1214 combo.append("<TD><input type=checkbox name=mappingDelete" + i + "></TD>\n"); 1215 combo.append("<TR>\n"); 1216 i++; 1217 } 1218 for (int in = 0; in < howManyRows; in++) { 1219 String selectStatement = createSelect("MAPPINGCODE" + i, tempSelectStatement); 1220 combo.append("<TD>" + selectStatement + "</TD>\n"); 1221 combo.append("<TD><input name=RANK" + i + " value=\"\" size=4></TD>\n"); 1222 combo.append("<TD> </TD>\n"); 1223 combo.append("<TR>\n"); 1224 i++; 1225 } 1226 1227 combo.append("<INPUT TYPE=HIDDEN NAME=numMappings VALUE = " + i + "></TABLE>\n"); 1228 return (combo.toString()); 1229 } 1230 1231 1232 1240 1241 public static String getSelectMultipleMultiplePublication(HttpSession session, int size, HttpServletRequest req) { 1242 String from = req.getParameter("from"); 1243 Vector selected = new Vector (); 1244 1245 if ((from != null) && (from.equals("savedSearch"))) { 1246 String publications[] = req.getParameterValues("publications"); 1247 for (int i = 0; i < publications.length; i++) { 1248 selected.add(publications[i]); 1249 } 1250 } else { 1251 CofaxToolsUser user = (CofaxToolsUser) (session.getAttribute("user")); 1252 String workingPubName = user.workingPubName; 1253 selected.add(workingPubName); 1254 } 1255 1256 1257 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 1258 HashMap userPubNamePubDescHash = user.userPubNamePubDescHash; 1259 String select = createMultipleSelect("publications", userPubNamePubDescHash, size, selected); 1260 return (select); 1261 } 1262 1263 1264 1265 1274 public static String getSelectCategoriesMultiplePublications(DataStore db, HttpSession session, HttpServletRequest req) { 1275 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 1276 String sectionPref = ""; 1277 String from = req.getParameter("from"); 1278 if ((from != null) && (from.equals("savedSearch"))) { 1279 sectionPref = req.getParameter("SECTION"); 1280 } 1281 1282 List al = new ArrayList (); 1283 HashMap tempLabel = new HashMap (); 1285 tempLabel.put("** " + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_allsections") + " **", ""); 1286 al.add(tempLabel); 1287 1288 String wkPub = user.workingPubName; 1289 HashMap userPubNamePubIDHash = new HashMap (); 1290 userPubNamePubIDHash.putAll(user.userPubNamePubIDHash); 1291 1292 userPubNamePubIDHash.remove(wkPub); 1293 HashMap wkFillReq = new HashMap (); 1294 wkFillReq.put("PUBNAME", wkPub); 1295 1296 StringBuffer sb = new StringBuffer (); 1297 1298 String wkTag = CofaxToolsDbUtils.fillTag(db, "getSectionDescAndSectionFromSectionsByPubName"); 1300 wkFillReq.put("currentUserID", (String )user.userInfoHash.get("USERID")); 1301 HashMap wkHt = CofaxToolsDbUtils.getValueValuePackageHash(db, wkFillReq, wkTag, "SECTIONDESC", "SECTION"); 1302 SortedMap wkSortedMap = new TreeMap (); 1303 wkSortedMap.putAll(wkHt); 1304 Set wkset = wkSortedMap.keySet(); 1305 Iterator wkIterator = wkset.iterator(); 1306 while (wkIterator.hasNext()) { 1307 String wkName = (String ) wkIterator.next(); 1308 String wkID = (String ) wkSortedMap.get(wkName); 1309 HashMap wkTemp = new HashMap (); 1310 wkTemp.put(wkName, wkID); 1311 al.add(wkTemp); 1312 } 1313 1314 Iterator en = userPubNamePubIDHash.keySet().iterator(); 1316 HashMap htSelect = new HashMap (); 1317 while (en.hasNext()) { 1318 String pubName = (String ) en.next(); 1319 HashMap fillReq = new HashMap (); 1320 fillReq.put("PUBNAME", pubName); 1321 fillReq.put("currentUserID", (String )user.userInfoHash.get("USERID")); 1322 String tag = CofaxToolsDbUtils.fillTag(db, "getSectionDescAndSectionFromSectionsByPubName"); 1323 HashMap ht = CofaxToolsDbUtils.getValueValuePackageHash(db, fillReq, tag, "SECTIONDESC", "SECTION"); 1324 Iterator enSel = ht.keySet().iterator(); 1325 while (enSel.hasNext()) { 1326 String section = (String ) enSel.next(); 1327 String sectionDesc = (String ) ht.get(section); 1328 htSelect.put(pubName + ": " + section, sectionDesc); 1329 } 1330 } 1331 SortedMap sortedMap = new TreeMap (); 1332 sortedMap.putAll(htSelect); 1333 Set set = sortedMap.keySet(); 1334 Iterator iterator = set.iterator(); 1335 while (iterator.hasNext()) { 1336 String name = (String ) iterator.next(); 1337 String ID = (String ) sortedMap.get(name); 1338 HashMap temp = new HashMap (); 1339 temp.put(name, ID); 1340 al.add(temp); 1341 } 1342 1343 String select = createSelect("SECTION", (ArrayList ) al, sectionPref); 1344 return (select); 1345 } 1346 1347 1348 1349 1358 public static HashMap getSelectMappingsMultiplePublications(DataStore db, String label, HttpSession session) { 1359 1360 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 1361 HashMap userPubNamePubIDHash = user.userPubNamePubIDHash; 1362 Iterator en = userPubNamePubIDHash.keySet().iterator(); 1363 StringBuffer sb = new StringBuffer (); 1364 HashMap htSelect = new HashMap (); 1365 1366 while (en.hasNext()) { 1367 String pubName = (String ) en.next(); 1368 HashMap fillReq = new HashMap (); 1369 fillReq.put("PUBNAME", pubName); 1370 String tag = CofaxToolsDbUtils.fillTag(db, "getSectionDescAndMapCodeFromSectionsByPubName"); 1371 HashMap ht = CofaxToolsDbUtils.getValueValuePackageHash(db, fillReq, tag, "SECTIONDESC", "MAPPINGCODE"); 1372 Iterator enSel = ht.keySet().iterator(); 1373 1374 while (enSel.hasNext()) { 1375 String section = (String ) enSel.next(); 1376 String sectionDesc = (String ) ht.get(section); 1377 htSelect.put(pubName + ": " + section, sectionDesc); 1378 } 1379 } 1380 htSelect.put(label, ""); 1381 1382 return (htSelect); 1383 } 1384 1385 1386 1387 1394 public static HashMap splitGetQuery(HttpServletRequest req) { 1395 1396 String info = req.getQueryString(); 1397 String leftOver = ""; 1399 String pair; 1400 HashMap ht = new HashMap (); 1401 1402 while (info.indexOf("=") >= 0) { 1403 1404 int firstAnd = info.indexOf("&"); 1405 1406 if (firstAnd >= 0) { 1408 pair = info.substring(0, firstAnd); 1409 leftOver = info.substring(firstAnd + 1); 1410 } 1411 else { 1413 pair = info; 1414 leftOver = ""; 1415 } 1416 1417 int firstEquals = pair.indexOf("="); 1419 String name = pair.substring(0, firstEquals); 1420 String value = pair.substring(firstEquals + 1); 1421 1422 if ((value.equals(null)) || (value.equals(""))) { 1423 value = ""; 1424 } 1425 1426 if (!ht.containsKey(name)) { 1428 ht.put(name, value); 1429 } 1430 else if (ht.containsKey(name)) { 1432 1433 try { 1434 Vector vec = (Vector ) ht.get(name); 1436 vec.add(value); 1437 } catch (java.lang.ClassCastException e) { 1438 String oldValue = (String ) ht.get(name); 1440 Vector newVec = new Vector (); 1441 newVec.add(oldValue); 1442 newVec.add(value); 1443 ht.remove(name); 1444 ht.put(name, newVec); 1445 } 1446 } 1447 1448 info = leftOver; 1449 } 1450 return (ht); 1451 } 1452 1453 1454 1461 public static HashMap splitPostQuery(HttpServletRequest req) { 1462 Enumeration _enum = req.getParameterNames(); 1463 HashMap ht = new HashMap (); 1464 while (_enum.hasMoreElements()) { 1465 String va = (String ) _enum.nextElement(); 1466 String s = req.getParameter(va); 1467 ht.put(va, s); 1468 } 1469 return (ht); 1470 } 1471 1472 1473 1478 public static void showHeader(HttpServletRequest req) { 1479 1480 Enumeration en = req.getHeaderNames(); 1481 while (en.hasMoreElements()) { 1482 String val = (String ) en.nextElement(); 1483 log("header: " + val); 1484 Enumeration enu = req.getHeaders(val); 1485 while (enu.hasMoreElements()) { 1486 log("" + val + ":" + enu.nextElement()); 1487 } 1488 } 1489 1490 Enumeration _enum = req.getParameterNames(); 1491 while (_enum.hasMoreElements()) { 1492 String va = (String ) _enum.nextElement(); 1493 String [] s = req.getParameterValues(va); 1494 1495 for (int in = 0; in < s.length; in++) { 1496 log(va + ":" + s[in] + ""); 1497 } 1498 } 1499 1500 } 1501 1502 1503 1511 1512 public static String searchArticles(DataStore db, HttpServletRequest req) { 1513 HttpSession session = req.getSession(); 1514 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 1515 String HttpPrefix = (String ) user.workingPubConfigElementsHash.get("MAINCOFAXSERVER"); 1516 if (!(HttpPrefix.endsWith("/"))) HttpPrefix += "/"; 1517 String useDate; 1518 1519 String toolsPath = CofaxToolsServlet.toolsPath; 1520 1521 String startDate = (req.getParameter("startDatemonth") + "/" + req.getParameter("startDateday") + "/" + req.getParameter("startDateyear")); 1523 String stopDate = (req.getParameter("stopDatemonth") + "/" + req.getParameter("stopDateday") + "/" + req.getParameter("stopDateyear")); 1524 String section = req.getParameter("SECTION"); 1525 String mapping = req.getParameter("mapping"); 1526 String field1 = req.getParameter("field1"); 1527 String condition1 = req.getParameter("condition1"); 1528 String fieldtwo1 = req.getParameter("fieldtwo1"); 1529 String field2 = req.getParameter("field2"); 1530 String condition2 = req.getParameter("condition2"); 1531 String fieldtwo2 = req.getParameter("fieldtwo2"); 1532 String field3 = req.getParameter("field3"); 1533 String condition3 = req.getParameter("condition3"); 1534 String fieldtwo3 = req.getParameter("fieldtwo3"); 1535 String results = req.getParameter("results"); 1536 String orderBy = req.getParameter("orderBy"); 1537 String startDatemonth = req.getParameter("startDatemonth"); 1538 String startDateday = req.getParameter("startDateday"); 1539 String startDateyear = req.getParameter("startDateyear"); 1540 String stopDatemonth = req.getParameter("stopDatemonth"); 1541 String stopDateday = req.getParameter("stopDateday"); 1542 String stopDateyear = req.getParameter("stopDateyear"); 1543 1544 HashMap fillReq = new HashMap (); 1545 fillReq.put("PUBNAME", (String ) user.workingPubName); 1546 String tag = CofaxToolsDbUtils.fillTag(db, "getUseDateFromPublicationsByPubName"); 1547 HashMap useDates = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 1548 useDate = (String ) useDates.get("USEDATE"); 1549 useDate = "1"; 1550 1551 String publications[] = req.getParameterValues("publications"); 1552 if (publications == null) { 1553 return ("You must select at least one publication to search. Please click back on your browser and try again<BR>"); 1554 } 1555 1556 if (publications.length < 1) { 1557 return ("You must select at least one publication to search. Please click back on your browser and try again<BR>"); 1558 } 1559 1560 HashMap htParams = new HashMap (); 1562 htParams.put("startDate",startDate); 1563 htParams.put("stopDate",stopDate); 1564 htParams.put("section",section); 1565 htParams.put("mapping",mapping); 1566 htParams.put("field1",field1); 1567 htParams.put("condition1",condition1); 1568 htParams.put("fieldtwo1",fieldtwo1); 1569 htParams.put("field2",field2); 1570 htParams.put("condition2",condition2); 1571 htParams.put("fieldtwo2",fieldtwo2); 1572 htParams.put("field3",field3); 1573 htParams.put("condition3",condition3); 1574 htParams.put("fieldtwo3",fieldtwo3); 1575 htParams.put("results",results); 1576 htParams.put("orderBy",orderBy); 1577 htParams.put("startDatemonth",startDatemonth); 1578 htParams.put("startDateday",startDateday); 1579 htParams.put("startDateyear",startDateyear); 1580 htParams.put("stopDatemonth",stopDatemonth); 1581 htParams.put("stopDateday",stopDateday); 1582 htParams.put("stopDateyear",stopDateyear); 1583 htParams.put("publications",publications); 1584 HashMap newHt = db.searchArticles(htParams); 1585 1586 StringBuffer thisSearch = (StringBuffer ) newHt.get("thisSearch"); 1587 StringBuffer SQLState = (StringBuffer ) newHt.get("SQLState"); 1588 1589 List resultsL = CofaxToolsDbUtils.getPackageData(db, SQLState.toString()); 1590 StringBuffer sbu = new StringBuffer (); 1591 sbu.append("<TABLE WIDTH=750 CELLSPACING=0 CELLPADDING=0 BORDER=0>"); 1592 sbu.append("<TD COLSPAN=3><INPUT TYPE=BUTTON VALUE=\"" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"searcharticle_savesearchas") + "\" onClick=\"saveSearch(\'" + thisSearch + "\')\"> <INPUT TYPE=TEXT NAME=SEARCHNAME SIZE=20 MAXLENGTH=50><HR></TD><TR>\n"); 1593 1594 if (resultsL.size() <= 0) { 1595 sbu.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_searchnoresult")); 1596 } 1597 1598 while (resultsL.size() > 0) { 1599 StringBuffer sbTemp = new StringBuffer (); 1600 HashMap hashInfo = (HashMap ) resultsL.get(0); 1601 sbTemp.append("" + (String ) hashInfo.get("SECTIONDESC") + ""); 1602 String lead = (String ) hashInfo.get("LEAD"); 1603 String sectionUrlName = (String ) hashInfo.get("SECTION"); 1604 String pubDate = (String ) hashInfo.get("PUBDATE"); 1605 String disableArticle = (String ) hashInfo.get("DISABLEARTICLE"); 1606 String disableIndex = (String ) hashInfo.get("DISABLEINDEX"); 1607 String workflow_state = (String ) hashInfo.get("WORKFLOW_STATE"); 1608 resultsL.remove(0); 1609 for (int ii = 0; ii < resultsL.size(); ii++) { 1610 HashMap tempH = (HashMap ) resultsL.get(ii); 1611 String tempItemID = (String ) tempH.get("ITEMID"); 1612 if (tempItemID.equals((String ) hashInfo.get("ITEMID"))) { 1613 String tempSectionDesc = (String ) tempH.get("SECTIONDESC"); 1614 sbTemp.append("<BR>" + tempSectionDesc + ""); 1615 resultsL.remove(ii); 1616 ii--; 1617 } 1618 } 1619 String linkFunction = req.getParameter("linkFunction"); 1620 if (linkFunction == null) { 1621 linkFunction = ""; 1622 } 1623 String fontColor = "RED"; 1624 if ((disableArticle.equals("1")) || (disableIndex.equals("1"))) { 1625 fontColor = "666666"; 1626 } 1627 if (workflow_state.equals("1")) fontColor="#C1C307"; 1628 else if (workflow_state.equals("2")) fontColor="#0066CC"; 1629 else if (workflow_state.equals("0")) fontColor="silver"; 1630 1631 sbu.append("<TD VALIGN=top><B><FONT SIZE=2 COLOR=" + fontColor + ">" + (String ) hashInfo.get("FILENAME") + "</FONT></B></TD>\n"); 1632 sbu.append("<TD VALIGN=top><B>"); 1633 String viewArticleLink="<A HREF=\"javascript:oL('" + HttpPrefix + (String ) hashInfo.get("VIRTUALFOLDER") + "/" + (String ) hashInfo.get("FILENAME") + ".htm')\";>"; 1634 if (workflow_state.equals("2")) sbu.append(viewArticleLink); 1635 sbu.append((String ) hashInfo.get("HEADLINE")); 1636 if (workflow_state.equals("2")) sbu.append("</A>"); 1637 sbu.append("</TD>\n"); 1638 sbu.append("<TD VALIGN=top><B><FONT SIZE=1>V:" + (String ) hashInfo.get("VERSIONNUM") + "</B></FONT></TD><TR>\n"); 1639 1640 if (linkFunction.equals("relate")) { 1641 String callingFormPortion = req.getParameter("callingFormPortion"); 1642 sbu.append("<TD VALIGN=TOP><FONT SIZE=1><B>" + (String ) hashInfo.get("ITEMID")); 1643 1644 sbu.append("<BR>" + (String ) hashInfo.get("PUBNAME") + "<BR><A HREF=\"javascript: returnLink(\'" + HttpPrefix + (String ) hashInfo.get("VIRTUALFOLDER") + "/" + (String ) hashInfo.get("FILENAME") + ".htm\',\'" + (String ) hashInfo.get("HEADLINE") + "\')\">" + getI18NMessage(CofaxToolsServlet.lcl,"searcharticle_linkarticle") + "</A>\n"); 1645 sbu.append("<BR>" + sbTemp + "</B></FONT></TD>\n"); 1646 } else { 1647 sbu.append("<TD VALIGN=TOP><FONT SIZE=1><B>" + (String ) hashInfo.get("ITEMID")); 1648 sbu.append("<BR>" + (String ) hashInfo.get("PUBNAME")); 1649 boolean hp = CofaxToolsSecurity.checkArticleEdition(db, session, (String ) hashInfo.get("ITEMID")); 1651 if (hp) { 1652 sbu.append("<BR><A HREF=" + toolsPath + "?mode=article_edit_article_by_itemID&ITEMID=" + (String ) hashInfo.get("ITEMID") + "&hl=article_create_article>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_edit") + "</A>\n"); 1653 if (!(workflow_state.equals("2"))) 1654 { 1655 String url="'?mode=article_preview_article&ITEMID=" + (String ) hashInfo.get("ITEMID") + "'"; 1656 String script= "window.open(" + url + ",'preview','WIDTH=700, HEIGHT=500 TOOLBAR=no TITLE=no MENUBAR=no STATUS=yes SCROLLBARS=no RESIZABLE=yes');"; 1657 sbu.append(" " + "<A HREF=\"#\" onClick=\"" + script + "\">" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_saveandpreview") + "</A>"); 1658 } else 1659 { 1660 sbu.append(" " + viewArticleLink + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_viewonwebsite") + "</A>"); 1661 } 1662 } 1663 sbu.append("<BR>" + sbTemp + "</B></FONT></TD>\n"); 1664 } 1665 1666 String byL = (String ) hashInfo.get("BYLINE"); 1667 if ((byL != null) && (!byL.equals(""))) { 1668 sbu.append("<TD VALIGN=TOP><FONT SIZE=1>" + (String ) hashInfo.get("BYLINE") + "</FONT><BR>"); 1669 } else { 1670 sbu.append("<TD VALIGN=TOP>"); 1671 } 1672 sbu.append("<FONT SIZE=1>" + (String ) hashInfo.get("LEAD") + "</FONT></TD>\n"); 1673 sbu.append("<TD VALIGN=bottom>"); 1674 if (workflow_state.equals("1")) sbu.append("<FONT COLOR=#C1C307 SIZE=1><B>" + getI18NMessage(CofaxToolsServlet.lcl,"createarticle_inprocessofvalidation") + "</B></FONT><BR>\n"); 1675 else if (workflow_state.equals("2")) sbu.append("<FONT COLOR=#0066CC SIZE=1><B>" + getI18NMessage(CofaxToolsServlet.lcl,"createarticle_published") + "</B></FONT><BR>\n"); 1676 else if (workflow_state.equals("0")) sbu.append("<FONT COLOR='silver' SIZE=1><B>" + getI18NMessage(CofaxToolsServlet.lcl,"createarticle_draft") + "</B></FONT><BR>\n"); 1677 1678 sbu.append("<FONT SIZE=1><B>" + pubDate.substring(0, 10) + "</B></FONT></TD><TR>\n"); 1679 sbu.append("<TD COLSPAN=3><HR></TD><TR>\n"); 1680 sbTemp = null; 1681 } 1682 sbu.append("</TABLE>"); 1683 return (sbu.toString()); 1684 } 1685 1686 1687 1688 1689 1694 public static HashMap getDateInfo() { 1695 java.util.Date date = new java.util.Date (); 1696 Calendar today = Calendar.getInstance(); 1697 today.setTime(date); 1698 1699 int monthTemp = today.get(Calendar.MONTH); 1700 monthTemp++; 1701 String month = String.valueOf(monthTemp); 1702 String year = String.valueOf(today.get(Calendar.YEAR)); 1703 String day = String.valueOf(today.get(Calendar.DAY_OF_MONTH)); 1704 String hour = String.valueOf(today.get(Calendar.HOUR)); 1705 if (hour.equals("0")) { 1706 hour = "12"; 1707 } 1708 String minute = String.valueOf(today.get(Calendar.MINUTE)); 1709 String second = String.valueOf(today.get(Calendar.SECOND)); 1710 String amPm = String.valueOf(today.get(Calendar.AM_PM)); 1711 if (amPm.equals("1")) { 1712 amPm = "PM"; 1713 } else { 1714 amPm = "AM"; 1715 } 1716 1717 if (hour.length() == 1) { 1719 hour = "0" + hour; 1720 } 1721 if (minute.length() == 1) { 1722 minute = "0" + minute; 1723 } 1724 if (second.length() == 1) { 1725 second = "0" + second; 1726 } 1727 1728 HashMap ht = new HashMap (); 1729 ht.put("year", year); 1730 ht.put("month", month); 1731 ht.put("day", day); 1732 ht.put("hour", hour); 1733 ht.put("minute", minute); 1734 ht.put("second", second); 1735 ht.put("amPm", amPm); 1736 return (ht); 1737 } 1738 1739 1740 1748 public static HashMap getArticleInfoByItemID(DataStore db, String itemID, HttpSession session) { 1749 HashMap fillReq = new HashMap (); 1750 fillReq.put("ITEMID", itemID); 1751 String tag = CofaxToolsDbUtils.fillTag(db, "getAllFromArticlesbyItemID"); 1752 HashMap ht = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 1753 try 1754 { 1755 HashMap tmpper = new HashMap (); 1756 tmpper.put("request:articleTypeID", (String )ht.get("ARTICLETYPEID")); 1757 String tagDefinition = db.getPackageTag("getArticleTypeByID", tmpper, "", "" ); 1758 List packageData = db.getPackageData( "getArticleTypeByID", tagDefinition, "", ""); 1759 1760 if (packageData == null || (packageData.size() == 0) ){ 1761 ht.put("ARTICLETYPE", ""); 1762 } else { 1763 Iterator rows = packageData.iterator(); 1764 HashMap rowData = (HashMap ) rows.next(); 1765 ht.put("ARTICLETYPE", (String )rowData.get("getArticleTypeByID:articleType")); 1766 } 1767 } catch (Exception e) 1768 { 1769 log("CofaxToolsUtil getArticleInfoByItemID: ERROR : " + e); 1770 } 1771 return (ht); 1772 } 1773 1774 1775 1781 public static HashMap escapeHTML(HashMap hm) { 1782 Iterator it = hm.keySet().iterator(); 1783 while (it.hasNext()) { 1784 String key = (String ) it.next(); 1785 String val = (String ) hm.get(key); 1786 if ((val != null) && (!val.equals(""))) { 1787 val = CofaxUtil.replace(val, "&", "&"); 1788 val = CofaxUtil.replace(val, "\"", """); 1789 val = CofaxUtil.replace(val, "<", "<"); 1790 val = CofaxUtil.replace(val, ">", ">"); 1791 val = CofaxUtil.replace(val, "\'", "'"); 1792 val = CofaxUtil.replace(val, "&#0039;", "'"); 1793 } 1794 if ((key != null) && (!key.equals(""))) { 1795 hm.put(key, val); 1796 } 1797 } 1798 return (hm); 1799 } 1800 1801 1802 1803 1813 public static HashMap getArticleMappingsAndRankByItemID(DataStore db, String itemID, String section, String pubName) { 1814 HashMap fillReq = new HashMap (); 1815 fillReq.put("SECTION", section); 1816 fillReq.put("PUBNAME", pubName); 1817 String tag = CofaxToolsDbUtils.fillTag(db, "getMapCodeFromtblsectionsBySectionAndPubName"); 1818 HashMap htTemp = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 1819 1820 String mappingCode = (String ) htTemp.get("MAPPINGCODE"); 1821 HashMap fillReqTwo = new HashMap (); 1822 fillReqTwo.put("ITEMID", itemID); 1823 tag = CofaxToolsDbUtils.fillTag(db, "getMapCodeRankFromViewAllArticlesByItemID"); 1824 HashMap ht = CofaxToolsDbUtils.getValueValuePackageHash(db, fillReqTwo, tag, "MAPPINGCODE", "ORDERINGRANK"); 1825 1826 try { 1827 ht.remove(mappingCode); 1828 } catch (Exception e) { 1829 } 1831 1832 Iterator en = ht.keySet().iterator(); 1833 while (en.hasNext()) { 1834 String mappingCodeTwo = (String ) en.next(); 1835 } 1836 return (ht); 1837 } 1838 1839 1840 1847 public static List getRelatedMultiMediaByItemID(DataStore db, String itemID) { 1848 HashMap fillReq = new HashMap (); 1849 fillReq.put("ITEMID", itemID); 1850 String tag = CofaxToolsDbUtils.fillTag(db, "getAllFromMultimediaByItemID"); 1851 List results = CofaxToolsDbUtils.getPackageData(db, fillReq, tag); 1852 return (results); 1853 } 1854 1855 1856 1864 public static List getRelatedMultiMediaByMultiMediaID(DataStore db, String itemID) { 1865 HashMap fillReq = new HashMap (); 1866 fillReq.put("ITEMID", itemID); 1867 String tag = CofaxToolsDbUtils.fillTag(db, "getAllFromMultimediaByItemID"); 1868 List results = CofaxToolsDbUtils.getPackageData(db, fillReq, tag); 1869 return (results); 1870 } 1871 1872 1873 1879 public static HashMap getMultiMediaTypes(DataStore db) { 1880 String tag = CofaxToolsDbUtils.fillTag(db, "getDistinctTypeFromMultimedia"); 1881 Vector vec = CofaxToolsDbUtils.getPackageVector(db, tag); 1882 HashMap ht = new HashMap (); 1883 Iterator it = vec.iterator(); 1884 while (it.hasNext()) { 1885 String type = (String ) it.next(); 1886 ht.put(type, type); 1887 } 1888 return (ht); 1889 } 1890 1891 1892 1898 public static String sqlDateToCofaxDate(String date) { 1899 if (date.length() > 0) { 1900 date = date.substring(0, 10); 1901 date = date.replace('-', '/'); 1902 } 1903 return (date); 1904 } 1905 1906 1907 1912 public static String getDateString() { 1913 HashMap ht = getDateInfo(); 1914 String year = (String ) ht.get("year"); 1915 String month = (String ) ht.get("month"); 1916 String day = (String ) ht.get("day"); 1917 if (month.length() == 1) { 1918 month = "0" + month; 1919 } 1920 if (day.length() == 1) { 1921 day = "0" + day; 1922 } 1923 return (year + "/" + month + "/" + day); 1924 } 1925 1926 1927 1928 1937 1938 public static String getSelectArticleType(DataStore db, String currentPubName, String label) { 1939 String select = getSelectArticleType(db, currentPubName, label, ""); 1940 return (select); 1941 } 1942 1943 1944 1953 1954 public static String getSelectArticleTypeNew(DataStore db, String currentPubName, String label) { 1955 String select = getSelectArticleTypeNew(db, currentPubName, label, ""); 1956 return (select); 1957 } 1958 1959 1960 1970 1971 public static String getSelectArticleType(DataStore db, String currentPubName, String label, String selected) { 1972 HashMap fillReq = new HashMap (); 1973 fillReq.put("currentPubName", currentPubName); 1974 String tag = CofaxToolsDbUtils.fillTag(db, "getArticleTypeDescAndTypeFromArticleTypesByPubName"); 1975 HashMap ht = CofaxToolsDbUtils.getValueValuePackageHash(db, fillReq, tag, "ARTICLETYPEDESC", "ARTICLETYPEID"); 1976 ht.put("** Select Articletype **", ""); 1977 String select = createSelect(label, ht, selected); 1978 return (select); 1979 } 1980 1981 1982 1992 public static String getSelectArticleTypeNew(DataStore db, String currentPubName, String label, String selected) { 1993 HashMap fillReq = new HashMap (); 1994 fillReq.put("currentPubName", currentPubName); 1995 String tag = CofaxToolsDbUtils.fillTag(db, "getArticleTypeDescAndTypeFromArticleTypeByPubName"); 1996 HashMap ht = CofaxToolsDbUtils.getValueValuePackageHash(db, fillReq, tag, "ARTICLETYPEDESC", "ARTICLETYPE"); 1997 ht.put("** Select Articletype **", ""); 1998 String select = createSelect(label, ht, selected); 1999 return (select); 2000 } 2001 2002 2003 2004 2005 2006 2015 public static String getSelectSection(DataStore db, String currentPubName, String label) { 2016 String select = getSelectSection(db, currentPubName, label, ""); 2017 return (select); 2018 } 2019 2020 2021 2022 2032 public static String getSelectSection(DataStore db, String pubName, String label, String selected) { 2033 HashMap fillReq = new HashMap (); 2034 fillReq.put("PUBNAME", pubName); 2035 String tag = CofaxToolsDbUtils.fillTag(db, "getSectionDescAndMapCodeFromSectionsByPubName"); 2036 HashMap ht = CofaxToolsDbUtils.getValueValuePackageHash(db, fillReq, tag, "SECTIONDESC", "MAPPINGCODE"); 2037 ht.put("** " + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_selectmappingsection") + " **", ""); 2038 String select = createSelect(label, ht, selected); 2039 return (select); 2040 } 2041 2042 2050 public static HashMap convertBooleanToChecked(HashMap ht, String itemToBeConverted) { 2051 if (ht.size() > 0) { 2052 2053 String checked = (String ) ht.get(itemToBeConverted); 2054 if ((checked != null) && (!checked.equals("0"))) { 2055 checked = "checked"; 2056 } else { 2057 checked = ""; 2058 } 2059 ht.put(itemToBeConverted, checked); 2060 } 2061 return (ht); 2062 } 2063 2064 2065 2071 public static String convertCheckedToBoolean(String checked) { 2072 if (checked != null) { 2073 checked = "1"; 2074 } else { 2075 checked = "0"; 2076 } 2077 return (checked); 2078 } 2079 2080 2081 2082 2089 2098 2099 2100 2101 2111 public static String getOrderSectionComboBox(DataStore db, String publication, HttpSession session, HttpServletRequest req, String numPreOrders) { 2112 HashMap ht = new HashMap (); 2113 return (getOrderSectionComboBox(db, publication, session, req, ht, numPreOrders)); 2114 } 2115 2116 2117 2128 public static String getOrderSectionComboBox(DataStore db, String publication, HttpSession session, HttpServletRequest req, HashMap temp, String numPreOrders) { 2129 List list; 2130 String mappingCode; 2131 String results; 2132 String startDate; 2133 String endDate; 2134 2135 if (temp.size() <= 0) { 2136 mappingCode = req.getParameter("mapping"); 2137 results = req.getParameter("results"); 2138 2139 String startYear = req.getParameter("selectStartDateyear"); 2140 String startMonth = req.getParameter("selectStartDatemonth"); 2141 String startDay = req.getParameter("selectStartDateday"); 2142 String stopYear = req.getParameter("selectEndDateyear"); 2143 String stopMonth = req.getParameter("selectEndDatemonth"); 2144 String stopDay = req.getParameter("selectEndDateday"); 2145 2146 if (startMonth.length() == 1) { 2147 startMonth = "0" + startMonth; 2148 } 2149 if (startDay.length() == 1) { 2150 startDay = "0" + startDay; 2151 } 2152 if (stopMonth.length() == 1) { 2153 stopMonth = "0" + stopMonth; 2154 } 2155 if (stopDay.length() == 1) { 2156 stopDay = "0" + stopDay; 2157 } 2158 2159 startDate = (startYear + "-" + startMonth + "-" + startDay); 2160 endDate = (stopYear + "-" + stopMonth + "-" + stopDay); 2161 } else { 2162 mappingCode = (String ) temp.get("mapping"); 2163 results = ("100"); 2164 startDate = (String ) temp.get("PUBDATE"); 2165 endDate = (String ) temp.get("PUBDATE"); 2166 } 2167 2168 if (mappingCode.equals("insertPublication")) { 2169 return ("You must select a section to order before submitting the form"); 2170 } 2171 2172 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 2173 String HttpPrefix = (String ) user.workingPubConfigElementsHash.get("MAINCOFAXSERVER"); 2174 HashMap fillRequest = new HashMap (); 2175 fillRequest.put("results", results); 2176 fillRequest.put("MAPPINGCODE", mappingCode); 2177 fillRequest.put("startDate", startDate); 2178 fillRequest.put("endDate", endDate); 2179 2180 if (startDate.equals(endDate)) { 2181 String tag = CofaxToolsDbUtils.fillTag(db, "getAllfromtblarticlesTblOrderByMapAndDate"); 2182 list = CofaxToolsDbUtils.getPackageData(db, fillRequest, tag); 2183 } else { 2184 String tag = CofaxToolsDbUtils.fillTag(db, "getAllfromtblarticlesTblOrderByMapAndDates"); 2185 list = CofaxToolsDbUtils.getPackageData(db, fillRequest, tag); 2186 } 2187 2188 HashMap fillReq = new HashMap (); 2189 fillReq.put("MAPPINGCODE", mappingCode); 2190 String tag = CofaxToolsDbUtils.fillTag(db, "getSectionNameDescFromtblsectionsByMappingCode"); 2191 HashMap htTemp = CofaxToolsDbUtils.getNameValuePackageHash(db, fillReq, tag); 2192 2193 String sectionName = (String ) htTemp.get("SECTIONNAME"); 2194 String section = (String ) htTemp.get("SECTION"); 2195 String sectionDesc = (String ) htTemp.get("SECTIONDESC"); 2196 2197 String toolsPath = CofaxToolsServlet.toolsPath; 2198 2199 ArrayList tempSelectMappingsMultiplePublications = (ArrayList ) getSelectMappingsMultiplePublicationsArrayList(db, "** Mapping Section **", session); 2200 2201 int mappingSize = list.size(); 2202 2203 HashMap ht = new HashMap (); 2204 for (int i = 0; i < (list.size() + 30); i++) { 2205 String tempNum = String.valueOf(i + 1); 2206 if (tempNum.length() == 1) { 2207 tempNum = "0" + tempNum; 2208 } 2209 ht.put(tempNum, tempNum); 2210 } 2211 2212 StringBuffer s = new StringBuffer (); 2213 s.append("<TABLE WIDTH=750>"); 2214 s.append("<INPUT TYPE=HIDDEN NAME=mapTo VALUE=\'" + mappingCode + "\'>"); 2215 2216 for (int i = 1; i <= list.size(); i++) { 2217 HashMap map = (HashMap ) list.get(i - 1); 2218 String headline = (String ) map.get("HEADLINE"); 2219 map = escapeHTML(map); 2220 2221 String itemID = (String ) map.get("ITEMID"); 2222 String docID = (String ) map.get("DOCID"); 2223 String pubName = (String ) map.get("PUBNAME"); 2224 String pubDate = sqlDateToCofaxDate((String ) map.get("PUBDATE")); 2225 String rank = (String ) map.get("RANK"); 2226 String disableArticle = (String ) map.get("DISABLEARTICLE"); 2227 String disableIndex = (String ) map.get("DISABLEINDEX"); 2228 String fileName = (String ) map.get("FILENAME"); 2229 if (disableIndex.equals("1")) { 2230 disableIndex = "checked"; 2231 } else { 2232 disableIndex = ""; 2233 } 2234 if (disableArticle.equals("1")) { 2235 disableArticle = "checked"; 2236 } else { 2237 disableArticle = ""; 2238 } 2239 String tempNum = String.valueOf(i); 2240 if (tempNum.length() == 1) { 2241 tempNum = "0" + tempNum; 2242 } 2243 String selectRank = createSelect("RANK" + i, ht, tempNum); 2244 2245 String headline2=headline; 2246 String validated = (String ) map.get("WORKFLOW_STATE"); 2247 if (validated.equals("0")) headline2="<font color='silver'><i>" + headline + "</i></font>"; 2248 else if (validated.equals("1")) headline2="<font color='#C1C307'><i>" + headline + "</i></font>"; 2249 else if (validated.equals("2")) headline2="<font color='#0066CC'>" + headline + "</font>"; 2250 2251 s.append("\n<INPUT TYPE=HIDDEN NAME=ITEMID" + i + " VALUE=" + itemID + ">\n"); 2252 s.append("<INPUT TYPE=HIDDEN NAME=SECTION" + i + " VALUE=\'" + section + "\'>\n"); 2253 s.append("<INPUT TYPE=HIDDEN NAME=MAPPINGCODE" + i + " VALUE=" + mappingCode + ">\n"); 2254 s.append("<INPUT TYPE=HIDDEN NAME=FILENAME" + i + " VALUE=" + fileName + ">\n"); 2255 s.append("<INPUT TYPE=HIDDEN NAME=PUBNAME" + i + " VALUE=" + pubName + ">\n"); 2256 s.append("<INPUT TYPE=HIDDEN NAME=PUBDATE" + i + " VALUE=" + pubDate + ">\n"); 2257 s.append("<TD>" + selectRank + "</TD><TD><B> " + fileName + "<B></TD><TD><B>" + headline2 + "</TD><TD><INPUT TYPE=CHECKBOX NAME=remove" + i + ">Delete from map</TD><TR>\n"); 2258 s.append("<TD><A HREF=" + toolsPath + "?mode=article_edit_article_by_itemID&ITEMID=" + itemID + ">Edit</A></TD><TD> " + sectionName + "</TD><TD>" + pubDate + "</TD><TD><INPUT TYPE=CHECKBOX NAME=DISABLEINDEX" + i + " " + disableIndex + " >" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_disableonsectionfront") + "</TD><TR>\n"); 2259 s.append("<TD>" + pubName + "</TD><TD></TD><TD></TD><TD><INPUT TYPE=CHECKBOX NAME=DISABLEARTICLE" + i + " " + disableArticle + " >" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_disablearticle") + "</TD><TR>\n"); 2260 s.append("<TD COLSPAN=4> </TD><TR>"); 2261 2262 } 2263 if (mappingSize == 0) { 2264 s.append("<TD><FONT COLOR=RED>No Stories have been found for this section.</FONT>\n"); 2265 } 2266 s.append("<TD><INPUT TYPE=HIDDEN NAME=listFilledSize VALUE=" + String.valueOf(list.size()) + ">\n"); 2267 s.append("</TABLE><TABLE WIDTH=750>\n"); 2268 if (Integer.parseInt(numPreOrders) > 0) { 2269 s.append("<TD COLSPAN=4><HR><CENTER><B>Pre-Order Non-Existent Stories</B></TD><TR>\n"); 2270 } else { 2271 s.append("<TD COLSPAN=4><HR></TD><TR>\n"); 2272 } 2273 2274 HashMap htTime = getDateInfo(); 2275 int year = Integer.parseInt((String ) htTime.get("year")); 2276 int month = Integer.parseInt((String ) htTime.get("month")); 2277 int day = Integer.parseInt((String ) htTime.get("day")); 2278 2279 for (int i = list.size() + 1; i <= (list.size() + Integer.parseInt(numPreOrders)); i++) { 2280 String tempNum = String.valueOf(i); 2281 if (tempNum.length() == 1) { 2282 tempNum = "0" + tempNum; 2283 } 2284 String selectDate = getSelectDate("date" + i, year, month, day); 2285 String selectRank = createSelect("RANK" + i, ht, tempNum); 2286 String selectMappingsMultiplePublications = createSelect("MAPPINGCODE" + i, tempSelectMappingsMultiplePublications); 2287 s.append("<TD COLSPAN=2><INPUT TYPE=HIDDEN NAME=ITEMID" + i + " VALUE=\"\">\n"); 2288 s.append("<INPUT TYPE=HIDDEN NAME=SECTION" + i + " VALUE=\'" + section + "\'>\n"); 2289 s.append("" + selectRank + " Slug:<INPUT TYPE=TEXT NAME=FILENAME" + i + "></TD><TR>\n"); 2290 s.append("<TD>From Section: " + selectMappingsMultiplePublications + "</TD><TD> Pub Date: " + selectDate + "</TD><TR>\n"); 2291 s.append("<TD COLSPAN=2> </TD><TR>\n"); 2292 2293 } 2294 2295 s.append("<INPUT TYPE=HIDDEN NAME=listSize VALUE=" + (list.size() + Integer.parseInt(numPreOrders)) + ">\n"); 2296 s.append("</TABLE>\n"); 2297 return (s.toString()); 2298 } 2299 2300 2301 2302 2312 public static String getMultiMediaComboBox(DataStore db, List l, String pubDate, 2314 HttpSession session, String storyItemID) { 2315 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 2316 String imagesURLPrefix = (String ) user.workingPubConfigElementsHash.get("IMAGESURLPREFIX"); 2317 2318 if (!imagesURLPrefix.endsWith("/")) { 2319 imagesURLPrefix = imagesURLPrefix + "/"; 2320 } 2321 2322 String pubName = user.workingPubName; 2323 String pubID = (String ) user.workingPub; 2324 StringBuffer sb = new StringBuffer (); 2325 String useDate = "0" ; 2327 pubDate = sqlDateToCofaxDate(pubDate); 2328 int finalCount = 0; 2329 2330 HashMap ht = new HashMap (); ht.put("** " + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_selecttype") + " **", ""); 2333 ht.put(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"article_image"), "articleImage"); 2334 ht.put(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"article_attachments"), "other"); 2335 2337 2338 sb.append("<input type=\"hidden\" name=\"ITEMID\" value=\"" + storyItemID + "\" />"); 2339 sb.append("<div class=\"multimediabox\">"); 2341 for (int i = 0; i < l.size(); i++) { 2343 HashMap hashInfo = (HashMap ) l.get(i); 2344 String multiMediaID = (String ) hashInfo.get("MULTIMEDIAID"); 2345 String type = (String ) hashInfo.get("TYPE"); 2346 String itemID = (String ) hashInfo.get("ITEMID"); 2347 String caption = (String ) hashInfo.get("CAPTION"); 2348 String itemName = (String ) hashInfo.get("ITEMNAME"); 2349 String size = (String ) hashInfo.get("SIZE"); 2350 String filename = (String ) hashInfo.get("FILENAME"); 2351 2352 if (type.equals("articleImage")) ht.remove("article image"); 2354 if (type.equals("sectionImage")) ht.remove("section image"); 2355 2356 String imagesURLPrefix2 = imagesURLPrefix; 2358 if (useDate.equals("1")) imagesURLPrefix2=imagesURLPrefix2+pubDate + "/"; 2359 imagesURLPrefix2=imagesURLPrefix2+itemName; 2360 if (imagesURLPrefix2.toLowerCase().endsWith("pdf")) imagesURLPrefix2="" + CofaxToolsServlet.aliasPath + "/static/images/pdf.gif"; 2361 if (imagesURLPrefix2.toLowerCase().endsWith("doc")) imagesURLPrefix2="" + CofaxToolsServlet.aliasPath + "/static/images/doc.gif"; 2362 if (imagesURLPrefix2.toLowerCase().endsWith("ppt")) imagesURLPrefix2="" + CofaxToolsServlet.aliasPath + "/static/images/ppt.gif"; 2363 if (imagesURLPrefix2.toLowerCase().endsWith("mdb")) imagesURLPrefix2="" + CofaxToolsServlet.aliasPath + "/static/images/mdb.gif"; 2364 if (imagesURLPrefix2.toLowerCase().endsWith("xls")) imagesURLPrefix2="" + CofaxToolsServlet.aliasPath + "/static/images/xls.gif"; 2365 if (imagesURLPrefix2.toLowerCase().endsWith("csv")) imagesURLPrefix2="" + CofaxToolsServlet.aliasPath + "/static/images/xls.gif"; 2366 if (imagesURLPrefix2.toLowerCase().endsWith("zip")) imagesURLPrefix2="" + CofaxToolsServlet.aliasPath + "/static/images/zip.gif"; 2367 2368 sb.append("<table>"); 2370 sb.append("<input type=\"hidden\" name=\"multiMediaType" + i + "\" value=\"" + type + "\" />"); 2371 sb.append("<input type=\"hidden\" name=\"uploadImage" + i + "\" value=\"" + filename + "\" />"); sb.append("<input type=\"hidden\" name=\"MULTIMEDIAID" + i + "\" value=\"" + multiMediaID + "\" />" + "\n"); 2373 sb.append("<tr><th>Type</th><td>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,type) +" <input type=\"checkbox\" name=\"deleteMultiMedia" + i + "\" />" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_delete")+ "</td></tr>"); 2374 sb.append("<tr><th>"+CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"article_file")+"</th><td><a HREF=\"javascript:openNewWindow(\'" + imagesURLPrefix); 2375 if (useDate.equals("1")) sb.append(pubDate + "/"); 2377 sb.append(itemName + "\',\'this\',\'WIDTH=300, HEIGHT=400 MENUBAR=yes SCROLLBARS=yes RESIZABLE=yes\')\">\n"); 2378 sb.append(" "+itemName+"</a>"); 2379 sb.append("</td></tr>"); 2382 sb.append("<tr><th>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_caption") + "</th>\n"); 2383 sb.append("<td><input type=\"text\" name=\"multiMediaCaption" + i + "\" size=\"20\" value=\"" + caption + "\" />"+ size+"</td></tr>\n"); 2384 sb.append("<input type=\"hidden\" name=\"itemName" + i + "\" value=\"" + itemName + "\" />"); 2385 sb.append("<input type=\"hidden\" name=\"SIZE" + i + "\" value=\"" + size + "\" />"); 2386 2387 sb.append("</table>\n"); 2388 sb.append(""); 2389 finalCount++; 2390 } 2391 2392 int i = finalCount; 2394 String selectMultiMediaType = createSelect("multiMediaType" + i, ht); 2395 sb.append("<hr />"); 2396 sb.append("<table>"); 2397 sb.append("<tr><th>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_addmultimedia") + "</th>"); 2398 sb.append("<td>"+ selectMultiMediaType + "</td></tr>"); 2399 sb.append("<th>"+CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"article_file")+"</th>"); 2400 sb.append("<td><input type=\"file\" name=\"uploadImage" + i + "\" size=\"5\" value=\"Upload New\" /></td></tr>\n"); 2401 sb.append("<input type=\"hidden\" name=\"numMultiMediaItems\" value=\"" + finalCount + "\" />\n"); 2402 sb.append("<input type=\"hidden\" name=\"newUpload" + i + "\" value=\"yes\" />\n"); 2403 sb.append("<tr><th>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_caption") + "</th>\n"); 2404 sb.append("<td><input type=\"text\" name=\"multiMediaCaption" + i + "\" size=\"20\" /></textarea></td></tr>\n"); 2405 sb.append("</table>"); 2406 sb.append("\n"); 2407 finalCount++; 2408 sb.append("<input type=\"hidden\" name=\"numMultiMediaItems\" value=\"" + finalCount + "\" />"); 2410 sb.append("</div>"); 2411 2412 return (sb.toString()); 2413 } 2414 2415 2416 2422 public static String getFileExtension(String path) { 2423 if ((path != null) && (!path.equals(""))) { 2424 int lastOccur = path.lastIndexOf("."); 2425 if (lastOccur > 0) { 2426 path = path.substring(lastOccur); 2427 } 2428 } 2429 return (path); 2430 } 2431 2432 2433 2439 public static String getRelatedLinksComboBox(DataStore db) { 2440 return (getRelatedLinksComboBox(db, "")); 2441 } 2442 2443 2444 2451 2452 public static String getRelatedLinksComboBox(DataStore db, String itemID) { 2453 HashMap fillReq = new HashMap (); 2454 fillReq.put("ITEMID", itemID); 2455 String tag = CofaxToolsDbUtils.fillTag(db, "getAllRelatedLinksByItemIDOrderByRank"); 2456 String toolsPath = CofaxToolsServlet.toolsPath; 2457 List l = new ArrayList (); 2458 if ((itemID != null) && (!itemID.equals(""))) { 2459 l = CofaxToolsDbUtils.getPackageData(db, fillReq, tag); 2460 } 2461 2462 StringBuffer sb = new StringBuffer (); 2463 2464 int selectSize = l.size() + 1; 2465 HashMap ht = new HashMap (); 2466 for (int in = 0; in < selectSize; in++) { 2467 ht.put(String.valueOf(in), String.valueOf(in)); 2468 } 2469 int i = 0; 2470 int ii = 0; 2471 2472 for (i = 0; i < l.size(); i++) { 2473 HashMap hm = (HashMap ) l.get(i); 2474 String link = (String ) hm.get("LINK"); 2475 String rank = (String ) hm.get("RANK"); 2476 String text = (String ) hm.get("TEXT"); 2477 sb.append("<table class='relatedLinks'>"); sb.append("<tr><th>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_link") + "</th><td><INPUT TYPE=TEXT SIZE=20 NAME=\"relatedLink" + i + "\" VALUE=\"" + link + "\"></td></tr>\n"); 2479 sb.append("<tr><th>Action</th><td><a target='_blank' HREF='"+link+"'>"+CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_link")+"</a> <INPUT TYPE=CHECKBOX NAME=\"deleteRelatedLink" + i + "\" />" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_delete") + "</td>"); 2480 sb.append("<tr><th>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_text") + "</th><td><INPUT TYPE=TEXT SIZE=20 NAME=\"relatedLinkText" + i + "\" VALUE=\"" + text + "\"></td></tr>\n"); 2481 String select = createSelect("relatedLinkRank" + i, ht, rank); 2482 sb.append("<tr><th>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_rank") + "</th><td>" + select + "</td>"); 2483 sb.append("</tr></table>\n<hr />\n"); 2484 } 2485 2486 for (ii = i; ii < l.size() + 1; ii++) { 2487 sb.append("<table class='createRelatedLinks'>"); sb.append("<tr><th colspan='2'>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_addlink") + "</th></tr>"); 2489 sb.append("<tr><th>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_link") + "</th><td><INPUT TYPE=TEXT SIZE=15 NAME=\"relatedLink" + ii + "\" VALUE=\"\"> <a HREF=\"#\" onClick=\"openNewWindow(\'" + toolsPath + "?mode=article_search_article&linkFunction=relate&callingFormPortion=" + ii + "\',\'window2\',\'WIDTH=760, HEIGHT=500 MENUBAR=yes SCROLLBARS=yes RESIZABLE=yes\')\"><IMG border=0 SRC=\"" + CofaxToolsServlet.aliasPath + "/static/images/im_loupe.gif\"></a></td></tr>\n"); 2490 sb.append("<tr><th>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_text") + "</th><td><INPUT TYPE=TEXT SIZE=15 NAME=\"relatedLinkText" + ii + "\" VALUE=\"\"></td>\n"); 2491 String select = createSelect("relatedLinkRank" + ii, ht, String.valueOf(ii)); 2492 sb.append("<tr><th>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createarticle_rank") + "</th><td>" + select + "</td>"); 2493 sb.append("</tr></table>\n"); 2494 } 2495 2496 sb.append("<INPUT TYPE=HIDDEN NAME=numLinks VALUE=" + ii + ">"); 2497 return (sb.toString()); 2498 } 2499 2500 2501 2508 2509 public static String getSearchSelectCombo(HttpServletRequest req) { 2510 2511 String from = req.getParameter("from"); 2512 String startDatemonthPref = ""; 2513 String startDatedayPref = ""; 2514 String startDateyearPref = ""; 2515 String stopDatemonthPref = ""; 2516 String stopDatedayPref = ""; 2517 String stopDateyearPref = ""; 2518 String publicationsPref = ""; 2519 String sectionPref = ""; 2520 String mappingPref = ""; 2521 String orderByPref = ""; 2522 String resultsPref = ""; 2523 String field1Pref = ""; 2524 String field2Pref = ""; 2525 String field3Pref = ""; 2526 String condition1Pref = ""; 2527 String condition2Pref = ""; 2528 String condition3Pref = ""; 2529 String fieldtwo1Pref = ""; 2530 String fieldtwo2Pref = ""; 2531 String fieldtwo3Pref = ""; 2532 2533 if ((from != null) && (from.equals("savedSearch"))) { 2534 startDatemonthPref = req.getParameter("startDatemonth"); 2535 startDatedayPref = req.getParameter("startDatemday"); 2536 startDateyearPref = req.getParameter("startDateyear"); 2537 stopDatemonthPref = req.getParameter("stopDatemonth"); 2538 stopDatedayPref = req.getParameter("stopDateday"); 2539 stopDateyearPref = req.getParameter("stopDateyear"); 2540 publicationsPref = req.getParameter("publications"); 2541 sectionPref = req.getParameter("SECTION"); 2542 mappingPref = req.getParameter("mapping"); 2543 orderByPref = req.getParameter("orderBy"); 2544 resultsPref = req.getParameter("results"); 2545 field1Pref = req.getParameter("field1"); 2546 field2Pref = req.getParameter("field2"); 2547 field3Pref = req.getParameter("field3"); 2548 condition1Pref = req.getParameter("condition1"); 2549 condition2Pref = req.getParameter("condition2"); 2550 condition3Pref = req.getParameter("condition3"); 2551 fieldtwo1Pref = req.getParameter("fieldtwo1"); 2552 fieldtwo2Pref = req.getParameter("fieldtwo2"); 2553 fieldtwo3Pref = req.getParameter("fieldtwo3"); 2554 } 2555 2556 HashMap field = new HashMap (); 2557 field.put(getI18NMessage(CofaxToolsServlet.lcl,"search_makeselection"), ""); 2558 field.put(getI18NMessage(CofaxToolsServlet.lcl,"createarticle_title"), "HEADLINE"); 2559 field.put(getI18NMessage(CofaxToolsServlet.lcl,"createarticle_byline"), "BYLINE"); 2560 field.put(getI18NMessage(CofaxToolsServlet.lcl,"createarticle_body"), "BODY"); 2561 field.put(getI18NMessage(CofaxToolsServlet.lcl,"createarticle_lead"), "LEAD"); 2562 field.put(getI18NMessage(CofaxToolsServlet.lcl,"section"), "SECTIONDESC"); 2563 field.put(getI18NMessage(CofaxToolsServlet.lcl,"createarticle_mapping"), "MAPPINGCODE"); 2564 field.put("Item ID", "ITEMID"); 2565 field.put(getI18NMessage(CofaxToolsServlet.lcl,"createarticle_code"), "FILENAME"); 2566 2567 HashMap condition = new HashMap (); 2568 condition.put(getI18NMessage(CofaxToolsServlet.lcl,"search_contains"), "LIKE"); 2569 condition.put(getI18NMessage(CofaxToolsServlet.lcl,"search_doesnotcontain"), "NOT LIKE"); 2570 condition.put(getI18NMessage(CofaxToolsServlet.lcl,"search_is"), "="); 2571 condition.put(getI18NMessage(CofaxToolsServlet.lcl,"search_isnot"), "!="); 2572 2573 HashMap orderBy = new HashMap (); 2574 orderBy.put(getI18NMessage(CofaxToolsServlet.lcl,"createarticle_title"), "HEADLINE"); 2575 orderBy.put("Pubdate", "PUBDATE"); 2576 orderBy.put(getI18NMessage(CofaxToolsServlet.lcl,"publication"), "PUBNAME"); 2577 orderBy.put(getI18NMessage(CofaxToolsServlet.lcl,"createarticle_byline"), "BYLINE"); 2578 orderBy.put(getI18NMessage(CofaxToolsServlet.lcl,"createarticle_code"), "FILENAME"); 2579 2580 HashMap results = new HashMap (); 2581 results.put("10", "10"); 2582 results.put("25", "25"); 2583 results.put("50", "50"); 2584 results.put("75", "75"); 2585 results.put("100", "100"); 2586 2587 String selectOrderBy = ""; 2588 if (!orderByPref.equals("")) { 2589 selectOrderBy = createSelect("orderBy", orderBy, orderByPref); 2590 } else { 2591 selectOrderBy = createSelect("orderBy", orderBy, "PUBNAME"); 2592 } 2593 2594 String selectResults = ""; 2595 if (!resultsPref.equals("")) { 2596 selectResults = createSelect("results", results, resultsPref); 2597 } else { 2598 selectResults = createSelect("results", results, "50"); 2599 } 2600 2601 StringBuffer sb = new StringBuffer (); 2602 sb.append("<TABLE>"); 2603 2604 String conditionSelect1 = ""; 2605 if (!condition1Pref.equals("")) { 2606 conditionSelect1 = createSelect("condition1", condition, condition1Pref); 2607 } else { 2608 conditionSelect1 = createSelect("condition1", condition, "LIKE"); 2609 } 2610 String fieldSelect1 = ""; 2611 if (!field1Pref.equals("")) { 2612 fieldSelect1 = createSelect("field1", field, field1Pref, "onChange = \"bodySearchCheck(\'field1\');\""); 2613 } else { 2614 fieldSelect1 = createSelect("field1", field, "", "onChange = \"bodySearchCheck(\'field1\');\""); 2615 } 2616 sb.append("<TD>" + fieldSelect1 + "</TD>\n"); 2617 sb.append("<TD>" + conditionSelect1 + "</TD>\n"); 2618 2619 if (!fieldtwo1Pref.equals("")) { 2620 sb.append("<TD><INPUT TYPE=TEXT SIZE=30 MAXLENGTH=50 NAME=fieldtwo1 VALUE=\"" + fieldtwo1Pref + "\">\n"); 2621 } else { 2622 sb.append("<TD><INPUT TYPE=TEXT SIZE=30 MAXLENGTH=50 NAME=fieldtwo1>\n"); 2623 } 2624 sb.append("<TR>\n"); 2625 2626 String conditionSelect2 = ""; 2627 if (!condition2Pref.equals("")) { 2628 conditionSelect2 = createSelect("condition2", condition, condition2Pref); 2629 } else { 2630 conditionSelect2 = createSelect("condition2", condition, "LIKE"); 2631 } 2632 String fieldSelect2 = ""; 2633 if (!field2Pref.equals("")) { 2634 fieldSelect2 = createSelect("field2", field, field2Pref, "onChange = \"bodySearchCheck(\'field2\');\""); 2635 } else { 2636 fieldSelect2 = createSelect("field2", field, "", "onChange = \"bodySearchCheck(\'field2\');\""); 2637 } 2638 sb.append("<TD>" + fieldSelect2 + "</TD>\n"); 2639 sb.append("<TD>" + conditionSelect2 + "</TD>\n"); 2640 2641 if (!fieldtwo2Pref.equals("")) { 2642 sb.append("<TD><INPUT TYPE=TEXT SIZE=30 MAXLENGTH=50 NAME=fieldtwo2 VALUE=\"" + fieldtwo2Pref + "\">\n"); 2643 } else { 2644 sb.append("<TD><INPUT TYPE=TEXT SIZE=30 MAXLENGTH=50 NAME=fieldtwo2>\n"); 2645 } 2646 sb.append("<TR>\n"); 2647 2648 String conditionSelect3 = ""; 2649 if (!condition3Pref.equals("")) { 2650 conditionSelect3 = createSelect("condition3", condition, condition3Pref); 2651 } else { 2652 conditionSelect3 = createSelect("condition3", condition, "LIKE"); 2653 } 2654 String fieldSelect3 = ""; 2655 if (!(field3Pref).equals("")) { 2656 fieldSelect3 = createSelect("field3", field, field3Pref, "onChange = \"bodySearchCheck(\'field3\');\""); 2657 } else { 2658 fieldSelect3 = createSelect("field3", field, "", "onChange = \"bodySearchCheck(\'field3\');\""); 2659 } 2660 sb.append("<TD>" + fieldSelect3 + "</TD>\n"); 2661 sb.append("<TD>" + conditionSelect3 + "</TD>\n"); 2662 2663 if (!fieldtwo3Pref.equals("")) { 2664 sb.append("<TD><INPUT TYPE=TEXT SIZE=30 MAXLENGTH=50 NAME=fieldtwo3 VALUE=\"" + fieldtwo3Pref + "\">\n"); 2665 } else { 2666 sb.append("<TD><INPUT TYPE=TEXT SIZE=30 MAXLENGTH=50 NAME=fieldtwo3>\n"); 2667 } 2668 sb.append("<TR>\n"); 2669 2670 2680 sb.append("<TR>\n"); 2681 sb.append("<TD colspan=2><B>" + getI18NMessage(CofaxToolsServlet.lcl,"search_orderby") + ": " + selectOrderBy + "</TD>\n"); 2682 sb.append("<TD><B>" + getI18NMessage(CofaxToolsServlet.lcl,"search_show") + ": " + selectResults + "</TD>\n"); 2683 sb.append("</TABLE>"); 2684 2685 return (sb.toString()); 2686 } 2687 2688 2689 2698 public static String saveSearch(DataStore db, HttpSession session, HttpServletRequest req) { 2699 HashMap htTemp = splitPostQuery(req); 2700 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 2701 String toolsPath = CofaxToolsServlet.toolsPath; 2702 HashMap ht = new HashMap (); 2703 String searchName = (String ) req.getParameter("SEARCHNAME"); 2704 ht.put("SEARCHNAME", searchName); 2705 String userID = (String ) user.userInfoHash.get("USERID"); 2706 ht.put("USERID", userID); 2707 String search = (String ) req.getQueryString(); 2708 search = replace(search, "search_save_search", "article_search_for_articles"); 2709 search = toolsPath + "?from=savedSearch&" + search; 2710 ht.put("SEARCH", search); 2711 String tag = CofaxToolsDbUtils.fillTag(db, "updateSavedSearches"); 2712 List list = CofaxToolsDbUtils.getPackageData(db, ht, tag); 2713 return ("Search " + searchName + " saved."); 2714 } 2715 2716 2717 2724 2725 public static String getSelectSavedSearches(DataStore db, HttpSession session) { 2726 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 2727 String userID = (String ) user.userInfoHash.get("USERID"); 2728 HashMap fillReq = new HashMap (); 2729 fillReq.put("USERID", userID); 2730 String tag = CofaxToolsDbUtils.fillTag(db, "getSavedSearchesByUserID"); 2731 HashMap ht = CofaxToolsDbUtils.getValueValuePackageHash(db, fillReq, tag, "SEARCHNAME", "SEARCH"); 2732 ht.put(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"search_savedsearches"), ""); 2733 String select = createSelect("savedSearches", ht, "", "onChange=\"skipTo();\""); 2734 return (select); 2735 } 2736 2737 2738 2745 public static boolean resetServlet(DataStore db) { 2746 2747 CofaxToolsServlet.dataStore.clearCache(DataStore.PACKAGE_TAG_RESULTS); 2748 CofaxToolsServlet.dataStore.setCache(CofaxToolsDbUtils.getValueValuePackageHash(db, "select tag_name, tag_value from cofax.tbltoolspackagetags", "TAG_NAME", "TAG_VALUE", true), DataStore.PACKAGE_TAG_PROCESSED); 2749 CofaxToolsServlet.dataStore.setCache(CofaxToolsDbUtils.getValueValuePackageHash(db, "select tag_value, cache from cofax.tbltoolspackagetags", "TAG_VALUE", "CACHE", true), DataStore.PACKAGE_TAG_CACHE_COMMAND); 2750 2751 return (true); 2752 } 2753 2754 2755 2762 public static HashMap getCofaxUrlParameters(String url) { 2763 String pub = ""; 2764 String date = ""; 2765 String section = ""; 2766 String fileNameWithExtension = ""; 2767 String fileName = ""; 2768 boolean gotDate = false; 2769 int datePartCount = 0; 2770 String fileNameExtension = ""; 2771 HashMap ht = new HashMap (); 2772 ht.put("SECTION", ""); 2773 ht.put("PUBNAME", ""); 2774 ht.put("FILENAME", ""); 2775 ht.put("PUBDATE", ""); 2776 2777 int pos = url.indexOf("" + CofaxToolsServlet.aliasPath + "/"); 2778 url = url.substring(pos + 1); 2779 2780 int count = 0; 2782 2783 Iterator paths = CofaxUtil.split("/", url).iterator(); 2784 while (paths.hasNext()) { 2785 String path = (String ) paths.next(); 2787 count++; 2788 if (count == 2) { 2790 if ((path.indexOf('.') > -1)) { 2791 fileNameWithExtension = path; 2793 } else { 2794 pub = path; 2795 } 2796 } 2797 2798 if (CofaxUtil.isDigits(path)) { 2799 datePartCount++; 2800 if (datePartCount == 1) { 2801 date = path; 2802 } else { 2803 date = date + "/" + path; 2804 } 2805 if (datePartCount == 3) { 2806 gotDate = true; 2807 } 2808 continue; 2809 } 2810 datePartCount = 0; 2811 2812 if (count >= 3) { 2817 if ((path.indexOf('.') > -1)) { 2818 fileNameWithExtension = path; 2820 } else { 2821 if (section.equals("")) { 2823 section = path; 2824 } else { 2825 section = section + "/" + path; 2826 } 2827 } 2828 } 2829 } 2830 2831 2833 ht.put("SECTION", section); 2834 ht.put("PUBNAME", pub); 2835 2836 int dotLoc = fileNameWithExtension.lastIndexOf('.'); 2839 if (dotLoc > -1) { 2840 fileName = fileNameWithExtension.substring(0, dotLoc); 2841 } 2842 ht.put("FILENAME", fileName); 2843 ht.put("PUBDATE", date); 2844 return (ht); 2845 } 2846 2847 2848 2855 public static String getMappingCodeBySectionPublication(DataStore db, HashMap ht) { 2856 2857 String tag = CofaxToolsDbUtils.fillTag(db, "getMapCodeFromtblsectionsBySectionNameAndPubName"); 2858 HashMap results = CofaxToolsDbUtils.getNameValuePackageHash(db, ht, tag); 2859 String mappingCode = (String ) results.get("MAPPINGCODE"); 2860 return (mappingCode); 2861 } 2862 2863 2864 2871 public static String getItemIDFromNameSectionDate(DataStore db, HashMap ht) { 2872 String tag = CofaxToolsDbUtils.fillTag(db, "getSectionFromtblsectionsByPublicationSectionName"); 2873 HashMap htTemp = CofaxToolsDbUtils.getNameValuePackageHash(db, ht, tag); 2874 String section = (String ) htTemp.get("SECTION"); 2875 ht.put("SECTION", section); 2876 2877 tag = CofaxToolsDbUtils.fillTag(db, "getItemIDFromNameSectionDate"); 2878 HashMap results = CofaxToolsDbUtils.getNameValuePackageHash(db, ht, tag); 2879 String itemID = (String ) results.get("ITEMID"); 2880 return (itemID); 2881 } 2882 2883 2884 2891 public static int caseInsensitiveIndexOf(String mainText, String index) { 2892 int stLen = index.length(); 2893 int stLenTest = 0; 2894 int indexIterator = 0; 2895 char indexChar[] = index.toCharArray(); 2896 char mainTextChar[] = mainText.toCharArray(); 2897 for (int i = 0; i < mainTextChar.length; i++) { 2898 char mainTextTest = mainTextChar[i]; 2899 char indexTest = indexChar[indexIterator]; 2900 String s1 = String.valueOf(mainTextTest).toLowerCase(); 2901 String s2 = String.valueOf(indexTest).toLowerCase(); 2902 if (s1.equals(s2)) { 2903 stLenTest++; 2904 indexIterator++; 2905 if (stLenTest == stLen) { 2906 return (i - stLen + 1); 2907 } 2908 } else { 2909 stLenTest = 0; 2910 indexIterator = 0; 2911 } 2912 } 2913 return (-1); 2914 } 2915 2916 2917 2923 public static boolean checkFileTransferFolder(String path) { 2924 boolean check = false; 2925 File file = new File (path); 2926 if (file.isDirectory()) { 2927 check = true; 2928 } 2929 return (check); 2930 } 2931 2932 2933 2939 2940 public static String getSelectOrderSectionResults(String selected) { 2941 HashMap hp = new HashMap (); 2942 hp.put("10", "10"); 2943 hp.put("25", "25"); 2944 hp.put("50", "50"); 2945 hp.put("75", "75"); 2946 return (createSelect("results", hp, selected)); 2947 } 2948 2949 2950 2954 2964 public static String getSelectTime(String name, int hour, int minute, int second, String amPm) { 2965 StringBuffer results = new StringBuffer (); 2966 HashMap hp = new HashMap (); 2967 2968 for (int i = 1; i <= 12; i++) { 2970 String min = String.valueOf(i); 2971 if (min.length() == 1) { 2972 min = "0" + min; 2973 } 2974 hp.put(min, min); 2975 } 2976 results.append(createSelect(name + "Hour", hp, String.valueOf(hour))); 2977 hp.clear(); 2978 2979 for (int i = 1; i <= 60; i++) { 2981 String min = String.valueOf(i); 2982 if (min.length() == 1) { 2983 min = "0" + min; 2984 } 2985 hp.put(min, min); 2986 } 2987 results.append(createSelect(name + "Minute", hp, String.valueOf(minute))); 2988 hp.clear(); 2989 2990 for (int i = 1; i <= 60; i++) { 2992 String min = String.valueOf(i); 2993 if (min.length() == 1) { 2994 min = "0" + min; 2995 } 2996 hp.put(min, min); 2997 } 2998 results.append(createSelect(name + "Second", hp, String.valueOf(second))); 2999 hp.clear(); 3000 3001 hp.put("AM", "AM"); 3003 hp.put("PM", "PM"); 3004 results.append(createSelect(name + "AmPm", hp, (String ) amPm)); 3005 hp.clear(); 3006 3007 return (results.toString()); 3008 } 3009 3010 3011 3012 3021 public static List getSelectMappingsMultiplePublicationsArrayList(DataStore db, String label, HttpSession session) { 3022 3023 CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user"); 3024 HashMap userPubNamePubIDHash = new HashMap (); 3025 userPubNamePubIDHash.putAll(user.userPubNamePubIDHash); 3026 3027 String wkPub = user.workingPubName; 3028 List al = new ArrayList (); 3029 HashMap tempLabel = new HashMap (); 3031 tempLabel.put(label, ""); 3032 al.add(tempLabel); 3033 3034 userPubNamePubIDHash.remove(wkPub); 3036 HashMap wkFillReq = new HashMap (); 3037 wkFillReq.put("PUBNAME", wkPub); 3038 wkFillReq.put("currentUserID", (String ) user.userInfoHash.get("USERID")); 3039 String wkTag = CofaxToolsDbUtils.fillTag(db, "getSectionDescAndMapCodeFromSectionsByPubName"); 3041 HashMap wkHt = CofaxToolsDbUtils.getValueValuePackageHash(db, wkFillReq, wkTag, "SECTIONDESC", "MAPPINGCODE"); 3042 SortedMap wkSortedMap = new TreeMap (); 3043 wkSortedMap.putAll(wkHt); 3044 Set wkset = wkSortedMap.keySet(); 3045 Iterator wkIterator = wkset.iterator(); 3046 while (wkIterator.hasNext()) { 3047 String wkName = (String ) wkIterator.next(); 3048 String wkID = (String ) wkSortedMap.get(wkName); 3049 HashMap wkTemp = new HashMap (); 3050 wkTemp.put(wkName, wkID); 3051 al.add(wkTemp); 3052 } 3053 3054 Iterator en = userPubNamePubIDHash.keySet().iterator(); 3056 HashMap htSelect = new HashMap (); 3057 while (en.hasNext()) { 3058 String pubName = (String ) en.next(); 3059 HashMap fillReq = new HashMap (); 3060 fillReq.put("PUBNAME", pubName); 3061 fillReq.put("currentUserID", (String ) user.userInfoHash.get("USERID")); 3062 String tag = CofaxToolsDbUtils.fillTag(db, "getSectionDescAndMapCodeFromSectionsByPubName"); 3063 HashMap ht = CofaxToolsDbUtils.getValueValuePackageHash(db, fillReq, tag, "SECTIONDESC", "MAPPINGCODE"); 3064 Iterator enSel = ht.keySet().iterator(); 3065 while (enSel.hasNext()) { 3066 String section = (String ) enSel.next(); 3067 String sectionDesc = (String ) ht.get(section); 3068 htSelect.put(pubName + ": " + section, sectionDesc); 3069 } 3070 } 3071 SortedMap sortedMap = new TreeMap (); 3072 sortedMap.putAll(htSelect); 3073 Set set = sortedMap.keySet(); 3074 Iterator iterator = set.iterator(); 3075 while (iterator.hasNext()) { 3076 String name = (String ) iterator.next(); 3077 String ID = (String ) sortedMap.get(name); 3078 HashMap temp = new HashMap (); 3079 temp.put(name, ID); 3080 al.add(temp); 3081 } 3082 return (al); 3083 } 3084 3085 3086 3093 public static String createSelect(String selectName, ArrayList nameValue) { 3094 String sb = createSelect(selectName, nameValue, ""); 3095 return (sb); 3096 } 3097 3098 3099 3108 public static String createSelect(String selectName, ArrayList nameValue, String selected) { 3109 String sb = createSelect(selectName, nameValue, selected, ""); 3110 return (sb); 3111 } 3112 3113 3114 3125 public static String createSelect(String selectName, ArrayList nameValue, String selected, String javaScript) { 3126 3127 StringBuffer s = new StringBuffer (); 3128 try { 3130 Iterator iterator = nameValue.iterator(); 3131 s.append("\n\n<SELECT NAME =\"" + selectName + "\" " + javaScript + ">\n"); 3132 String i = ""; 3133 3134 while (iterator.hasNext()) { 3135 HashMap h = (HashMap ) iterator.next(); 3136 Iterator it = h.keySet().iterator(); 3137 while (it.hasNext()) { 3138 String key = (String ) it.next(); 3139 String value = (String ) h.get(key); 3140 if (value == selected || value.equals(selected)) { 3141 i = " selected"; 3142 } else { 3143 i = ""; 3144 } 3145 s.append("<OPTION VALUE=\"" + value + "\"" + i + ">" + key + "\n"); 3146 } 3147 } 3148 s.append("\n</SELECT>\n\n"); 3149 } catch (ArrayIndexOutOfBoundsException e) { 3150 log("CofaxToolsUtil createSelect ERROR: " + e.toString()); 3151 } finally { 3152 3153 } 3154 return (s.toString()); 3155 } 3156 3157 3158 3162 3169 public static String createShowPreOrderSelect(String label, String selected) { 3170 HashMap ht = new HashMap (); 3171 ht.put("00", "00"); 3172 ht.put("05", "05"); 3173 ht.put("10", "10"); 3174 ht.put("15", "15"); 3175 ht.put("20", "20"); 3176 ht.put("25", "25"); 3177 String select = createSelect(label, ht, selected); 3178 return (select); 3179 } 3180 3181 3182 3187 3188 public static String getSelectSections(DataStore db, String userID, String pubName, String sectionMappingCode) { 3189 StringBuffer selectSections = new StringBuffer (""); 3190 try { 3191 if ((userID!=null) && !(userID.equals(""))) { 3192 selectSections.append("<SELECT NAME='sectionMappingCode'>"); 3193 selectSections.append("<OPTION VALUE='' selected>** " + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_selectmappingsection") + " **"); 3194 String tag = "select S.*, manager from tblsections AS S LEFT JOIN tblpermusersection AS PUS "; 3195 tag = tag + "on (S.mappingCode=PUS.mappingCode and PUS.userID=" + userID + ") "; 3196 tag = tag + "where S.pubName='" + pubName + "' and S.subMapOf=0 "; 3197 tag = tag + "order by rank "; 3198 HashMap htTmp = new HashMap (); 3199 List lstSections = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3200 if (lstSections.size() <= 0) { 3201 selectSections.append("<OPTION value=''>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_nosection")); 3202 } 3203 while (lstSections.size() > 0) { 3204 StringBuffer sbTemp = new StringBuffer (); 3205 HashMap hashInfo = (HashMap ) lstSections.get(0); 3206 String mappingCode = (String ) hashInfo.get("MAPPINGCODE"); 3207 String sectionDesc = (String ) hashInfo.get("SECTIONDESC"); 3208 String manager = (String ) hashInfo.get("MANAGER"); 3209 if (manager==null) manager="0"; 3210 if (manager.equals("1")) { 3211 if (mappingCode.equals(sectionMappingCode)) { 3212 selectSections.append("<OPTION SELECTED VALUE='" + mappingCode + "'>" + sectionDesc + "\n"); 3213 } else { 3214 selectSections.append("<OPTION VALUE='" + mappingCode + "'>" + sectionDesc + "\n"); 3215 } 3216 } 3217 String blanks = "+--"; 3218 selectSections.append(getSelectSubSections(db, userID, pubName, mappingCode, blanks, sectionMappingCode)); 3219 lstSections.remove(0); 3220 } 3221 selectSections.append("</SECTION>"); 3222 } 3223 } catch (Exception e) {return "";} 3224 return (selectSections.toString()); 3225 } 3226 3227 public static String getSelectSubSections(DataStore db, String userID, String pubName, String sectionMappingCode, String blanks, String selected) { 3228 StringBuffer selectSubSections = new StringBuffer (""); 3229 try { 3230 String tag = CofaxToolsDbUtils.fillTag(db, "getListSubSection"); 3231 HashMap htTmp = new HashMap (); 3232 htTmp.put("userID",userID); 3233 htTmp.put("sectionMappingCode",sectionMappingCode); 3234 htTmp.put("pubName",pubName); 3235 List lstUsers = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3236 List lstSections2 = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3237 while (lstSections2.size() > 0) { 3238 StringBuffer sbTemp2 = new StringBuffer (); 3239 HashMap hashInfo2 = (HashMap ) lstSections2.get(0); 3240 String mappingCode2 = (String ) hashInfo2.get("MAPPINGCODE"); 3241 String sectionDesc2 = (String ) hashInfo2.get("SECTIONDESC"); 3242 String manager2 = (String ) hashInfo2.get("MANAGER"); 3243 if (manager2==null) manager2="0"; 3244 if (manager2.equals("1")) { 3245 if (mappingCode2.equals(selected)) { 3246 selectSubSections.append("<OPTION SELECTED VALUE='" + mappingCode2 + "'>" + blanks + sectionDesc2 + "\n"); 3247 } else { 3248 selectSubSections.append("<OPTION VALUE='" + mappingCode2 + "'>" + blanks + sectionDesc2 + "\n"); 3249 } 3250 } 3251 String tag3 = CofaxToolsDbUtils.fillTag(db, "getListSubSection"); 3253 HashMap htTmp3 = new HashMap (); 3254 htTmp3.put("userID",userID); 3255 htTmp3.put("sectionMappingCode",mappingCode2); 3256 htTmp3.put("pubName",pubName); 3257 List lstSections3 = CofaxToolsDbUtils.getPackageData(db, htTmp3, tag3); 3258 if (lstSections3.size() > 0) { 3259 String blanks2 = " " + blanks; 3260 selectSubSections.append(getSelectSubSections(db, userID, pubName, mappingCode2, blanks2, selected)); 3261 } 3262 lstSections2.remove(0); 3263 } 3264 } catch (Exception e) {return "";} 3265 return (selectSubSections.toString()); 3266 } 3267 3268 3269 3270 3274 3275 public static String getsectionManagerTable(DataStore db, int manager, String sectionMappingCode, boolean isAdministrator, String limit) { 3276 StringBuffer sectionManagerTable = new StringBuffer (""); 3277 try { 3278 if ((sectionMappingCode!=null) && !(sectionMappingCode.equals(""))) { 3279 String tag = CofaxToolsDbUtils.fillTag(db, "getListManagerSection"); 3280 HashMap htTmp = new HashMap (); 3281 htTmp.put("sectionMappingCode",sectionMappingCode); 3282 htTmp.put("manager",manager + ""); 3283 List lstUsers = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3284 if (lstUsers.size() <= 0) { 3285 if (manager==1) sectionManagerTable.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_nomanager") + "<br>\n"); 3286 else sectionManagerTable.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_noredactor") + "<br>\n"); 3287 } 3288 int i=0; 3289 int numrows = CofaxToolsServlet.numrows; 3290 if (limit.equals("no")) numrows=0; 3291 while ((lstUsers.size() > 0) && ((i<numrows)||(numrows==0))) { 3292 StringBuffer sbTemp = new StringBuffer (); 3293 HashMap hashInfo = (HashMap ) lstUsers.get(0); 3294 String userID = (String ) hashInfo.get("USERID"); 3295 String userName = (String ) hashInfo.get("USERNAME"); 3296 if (isAdministrator) { 3297 sectionManagerTable.append("> <a HREF='?mode=admin_get_user_info&selectUser=" + userID + "'>" + userName + "</a>"); 3298 sectionManagerTable.append(" (<a HREF='?mode=section_add_user&USERS=" + userID + "§ionMappingCode=" + sectionMappingCode + "&DIRECTOR=" + manager + "&DELETE=1' alt='Delete'>x</a>)<br>\n"); 3299 } else { 3300 sectionManagerTable.append("> " + userName + "<br>\n"); 3301 } 3302 lstUsers.remove(0); 3303 i++; 3304 } 3305 if ((i>=numrows) && (numrows==CofaxToolsServlet.numrows)) { 3306 sectionManagerTable.append(">> <a HREF='?mode=section_get_section§ionMappingCode=" + sectionMappingCode + "&ht=section_edit_section&limitUser=no'>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createsection_moreusers")+"</a>"); 3307 } 3308 } 3309 } catch (Exception e) {return("");} 3310 3311 return (sectionManagerTable.toString()); 3312 } 3313 3314 3315 3319 3320 public static String getSectionOtherUsersTable(DataStore db, int manager, String sectionMappingCode, String limit) { 3321 StringBuffer sectionOtherUsersTable = new StringBuffer (""); 3322 try { 3323 if ((sectionMappingCode!=null) && !(sectionMappingCode.equals(""))) { 3324 String tag = CofaxToolsDbUtils.fillTag(db, "getOtherUsersOnSection"); 3325 HashMap htTmp = new HashMap (); 3326 htTmp.put("sectionMappingCode",sectionMappingCode); 3327 htTmp.put("manager",manager + ""); 3328 List lstUsers = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3329 if (lstUsers.size() <= 0) { 3330 sectionOtherUsersTable.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_nootheruser") + "<br>\n"); 3331 } else { 3332 int i=0; 3333 int numrows = CofaxToolsServlet.numrows; 3334 if (limit.equals("no")) numrows=0; 3335 sectionOtherUsersTable.append("<SELECT NAME=USERS>\n"); 3336 while ((lstUsers.size() > 0) && ((i<numrows)||(numrows==0))) { 3337 StringBuffer sbTemp = new StringBuffer (); 3338 HashMap hashInfo = (HashMap ) lstUsers.get(0); 3339 String userID = (String ) hashInfo.get("USERID"); 3340 String userName = (String ) hashInfo.get("USERNAME"); 3341 String director = (String ) hashInfo.get("MANAGER"); 3342 if ((director==null) || ((director.equals("")))) { 3343 sectionOtherUsersTable.append("<OPTION VALUE='" + userID + "'>" + userName + "\n"); 3344 i++; 3345 } 3346 lstUsers.remove(0); 3347 } 3348 sectionOtherUsersTable.append("</SELECT>\n"); 3349 if ((i>=numrows) && (numrows==CofaxToolsServlet.numrows)) { 3350 sectionOtherUsersTable.append(" (<a alt='" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"createsection_moreusers") + "' HREF='?mode=section_get_section§ionMappingCode=" + sectionMappingCode + "&ht=section_edit_section&limitUser=no'>+</a>)"); 3351 } 3352 } 3353 } 3354 } catch (Exception e) { 3355 return(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_anerroroccured")); 3356 } 3357 return (sectionOtherUsersTable.toString()); 3358 } 3359 3360 3361 3362 3363 3364 3368 3369 public static String getMyLastArticles(DataStore db, String pubname, String userID) { 3370 StringBuffer listMyLastArticles = new StringBuffer (""); 3371 try { 3372 if ((userID!=null) && !(userID.equals(""))) { 3373 String tag = CofaxToolsDbUtils.fillTag(db, "getMyLastArticles"); 3374 HashMap htTmp = new HashMap (); 3375 htTmp.put("pubname",pubname); 3376 htTmp.put("userID",userID); 3377 List lstUsers = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3378 if (lstUsers.size() <= 0) { 3379 listMyLastArticles.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"myaccount_noarticle") + "<br>\n"); 3380 } 3381 listMyLastArticles.append("<table class='mylastarticles'>"); while (lstUsers.size() > 0) { 3383 StringBuffer sbTemp = new StringBuffer (); 3384 HashMap hashInfo = (HashMap ) lstUsers.get(0); 3385 String itemID = (String ) hashInfo.get("ITEMID"); 3386 String headline = (String ) hashInfo.get("HEADLINE"); 3387 String updateDate = (String ) hashInfo.get("UPDATEDATE"); 3388 String validated = (String ) hashInfo.get("WORKFLOW_STATE"); 3389 String state=""; 3390 3391 3392 listMyLastArticles.append("<tr>"); 3393 3394 if (validated.equals("0")) state="<span class='draft'>" + getI18NMessage(CofaxToolsServlet.lcl,"createarticle_draft") + "</span>"; 3396 else if (validated.equals("1")) state="<span class='in_validation'>" + getI18NMessage(CofaxToolsServlet.lcl,"createarticle_inprocessofvalidation") + "</span>"; 3397 else if (validated.equals("2")) state="<span class='published'>" + getI18NMessage(CofaxToolsServlet.lcl,"createarticle_published") + "</span>"; 3398 listMyLastArticles.append("<td><a HREF='?mode=article_edit_article_by_itemID&ITEMID=" + itemID + "&hl=article_create_article'>" + headline + "</a></td><td>" + updateDate + "</td><td>" + state + "</td>"); 3399 lstUsers.remove(0); 3400 sbTemp.append("</tr>"); 3401 } 3402 listMyLastArticles.append("</table>"); 3403 } 3404 } catch (Exception e) {listMyLastArticles.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_anerroroccured"));} 3405 return (listMyLastArticles.toString()); 3406 } 3407 3408 3412 3413 public static String getMySavedSearches(DataStore db, String userID) { 3414 StringBuffer listMySavedSearches = new StringBuffer (""); 3415 try { 3416 if ((userID!=null) && !(userID.equals(""))) { 3417 String tag = "select * from tblpermsavedsearches "; 3418 tag = tag + "where userID=" + userID + " "; 3419 tag = tag + "order by searchName"; 3420 HashMap htTmp = new HashMap (); 3421 List lstUsers = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3422 if (lstUsers.size() <= 0) { 3423 listMySavedSearches.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"no_recorded_searches")); 3424 } 3425 while (lstUsers.size() > 0) { 3426 StringBuffer sbTemp = new StringBuffer (); 3427 HashMap hashInfo = (HashMap ) lstUsers.get(0); 3428 String search = (String ) hashInfo.get("SEARCH"); 3429 String searchName = (String ) hashInfo.get("SEARCHNAME"); 3430 listMySavedSearches.append("> "); 3431 listMySavedSearches.append("<a alt='delete' HREF='?mode=article_search_delete&SEARCHNAME=" + searchName + "&USERID="+ userID + "'>(x)</a> "); 3432 listMySavedSearches.append("<a HREF='" + search + "'>" + searchName + "</a> "); 3433 listMySavedSearches.append("<br>"); 3434 lstUsers.remove(0); 3435 } 3436 } 3437 } catch (Exception e) {listMySavedSearches.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_anerroroccured"));} 3438 return (listMySavedSearches.toString()); 3439 } 3440 3441 3442 3446 3447 public static String getArticlesToPublish(DataStore db, String pubName, String userID) { 3448 StringBuffer listArticlesToPublish = new StringBuffer (""); 3449 try { 3450 if ((userID!=null) && !(userID.equals(""))) { 3451 String tag = CofaxToolsDbUtils.fillTag(db, "getArticlesToPublish"); 3452 HashMap htTmp = new HashMap (); 3453 htTmp.put("pubName",pubName); 3454 htTmp.put("userID",userID); 3455 List lstUsers = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3456 3457 if (lstUsers.size() <= 0) { 3458 listArticlesToPublish.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"myaccount_noarticle") + "<br>\n"); 3459 } 3460 while (lstUsers.size() > 0) { 3461 StringBuffer sbTemp = new StringBuffer (); 3462 HashMap hashInfo = (HashMap ) lstUsers.get(0); 3463 String headline = (String ) hashInfo.get("HEADLINE"); 3464 String filename = (String ) hashInfo.get("FILENAME"); 3465 String itemID = (String ) hashInfo.get("ITEMID"); 3466 listArticlesToPublish.append("> "); 3467 listArticlesToPublish.append("<a HREF='?mode=article_edit_article_by_itemID&ITEMID=" + itemID + "&hl=article_create_article'>" + filename + "</a> <i><font color='#C1C307'>" + getI18NMessage(CofaxToolsServlet.lcl,"createarticle_inprocessofvalidation") + ".</i></font>"); 3468 listArticlesToPublish.append("<br>"); 3469 lstUsers.remove(0); 3470 } 3471 } 3472 } catch (Exception e) {listArticlesToPublish.append(CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_anerroroccured"));} 3473 return (listArticlesToPublish.toString()); 3474 } 3475 3476 3477 3478 3479 3485 public static String getRightSectionCheckboxTable(DataStore db, String userID, String pubName, String limit) { 3486 StringBuffer checkboxTable = new StringBuffer (""); 3487 try 3488 { 3489 if ((userID!=null) && !(userID.equals(""))) { 3490 checkboxTable.append("<TABLE BORDER=0>"); 3491 checkboxTable.append("<TR><TD><i>dir.</i></TD><TD><i>acc.</i></TD></TR>"); 3492 String tag = "select S.mappingCode, PUS.Manager, S.sectionDesc from tblsections AS S LEFT JOIN tblpermusersection AS PUS "; 3493 tag = tag + "on S.mappingCode=PUS.mappingCode and PUS.userID=" + userID + " "; 3494 tag = tag + "where S.pubName='" + pubName + "' and S.subMapOf=0 order by rank"; 3495 HashMap htTmp = new HashMap (); 3496 List lstSections = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3497 if (lstSections.size() <= 0) { 3498 checkboxTable.append("<TR><TD>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_nosectionallowed") + "</TD></TR>"); 3499 } 3500 int checkBoxTableRightLength = 0; 3501 while (lstSections.size() > 0) { 3502 HashMap hashInfo = (HashMap ) lstSections.get(0); 3503 String mappingCode = (String ) hashInfo.get("MAPPINGCODE"); 3504 String sectionDesc = (String ) hashInfo.get("SECTIONDESC"); 3505 String userPerm = (String ) hashInfo.get("MANAGER"); 3506 3507 String managerChecked = ""; 3508 String redactorChecked = ""; 3509 if ("0".equals(userPerm)) 3510 redactorChecked = "checked"; 3511 else if ("1".equals(userPerm)) { 3512 redactorChecked = "checked"; 3513 managerChecked = "checked"; 3514 } 3515 3516 checkboxTable.append("<TR>"); 3517 checkboxTable.append("<TD><INPUT TYPE=CHECKBOX " + managerChecked + " NAME='d" + checkBoxTableRightLength + "' VALUE='1'></TD>"); 3518 checkboxTable.append("<TD><INPUT TYPE=CHECKBOX " + redactorChecked + " NAME='s" + checkBoxTableRightLength + "' VALUE='" + mappingCode + "'>"); 3519 checkboxTable.append( 3520 "<INPUT TYPE=HIDDEN NAME='PARAM" + checkBoxTableRightLength + "' VALUE='" + mappingCode + "'></TD><TD nowrap><b>" + sectionDesc + "</b></TD></TR>\n"); 3521 lstSections.remove(0); 3522 checkBoxTableRightLength++; 3523 if (limit.equals("no")) { 3524 String blanks = " "; 3525 HashMap ht3 = getRightSubSectionCheckboxTable(db, userID, pubName, mappingCode, blanks, checkBoxTableRightLength); 3526 checkboxTable.append(ht3.get("tabSubSection")); 3527 checkBoxTableRightLength = Integer.parseInt((String ) ht3.get("checkBoxTableRightLength")); 3528 } 3529 } 3530 checkboxTable.append("</TABLE>\n"); 3531 checkboxTable.append("<INPUT TYPE=HIDDEN NAME='checkBoxTableRightLength' VALUE='" + checkBoxTableRightLength + "'>\n"); 3532 if (!(limit.equals("no"))) { 3533 checkboxTable.append("> <a HREF='?mode=admin_get_user_info&selectUser=" + userID + "&limit=no'>" + CofaxToolsUtil.getI18NMessage(CofaxToolsServlet.lcl,"tools_allsections") + "</a>"); 3534 } 3535 } 3536 } catch (Exception e) {CofaxToolsUtil.log(e.toString()); return "";} 3537 return (checkboxTable.toString()); 3538 } 3539 3540 public static HashMap getRightSubSectionCheckboxTable(DataStore db, String userID, String pubName, String sectionMappingCode, String blanks, int checkBoxTableRightLength) { 3541 HashMap returnHt = new HashMap (); 3542 StringBuffer tabSubSections = new StringBuffer (""); 3543 int sectionCnt = 0; 3544 try { 3545 String tag2 = "select S.mappingCode, PUS.Manager, S.sectionDesc from tblsections AS S LEFT JOIN tblpermusersection AS PUS "; 3546 tag2 = tag2 + "on S.mappingCode=PUS.mappingCode and PUS.userID=" + userID + " "; 3547 tag2 = tag2 + "where S.submapOf='" + sectionMappingCode + "' order by rank"; 3548 HashMap htTmp2 = new HashMap (); 3549 List lstSections2 = CofaxToolsDbUtils.getPackageData(db, htTmp2, tag2); 3550 while (lstSections2.size() > 0) { 3551 HashMap hashInfo2 = (HashMap ) lstSections2.get(0); 3552 String mappingCode2 = (String ) hashInfo2.get("MAPPINGCODE"); 3553 String sectionDesc2 = (String ) hashInfo2.get("SECTIONDESC"); 3554 String userPerm = (String ) hashInfo2.get("MANAGER"); 3555 3556 String managerChecked = ""; 3557 String redactorChecked = ""; 3558 if ("0".equals(userPerm)) 3559 redactorChecked = "checked"; 3560 else if ("1".equals(userPerm)) { 3561 redactorChecked = "checked"; 3562 managerChecked = "checked"; 3563 } 3564 3565 tabSubSections.append("<TR>"); 3566 tabSubSections.append("<TD><INPUT TYPE=CHECKBOX " + managerChecked + " NAME='d" + checkBoxTableRightLength + "' VALUE='1'></TD>"); 3567 tabSubSections.append("<TD><INPUT TYPE=CHECKBOX " + redactorChecked + " NAME='s" + checkBoxTableRightLength + "' VALUE='" + mappingCode2 + "'>"); 3568 tabSubSections.append("<INPUT TYPE=HIDDEN NAME='PARAM" + checkBoxTableRightLength + "' VALUE='" + mappingCode2 + "'></TD><TD nowrap>" + blanks + sectionDesc2 + "</TD></TR>\n"); 3569 3570 checkBoxTableRightLength++; 3571 3572 String tag3 = CofaxToolsDbUtils.fillTag(db, "getTabSubSections"); 3574 HashMap htTmp3 = new HashMap (); 3575 htTmp3.put("pubName",pubName); 3576 htTmp3.put("userID",userID); 3577 htTmp3.put("sectionMappingCode",mappingCode2); 3578 List lstSections3 = CofaxToolsDbUtils.getPackageData(db, htTmp3, tag3); 3579 if (lstSections3.size() > 0) { 3580 String blanks2 = blanks + " "; 3581 HashMap ht3 = getRightSubSectionCheckboxTable(db, userID, pubName, mappingCode2, blanks2, checkBoxTableRightLength); 3582 tabSubSections.append(ht3.get("tabSubSection")); 3583 checkBoxTableRightLength=Integer.parseInt((String )ht3.get("checkBoxTableRightLength")); 3584 } 3585 lstSections2.remove(0); 3586 } 3587 3588 } catch (Exception e) {return returnHt;} 3589 returnHt.put("tabSubSection",tabSubSections.toString()); 3590 returnHt.put("checkBoxTableRightLength",checkBoxTableRightLength+""); 3591 return (returnHt); 3592 } 3593 3594 3600 3601 public static String getSecurityCheckboxTable(DataStore db) { 3602 StringBuffer selectComp = new StringBuffer ("\n\n<TABLE BORDER=1>\n"); 3603 selectComp.append("<TD><B>Action</B></TD>"); 3604 String modeHashType = ""; 3605 3606 HashMap preSortHash = new HashMap (); 3607 StringBuffer preSortText = new StringBuffer (); 3608 3609 Vector groupTypeNames = CofaxToolsUtil.getGroupTypeNames(db); 3610 Iterator gtnIter = groupTypeNames.iterator(); 3611 3612 while (gtnIter.hasNext()) { 3613 String groupTypeNamesLabel = (String ) gtnIter.next(); 3614 selectComp.append("<TD><B>" + groupTypeNamesLabel + "</B></TD>\n"); 3615 } 3616 3617 selectComp.append("<TR>\n"); 3618 Vector groupTypeIDs = CofaxToolsUtil.getGroupTypeIDs(db); 3619 3620 HashMap htChecks = new HashMap (); 3621 List modes = (ArrayList ) CofaxToolsUtil.getModes(db); 3622 3623 Iterator modesIter = modes.iterator(); 3624 while (modesIter.hasNext()) { 3625 Object modesO = modesIter.next(); 3626 HashMap modeType = new HashMap (); 3627 modeType = (HashMap ) modesO; 3628 Iterator en = modeType.keySet().iterator(); 3629 String modeE = (String ) modeType.get("MODES"); 3630 if (!htChecks.containsKey(modeE)) { 3631 htChecks.put(modeE, ""); 3632 } 3633 } 3634 3635 Iterator enu = htChecks.keySet().iterator(); 3636 while (enu.hasNext()) { 3637 String modeName = (String ) enu.next(); 3638 String tempModeName = modeName; 3639 tempModeName = tempModeName.replace('_', ' '); 3640 preSortText.append("<TD><B>" + tempModeName + "</TD>"); 3641 Iterator groupTypeIDsIter = groupTypeIDs.iterator(); 3642 while (groupTypeIDsIter.hasNext()) { 3643 String modeTypeS = (String ) groupTypeIDsIter.next(); 3644 boolean checked = false; 3645 Iterator modesItera = modes.iterator(); 3646 while (modesItera.hasNext()) { 3647 Object o = modesItera.next(); 3648 HashMap modeTypeH = new HashMap (); 3649 modeTypeH = (HashMap ) o; 3650 String modeHashName = (String ) modeTypeH.get("MODES"); 3651 modeHashType = (String ) modeTypeH.get("TYPE"); 3652 if (modeHashName.equals(modeName) && modeHashType.equals(modeTypeS)) { 3653 preSortText.append("<TD><INPUT TYPE=CHECKBOX NAME=" + modeName + "." + modeTypeS + " CHECKED></TD>\n"); 3654 checked = true; 3655 } 3656 } 3657 if (checked == false) { 3658 preSortText.append("<TD><INPUT TYPE=CHECKBOX NAME=" + modeName + "." + modeTypeS + "></TD>\n"); 3659 } 3660 } 3661 preSortText.append("<TR>\n"); 3662 preSortHash.put(modeName, preSortText.toString()); 3663 preSortText.setLength(0); 3664 } 3665 3666 SortedMap sortedMap = new TreeMap (); 3667 sortedMap.putAll(preSortHash); 3668 Set set = sortedMap.keySet(); 3669 Iterator iterator = set.iterator(); 3670 StringBuffer s = new StringBuffer (); 3671 while (iterator.hasNext()) { 3672 s.append(sortedMap.get(iterator.next())); 3673 } 3674 selectComp.append(s); 3675 selectComp.append("</TABLE>\n\n"); 3676 return (selectComp.toString()); 3677 } 3678 3679 3680 3684 public static String addUserSection(DataStore db, HttpServletRequest req){ 3685 HashMap ht = splitPostQuery(req); 3686 3687 String director = req.getParameter("DIRECTOR"); 3688 String userID = req.getParameter("USERS"); 3689 String mappingCode = req.getParameter("sectionMappingCode"); 3690 String delete = req.getParameter("DELETE"); 3691 ht.put("MAPPINGCODE",mappingCode); 3692 3693 if ( ((userID!=null) && (!(userID.equals("")))) && 3694 ((mappingCode!=null) && (!(mappingCode.equals("")))) && 3695 ((director!=null) && (!(director.equals("")))) ) { 3696 3697 if ( ((delete!=null) && (!(delete.equals(""))))) { 3698 StringBuffer v_del = new StringBuffer (); 3700 if (director.equals("0")) v_del.append("delete from tblpermusersection WHERE userID = " + userID + " and mappingCode=" + mappingCode + " "); 3701 if (director.equals("1")) v_del.append("update tblpermusersection set manager=0 WHERE userID = " + userID + " and mappingCode=" + mappingCode + " "); 3702 List del = CofaxToolsDbUtils.getPackageData(db, ht, v_del.toString()); 3703 return("User " + userID + " deleted from section " + mappingCode + "."); 3704 } else { 3705 Vector u_users = null; 3706 StringBuffer v = new StringBuffer (); 3707 v.append("SELECT * FROM tblpermusersection WHERE userID = " + userID + " and mappingCode=" + mappingCode + " "); 3708 u_users = CofaxToolsDbUtils.getPackageVector(db,ht,v.toString()); 3709 if (u_users.size() > 0 && u_users != null) { 3710 StringBuffer v_ins = new StringBuffer (); 3711 v_ins.append("UPDATE tblpermusersection set manager=1 WHERE userID = " + userID + " and mappingCode=" + mappingCode + " "); 3712 List del2 = CofaxToolsDbUtils.getPackageData(db, ht, v_ins.toString()); 3713 } else 3714 { 3715 StringBuffer v_ins = new StringBuffer (); 3716 v_ins.append("INSERT INTO tblpermusersection (mappingCode, userID, manager) Values(" + mappingCode + "," + userID + "," + director + ")"); 3717 List del2 = CofaxToolsDbUtils.getPackageData(db, ht, v_ins.toString()); 3718 } 3719 return("User " + userID + " added to section " + mappingCode + "."); 3720 } 3721 } 3722 else 3723 { 3724 return("You must select a user"); 3725 } 3726 } 3727 3728 3729 3734 3735 public static String getTabSections(DataStore db, String userID, String pubName, int pubCnt) { 3736 StringBuffer tabSections = new StringBuffer (""); 3737 int sectionCnt = 0; 3738 try { 3739 if ((userID!=null) && !(userID.equals(""))) { 3740 3741 String tag = CofaxToolsDbUtils.fillTag(db, "getTabSections"); 3742 HashMap htTmp = new HashMap (); 3743 htTmp.put("pubName",pubName); 3744 htTmp.put("userID",userID); 3745 List lstSections = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3746 while (lstSections.size() > 0) { 3747 StringBuffer sbTemp = new StringBuffer (); 3748 HashMap hashInfo = (HashMap ) lstSections.get(0); 3749 String mappingCode = (String ) hashInfo.get("MAPPINGCODE"); 3750 String sectionDesc = (String ) hashInfo.get("SECTIONDESC"); 3751 String manager = (String ) hashInfo.get("MANAGER"); 3752 sectionCnt ++; 3753 3754 tabSections.append("<li class='nav_section'><a HREF='"+ CofaxToolsServlet.aliasPath + "/tools/?mode=section_get_section§ionMappingCode=" + mappingCode + "&ht=section_edit_section'>" + sectionDesc + "</a>"); 3756 tabSections.append("</li>\n"); 3757 3758 String blanks = pubCnt + "." + sectionCnt; 3759 tabSections.append(getTabSubSections(db, userID, pubName, mappingCode, blanks)); 3760 lstSections.remove(0); 3762 } 3763 } 3764 } catch (Exception e) {return "";} 3765 return (tabSections.toString()); 3766 } 3767 3768 public static String getTabSubSections(DataStore db, String userID, String pubName, String sectionMappingCode, String blanks) { 3769 StringBuffer tabSubSections = new StringBuffer (""); 3770 int sectionCnt = 0; 3771 try { 3772 String tag2 = CofaxToolsDbUtils.fillTag(db, "getTabSubSections"); 3773 HashMap htTmp2 = new HashMap (); 3774 htTmp2.put("pubName",pubName); 3775 htTmp2.put("userID",userID); 3776 htTmp2.put("sectionMappingCode",sectionMappingCode); 3777 List lstSections2 = CofaxToolsDbUtils.getPackageData(db, htTmp2, tag2); 3778 if (lstSections2.size()>0) 3780 { 3781 tabSubSections.append("<ul>\n"); 3782 while (lstSections2.size() > 0) { 3783 StringBuffer sbTemp2 = new StringBuffer (); 3784 HashMap hashInfo2 = (HashMap ) lstSections2.get(0); 3785 String mappingCode2 = (String ) hashInfo2.get("MAPPINGCODE"); 3786 String sectionDesc2 = (String ) hashInfo2.get("SECTIONDESC"); 3787 String manager2 = (String ) hashInfo2.get("MANAGER"); 3788 sectionCnt ++; 3789 3790 tabSubSections.append("<li class='nav_section'>"); 3791 tabSubSections.append("<a HREF='"+ CofaxToolsServlet.aliasPath + "/tools/?mode=section_get_section§ionMappingCode=" + mappingCode2 + "&ht=section_edit_section\'>"+sectionDesc2+"</a>"); 3792 tabSubSections.append("</li>\n"); 3793 3794 3795 String tag3 = CofaxToolsDbUtils.fillTag(db, "getTabSubSections"); 3797 HashMap htTmp3 = new HashMap (); 3798 htTmp3.put("pubName",pubName); 3799 htTmp3.put("userID",userID); 3800 htTmp3.put("sectionMappingCode",mappingCode2); 3801 List lstSections3 = CofaxToolsDbUtils.getPackageData(db, htTmp3, tag3); 3802 if (lstSections3.size() > 0) { 3803 String blanks2 = blanks + "." + sectionCnt; 3804 tabSubSections.append(getTabSubSections(db, userID, pubName, mappingCode2, blanks2)); 3805 } else 3806 { 3807 tabSubSections.append(getTabArticles(db, userID, mappingCode2, blanks + "." + sectionCnt, 0)); 3808 } 3809 lstSections2.remove(0); 3810 } 3811 tabSubSections.append("</ul>\n"); 3812 } 3813 tabSubSections.append(getTabArticles(db, userID, sectionMappingCode, blanks, sectionCnt)); 3814 3815 3816 } catch (Exception e) {return "";} 3817 return (tabSubSections.toString()); 3818 } 3819 3820 public static String getTabPublications(DataStore db, String userID, String currentPubID) { 3821 StringBuffer tabPublications = new StringBuffer (""); 3822 int pubCnt = 0; 3823 try { 3824 if ((userID!=null) && !(userID.equals(""))) { 3825 String tag = CofaxToolsDbUtils.fillTag(db, "getTabPublications"); 3826 HashMap htTmp = new HashMap (); 3827 htTmp.put("userID",userID); 3828 htTmp.put("currentPubID",currentPubID); 3829 List lstSections = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3830 while (lstSections.size() > 0) { 3831 StringBuffer sbTemp = new StringBuffer (); 3832 HashMap hashInfo = (HashMap ) lstSections.get(0); 3833 String pubID = (String ) hashInfo.get("PUBID"); 3834 String pubDesc = (String ) hashInfo.get("PUBDESC"); 3835 String pubName = (String ) hashInfo.get("PUBNAME"); 3836 pubCnt ++; 3837 tabPublications.append("<div class='nav_publication_name'>"); 3838 tabPublications.append("<a HREF='"+ CofaxToolsServlet.aliasPath + "/tools/?mode=admin_get_publication_info&PUBLICATION=" + pubID + "&hl=admin'>" + pubDesc + "</a></div>"); 3839 tabPublications.append("<div class='nav_publication'>"); 3840 tabPublications.append(getTabSections(db, userID, pubName, pubCnt)); 3841 tabPublications.append("\n</div>"); 3842 lstSections.remove(0); 3843 } 3844 } 3845 } catch (Exception e) {return "";} 3846 return (tabPublications.toString()); 3847 } 3848 3849 public static String getTabArticles(DataStore db, String userID, String mappingCode, String blanks, int cnt) { 3850 StringBuffer tabArticles = new StringBuffer (""); 3851 int articlesCnt = cnt; 3852 try { 3853 if ((userID!=null) && !(userID.equals(""))) { 3854 String tag = CofaxToolsDbUtils.fillTag(db, "getTabArticles"); 3855 HashMap htTmp = new HashMap (); 3856 htTmp.put("mappingCode",mappingCode); 3857 List lstSections = CofaxToolsDbUtils.getPackageData(db, htTmp, tag); 3858 if (lstSections.size() > 0) 3860 { 3861 tabArticles.append("<ul>"); 3862 while (lstSections.size() > 0) 3863 { 3864 StringBuffer sbTemp = new StringBuffer (); 3865 HashMap hashInfo = (HashMap ) lstSections.get(0); 3866 3867 String itemID = (String ) hashInfo.get("ITEMID"); 3868 String fileName = (String ) hashInfo.get("FILENAME"); 3869 String fullLink = (String ) hashInfo.get("FULLLINK"); 3870 String wstate = (String ) hashInfo.get("WORKFLOW_STATE"); 3871 articlesCnt ++; 3872 tabArticles.append("<li class='article_state_"+wstate+"'><a HREF='"+CofaxToolsServlet.aliasPath + "/tools/?mode=article_edit_article_by_itemID&ITEMID=" + itemID + "&hl=article_create_article'>"+ fileName + "</a></li>\n"); 3874 lstSections.remove(0); 3875 } 3876 tabArticles.append("</ul>"); 3877 } 3878 } 3879 } catch (Exception e) {return "";} 3880 return (tabArticles.toString()); 3881 } 3882 3883 static public String getI18NMessage(Locale lcl, String message) { 3884 ResourceBundle messages; 3885 String returnMessage=""; 3886 try 3887 { 3888 messages = ResourceBundle.getBundle("org.cofax.i18n.cmsTools", lcl); 3889 returnMessage = messages.getString(message); 3890 } catch (Exception e) { 3891 CofaxToolsUtil.log("CofaxToolsUtil : getI18NMessage : error while reading " + message); 3892 } 3893 return (returnMessage); 3894 } 3895} 3896 3897 3898 | Popular Tags |