Project

General

Profile

Revision 2326

Added by harris almost 17 years ago

Adde a function to the metacat client to set access on an xml document in a
metacat repository.

View differences:

src/edu/ucsb/nceas/metacat/client/MetacatClient.java
442 442
          return response;
443 443
      }
444 444

  
445
      /**
445
        /**
446 446
          * Upload a data document into the repository.
447 447
          *
448 448
          * @param docid the docid to insert the document
......
526 526
                throw new MetacatException(response);
527 527
            }
528 528
        }
529
        return response;
530
    }
529 531

  
532

  
533
    /**
534
     * set the access on an XML document in the repository.
535
     *
536
     * @param _docid the docid to delete
537
     *
538
     * @param _principal the document's principal
539
     *
540
     * @param _permission the access permission to be applied to the docid
541
     *  {e.g. read,write,all}
542
     *
543
     * @param _permType the permission type to be applied to the document
544
     *  {e.g. allow or deny}
545
     *
546
     * @param _permOrder the order that the document's permissions should be
547
     *  processed {e.g. denyFirst or allowFirst}
548
     *
549
     *
550
     * @return the metacat response message
551
     *
552
     * @throws InsufficientKarmaException when the user has insufficent rights
553
     *                                    for the operation
554
     * @throws MetacatInaccessibleException when the metacat server can not be
555
     *                                    reached or does not respond
556
     * @throws MetacatException when the metacat server generates another error
557
     */
558
    public String setAccess(String _docid, String _principal, String
559
                            _permission, String _permType, 
560
                            String _permOrder )
561
        throws InsufficientKarmaException, MetacatException,
562
        MetacatInaccessibleException
563
    {  
564
        //set up properties
565
        Properties prop = new Properties();
566
        prop.put("action", "setaccess");
567
        prop.put("docid", _docid);
568
        prop.put("principal", _principal);
569
        prop.put("permission", _permission);
570
        prop.put("permType", _permType);
571
        prop.put("permOrder", _permOrder);
572

  
573
        String response = null;
574
        try {
575
            response = sendDataForString(prop, null, null, 0);
576
        } catch (Exception e) {
577
            throw new MetacatInaccessibleException(e.getMessage());
578
        }
579

  
580
        // Check for an error condition
581
        if (response.indexOf("<error>") != -1) {
582
            if (response.indexOf("does not have permission") != -1) {
583
                throw new InsufficientKarmaException(response);
584
            } else {
585
                throw new MetacatException(response);
586
            }
587
        }
530 588
        return response;
531 589
    }
532 590

  
src/edu/ucsb/nceas/metacat/client/Metacat.java
195 195
        MetacatInaccessibleException;
196 196

  
197 197
    /**
198
     * set the access on an XML document in the repository.
199
     *
200
     * @param _docid the docid to delete
201
     *
202
     * @param _principal the document's principal
203
     *
204
     * @param _permission the access permission to be applied to the docid
205
     *  {e.g. read,write,all}
206
     *
207
     * @param _permType the permission type to be applied to the document
208
     *  {e.g. allow or deny}
209
     *
210
     * @param _permOrder the order that the document's permissions should be
211
     *  processed {e.g. denyFirst or allowFirst}
212
     *
213
     *
214
     * @return the metacat response message
215
     *
216
     * @throws InsufficientKarmaException when the user has insufficent rights
217
     *                                    for the operation
218
     * @throws MetacatInaccessibleException when the metacat server can not be
219
     *                                    reached or does not respond
220
     * @throws MetacatException when the metacat server generates another error
221
     */
222
    public String setAccess(String _docid, String _principal, String
223
                            _permission, String _permType, String _permOrder )
224
        throws InsufficientKarmaException, MetacatException,
225
        MetacatInaccessibleException;
226

  
227
    /**
198 228
     * When the MetacatFactory creates an instance it needs to set the
199 229
     * MetacatUrl to which connections should be made.
200 230
     *

Also available in: Unified diff