Project

General

Profile

« Previous | Next » 

Revision 4698

Added by daigle over 15 years ago

Renamed MetaCatUtil to MetacatUtil

View differences:

DocumentImpl.java
59 59
import edu.ucsb.nceas.metacat.service.XMLSchemaService;
60 60
import edu.ucsb.nceas.metacat.spatial.SpatialHarvester;
61 61
import edu.ucsb.nceas.metacat.util.AuthUtil;
62
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
62
import edu.ucsb.nceas.metacat.util.MetacatUtil;
63 63
import edu.ucsb.nceas.metacat.util.SystemUtil;
64 64
import edu.ucsb.nceas.utilities.FileUtil;
65 65
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
......
183 183
    {
184 184
        try {
185 185
            //this.conn = conn;
186
            this.docid = MetaCatUtil.getDocIdFromAccessionNumber(accNum);
187
            this.rev   = MetaCatUtil.getRevisionFromAccessionNumber(accNum);
186
            this.docid = MetacatUtil.getDocIdFromAccessionNumber(accNum);
187
            this.rev   = MetacatUtil.getRevisionFromAccessionNumber(accNum);
188 188

  
189 189
            // Look up the document information
190 190
            getDocumentInfo(docid, rev);
......
334 334
            serialNumber = conn.getCheckOutSerialNumber();
335 335
            conn.setAutoCommit(false);
336 336
            String action = null;
337
            String docIdWithoutRev = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
338
            int userSpecifyRev = MetaCatUtil.getRevisionFromAccessionNumber(accnum);
337
            String docIdWithoutRev = MetacatUtil.getDocIdFromAccessionNumber(accnum);
338
            int userSpecifyRev = MetacatUtil.getRevisionFromAccessionNumber(accnum);
339 339
            action = checkRevInXMLDocuments(docIdWithoutRev, userSpecifyRev);
340 340
            logMetacat.warn("after check rev, the action is "+action);
341 341
            if (action.equals("UPDATE"))
......
414 414
            serialNumber = conn.getCheckOutSerialNumber();
415 415
            conn.setAutoCommit(false);
416 416
            String action = null;
417
            String docIdWithoutRev = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
418
            int userSpecifyRev = MetaCatUtil.getRevisionFromAccessionNumber(accnum);
417
            String docIdWithoutRev = MetacatUtil.getDocIdFromAccessionNumber(accnum);
418
            int userSpecifyRev = MetacatUtil.getRevisionFromAccessionNumber(accnum);
419 419
            if (tableName.equals(DOCUMENTTABLE))
420 420
            {
421 421
                action = checkRevInXMLDocuments(docIdWithoutRev, userSpecifyRev);
......
743 743
            throws Exception
744 744
    {
745 745
        boolean flag = true;
746
        String docid = MetaCatUtil.getDocIdFromString(accnum);
747
        int rev = MetaCatUtil.getVersionFromString(accnum);
746
        String docid = MetacatUtil.getDocIdFromString(accnum);
747
        int rev = MetacatUtil.getVersionFromString(accnum);
748 748

  
749 749
        if (serverCode == 1) {
750 750
            flag = true;
......
764 764
                    .getServerNameForServerCode(serverCode);
765 765
            MetacatReplication.replLog("attempting to lock " + accnum);
766 766
            URL u = new URL("https://" + server + "?server="
767
                    + MetaCatUtil.getLocalReplicationServerName()
767
                    + MetacatUtil.getLocalReplicationServerName()
768 768
                    + "&action=getlock&updaterev=" + rev + "&docid=" + docid);
769 769
            //System.out.println("sending message: " + u.toString());
770 770
            String serverResStr = MetacatReplication.getURLContent(u);
......
1195 1195
                    // if it is inline data first to get the inline data
1196 1196
                    // internal id
1197 1197
                    String fileName = currentNode.getNodeData();
1198
                    String accessfileName = MetaCatUtil
1198
                    String accessfileName = MetacatUtil
1199 1199
                            .getDocIdWithoutRevFromInlineDataID(fileName);
1200 1200
                    // check if user has read permision for this inline data
1201 1201
                    boolean readInlinedata = false;
......
1724 1724
                      currentName, docid, doctype, parentId));
1725 1725
                  }
1726 1726
                }
1727
                if( MetaCatUtil.pathsForIndexing.contains(currentName) &&
1727
                if( MetacatUtil.pathsForIndexing.contains(currentName) &&
1728 1728
                    leafData.trim().length() != 0 ){
1729 1729
                	logMetacat.debug("paths found for indexing: " + currentName);
1730 1730
                	pathsFoundForIndexing.put(currentName, new PathIndexEntry(
......
1748 1748
                logMetacat.debug("B: " + path +"\n");
1749 1749
                pathList.put(path, new PathIndexEntry(leafNodeId, path, docid,
1750 1750
                    doctype, parentId));
1751
                if( MetaCatUtil.pathsForIndexing.contains(path) &&
1751
                if( MetacatUtil.pathsForIndexing.contains(path) &&
1752 1752
                    leafData.trim().length() != 0 ){
1753 1753
                	logMetacat.debug("paths found for indexing: " + currentName);
1754 1754
                	pathsFoundForIndexing.put(path, new PathIndexEntry(
......
1765 1765
                logMetacat.debug("C: " + fullPath +"\n");
1766 1766
                pathList.put(fullPath, new PathIndexEntry(leafNodeId, fullPath,
1767 1767
                    docid, doctype, parentId));
1768
                if( MetaCatUtil.pathsForIndexing.contains(fullPath) &&
1768
                if( MetacatUtil.pathsForIndexing.contains(fullPath) &&
1769 1769
                   leafData.trim().length() != 0 ){
1770 1770
                	logMetacat.debug("paths found for indexing: " + currentName);
1771 1771
                	pathsFoundForIndexing.put(fullPath, new PathIndexEntry(
......
1785 1785
     */
1786 1786
    private void deleteNodeIndex(DBConnection conn) throws SQLException
1787 1787
    {
1788
        //String familyId = MetaCatUtil.getDocIdFromString(docid);
1788
        //String familyId = MetacatUtil.getDocIdFromString(docid);
1789 1789
    	double start = System.currentTimeMillis()/1000;
1790 1790
        String familyId = docid;
1791 1791
        String sql = "DELETE FROM xml_index WHERE docid = ?";
......
2054 2054
                if (!server.equals("localhost")) {
2055 2055
                    this.docHomeServer = server;
2056 2056
                } else {
2057
                    this.docHomeServer = MetaCatUtil
2057
                    this.docHomeServer = MetacatUtil
2058 2058
                            .getLocalReplicationServerName();
2059 2059
                }
2060 2060
                logMetacat.info("server: " + docHomeServer);
......
2173 2173
                try
2174 2174
                {
2175 2175
                	logMetacat.debug("Node data in read process before normalize=== "+nodedata);
2176
                	nodedata = MetaCatUtil.normalize(nodedata);
2176
                	nodedata = MetacatUtil.normalize(nodedata);
2177 2177
                	logMetacat.debug("Node data in read process after normalize==== "+nodedata);
2178 2178
                } catch (java.lang.StringIndexOutOfBoundsException SIO){
2179 2179
                	logMetacat.warn("StringIndexOutOfBoundsException in normalize() while reading the document");
......
2538 2538
            }
2539 2539

  
2540 2540
            //DocumentIdentifier id = new DocumentIdentifier(accnum);
2541
            int revision = MetaCatUtil.getRevisionFromAccessionNumber(accnum);
2541
            int revision = MetacatUtil.getRevisionFromAccessionNumber(accnum);
2542 2542
            String updaterev = (new Integer(revision)).toString();
2543 2543
            String server = MetacatReplication
2544 2544
                    .getServerNameForServerCode(serverCode);
2545 2545
            MetacatReplication.replLog("attempting to lock " + accnum);
2546 2546
            URL u = new URL("https://" + server + "?server="
2547
                    + MetaCatUtil.getLocalReplicationServerName()
2547
                    + MetacatUtil.getLocalReplicationServerName()
2548 2548
                    + "&action=getlock&updaterev=" + updaterev + "&docid="
2549 2549
                    + docid);
2550 2550
            //System.out.println("sending message: " + u.toString());
......
2769 2769
        String catalogId = null;
2770 2770
        logMetacat.info("user in replication" + user);
2771 2771
        // Docid without revision
2772
        String docid = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
2772
        String docid = MetacatUtil.getDocIdFromAccessionNumber(accnum);
2773 2773
        logMetacat.warn("The docid without rev is " + docid);
2774 2774
        // Revision specified by user (int)
2775
        int userSpecifyRev = MetaCatUtil.getRevisionFromAccessionNumber(accnum);
2775
        int userSpecifyRev = MetacatUtil.getRevisionFromAccessionNumber(accnum);
2776 2776
        logMetacat.warn("The user specifyRev: " + userSpecifyRev);
2777 2777
        // Revision for this docid in current database
2778 2778
        int revInDataBase = DBUtil.getLatestRevisionInDocumentTable(docid);
......
2921 2921
        try {
2922 2922
            String packagedoctype = PropertyService.getProperty("xml.packagedoctype");
2923 2923
            Vector<String> packagedoctypes = new Vector<String>();
2924
            packagedoctypes = MetaCatUtil.getOptionList(packagedoctype);
2925
            String docIdWithoutRev = MetaCatUtil.getDocIdFromAccessionNumber(accnumber);
2926
            int revision = MetaCatUtil.getRevisionFromAccessionNumber(accnumber);
2924
            packagedoctypes = MetacatUtil.getOptionList(packagedoctype);
2925
            String docIdWithoutRev = MetacatUtil.getDocIdFromAccessionNumber(accnumber);
2926
            int revision = MetacatUtil.getRevisionFromAccessionNumber(accnumber);
2927 2927
            if (documenttype != null &&
2928 2928
                    packagedoctypes.contains(documenttype)) {
2929 2929
                dbconn = DBConnectionPool.getDBConnection(
......
2934 2934
                String aclidWithRev = RelationHandler.getAccessFileIDWithRevision(docIdWithoutRev);
2935 2935
                if (aclidWithRev != null)
2936 2936
                {
2937
                  String aclid = MetaCatUtil.getDocIdFromAccessionNumber(aclidWithRev);
2938
                  revision = MetaCatUtil.getRevisionFromAccessionNumber(aclidWithRev);
2937
                  String aclid = MetacatUtil.getDocIdFromAccessionNumber(aclidWithRev);
2938
                  revision = MetacatUtil.getRevisionFromAccessionNumber(aclidWithRev);
2939 2939
                 
2940 2940
                  // if there are access file, write ACL for that package
2941 2941
                  if (aclid != null) {
......
2948 2948
            }
2949 2949
            // if it is an access file
2950 2950
            else if (documenttype != null
2951
                    && MetaCatUtil.getOptionList(
2951
                    && MetacatUtil.getOptionList(
2952 2952
                            PropertyService.getProperty("xml.accessdoctype")).contains(
2953 2953
                            documenttype)) {
2954 2954
                dbconn = DBConnectionPool.getDBConnection(
......
3003 3003
        int serialNumber = -1;
3004 3004
        try {
3005 3005
            //get rid of revision number
3006
            docid = MetaCatUtil.getDocIdFromString(accnumber);
3006
            docid = MetacatUtil.getDocIdFromString(accnumber);
3007 3007
            dbConnection = DBConnectionPool.getDBConnection(
3008 3008
                    "DocumentImpl.getDocTypeFromDBForCurrentDoc");
3009 3009
            serialNumber = dbConnection.getCheckOutSerialNumber();
......
3057 3057
            // NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV
3058 3058
            // IN IT
3059 3059
            //AccessionNumber ac = new AccessionNumber(accnum, "DELETE");
3060
            String docid = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
3060
            String docid = MetacatUtil.getDocIdFromAccessionNumber(accnum);
3061 3061
            //String rev = ac.getRev();
3062 3062

  
3063 3063
            // Check if the document exists.
......
3655 3655
            throws SQLException
3656 3656
    {
3657 3657
        //get rid of revNum part
3658
        String docId = MetaCatUtil.getDocIdFromString(accNum);
3658
        String docId = MetacatUtil.getDocIdFromString(accNum);
3659 3659
        PreparedStatement pStmt = null;
3660 3660
        int serverLocation = 1;
3661 3661
        DBConnection conn = null;
......
3717 3717
        int serialNumber = -1;
3718 3718

  
3719 3719
        //we should consider about local host too
3720
        if (serverName.equals(MetaCatUtil.getLocalReplicationServerName())) {
3720
        if (serverName.equals(MetacatUtil.getLocalReplicationServerName())) {
3721 3721
            serverLocation = 1;
3722 3722
            return serverLocation;
3723 3723
        }
......
3801 3801
            // If the server is not in the table, and server is not local host,
3802 3802
            // insert it
3803 3803
            if (!hasRow
3804
                    && !server.equals(MetaCatUtil
3804
                    && !server.equals(MetacatUtil
3805 3805
                            .getLocalReplicationServerName())) {
3806 3806
                // Set auto commit false
3807 3807
                dbConn.setAutoCommit(false);
......
4139 4139
            dbconn = DBConnectionPool.getDBConnection(
4140 4140
                    "DeletedDocumentImpl.registerDeletedDataFile");
4141 4141
            serialNumber = dbconn.getCheckOutSerialNumber();
4142
            String docIdWithoutRev = MetaCatUtil
4142
            String docIdWithoutRev = MetacatUtil
4143 4143
                    .getDocIdFromAccessionNumber(accnum);
4144
            String rev = MetaCatUtil.getRevisionStringFromString(accnum);
4144
            String rev = MetacatUtil.getRevisionStringFromString(accnum);
4145 4145
            writeDocumentToRevisionTable(dbconn, docIdWithoutRev, 
4146 4146
                    rev, doctype, docname, user,
4147 4147
                    null, serverCode, -1, createDate, updateDate); 

Also available in: Unified diff