Changeset 9166
- Timestamp:
- 2005-02-24T13:57:06+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/GathererApplet.java
r9095 r9166 209 209 210 210 211 static public void download_url_zip(String col_name, String dir, GShell source )211 static public void download_url_zip(String col_name, String dir, GShell source, String accept_expr, String reject_expr) 212 212 { 213 213 try { … … 219 219 String dir_encoded = URLEncoder.encode(dir,"UTF-8"); 220 220 String cgi_args = "c=" + col_name_encoded; 221 cgi_args += "&dir=" + dir_encoded ;221 cgi_args += "&dir=" + dir_encoded + "&a=" + accept_expr + "&r=" + reject_expr; 222 222 223 223 URL download_url = new URL(download_cgi); -
trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java
r9095 r9166 216 216 if (formats_changed && Gatherer.c_man.built()) { 217 217 // upload etc/collect.cfg to server to reflect changes 218 Utility.zipup(Gatherer.getCollectDirectoryPath(), collection_name, Utility.CONFIG_FILE, null );218 Utility.zipup(Gatherer.getCollectDirectoryPath(), collection_name, Utility.CONFIG_FILE, null, "", ""); 219 219 GathererApplet.upload_url_zip(collection_name, "etc", null); 220 220 } -
trunk/gli/src/org/greenstone/gatherer/collection/Collection.java
r9136 r9166 67 67 /** <i>true</i> if the currently loaded collection has been saved since the last significant change, <i>false</i> otherwise. */ 68 68 private boolean saved = false; 69 /*<i>true</i> if the currently loaded collection has had files added since its last build */ 70 private boolean filesChanged = true; 71 /*<i>true</i> if the currently loaded collection has had metadata added since its last build */ 72 private boolean metadataChanged = true; 69 73 /** The document around which this collection class is based. */ 70 74 private Document document; … … 175 179 return saved; 176 180 } 177 181 182 /** Determine if this collection has had its collection files changed since the last build. 183 * @return <i>true</i> if they have been saved, <i>false</i> otherwise. 184 */ 185 public boolean getFilesChanged() { 186 return filesChanged; 187 } 188 189 /** Set the flag that marks weather or not the files has been changed since the last build. 190 @param changed if files has been added/removed, as a <strong>boolean</strong> 191 */ 192 public void setFilesChanged(boolean changed) { 193 filesChanged = changed; 194 } 195 196 /** Determine if this collection has had metadata changed since the last build. 197 * @return <i>true</i> if it has been changed, <i>false</i> otherwise. 198 */ 199 public boolean getMetadataChanged() { 200 return metadataChanged; 201 } 202 203 /** Set the flag that marks weather or not the metadata has been changed since the last build. 204 @param changed if metadata has been added/changed/removed, as a <strong>boolean</strong> 205 */ 206 public void setMetadataChanged(boolean changed) { 207 metadataChanged = changed; 208 } 209 178 210 /** Retrieve the title of this collection. 179 211 * @return The title as a <strong>String</strong>. -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r9136 r9166 1064 1064 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1065 1065 Gatherer.refresh(Gatherer.COLLECTION_REBUILT); 1066 DebugStream.println("Status is ok but !installCollection()"); 1066 1067 } 1067 1068 } … … 1491 1492 if(collection != null) { 1492 1493 collection.setSaved(false); 1494 collection.setFilesChanged(true); 1493 1495 } 1494 1496 } … … 1499 1501 if(collection != null) { 1500 1502 collection.setSaved(false); 1503 collection.setFilesChanged(true); 1501 1504 } 1502 1505 } … … 1507 1510 if(collection != null) { 1508 1511 collection.setSaved(false); 1512 collection.setFilesChanged(true); 1513 1509 1514 } 1510 1515 } -
trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java
r9137 r9166 643 643 */ 644 644 public void actionPerformed(ActionEvent event) { 645 build_button.setEnabled( true);645 build_button.setEnabled(false); 646 646 cancel_button.setEnabled(false); 647 647 preview_button.setEnabled(false); 648 648 649 simple_build_button.setEnabled( true);649 simple_build_button.setEnabled(false); 650 650 simple_cancel_button.setEnabled(false); 651 651 simple_preview_button.setEnabled(false); -
trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java
r9109 r9166 186 186 // Add button pressed 187 187 if (esrc == add) { 188 Gatherer.c_man.getCollection().setMetadataChanged(true); 188 189 MetadataElement metadata_element = metadata_value_table.getSelectedMetadataElement(); 189 190 MetadataValueTreeNode metadata_value_tree_node = metadata_element.addMetadataValue(metadata_value_tree.getSelectedValue()); … … 195 196 // Replace button pressed 196 197 else if (esrc == update) { 198 Gatherer.c_man.getCollection().setMetadataChanged(true); 197 199 MetadataElement metadata_element = metadata_value_table.getSelectedMetadataElement(); 198 200 MetadataValueTreeNode metadata_value_tree_node = metadata_element.addMetadataValue(metadata_value_tree.getSelectedValue()); … … 204 206 // Remove button pressed 205 207 else if (esrc == remove) { 208 Gatherer.c_man.getCollection().setMetadataChanged(true); 206 209 (new RemoveMetadataTask()).start(); 207 210 } -
trunk/gli/src/org/greenstone/gatherer/shell/GShell.java
r9148 r9166 241 241 String collect_directory_path = Gatherer.getCollectDirectoryPath(); 242 242 243 // zip up import folder 244 Utility.zipup(collect_directory_path, col_name, "import", this); 245 246 if(hasSignalledStop()) { return; } 247 // upload it to gsdl server 248 GathererApplet.upload_url_zip(col_name, "import", this); 249 243 //Only upload the import directory if the files or metadata has changed. 244 System.err.println("getFilesChanged(): " + Gatherer.c_man.getCollection().getFilesChanged()); 245 System.err.println("getMetadataChanged(): " + Gatherer.c_man.getCollection().getMetadataChanged()); 246 if(Gatherer.c_man.getCollection().getFilesChanged() || Gatherer.c_man.getCollection().getMetadataChanged()) { 247 // zip up import folder 248 Utility.zipup(collect_directory_path, col_name, "import", this, "", ""); 249 System.err.println("collect_directory_path: " + collect_directory_path); 250 System.err.println("col_name: " + col_name); 251 252 if(hasSignalledStop()) { return; } 253 // upload it to gsdl server 254 GathererApplet.upload_url_zip(col_name, "import", this); 255 256 Gatherer.c_man.getCollection().setFilesChanged(false); 257 Gatherer.c_man.getCollection().setMetadataChanged(false); 258 } 259 250 260 if(hasSignalledStop()) { return; } 251 261 // upload etc folder to server (need collect.cfg and any hfiles) 252 Utility.zipup(collect_directory_path, col_name, "etc", this );262 Utility.zipup(collect_directory_path, col_name, "etc", this, "", ""); 253 263 254 264 if(hasSignalledStop()) { return; } … … 260 270 // upload images/ directory to server 261 271 if(hasSignalledStop()) { return; } 262 Utility.zipup(collect_directory_path, col_name, "images", this );272 Utility.zipup(collect_directory_path, col_name, "images", this, "", ""); 263 273 264 274 if(hasSignalledStop()) { return; } … … 354 364 fireMessage(type, typeAsString(type) + "> " + line, status, bos); 355 365 } 356 System.err.println("Wants to stop (1).");366 //System.err.println("Wants to stop (1)."); //debug --Matthew 357 367 } 358 368 stdbr.close(); … … 533 543 if (type == NEW) { 534 544 if (Gatherer.isGsdlRemote) { 535 GathererApplet.download_url_zip(col_name, ".", this );545 GathererApplet.download_url_zip(col_name, ".", this, "", ""); 536 546 if (!hasSignalledStop()) { 537 547 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); … … 549 559 550 560 Utility.delete(Gatherer.c_man.getCollectionArchivesDirectoryPath()); // remove current archives 551 GathererApplet.download_url_zip(col_name, "archives", this); 552 if (!hasSignalledStop()) { 553 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); 554 } 555 if (progress!=null) { 556 progress.messageOnProgressBar(""); 557 } 561 //new File(Gatherer.c_man.getCollectionArchivesDirectoryPath()).mkdir(); //Make a clean dir 562 GathererApplet.download_url_zip(col_name, "archives", this, ".*doc\\.xml", ""); 563 if (hasSignalledStop()) { 564 // Clean up, then exit 565 fireProcessComplete(type, status); 566 // Close bos 567 if(bos != null) { 568 try { 569 bos.close(); 570 bos = null; 571 } 572 catch(Exception error) { 573 DebugStream.printStackTrace(error); 574 } 575 } 576 return; 577 } 578 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); 579 580 if (progress!=null) { 581 progress.messageOnProgressBar(""); 582 } 558 583 } 559 584 … … 574 599 File buildDir = new File(Gatherer.c_man.getCollectionBuildingDirectoryPath()); 575 600 Utility.delete(buildDir); // remove current build dir 576 buildDir.mkdir(); //Make a clean dir 577 GathererApplet.download_url_zip(col_name, "building/build.cfg", this); //Only need build.cfg 601 //buildDir.mkdir(); //Make a clean dir 602 GathererApplet.download_url_zip(col_name, "building/build.cfg", this, "", ""); //Only need build.cfg 603 //Maybe change to GathererApplet.download_url_zip(col_name, "building", this, "build.cfg") 578 604 if (!hasSignalledStop()) { 579 605 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); -
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r9095 r9166 602 602 } 603 603 604 static protected void zipFunc (ZipOutputStream zos, String file_path, int prefix_strip, GShell source) 605 { 604 /* 605 Method to handle zipping up of a file. Called by zipup and dirFunc. 606 607 @param zos the zip output stream, as a <strong>ZipOutputStream</strong> 608 @param file_path the <strong>String</strong> containing the path to the file/directory tozip up 609 @param prefix_strip the <strong>int</strong> used to substring the file_path 610 @param source the <strong>GShell</strong> that is calling this method, so that we can check to see if the process has been cancelled. null if GShell is not the calling object. 611 @param accept_expr a <strong>String</strong> containing a regular expression of files to include in the archive. All other files will be excluded. 612 @param reject_expr a <strong>String</strong> containing a regular expression of files not to include in the archive. 613 614 @return boolean 615 616 @see dirFunc 617 @see zipup 618 */ 619 static protected boolean zipFunc (ZipOutputStream zos, String file_path, int prefix_strip, GShell source, boolean encountered_file, String accept_expr, String reject_expr) 620 { 621 622 if((reject_expr != "") && (file_path.matches(reject_expr))) { 623 // matches reject expression 624 DebugStream.println("File \'" + file_path + "\' matches the reject expression \'" + reject_expr + "\'"); 625 return encountered_file; 626 } 627 628 if ((accept_expr != "") && (!file_path.matches(accept_expr))) { 629 // does not match accept expression 630 DebugStream.println("File \'" + file_path + "\' doesn't match accept expression \'" + accept_expr + "\'"); 631 return encountered_file; 632 } 633 606 634 // Using try is required because of file io. 607 635 try { 608 636 // Exit if pressed cancel. 609 637 if (source != null && source.hasSignalledStop()) { 610 return; 611 } 638 return false; 639 } 640 612 641 // Create a Zip Entry and put it into the archive (no data yet). 613 642 … … 616 645 // Zip files use '/' for directory separator 617 646 String unix_style_path = unixStylePath(zip_path); 647 618 648 ZipEntry fileEntry = new ZipEntry(unix_style_path); 619 649 zos.putNextEntry(fileEntry); … … 637 667 zos.write(data, 0, byteCount); 638 668 } 669 encountered_file = true; 639 670 } 640 671 catch (IOException e) { … … 642 673 } 643 674 644 DebugStream.println(" Zipping up: " + file_path); 645 } 646 647 static protected void dirFunc (ZipOutputStream zos, String dir_name, int prefix_strip, GShell source) 648 { 675 DebugStream.println("Zipping up: " + file_path); 676 return encountered_file; 677 } 678 679 /* 680 Method to handle ziping up of a directory. 681 682 @param zos 683 @param dir_name 684 @param prefix_strip 685 @param source 686 @param encountered_file ??What's this?? 687 @param accept_expr 688 @param reject_expr 689 690 @see zipup 691 @see zipFunc 692 */ 693 static protected boolean dirFunc (ZipOutputStream zos, String dir_name, int prefix_strip, GShell source, boolean encountered_file, String accept_expr, String reject_expr) 694 { 695 /* 696 if (reject_expr != "" && (dir_name.matches(reject_expr))) { 697 // matches reject expression 698 System.err.println("matches reject expression"); 699 return encountered_file; 700 } 701 702 if ((accept_expr != "") && (!dir_name.matches(accept_expr))) { 703 // does not match accept expression 704 System.err.println("doesn't match accept expression"); 705 return encountered_file; 706 } 707 */ 708 649 709 File dirObj = new File(dir_name); 650 710 … … 656 716 // Loop through File array and display. 657 717 for (int i = 0; i < fileList.length; i++) { 658 if(source != null) { 659 if(source.hasSignalledStop()) { 660 break; 661 } 662 } 718 if(source != null && source.hasSignalledStop()) { break; } 663 719 File file = fileList[i]; 664 720 if (file.isDirectory()) { … … 677 733 } 678 734 679 dirFunc(zos,dir_path,prefix_strip, source);735 encountered_file = dirFunc(zos, dir_path, prefix_strip, source, encountered_file, accept_expr, reject_expr); 680 736 } else if (file.isFile()) { 681 737 // Call the zipFunc function 682 738 String file_path = fileList[i].getPath(); 683 zipFunc(zos,file_path,prefix_strip, source);739 encountered_file = zipFunc(zos,file_path,prefix_strip, source, encountered_file, accept_expr, reject_expr); 684 740 } 685 } 741 } 686 742 } 687 743 else { … … 692 748 System.err.println ("Directory "+dir_name+" does not exist."); 693 749 } 750 return encountered_file; 694 751 } 695 752 696 697 698 static public void zipup(String col_dir, String col_name, String dir_or_file, GShell source) 753 /** 754 Method to zip up a given file or directory 755 756 @param col_dir 757 @param col_name 758 @param dir_or_file 759 @param source 760 @param filter 761 762 @see zipFunc 763 @see dirFunc 764 */ 765 static public boolean zipup(String col_dir, String col_name, String dir_or_file, GShell source, String accept_expr, String reject_expr) 699 766 { 700 767 int prefix_strip = col_dir.length(); 768 boolean encountered_file = false; 701 769 702 770 String zip_fname = col_dir + col_name + ".zip"; … … 711 779 if (zip_dof.isDirectory()) { 712 780 String zip_dir = zip_dir_or_file; 713 dirFunc(zos,zip_dir,prefix_strip, source);781 encountered_file = dirFunc(zos, zip_dir, prefix_strip, source, encountered_file, accept_expr, reject_expr); 714 782 } 715 783 else { … … 730 798 } 731 799 } 732 zipFunc(zos,zip_full_file,prefix_strip, source);800 encountered_file = zipFunc(zos, zip_full_file, prefix_strip, source, encountered_file, accept_expr, reject_expr); 733 801 } 734 802 } … … 744 812 catch (IOException exception) { 745 813 DebugStream.printStackTrace(exception); 746 } 814 return false; 815 } 816 return encountered_file; 747 817 } 748 818 … … 760 830 ZipEntry zipentry = (ZipEntry) e.nextElement(); 761 831 String zentryname = col_dir + zipentry.getName(); 832 File file = new File(zentryname); 762 833 DebugStream.println(" Unzipping: " + zentryname); 763 834 … … 771 842 else { 772 843 // Write out file to disk 844 845 //Make sure it's parent directory exists. 846 File dir = new File(file.getParent()); 847 dir.mkdirs(); 773 848 774 849 // set up input stream
Note:
See TracChangeset
for help on using the changeset viewer.