Project

General

Profile

« Previous | Next » 

Revision 4684

Added by daigle over 15 years ago

revert the changes for: -- On update, check if the accession number exists in the db. If not, change the action to insert.

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
2154 2154
                String[] docid = params.get("docid");
2155 2155
                String newdocid = null;
2156 2156
                
2157
                String accNumber = docid[0];
2158

  
2159
                if (accNumber.equals("")) {
2160
                    accNumber = null;
2161
                }
2162
                
2163 2157
                String doAction = null;
2164
                boolean accessionNumberExists = AccessionNumber.accNumberIsCurrent(accNumber);
2165 2158
                if (action[0].equals("insert") || action[0].equals("insertmultipart")) {
2166 2159
                    doAction = "INSERT";
2167
                } else if (action[0].equals("update") && !accessionNumberExists) {
2168
                	doAction = "INSERT";
2169 2160
                } else if (action[0].equals("update")) {
2170 2161
                    doAction = "UPDATE";
2171 2162
                }
2172 2163
                
2173
                logMetacat.debug("" + doAction + " " + accNumber + "...");
2174
                
2175 2164
                try {
2176 2165
                    // get a connection from the pool
2177 2166
                    dbConn = DBConnectionPool
......
2180 2169
                    
2181 2170
                    // write the document to the database and disk
2182 2171
                    try {
2172
                        String accNumber = docid[0];
2173
                        logMetacat.debug("" + doAction + " "
2174
                                + accNumber + "...");
2175
                        if (accNumber.equals("")) {
2176
                            accNumber = null;
2177
                        }
2183 2178

  
2184 2179
                        newdocid = documentWrapper.write(dbConn, xml, pub, dtd,
2185 2180
                                doAction, accNumber, user, groups);
src/edu/ucsb/nceas/metacat/AccessionNumber.java
203 203
    return hasAccNumber;
204 204
  }
205 205

  
206
  // check for existence of Accession Number in xml_documents table
207
  public static boolean accNumberIsCurrent(String accNumber) throws SQLException {
206
  // check for existence of Accesssion Number in xml_documents table
207
  private boolean accNumberIsCurrent(String accNumber) throws SQLException {
208 208

  
209 209
    boolean hasCurrentAccNumber = false;
210 210
    DBConnection conn = null;

Also available in: Unified diff