Changeset 10205


Ignore:
Timestamp:
2005-07-04T17:14:06+12:00 (19 years ago)
Author:
mdewsnip
Message:

Can now create a collection with Unicode title and description. This did not work before because these were passed as arguments to mkcol.pl, and encoding and shell issues would cause them to be screwed up. Now the collection title and description is set by the GLI after mkcol.pl has been run.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r10006 r10205  
    310310
    311311        // Create the new collection.
    312         makeCollection(description, email, name, title);
     312        makeCollection(name, email);
    313313        progress.setProgress(1);
    314314       
     
    400400        collection.cdm = new CollectionDesignManager(new File(getCollectionConfigFilePath()));
    401401
     402        // We always set title and description here rather than calling mkcol.pl with Unicode arguments
     403        CollectionMeta collection_name_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
     404        collection_name_collectionmeta.setValue(title);
     405        CollectionMeta collection_extra_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONEXTRA_STR);
     406        collection_extra_collectionmeta.setValue(description);
     407
    402408        // Now that we have a CDM, update several settings, such as if we created this collection by basing it on another, set it as public automatically
    403409        if (base_collection_directory != null) {
     
    410416        maintainer_collectionmeta = null;
    411417
    412         // Update the collection title
    413         CollectionMeta collection_name_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
    414         collection_name_collectionmeta.setValue(title);
    415         collection_name_collectionmeta = null;
    416 
    417         // And now the description
    418         CollectionMeta collection_extra_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONEXTRA_STR);
    419         collection_extra_collectionmeta.setValue(description);
    420         collection_extra_collectionmeta = null;
    421 
    422418        // All collections based on others are automatically public
    423419        CollectionMeta public_collectionmeta = new CollectionMeta(collection.cdm.collect_config.getPublic());
     
    434430        }
    435431
     432        collection.cdm.save();
    436433        progress.setProgress(3);
    437434
     
    901898
    902899
    903     private void makeCollection(String description, String email, String name, String title) {
    904     // Encode the description so it is safe to write to shell
    905     if(Utility.isWindows()) {
    906         description = Codec.transform(description, Codec.TEXT_TO_SHELL_WINDOWS);
    907     }
    908     else {
    909         description = Codec.transform(description, Codec.TEXT_TO_SHELL_UNIX);
    910     }
    911 
     900    private void makeCollection(String name, String email)
     901    {
    912902    // Generate the mkcol.pl command
    913903    ArrayList command_parts_list = new ArrayList();
     
    923913    command_parts_list.add((Gatherer.isGsdlRemote) ? "false" : "true");
    924914
    925     if (title != null && !title.equals("")) {
    926         command_parts_list.add("-title");
    927         command_parts_list.add(title);
    928     }
    929915    if (email != null && !email.equals("")) {
    930916        command_parts_list.add("-creator");
    931917        command_parts_list.add(email);
    932     }
    933     if (description != null && !description.equals("")) {
    934         command_parts_list.add("-about");
    935         command_parts_list.add(description);
    936918    }
    937919
Note: See TracChangeset for help on using the changeset viewer.