|
|
@ -146,7 +146,7 @@ public class Transactions {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean store(final SolrInputDocument doc, final boolean loadImage, final boolean replaceOld, final String proxy, final ClientIdentification.Agent agent, final String acceptLanguage) {
|
|
|
|
public static boolean store(final SolrInputDocument doc, final boolean concurrency, final boolean loadImage, final boolean replaceOld, final String proxy, final ClientIdentification.Agent agent, final String acceptLanguage) {
|
|
|
|
|
|
|
|
|
|
|
|
// GET METADATA FROM DOC
|
|
|
|
// GET METADATA FROM DOC
|
|
|
|
final String urls = (String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());
|
|
|
|
final String urls = (String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());
|
|
|
@ -160,17 +160,11 @@ public class Transactions {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CLEAN UP OLD DATA (if wanted)
|
|
|
|
boolean success = loadImage ? store(url, date, depth, concurrency, replaceOld, proxy, agent, acceptLanguage) : true;
|
|
|
|
Collection<File> oldPaths = Transactions.findPaths(url, depth, null, Transactions.State.INVENTORY);
|
|
|
|
if (success) {
|
|
|
|
if (replaceOld) {
|
|
|
|
|
|
|
|
for (File oldPath: oldPaths) oldPath.delete();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STORE METADATA FOR THE IMAGE
|
|
|
|
// STORE METADATA FOR THE IMAGE
|
|
|
|
File metadataPath = Transactions.definePath(url, depth, date, "xml", Transactions.State.INVENTORY);
|
|
|
|
File metadataPath = Transactions.definePath(url, depth, date, "xml", Transactions.State.INVENTORY);
|
|
|
|
metadataPath.getParentFile().mkdirs();
|
|
|
|
metadataPath.getParentFile().mkdirs();
|
|
|
|
boolean success = true;
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (doc != null) {
|
|
|
|
if (doc != null) {
|
|
|
|
FileOutputStream fos = new FileOutputStream(metadataPath);
|
|
|
|
FileOutputStream fos = new FileOutputStream(metadataPath);
|
|
|
@ -189,11 +183,29 @@ public class Transactions {
|
|
|
|
ConcurrentLog.logException(e);
|
|
|
|
ConcurrentLog.logException(e);
|
|
|
|
success = false;
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean store(final DigestURL url, final Date date, final int depth, final boolean concurrency, final boolean replaceOld, final String proxy, final ClientIdentification.Agent agent, final String acceptLanguage) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CLEAN UP OLD DATA (if wanted)
|
|
|
|
|
|
|
|
Collection<File> oldPaths = Transactions.findPaths(url, depth, null, Transactions.State.INVENTORY);
|
|
|
|
|
|
|
|
if (replaceOld && oldPaths != null) {
|
|
|
|
|
|
|
|
for (File oldPath: oldPaths) oldPath.delete();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STORE METADATA FOR THE IMAGE
|
|
|
|
|
|
|
|
File metadataPath = Transactions.definePath(url, depth, date, "xml", Transactions.State.INVENTORY);
|
|
|
|
|
|
|
|
metadataPath.getParentFile().mkdirs();
|
|
|
|
|
|
|
|
boolean success = true;
|
|
|
|
|
|
|
|
|
|
|
|
// STORE AN IMAGE
|
|
|
|
// STORE AN IMAGE
|
|
|
|
if (success && loadImage) {
|
|
|
|
final String urls = url.toNormalform(true);
|
|
|
|
final File pdfPath = Transactions.definePath(url, depth, date, "pdf", Transactions.State.INVENTORY);
|
|
|
|
final File pdfPath = Transactions.definePath(url, depth, date, "pdf", Transactions.State.INVENTORY);
|
|
|
|
if (executorRunning.intValue() < Runtime.getRuntime().availableProcessors()) {
|
|
|
|
if (concurrency && executorRunning.intValue() < Runtime.getRuntime().availableProcessors()) {
|
|
|
|
Thread t = new Thread(){
|
|
|
|
Thread t = new Thread(){
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
@ -209,7 +221,6 @@ public class Transactions {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
success = Html2Image.writeWkhtmltopdf(urls, proxy, agent.userAgent, acceptLanguage, pdfPath);
|
|
|
|
success = Html2Image.writeWkhtmltopdf(urls, proxy, agent.userAgent, acceptLanguage, pdfPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|