From d02ccd2beeafd2677bf1bf36f8ae411d68a38574 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Fri, 16 Sep 2016 10:59:14 +0200 Subject: [PATCH] SEARCH-146: Javadoc updates --- .../alfresco/solr/HandlerReportBuilder.java | 149 +++++++++++++----- 1 file changed, 111 insertions(+), 38 deletions(-) diff --git a/search-services/alfresco-solr/src/main/java/org/alfresco/solr/HandlerReportBuilder.java b/search-services/alfresco-solr/src/main/java/org/alfresco/solr/HandlerReportBuilder.java index 6c1e56f73..5ccd37ed8 100644 --- a/search-services/alfresco-solr/src/main/java/org/alfresco/solr/HandlerReportBuilder.java +++ b/search-services/alfresco-solr/src/main/java/org/alfresco/solr/HandlerReportBuilder.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ package org.alfresco.solr; import org.alfresco.httpclient.AuthenticationException; @@ -17,13 +38,67 @@ import java.util.Map; import java.util.Set; /** - * Created by gethin on 13/09/16. + * Methods taken from AlfrescoCoreAdminHandler that deal with building reports */ public class HandlerReportBuilder { + /** + * Builds AclReport + * @param tracker + * @param aclid + * @return + * @throws IOException + * @throws JSONException + */ + public static NamedList buildAclReport(AclTracker tracker, Long aclid) throws IOException, JSONException + { + AclReport aclReport = tracker.checkAcl(aclid); + + NamedList nr = new SimpleOrderedMap(); + nr.add("Acl Id", aclReport.getAclId()); + nr.add("Acl doc in index", aclReport.getIndexAclDoc()); + if (aclReport.getIndexAclDoc() != null) + { + nr.add("Acl tx in Index", aclReport.getIndexAclTx()); + } + + return nr; + } /** - * + * Builds TxReport + * @param trackerRegistry + * @param srv + * @param coreName + * @param tracker + * @param txid + * @return + * @throws AuthenticationException + * @throws IOException + * @throws JSONException + * @throws EncoderException + */ + public static NamedList buildTxReport(TrackerRegistry trackerRegistry, InformationServer srv, String coreName, MetadataTracker tracker, Long txid) + throws AuthenticationException, IOException, JSONException, EncoderException + { + NamedList nr = new SimpleOrderedMap(); + nr.add("TXID", txid); + nr.add("transaction", buildTrackerReport(trackerRegistry, srv, coreName, txid, txid, 0l, 0l, null, null)); + NamedList nodes = new SimpleOrderedMap(); + // add node reports .... + List dbNodes = tracker.getFullNodesForDbTransaction(txid); + for (Node node : dbNodes) + { + nodes.add("DBID " + node.getId(), buildNodeReport(tracker, node)); + } + + nr.add("txDbNodeCount", dbNodes.size()); + nr.add("nodes", nodes); + return nr; + } + + /** + * Builds AclTxReport * @param trackerRegistry * @param srv * @param coreName @@ -53,41 +128,14 @@ public class HandlerReportBuilder { return nr; } - - public static NamedList buildAclReport(AclTracker tracker, Long aclid) throws IOException, JSONException - { - AclReport aclReport = tracker.checkAcl(aclid); - - NamedList nr = new SimpleOrderedMap(); - nr.add("Acl Id", aclReport.getAclId()); - nr.add("Acl doc in index", aclReport.getIndexAclDoc()); - if (aclReport.getIndexAclDoc() != null) - { - nr.add("Acl tx in Index", aclReport.getIndexAclTx()); - } - - return nr; - } - - public static NamedList buildTxReport(TrackerRegistry trackerRegistry, InformationServer srv, String coreName, MetadataTracker tracker, Long txid) - throws AuthenticationException, IOException, JSONException, EncoderException - { - NamedList nr = new SimpleOrderedMap(); - nr.add("TXID", txid); - nr.add("transaction", buildTrackerReport(trackerRegistry, srv, coreName, txid, txid, 0l, 0l, null, null)); - NamedList nodes = new SimpleOrderedMap(); - // add node reports .... - List dbNodes = tracker.getFullNodesForDbTransaction(txid); - for (Node node : dbNodes) - { - nodes.add("DBID " + node.getId(), buildNodeReport(tracker, node)); - } - - nr.add("txDbNodeCount", dbNodes.size()); - nr.add("nodes", nodes); - return nr; - } - + /** + * Builds Node report + * @param tracker + * @param node + * @return + * @throws IOException + * @throws JSONException + */ public static NamedList buildNodeReport(MetadataTracker tracker, Node node) throws IOException, JSONException { NodeReport nodeReport = tracker.checkNode(node); @@ -108,6 +156,14 @@ public class HandlerReportBuilder { return nr; } + /** + * Builds Node Report + * @param tracker + * @param dbid + * @return + * @throws IOException + * @throws JSONException + */ public static NamedList buildNodeReport(MetadataTracker tracker, Long dbid) throws IOException, JSONException { NodeReport nodeReport = tracker.checkNode(dbid); @@ -128,7 +184,23 @@ public class HandlerReportBuilder { return nr; } - + /** + * Builds Tracker report + * @param trackerRegistry + * @param srv + * @param coreName + * @param fromTx + * @param toTx + * @param fromAclTx + * @param toAclTx + * @param fromTime + * @param toTime + * @return + * @throws IOException + * @throws JSONException + * @throws AuthenticationException + * @throws EncoderException + */ public static NamedList buildTrackerReport(TrackerRegistry trackerRegistry, InformationServer srv, String coreName, Long fromTx, Long toTx, Long fromAclTx, Long toAclTx, Long fromTime, Long toTime) throws IOException, JSONException, AuthenticationException, EncoderException { @@ -226,6 +298,7 @@ public class HandlerReportBuilder { /** + * Adds a core summary * @param cname * @param detail * @param hist