Revision 10123
Added by Jing Tao almost 8 years ago
src/edu/ucsb/nceas/metacat/IdentifierManager.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
package edu.ucsb.nceas.metacat; |
26 | 26 |
|
27 |
import java.io.File; |
|
27 | 28 |
import java.math.BigInteger; |
28 | 29 |
import java.sql.PreparedStatement; |
29 | 30 |
import java.sql.ResultSet; |
... | ... | |
66 | 67 |
import edu.ucsb.nceas.metacat.shared.AccessException; |
67 | 68 |
import edu.ucsb.nceas.metacat.shared.ServiceException; |
68 | 69 |
import edu.ucsb.nceas.metacat.util.DocumentUtil; |
70 |
import edu.ucsb.nceas.utilities.FileUtil; |
|
69 | 71 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
70 | 72 |
import edu.ucsb.nceas.utilities.access.AccessControlInterface; |
71 | 73 |
import edu.ucsb.nceas.utilities.access.XMLAccessDAO; |
... | ... | |
2394 | 2396 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
2395 | 2397 |
} |
2396 | 2398 |
} |
2399 |
|
|
2400 |
/** |
|
2401 |
* Determine if the object file exist for the given localId. |
|
2402 |
* @param localId |
|
2403 |
* @param isScienceMetadata |
|
2404 |
* @return |
|
2405 |
* @throws PropertyNotFoundException |
|
2406 |
*/ |
|
2407 |
public boolean objectFileExists(String localId, boolean isScienceMetadata) throws PropertyNotFoundException { |
|
2408 |
boolean exist =false; |
|
2409 |
if (localId != null) { |
|
2410 |
String documentPath = getObjectFilePath(localId, isScienceMetadata); |
|
2411 |
if(documentPath != null) { |
|
2412 |
File file = new File(documentPath); |
|
2413 |
exist = file.exists(); |
|
2414 |
} |
|
2415 |
} |
|
2416 |
logMetacat.debug("IdentifierManager.ObjectFileExist - Does the object file for the local id "+localId+" which is science metadata "+isScienceMetadata+" exist in the Metacast file system? The answer is "+exist); |
|
2417 |
return exist; |
|
2418 |
} |
|
2419 |
|
|
2420 |
/** |
|
2421 |
*Get the the file path for the given object local id |
|
2422 |
* @param localId |
|
2423 |
* @param isScienceMetadata |
|
2424 |
* @return |
|
2425 |
* @throws PropertyNotFoundException |
|
2426 |
*/ |
|
2427 |
public String getObjectFilePath(String localId, boolean isScienceMetadata) throws PropertyNotFoundException { |
|
2428 |
String documentPath = null; |
|
2429 |
if (localId != null) { |
|
2430 |
String documentDir = null; |
|
2431 |
// get the correct location on disk |
|
2432 |
if (isScienceMetadata) { |
|
2433 |
documentDir = PropertyService.getProperty("application.documentfilepath"); |
|
2434 |
} else { |
|
2435 |
documentDir = PropertyService.getProperty("application.datafilepath"); |
|
2436 |
} |
|
2437 |
documentPath = documentDir + FileUtil.getFS() + localId; |
|
2438 |
} |
|
2439 |
logMetacat.debug("IdentifierManager.getObjectFilePath - the file path for the object with localId "+localId+" which is scienceMetacat "+isScienceMetadata+", is "+documentPath+". If the value is null, this means we can't find it."); |
|
2440 |
return documentPath; |
|
2441 |
} |
|
2397 | 2442 |
} |
2398 | 2443 |
|
Also available in: Unified diff
Add methods to determine if the object does exist with the given local id.