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
5 changes: 2 additions & 3 deletions src/org/labkey/targetedms/datasource/PsiInstruments.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.labkey.api.module.ModuleLoader;
import org.labkey.api.resource.FileResource;
import org.labkey.api.util.Path;
import org.labkey.api.util.XmlBeansUtil;
import org.labkey.targetedms.TargetedMSModule;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Expand All @@ -29,7 +30,6 @@
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -75,12 +75,11 @@ public static List<PsiInstrument> getInstruments()
LOG.error("File not found: psi-ms-PARSED.xml.");
return Collections.emptyList();
}
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
Document document;
try
{
db = dbf.newDocumentBuilder();
db = XmlBeansUtil.DOCUMENT_BUILDER_FACTORY.newDocumentBuilder();
document = db.parse(file);
}
catch (ParserConfigurationException | SAXException | IOException e)
Expand Down
4 changes: 2 additions & 2 deletions src/org/labkey/targetedms/parser/SkylineDocumentParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.labkey.api.util.Pair;
import org.labkey.api.util.Tuple3;
import org.labkey.api.util.UnexpectedException;
import org.labkey.api.util.XmlBeansUtil;
import org.labkey.targetedms.IrtPeptide;
import org.labkey.targetedms.SkylineDocImporter.IProgressStatus;
import org.labkey.targetedms.chromlib.ConnectionSource;
Expand Down Expand Up @@ -230,8 +231,7 @@ public SkylineDocumentParser(File file, Logger log, Container container, IProgre
_progressStatus = progressStatus;
_container = container;
_inputStream = new ProgressInputStream(new FileInputStream(_file));
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
_reader = inputFactory.createXMLStreamReader(_inputStream);
_reader = XmlBeansUtil.XML_INPUT_FACTORY.createXMLStreamReader(_inputStream);
_log = log;
readDocumentVersion(_reader);
}
Expand Down
4 changes: 2 additions & 2 deletions src/org/labkey/targetedms/parser/SpectrumFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import com.google.protobuf.InvalidProtocolBufferException;
import org.junit.Assert;
import org.junit.Test;
import org.labkey.api.util.XmlBeansUtil;
import org.labkey.targetedms.parser.proto.ChromatogramGroupDataOuterClass;
import org.labkey.targetedms.parser.proto.ChromatogramGroupDataOuterClass.ChromatogramGroupIdsProto.FilterOperation;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.StringReader;
Expand Down Expand Up @@ -260,7 +260,7 @@ public void testParse() throws Exception
" </spectrum_filter>",
" <bibliospec_spectrum_info count_measured=\"1\" />",
" </precursor>");
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
XMLStreamReader reader = XmlBeansUtil.XML_INPUT_FACTORY.createXMLStreamReader(new StringReader(xml));
int bibliospecSpectrumInfoCount = 0;
List<FilterClause> clauses = new ArrayList<>();
while (reader.hasNext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import org.apache.logging.log4j.Logger;
import org.labkey.api.util.UnexpectedException;
import org.labkey.api.util.XmlBeansUtil;
import org.labkey.targetedms.parser.proto.SkylineDocument;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.File;
Expand Down Expand Up @@ -38,7 +38,7 @@ public boolean isWithinLimits(File file, Logger log) throws XMLStreamException,
XMLStreamReader reader;
try (FileInputStream inputStream = new FileInputStream(file))
{
reader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
reader = XmlBeansUtil.XML_INPUT_FACTORY.createXMLStreamReader(inputStream);
try
{
readCounts(reader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import org.labkey.api.resource.FileResource;
import org.labkey.api.util.GUID;
import org.labkey.api.util.Path;
import org.labkey.api.util.XmlBeansUtil;
import org.labkey.targetedms.TargetedMSModule;
import org.labkey.targetedms.parser.XmlUtil;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;
Expand All @@ -44,7 +44,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.time.format.DateTimeParseException;
import java.util.Collections;
Expand Down Expand Up @@ -124,7 +123,7 @@ private void validateXml() throws IOException, SAXException, AuditLogParsingExce
}

@NotNull
private InputStream openSchemaInputStream() throws AuditLogParsingException, FileNotFoundException, UnsupportedEncodingException
private InputStream openSchemaInputStream() throws AuditLogParsingException, FileNotFoundException
{
if (ModuleLoader.getInstance() != null)
{ //if we are running web test
Expand All @@ -148,8 +147,7 @@ private InputStream openSchemaInputStream() throws AuditLogParsingException, Fil
private void parseLogHeader() throws IOException, XMLStreamException
{
_fileStream = new FileInputStream(_file);
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
_stream = inputFactory.createXMLStreamReader(_fileStream);
_stream = XmlBeansUtil.XML_INPUT_FACTORY.createXMLStreamReader(_fileStream);

//Skipping most XML structure validation since the file passed the schema validation
int evtType = _stream.nextTag(); //log root element read
Expand Down Expand Up @@ -305,8 +303,6 @@ public String getEnRootHash()
//--------------------------------------------
public static class TestCase extends Assert{

private File _logFile;
private SkylineAuditLogParser _parser;
private static final Logger _logger = LogManager.getLogger(TestCase.class);
public final static String SYS_PROPERTY_CWD = "user.dir";
public final static String SKYLINE_LOG_EXTENSION = "skyl";
Expand All @@ -325,49 +321,55 @@ public void testLogParser() throws XMLStreamException, AuditLogException, Audit
List<AuditLogEntry> entries = new LinkedList<>();

File fZip = UnitTestUtil.getSampleDataFile("AuditLogFiles/MethodEdit_v6.2.zip");
_logFile = UnitTestUtil.extractLogFromZip(fZip, _logger);
_parser = new SkylineAuditLogParser(_logFile, _logger);
Assert.assertNotNull(_parser.getEnRootHash());
File logFile = UnitTestUtil.extractLogFromZip(fZip, _logger);
try (SkylineAuditLogParser parser = new SkylineAuditLogParser(logFile, _logger))
{
Assert.assertNotNull(parser.getEnRootHash());

AuditLogEntry prevEntry = null;
AuditLogEntry prevEntry = null;

while(_parser.hasNextEntry())
{
AuditLogEntry ent = _parser.parseLogEntry();
ent.setDocumentGUID(_docGUID);
if(prevEntry != null)
ent.setParentEntryHash(prevEntry.getEntryHash());
entries.add(ent);
_logger.debug(ent.toString());
//all messages in this file should have expanded text
//ent.persist();

for(AuditLogMessage msg : ent.getAllInfoMessage())
while (parser.hasNextEntry())
{
Assert.assertNotNull(msg.getEnText());
AuditLogEntry ent = parser.parseLogEntry();
ent.setDocumentGUID(_docGUID);
if (prevEntry != null)
ent.setParentEntryHash(prevEntry.getEntryHash());
entries.add(ent);
_logger.debug(ent.toString());
//all messages in this file should have expanded text
//ent.persist();

for (AuditLogMessage msg : ent.getAllInfoMessage())
{
Assert.assertNotNull(msg.getEnText());
}
prevEntry = ent;
}
prevEntry = ent;
}

Assert.assertNotNull(entries.get(2).getExtraInfo());
Assert.assertNull(entries.get(1).getExtraInfo());
Assert.assertNotNull(entries.get(2).getExtraInfo());
Assert.assertNull(entries.get(1).getExtraInfo());

Assert.assertEquals(11, entries.size());
Assert.assertEquals(6, entries.get(5).getAllInfoMessage().size());
Assert.assertTrue(entries.get(0).canBeHashed());
Assert.assertEquals(11, entries.size());
Assert.assertEquals(6, entries.get(5).getAllInfoMessage().size());
Assert.assertTrue(entries.get(0).canBeHashed());
}
}

@Test
public void testInvalidXmlFile() throws IOException
{
SkylineAuditLogParser parser = null;
try
{
File logFile = UnitTestUtil.getSampleDataFile("AuditLogFiles/InvalidSchemaTest.skyl");
SkylineAuditLogParser parser = new SkylineAuditLogParser(logFile, _logger);
parser = new SkylineAuditLogParser(logFile, _logger);
Assert.fail("Expected file validation failure but it succeeded.");
}
catch (AuditLogException ignored)
catch (AuditLogException _) {}
finally
{
if (parser != null)
parser.close();
}
}

Expand Down
2 changes: 1 addition & 1 deletion webapp/TargetedMS/js/LinkVersionsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Ext4.define('LABKEY.targetedms.LinkedVersions', {
removeColumnCellClick : function(grid, td, cellIndex, record, tr, rowIndex, e) {
// 'Remove' column listener to remove a record from an existing method chain
if (cellIndex == 0 && e.target.className.indexOf('remove-link-version') > 0) {
Ext4.Msg.confirm('Remove Confirmation', 'Are you sure you want to remove <b>' + record.get('File/FileName')
Ext4.Msg.confirm('Remove Confirmation', 'Are you sure you want to remove <b>' + LABKEY.Utils.encodeHtml(record.get('File/FileName'))
+ '</b> from its existing method chain?',
function(btnId) {
if (btnId == 'yes') {
Expand Down
2 changes: 1 addition & 1 deletion webapp/passport/js/beforeAfter/protein.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protein =

var label = document.createElement('Label');
label.setAttribute("for",checkbox.id);
label.innerHTML = capitalizeFirstLetter(type);
label.innerText = capitalizeFirstLetter(type);
label.setAttribute("style", "padding-left: 5px; border-left: 5px solid "+protein.UI.features.colors[featureId] +";");

var listItem = document.createElement("li");
Expand Down