Left: | ||
Right: |
OLD | NEW |
---|---|
1 // Copyright 2014 Google Inc. All Rights Reserved. | 1 // Copyright 2014 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 private static final SimpleDateFormat dateFormat = | 102 private static final SimpleDateFormat dateFormat = |
103 new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 103 new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
104 | 104 |
105 private static final long ONE_DAY_MILLIS = 24 * 60 * 60 * 1000L; | 105 private static final long ONE_DAY_MILLIS = 24 * 60 * 60 * 1000L; |
106 | 106 |
107 // Initial incremental checkpoints will have timestamps 24 hours in | 107 // Initial incremental checkpoints will have timestamps 24 hours in |
108 // the past, because Documentum timestamps are local server time. | 108 // the past, because Documentum timestamps are local server time. |
109 private static final String YESTERDAY = dateFormat.format( | 109 private static final String YESTERDAY = dateFormat.format( |
110 new Date(System.currentTimeMillis() - ONE_DAY_MILLIS)); | 110 new Date(System.currentTimeMillis() - ONE_DAY_MILLIS)); |
111 | 111 |
112 private AdaptorContext context; | |
112 private final IDfClientX dmClientX; | 113 private final IDfClientX dmClientX; |
113 private List<String> startPaths; | 114 private List<String> startPaths; |
114 private List<String> documentTypes; | 115 private List<String> documentTypes; |
115 private CopyOnWriteArrayList<String> validatedStartPaths = | 116 private CopyOnWriteArrayList<String> validatedStartPaths = |
116 new CopyOnWriteArrayList<String>(); | 117 new CopyOnWriteArrayList<String>(); |
117 private CopyOnWriteArrayList<String> validatedDocumentTypes = | 118 private CopyOnWriteArrayList<String> validatedDocumentTypes = |
118 new CopyOnWriteArrayList<String>(); | 119 new CopyOnWriteArrayList<String>(); |
119 private boolean indexFolders; | 120 private boolean indexFolders; |
120 | 121 |
121 // The object attributes that should not be supplied as metadata. | 122 // The object attributes that should not be supplied as metadata. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 } | 318 } |
318 | 319 |
319 private static String docIdToPath(DocId docId) { | 320 private static String docIdToPath(DocId docId) { |
320 String path = docIdToRawPath(docId); | 321 String path = docIdToRawPath(docId); |
321 if (path.matches(".*:\\p{XDigit}{16}")) { | 322 if (path.matches(".*:\\p{XDigit}{16}")) { |
322 path = path.substring(0, path.length() - 17); | 323 path = path.substring(0, path.length() - 17); |
323 } | 324 } |
324 return path; | 325 return path; |
325 } | 326 } |
326 | 327 |
328 private static DocId docIdWithObjectId(DocId docId, IDfId objectId) { | |
329 String id = docId.getUniqueId(); | |
330 return new DocId(id + ":" + objectId); | |
331 } | |
332 | |
327 public DocumentumAdaptor() { | 333 public DocumentumAdaptor() { |
328 this(new DfClientX()); | 334 this(new DfClientX()); |
329 } | 335 } |
330 | 336 |
331 @VisibleForTesting | 337 @VisibleForTesting |
332 DocumentumAdaptor(IDfClientX dmClientX) { | 338 DocumentumAdaptor(IDfClientX dmClientX) { |
333 this.dmClientX = dmClientX; | 339 this.dmClientX = dmClientX; |
334 } | 340 } |
335 | 341 |
336 @Override | 342 @Override |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 + "r_current_state, r_folder_path, r_frozen_flag, r_frzn_assembly_cnt, " | 379 + "r_current_state, r_folder_path, r_frozen_flag, r_frzn_assembly_cnt, " |
374 + "r_full_content_size, r_has_events, r_has_frzn_assembly, " | 380 + "r_full_content_size, r_has_events, r_has_frzn_assembly, " |
375 + "r_immutable_flag, r_is_public, r_is_virtual_doc, r_link_cnt, " | 381 + "r_immutable_flag, r_is_public, r_is_virtual_doc, r_link_cnt, " |
376 + "r_link_high_cnt, r_lock_date, r_lock_machine, r_lock_owner, " | 382 + "r_link_high_cnt, r_lock_date, r_lock_machine, r_lock_owner, " |
377 + "r_modifier, r_order_no, r_page_cnt, r_policy_id, r_resume_state, " | 383 + "r_modifier, r_order_no, r_page_cnt, r_policy_id, r_resume_state, " |
378 + "r_version_label, resolution_label, world_permit"); | 384 + "r_version_label, resolution_label, world_permit"); |
379 } | 385 } |
380 | 386 |
381 @Override | 387 @Override |
382 public void init(AdaptorContext context) throws DfException { | 388 public void init(AdaptorContext context) throws DfException { |
389 this.context = context; | |
383 docIdEncoder = context.getDocIdEncoder(); | 390 docIdEncoder = context.getDocIdEncoder(); |
384 config = context.getConfig(); | 391 config = context.getConfig(); |
385 validateConfig(config); | 392 validateConfig(config); |
386 docbase = config.getValue("documentum.docbaseName").trim(); | 393 docbase = config.getValue("documentum.docbaseName").trim(); |
387 displayUrl = config.getValue("documentum.displayUrlPattern"); | 394 displayUrl = config.getValue("documentum.displayUrlPattern"); |
388 markAllDocsAsPublic = | 395 markAllDocsAsPublic = |
389 Boolean.parseBoolean(config.getValue("adaptor.markAllDocsAsPublic")); | 396 Boolean.parseBoolean(config.getValue("adaptor.markAllDocsAsPublic")); |
390 logger.log(Level.CONFIG, "adaptor.markAllDocsAsPublic: {0}", | 397 logger.log(Level.CONFIG, "adaptor.markAllDocsAsPublic: {0}", |
391 markAllDocsAsPublic); | 398 markAllDocsAsPublic); |
392 | 399 |
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1432 if (path.matches(".*:\\p{XDigit}{16}")) { | 1439 if (path.matches(".*:\\p{XDigit}{16}")) { |
1433 String objId = path.substring(path.length() - 16); | 1440 String objId = path.substring(path.length() - 16); |
1434 logger.log(Level.FINER, "Object Id: {0}", objId); | 1441 logger.log(Level.FINER, "Object Id: {0}", objId); |
1435 try { | 1442 try { |
1436 dmPersObj = dmSession.getObject(new DfId(objId)); | 1443 dmPersObj = dmSession.getObject(new DfId(objId)); |
1437 } catch (DfIdNotFoundException e) { | 1444 } catch (DfIdNotFoundException e) { |
1438 // Check for a false positive regex match. | 1445 // Check for a false positive regex match. |
1439 dmPersObj = dmSession.getObjectByPath(path); | 1446 dmPersObj = dmSession.getObjectByPath(path); |
1440 } | 1447 } |
1441 } else { | 1448 } else { |
1442 logger.log(Level.FINE, "Path doesn't contain objectid: {0}", path); | 1449 logger.log(Level.FINE, "Path does not contain objectid: {0}", path); |
1443 dmPersObj = dmSession.getObjectByPath(path); | 1450 dmPersObj = dmSession.getObjectByPath(path); |
1451 if (dmPersObj != null) { | |
JohnL
2017/02/01 22:52:58
You need to do this for the catch block also. Bret
Srinivas
2017/02/04 02:27:54
Done.
| |
1452 DocId newId = docIdWithObjectId(id, dmPersObj.getObjectId()); | |
1453 logger.log(Level.FINE, "New location: {0}", newId.toString()); | |
JohnL
2017/02/01 22:52:59
toString is redundant.
Srinivas
2017/02/04 02:27:54
Done.
| |
1454 URI newUri = docIdEncoder.encodeDocId(newId); | |
JohnL
2017/02/01 22:52:58
Why are you sending an URI here, since you're no l
Srinivas
2017/02/04 02:27:54
Done.
| |
1455 context.getAsyncDocIdPusher().pushDocId(new DocId(newUri.toString())); | |
JohnL
2017/02/01 22:52:58
Brett says this returns fall if the queuing failed
Srinivas
2017/02/04 02:27:54
Done.
| |
1456 resp.respondNotFound(); | |
1457 return; | |
1458 } | |
1444 } | 1459 } |
1445 | 1460 |
1446 if (dmPersObj == null) { | 1461 if (dmPersObj == null) { |
1447 logger.log(Level.FINER, "Not found: {0}", id); | 1462 logger.log(Level.FINER, "Not found: {0}", id); |
1448 resp.respondNotFound(); | 1463 resp.respondNotFound(); |
1449 return; | 1464 return; |
1450 } | 1465 } |
1451 | 1466 |
1452 IDfId dmObjId = dmPersObj.getObjectId(); | 1467 IDfId dmObjId = dmPersObj.getObjectId(); |
1453 IDfType type = dmPersObj.getType(); | 1468 IDfType type = dmPersObj.getType(); |
1454 //TODO (Srinivas): remove this code | |
1455 if (!path.matches(".*:\\p{XDigit}{16}")) { | |
1456 id = docIdFromPath(path, dmPersObj.getObjectId().toString()); | |
1457 } | |
1458 logger.log(Level.FINER, "Object Id: {0}; Type: {1}", | 1469 logger.log(Level.FINER, "Object Id: {0}; Type: {1}", |
1459 new Object[] {dmObjId, type.getName()}); | 1470 new Object[] {dmObjId, type.getName()}); |
1460 | 1471 |
1461 if (type.isTypeOf("dm_sysobject")) { | 1472 if (type.isTypeOf("dm_sysobject")) { |
1462 Date lastModified = dmPersObj.getTime("r_modify_date").getDate(); | 1473 Date lastModified = dmPersObj.getTime("r_modify_date").getDate(); |
1463 resp.setLastModified(lastModified); | 1474 resp.setLastModified(lastModified); |
1464 | 1475 |
1465 if (type.isTypeOf("dm_folder")) { | 1476 if (type.isTypeOf("dm_folder")) { |
1466 getFolderContent(resp, (IDfFolder) dmPersObj, id); | 1477 getFolderContent(resp, (IDfFolder) dmPersObj, id); |
1467 } else if (isValidatedDocumentType(type)) { | 1478 } else if (isValidatedDocumentType(type)) { |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1785 logger.log(Level.INFO, "Created a new session for the docbase {0}", | 1796 logger.log(Level.INFO, "Created a new session for the docbase {0}", |
1786 docbaseName); | 1797 docbaseName); |
1787 } finally { | 1798 } finally { |
1788 logger.log(Level.INFO, "Releasing dfc session for {0}", docbaseName); | 1799 logger.log(Level.INFO, "Releasing dfc session for {0}", docbaseName); |
1789 dmSessionManager.release(dmSession); | 1800 dmSessionManager.release(dmSession); |
1790 } | 1801 } |
1791 | 1802 |
1792 return dmSessionManager; | 1803 return dmSessionManager; |
1793 } | 1804 } |
1794 } | 1805 } |
OLD | NEW |