Project

General

Profile

Revision 1356

Added by Jing Tao almost 18 years ago

Merge the code to handle export single document.

View differences:

src/edu/ucsb/nceas/metacat/DBQuery.java
1535 1535
    version=MetaCatUtil.getVersionFromString(docIdString);
1536 1536
 
1537 1537
    //check if the reqused docId is a data package id
1538
    if (!isDataPackageId(docId))//if it is not, throw a exception
1538
    if (!isDataPackageId(docId))
1539 1539
    {
1540
      Exception e = new Exception("The request the doc id " +docIdString+
1540
      
1541
      /*Exception e = new Exception("The request the doc id " +docIdString+
1541 1542
                                    " is not a data package id");
1542
      throw e;
1543
      throw e;*/
1544
      
1545
      
1546
      //CB 1/6/03: if the requested docid is not a datapackage, we just zip
1547
      //up the single document and return the zip file.
1548

  
1549
      if(!hasPermissionToExportPackage(docId, user, groups))
1550
      {
1551

  
1552
        Exception e = new Exception("User " + user + " does not have permission"
1553
                         +" to export the data package " + docIdString);
1554
        throw e;
1555
      }
1556

  
1557
      docImpls=new DocumentImpl(docId);
1558
      //checking if the user has the permission to read the documents
1559
      if (docImpls.hasReadPermission(user,groups,docImpls.getDocID()))
1560
      {
1561
        zOut = new ZipOutputStream(out);
1562
        //if the docImpls is metadata
1563
        if ((docImpls.getDoctype()).compareTo("BIN")!=0)
1564
        {
1565
          //add metadata into zip output stream
1566
          addDocToZipOutputStream(docImpls, zOut, rootName);
1567
        }//if
1568
        else
1569
        {
1570
          //it is data file
1571
          addDataFileToZipOutputStream(docImpls, zOut, rootName);
1572
          htmlDocumentImplList.add(docImpls);
1573
        }//else
1574
      }//if
1575

  
1576
      zOut.finish(); //terminate the zip file
1577
      return zOut;
1543 1578
    }
1544 1579
    // Check the permission of user
1545 1580
    else if(!hasPermissionToExportPackage(docId, user, groups))

Also available in: Unified diff