use of org.alfresco.repo.solr.Transaction in project alfresco-remote-api by Alfresco.
the class TransactionsGet method executeImpl.
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
String minTxnIdParam = req.getParameter("minTxnId");
String fromCommitTimeParam = req.getParameter("fromCommitTime");
String maxTxnIdParam = req.getParameter("maxTxnId");
String toCommitTimeParam = req.getParameter("toCommitTime");
String maxResultsParam = req.getParameter("maxResults");
String baseUrl = req.getParameter("baseUrl");
String hostName = req.getParameter("hostName");
String template = req.getParameter("template");
String instance = req.getParameter("instance");
String numberOfShards = req.getParameter("numberOfShards");
String port = req.getParameter("port");
String stores = req.getParameter("stores");
String isMaster = req.getParameter("isMaster");
String hasContent = req.getParameter("hasContent");
String shardMethod = req.getParameter("shardMethod");
String lastUpdated = req.getParameter("lastUpdated");
String lastIndexedChangeSetCommitTime = req.getParameter("lastIndexedChangeSetCommitTime");
String lastIndexedChangeSetId = req.getParameter("lastIndexedChangeSetId");
String lastIndexedTxCommitTime = req.getParameter("lastIndexedTxCommitTime");
String lastIndexedTxId = req.getParameter("lastIndexedTxId");
if (baseUrl != null) {
ShardState shardState = ShardStateBuilder.shardState().withMaster(Boolean.valueOf(isMaster)).withLastUpdated(Long.valueOf(lastUpdated)).withLastIndexedChangeSetCommitTime(Long.valueOf(lastIndexedChangeSetCommitTime)).withLastIndexedChangeSetId(Long.valueOf(lastIndexedChangeSetId)).withLastIndexedTxCommitTime(Long.valueOf(lastIndexedTxCommitTime)).withLastIndexedTxId(Long.valueOf(lastIndexedTxId)).withShardInstance().withBaseUrl(baseUrl).withPort(Integer.valueOf(port)).withHostName(hostName).withShard().withInstance(Integer.valueOf(instance)).withFloc().withNumberOfShards(Integer.valueOf(numberOfShards)).withTemplate(template).withHasContent(Boolean.valueOf(hasContent)).withShardMethod(ShardMethodEnum.getShardMethod(shardMethod)).endFloc().endShard().endShardInstance().build();
for (String store : stores.split(",")) {
shardState.getShardInstance().getShard().getFloc().getStoreRefs().add(new StoreRef(store));
}
for (String pName : req.getParameterNames()) {
if (pName.startsWith("floc.property.")) {
String key = pName.substring("floc.property.".length());
String value = req.getParameter(pName);
shardState.getShardInstance().getShard().getFloc().getPropertyBag().put(key, value);
} else if (pName.startsWith("state.property.")) {
String key = pName.substring("state.property.".length());
String value = req.getParameter(pName);
shardState.getPropertyBag().put(key, value);
}
}
solrTrackingComponent.registerShardState(shardState);
}
Long minTxnId = (minTxnIdParam == null ? null : Long.valueOf(minTxnIdParam));
Long fromCommitTime = (fromCommitTimeParam == null ? null : Long.valueOf(fromCommitTimeParam));
Long maxTxnId = (maxTxnIdParam == null ? null : Long.valueOf(maxTxnIdParam));
Long toCommitTime = (toCommitTimeParam == null ? null : Long.valueOf(toCommitTimeParam));
int maxResults = (maxResultsParam == null ? 1024 : Integer.valueOf(maxResultsParam));
List<Transaction> transactions = solrTrackingComponent.getTransactions(minTxnId, fromCommitTime, maxTxnId, toCommitTime, maxResults);
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
model.put("transactions", transactions);
Long maxTxnCommitTime = solrTrackingComponent.getMaxTxnCommitTime();
if (maxTxnCommitTime != null) {
model.put("maxTxnCommitTime", maxTxnCommitTime);
}
Long maxTxnIdOnServer = solrTrackingComponent.getMaxTxnId();
if (maxTxnIdOnServer != null) {
model.put("maxTxnId", maxTxnIdOnServer);
}
if (logger.isDebugEnabled()) {
logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
}
return model;
}
Aggregations