Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@
import org.bitrepository.protocol.messagebus.MessageBusManager;
import org.bitrepository.protocol.security.SecurityManager;
import org.bitrepository.settings.referencesettings.ProtocolType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Provides access to the different component in the org.bitrepository.org.bitrepository.protocol module (Spring/IOC wannabe)
*/
public final class ProtocolComponentFactory {
private static final Logger log = LoggerFactory.getLogger(ProtocolComponentFactory.class);
private static ProtocolComponentFactory instance;

public static synchronized ProtocolComponentFactory getInstance() {
Expand Down Expand Up @@ -84,7 +87,8 @@ public FileExchange getFileExchange(Settings settings) {
} else if (protocolType == ProtocolType.HTTPS) {
fileExchange = new HttpsFileExchange(settings);
} else if (protocolType == ProtocolType.FILE) {
fileExchange = new LocalFileExchange(settings.getReferenceSettings().getFileExchangeSettings().getPath());
fileExchange = new LocalFileExchange(
settings.getReferenceSettings().getFileExchangeSettings().getPath());
}
} else {
fileExchange = new HttpFileExchange(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,10 @@
</PillarDetails>
</PillarIntegrityDetails>
</IntegrityServiceSettings>
<FileExchangeSettings>
<ProtocolType>HTTP</ProtocolType>
<ServerName>localhost</ServerName>
<Port>80</Port>
<Path>/dav</Path>
</FileExchangeSettings>
</ReferenceSettings>
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void generateReport() throws IOException {
private String generateSummary() {
StringBuilder report = new StringBuilder();
if (deletedFilesCount != 0L) {
report.append("Detected ").append(deletedFilesCount).append(" files as removed from the collection.");
report.append("\n").append("Detected ").append(deletedFilesCount).append(" file(s) as removed from the collection.");
}
for (String pillar : missingFiles.keySet()) {
if (missingFiles.get(pillar) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
import java.util.Map;

/**
* A workflow step for finding missing checksums.
* Uses the IntegrityChecker to perform the actual check.
* A workflow step for creating pillar statistics.
*/
public class CreateStatisticsEntryStep extends AbstractWorkFlowStep {
private final IntegrityModel store;
Expand All @@ -51,8 +50,7 @@ public String getName() {
}

/**
* Uses IntegrityChecker to validate whether any checksums are missing.
* Dispatches an alarm if any checksums were missing.
* Collects pillar metrics for the given collection and creates from them a statistics entry in the store.
*/
@Override
public synchronized void performStep() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ private File makeTemporaryChecksumFile(GetChecksumsRequest request,
}

// Print all the checksums safely (close the streams!)
try (OutputStream is = new FileOutputStream(checksumResultFile)) {
try (OutputStream os = new FileOutputStream(checksumResultFile)) {
JaxbHelper jaxb = new JaxbHelper(XSD_CLASSPATH, XSD_BR_DATA);
String xmlMessage = jaxb.serializeToXml(results);
jaxb.validate(new ByteArrayInputStream(xmlMessage.getBytes(StandardCharsets.UTF_8)));
is.write(xmlMessage.getBytes(StandardCharsets.UTF_8));
is.flush();
os.write(xmlMessage.getBytes(StandardCharsets.UTF_8));
os.flush();
}

return checksumResultFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ protected File createAuditTrailFile(GetAuditTrailsRequest request, AuditTrailDat
results.setCollectionID(request.getCollectionID());
results.getAuditTrailEvents().add(extractedAuditTrails.getAuditTrailEvents());

try (OutputStream is = new FileOutputStream(checksumResultFile)) {
try (OutputStream os = new FileOutputStream(checksumResultFile)) {
JaxbHelper jaxb = new JaxbHelper(XSD_CLASSPATH, XSD_BR_DATA);
String xmlMessage = jaxb.serializeToXml(results);
jaxb.validate(new ByteArrayInputStream(xmlMessage.getBytes(StandardCharsets.UTF_8)));
is.write(xmlMessage.getBytes(StandardCharsets.UTF_8));
is.flush();
os.write(xmlMessage.getBytes(StandardCharsets.UTF_8));
os.flush();
}

return checksumResultFile;
Expand Down

This file was deleted.

104 changes: 52 additions & 52 deletions bitrepository-webclient/src/main/webapp/alarm-service.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
<div class="row-fluid">
<div class="span11">
<div class="span11" style="height:0px; min-height:0px"></div>
<div class="span11"><h2>Alarm service</h2></div>
<div class="span11">
<h2>Alarm service</h2>
</div>
<div class="span11">
<form class="form-inline">
<legend>Alarm display filters</legend>
Expand Down Expand Up @@ -133,7 +135,7 @@

<script>
let nameMapper;
let descriptionMapper;
let descriptionExpandedMapper;
let autoGetAlarmsInterval;
let alarmServiceUrl;

Expand All @@ -151,7 +153,7 @@
let collectionIDStr = $("#collectionIDFilter").val();
let url = alarmServiceUrl + '/alarm/AlarmService/queryAlarms/';

getDescriptionState();
getDescriptionExpandedState();

$.post(url,
{
Expand All @@ -163,65 +165,51 @@
maxAlarms: maxAlarmStr,
collectionID: collectionIDStr,
oldestAlarmFirst: false
}, function (j) {
}, function (json) {
let htmlTableBody = "";
if (j != null) {
for (let i = 0; i < j.length; i++) {
if (json != null) {
for (let i = 0; i < json.length; i++) {
htmlTableBody += `<tr>
<td>${j[i].origDateTime}</td>
<td>${j[i].alarmRaiser}</td>
<td>${nameMapper.getName(j[i].collectionID)}</td>
<td>${j[i].fileID}</td>
<td>${j[i].alarmCode}</td>
<td class="description"><p class="teaser">${nl2br(j[i].alarmText)}</p></td>
<td>${json[i].origDateTime}</td>
<td>${json[i].alarmRaiser}</td>
<td>${nameMapper.getName(json[i].collectionID)}</td>
<td>${json[i].fileID}</td>
<td>${json[i].alarmCode}</td>
<td class="description">${renderAlarmDescription(i, json[i].alarmText).prop('outerHTML')}</td>
</tr>`;
}
}
$("#alarms-table-body").html(htmlTableBody);
compressDescription();
enableDescriptionExpansionOnClick();
});
}

function init() {
$.get('repo/urlservice/alarmService/', {}, function (url) {
alarmServiceUrl = url;
}, 'html').done(function () {
$.getJSON('repo/reposervice/getCollections/', {}, function (collections) {
nameMapper = new CollectionNameMapper(collections);
let cols = nameMapper.getCollectionIDs();
for (let i in cols) {
$("#collectionIDFilter").append(
`<option value="${cols[i]}">${nameMapper.getName(cols[i])}</option>`
);
}
updateAlarms();
autoGetAlarmsInterval = setInterval(function () {
updateAlarms();
}, 2500);
});
function getDescriptionExpandedState() {
descriptionExpandedMapper = {};
$("#alarms-table-body tr").each(function (index) {
// Grab the
descriptionExpandedMapper[index] = $(this).find("td:eq(5)").find(".complete").css("display");
});
}

function compressDescription() {
function renderAlarmDescription(index, alarmDescription) {
const maxLength = 80;
$(".teaser").each(function () {
let index = $(this).closest("tr").find("td:eq(0)").text() + $(this).text();
let string = $(this).html();
let descriptionHtml = $('<p class="teaser">').css("margin", 0);
let isExpandedDesc = descriptionExpandedMapper.hasOwnProperty(index) &&
descriptionExpandedMapper[index] !== "none";

if (descriptionMapper.hasOwnProperty(index) && descriptionMapper[index] !== "none") {
$(this).empty().html(`<span class="complete" style="display: inline">${string}</span>`);
} else {
if (string.length > maxLength) {
let newString = string.substring(0, maxLength);
let removedString = string.substring(maxLength, string.length);
$(this).empty().html(newString);
$(this).append(`<span class="dots">... </span>`)
$(this).append(`<span class="complete">${removedString}</span>`);
$(this).append('<a href="javascript:void(0);" class="show-more">show more</a>');
}
}
});
if (alarmDescription.length <= maxLength || isExpandedDesc) {
let fullDescSpan = `<span class="complete" style="display: inline">${nl2br(alarmDescription)}</span>`
descriptionHtml.empty().html(fullDescSpan);
} else { // Alarm description is too long and is not expanded
let shortenedDesc = alarmDescription.substring(0, maxLength);
let remainingDesc = alarmDescription.substring(maxLength, alarmDescription.length);
descriptionHtml.empty().html(nl2br(shortenedDesc));
descriptionHtml.append(`<span class="dots">... </span>`)
descriptionHtml.append(`<span class="complete">${nl2br(remainingDesc)}</span>`);
descriptionHtml.append('<a href="javascript:void(0);" class="show-more">show more</a>');
}
return descriptionHtml;
}

function enableDescriptionExpansionOnClick() {
Expand All @@ -234,11 +222,23 @@
});
}

function getDescriptionState() {
descriptionMapper = {};
$("#alarms-table-body tr").each(function () {
let identifier = $(this).find("td:eq(0)").text() + $(this).find("td:eq(5)").text();
descriptionMapper[identifier] = $(this).find("td:eq(5)").find(".complete").css("display");
function init() {
$.get('repo/urlservice/alarmService/', {}, function (url) {
alarmServiceUrl = url;
}, 'html').done(function () {
$.getJSON('repo/reposervice/getCollections/', {}, function (collections) {
nameMapper = new CollectionNameMapper(collections);
let cols = nameMapper.getCollectionIDs();
for (let i in cols) {
$("#collectionIDFilter").append(
`<option value="${cols[i]}">${nameMapper.getName(cols[i])}</option>`
);
}
updateAlarms();
autoGetAlarmsInterval = setInterval(function () {
updateAlarms();
}, 2500);
});
});
}

Expand Down