Project

General

Profile

« Previous | Next » 

Revision 2326

Added by harris over 19 years ago

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

View differences:

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

  

Also available in: Unified diff