test.junit.fedora.server.journal.readerwriter.multicast.SampleJournalEntries Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fcrepo-client Show documentation
Show all versions of fcrepo-client Show documentation
The Fedora Client is a Java Library that allows API access to a Fedora Repository. The client is typically one part of a full Fedora installation.
The newest version!
package fedora.server.journal.readerwriter.multicast;
import java.io.ByteArrayInputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import fedora.server.MultiValueMap;
import fedora.server.journal.JournalException;
import fedora.server.journal.entry.CreatorJournalEntry;
import fedora.server.journal.entry.JournalEntryContext;
/**
*
* SampleJournalEntries.java
*
*
* Some sample CreatorJournalEntry objects for use in unit tests.
*
*
* KLUGE: add more sample entries from these files:
* C:\FedoraArchiveFiles\fedoraJournal20070130.154626.282Z,
* C:\FedoraArchiveFiles\fedoraJournal20070130.154628.282Z,
* C:\FedoraArchiveFiles\fedoraJournal20070130.154627.892Z
*
*
* @author jblake
* @version $Id: SampleJournalEntries.java,v 1.3 2007/06/01 17:21:32 jblake Exp $
*/
public class SampleJournalEntries {
public static final CreatorJournalEntry ENTRY_1;
public static final CreatorJournalEntry ENTRY_1A;
public static final CreatorJournalEntry ENTRY_2;
public static final CreatorJournalEntry ENTRY_3;
public static final List ALL_ENTRIES;
private static final String[][] EMPTY = new String[0][2];
private static final Date DATE_1 = createDate("2007-02-18T08:55:07.951Z");
private static final String CONTENT_1 =
"\n"
+ "\n"
+ " http://serc.carleton.edu/introgeo/roleplaying/examples/globwarm.html \n"
+ " Calculation or Conversion Tool \n"
+ " Scientific Visualization \n"
+ " Image \n"
+ " InteractiveResource \n"
+ " Software \n"
+ " Text \n"
+ " Lesson \n"
+ " Course \n"
+ " Project \n"
+ " Reference \n"
+ " Illustration \n"
+ " Map \n"
+ " Remotely Sensed Imagery \n"
+ " Simulation \n"
+ " text/html \n"
+ " Adobe Acrobat reader \n"
+ " video/quicktime \n"
+ " Microsoft Windows \n"
+ " Macintosh \n"
+ " en \n"
+ " 2001-01-01 \n"
+ " The World Watcher Project: The Global Warming Project \n"
+ " Climatology \n"
+ " Environmental science \n"
+ " Cryology \n"
+ " Physical geography \n"
+ " Atmospheric science \n"
+ " Remote Sensing \n"
+ " Systems \n"
+ " Heat & Energy \n"
+ " Climate Change \n"
+ " Scientific Visualization \n"
+ " image processing \n"
+ " Atmosphere \n"
+ " Global Climate Systems \n"
+ " Environmental Science \n"
+ " Human geography \n"
+ " Topography/Physical Geography \n"
+ " Policy issues \n"
+ " Composition and Chemistry \n"
+ " Atmospheric Dynamics \n"
+ " Global Warming \n"
+ " Weather \n"
+ " Anthropogenic Activity \n"
+ " Systems, Interactions, Feedback Loops \n"
+ " Science \n"
+ " Earth science \n"
+ " Physical sciences \n"
+ " Meteorology \n"
+ " Geology \n"
+ " Geography \n"
+ " Chemistry \n"
+ " Physics \n"
+ " Astronomy \n"
+ " Space sciences \n"
+ " Global warming and its potential impact provide the context for this unit, in which students learn about the scientific factors contributing to the debate. Students act as advisors to the heads of state of several nations and explore the issues as they respond to the various questions and concerns of these leaders. Activities include a combination of physical labs and investigations using World Watcher software, a geographic data visualization tool developed by Northwestern University. \n"
+ " This product is free and clear for general use. \n"
+ " Middle School \n"
+ " High School \n"
+ " \n" + "\n";
private static final String[][] ENVIRONMENT_1 =
new String[][] {
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:authType",
"BASIC"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:security",
"urn:fedora:names:fedora:2.1:environment:httpRequest:security-secure"},
{"urn:fedora:names:fedora:2.1:environment:currentDate",
"2007-02-18Z"},
{"urn:fedora:names:fedora:2.1:environment:currentTime",
"08:55:07.951Z"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:sessionStatus",
"invalid"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:scheme",
"https"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:clientIpAddress",
"127.0.0.1"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:contentLength",
"6730"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:clientFqdn",
"repo5.nsdl.org"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:serverIpAddress",
"127.0.0.1"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:serverPort",
"8843"},
{"urn:fedora:names:fedora:2.1:environment:currentDateTime",
"2007-02-18T08:55:07.951Z"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:messageProtocol",
"urn:fedora:names:fedora:2.1:environment:httpRequest:messageProtocol-soap"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:contentType",
"text/xml; charset=utf-8"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:method",
"POST"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:protocol",
"HTTP/1.0"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:serverFqdn",
"repo5.nsdl.org"}};
private static final String[][] SUBJECT_1 =
new String[][] {
{"fedoraRole", "administrator"},
{"urn:fedora:names:fedora:2.1:subject:loginId",
"fedoraAdmin"}};
private static final String[][] RESOURCE_1 =
new String[][] {
{
"urn:fedora:names:fedora:2.1:resource:datastream:newState",
"A"},
{
"urn:fedora:names:fedora:2.1:resource:datastream:newFormatUri",
"unknown"},
{
"urn:fedora:names:fedora:2.1:resource:datastream:newMimeType",
"application/xml"},
{"urn:fedora:names:fedora:2.1:resource:datastream:id",
"format_nsdl_dc"}};
private static final String CONTENT_2 =
"\n"
+ "\n"
+ "\n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " NSDL Metadata Provider \n"
+ " hdl:2200%2F20070216150029939T \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " MetadataProvider \n"
+ " 2200/20070216150029939T \n"
+ " \n"
+ " \n"
+ " \n"
+ " 2802851 \n"
+ " 2802851 \n"
+ " The Teaching Company: Science and Mathematics Courses \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " The Teaching Company: Science and Mathematics Courses OAI Service \n"
+ " Provides The Teaching Company: Science and Mathematics Courses records \n"
+ " MetadataProvider \n"
+ " \n"
+ " http://crs.nsdl.org/brands/2802851.jpg \n"
+ " The Teaching Company: Science and Mathematics Courses \n"
+ " 100 \n"
+ " 30 \n"
+ " \n"
+ " \n"
+ " \n"
+ " none specified \n"
+ " [email protected] \n"
+ " OAI Admin \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " http://grackle.cc.columbia.edu/cwis/SPT--OAI.php \n"
+ " 2802851 \n"
+ " harvest \n"
+ " [email protected] \n"
+ " \n"
+ " 2007-02-08 \n"
+ " \n"
+ " Publisher:Scientific_American \n"
+ " Publisher:Cambridge_University_Press_UK \n"
+ " Publisher:Cambridge_University_Press_US \n"
+ " Publisher:Columbia_University_Press \n"
+ " Publisher:American_Mathematical_Society \n"
+ " Publisher:Tool_Factory_Inc. \n"
+ " Publisher:John_Wiley_and_Sons \n"
+ " Publisher:Houghton_Mifflin_Science_Education_Place \n"
+ " Publisher:Prentice_Hall \n"
+ " Publisher:The_Apprentice_Corporation \n"
+ " Publisher:test \n"
+ " Publisher:Elsevier_Science_and_Technology \n"
+ " Publisher:Elsevier_Science_and_Technology \n"
+ " Publisher:Elsevier Science and Technology \n"
+ " Publisher:McDougal_Littell \n"
+ " Publisher:McDougal_Littel \n"
+ " Publisher:The_Teaching_Company \n"
+ " Publisher:The_Apprentice_Corporation_Non_Profit \n"
+ " Publisher:American_Ed \n"
+ " Publisher:Aimstar \n"
+ " Publisher:Autodesk \n"
+ " Publisher:Riverdeep_The_Learning_Company \n"
+ " Publisher:Sunburst \n"
+ " Publisher:LCSI \n"
+ " Publisher:Lynda.com \n"
+ " Publisher:Clearvue \n"
+ " Publisher:APTE \n"
+ " Publisher:Homeworkhelp.com \n"
+ " Publisher:Atomic_Learning \n"
+ " Publisher:ATEEC \n"
+ " Publisher:Avid \n"
+ " Publisher:Barnum_Software \n"
+ " Publisher:Learning_Company \n"
+ " Publisher:PCI_Educational_Publishing \n"
+ " Publisher:ADAM_Software \n"
+ " Publisher:Bagatrix \n"
+ " Publisher:Block_Publishing \n"
+ " Publisher:Cabrilog \n"
+ " Publisher:CyberEd \n"
+ " Publisher:Centron \n"
+ " Publisher:Chariot_Software \n"
+ " Publisher:Canela_Software \n"
+ " Publisher:Cord_Communications \n"
+ " Publisher:Core_Learning \n"
+ " Publisher:MathRealm \n"
+ " Publisher:Course_Technology \n"
+ " Publisher:Chemware \n"
+ " Publisher:Knowledge_Adventure \n"
+ " Publisher:Discovery_Education \n"
+ " Publisher:DeMarque,_Inc \n"
+ " Publisher:Ingenuity_Works \n"
+ " Publisher:Gamco \n"
+ " Publisher:Encore_Software \n"
+ " Publisher:Essential_Skills \n"
+ " Publisher:Emanuel_Software \n"
+ " Publisher:EOA_Scientific \n"
+ " Publisher:Edusoft \n"
+ " Publisher:Edu2000_America \n"
+ " Publisher:EdVenture \n"
+ " Publisher:Dorling_Kindersley_by_GSP \n"
+ " Publisher:Facts_on_File \n"
+ " Publisher:Focus_Educational_Software_Ltd \n"
+ " Publisher:FSCreations,_Inc. \n"
+ " Publisher:FTC_Publishing \n"
+ " Publisher:Scholastic_Software \n"
+ " Publisher:GollyGee_Software \n"
+ " Publisher:Gallopade_International \n"
+ " Publisher:Hotmath.com \n"
+ " Publisher:Hopkins_Technology \n"
+ " Publisher:Heartsoft \n"
+ " Publisher:Cambridgesoft \n"
+ " Publisher:Interactive_Learning \n"
+ " Publisher:Ideas_Learning \n"
+ " Publisher:AIMS Multimedia \n"
+ " Publisher:Queue \n"
+ " Publisher:SYSTAT \n"
+ " Publisher:Jaguar_Educational \n"
+ " Publisher:Inspiration_Software \n"
+ " Publisher:Academic_Hallmarks \n"
+ " Publisher:Kognito \n"
+ " Publisher:Kutoka \n"
+ " Publisher:Learning_Zone_Express \n"
+ " Publisher:Learning_Multi-Systems \n"
+ " Publisher:Learning_Team \n"
+ " Publisher:Maestro_Learning \n"
+ " Publisher:MCH_Multimedia \n"
+ " Publisher:MegaSystems \n"
+ " Publisher:Micrograms \n"
+ " Publisher:Milliken_Software \n"
+ " Publisher:Adobe_Press \n"
+ " Publisher:SVE \n"
+ " Publisher:MathResources \n"
+ " Publisher:Microsoft \n"
+ " Publisher:Multimedia_Science \n"
+ " Publisher:Sleek_Software \n"
+ " Publisher:Attainment_Company \n"
+ " Publisher:Tom_Snyder_Productions \n"
+ " Publisher:Ventura \n"
+ " Publisher:Optimum_Resource \n"
+ " Publisher:MathSoft \n"
+ " Publisher:Critical_Thinking \n"
+ " Publisher:Nordic_Software \n"
+ " Publisher:NECTAR_Foundation \n"
+ " Publisher:NeoSci \n"
+ " Publisher:2Simple_Software \n"
+ " Publisher:Pintar_Learning \n"
+ " Publisher:Maplesoft \n"
+ " Publisher:4:20_Communications \n"
+ " Publisher:Broderbund \n"
+ " Publisher:QA-Kids \n"
+ " Publisher:REMedia \n"
+ " Publisher:ScienceWorks \n"
+ " Publisher:Seeds_Software \n"
+ " Publisher:sciPROOF \n"
+ " Publisher:Sing_'n'_Learn_Software \n"
+ " Publisher:SPSS \n"
+ " Publisher:Imaginova \n"
+ " Publisher:School_Zone \n"
+ " Publisher:Two-Can_Publishing \n"
+ " Publisher:Tool_Factory \n"
+ " Publisher:Bright_Science \n"
+ " Publisher:Digital_Frog \n"
+ " Publisher:SuperSchool_Software \n"
+ " Publisher:Vernier \n"
+ " Publisher:Visions_Technology \n"
+ " Publisher:Wildridge_Software \n"
+ " Publisher:Pre-Engineering_Software \n"
+ " Publisher:Brighter_Minds \n"
+ " Publisher:Texas_Instruments \n"
+ " Publisher:Wolfram_Research \n"
+ " \n" + " \n"
+ " nsdl_dc \n"
+ " \n"
+ " true \n"
+ " \n" + " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n" + " \n"
+ "\n";
private static final String[][] ENVIRONMENT_2 =
new String[][] {
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:authType",
"BASIC"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:security",
"urn:fedora:names:fedora:2.1:environment:httpRequest:security-secure"},
{"urn:fedora:names:fedora:2.1:environment:currentDate",
"2007-02-16Z"},
{"urn:fedora:names:fedora:2.1:environment:currentTime",
"20:00:31.139Z"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:sessionStatus",
"invalid"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:scheme",
"https"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:clientIpAddress",
"127.0.0.1"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:contentLength",
"16904"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:clientFqdn",
"repo5.nsdl.org"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:serverIpAddress",
"127.0.0.1"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:serverPort",
"8843"},
{"urn:fedora:names:fedora:2.1:environment:currentDateTime",
"2007-02-16T20:00:31.139Z"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:messageProtocol",
"urn:fedora:names:fedora:2.1:environment:httpRequest:messageProtocol-soap"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:contentType",
"text/xml; charset=utf-8"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:method",
"POST"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:protocol",
"HTTP/1.0"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:serverFqdn",
"repo5.nsdl.org"}};
private static final String[][] SUBJECT_2 =
new String[][] {
{"fedoraRole", "administrator"},
{"urn:fedora:names:fedora:2.1:subject:loginId",
"fedoraAdmin"}};
private static final String[][] RESOURCE_2 =
new String[][] {
{"urn:fedora:names:fedora:2.1:resource:object:encoding",
"UTF-8"},
{"urn:fedora:names:fedora:2.1:resource:object:formatUri",
"foxml1.0"}};
private static final String[][] RECOVERY_2 =
new String[][] {{"info:fedora/fedora-system:def/recovery#pid",
"hdl:2200%2F20070216150029939T"}};
private static final String[][] ENVIRONMENT_3 =
new String[][] {
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:authType",
"BASIC"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:security",
"urn:fedora:names:fedora:2.1:environment:httpRequest:security-insecure"},
{"urn:fedora:names:fedora:2.1:environment:currentDate",
"2007-01-30Z"},
{"urn:fedora:names:fedora:2.1:environment:currentTime",
"15:46:36.470Z"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:sessionStatus",
"invalid"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:scheme",
"http"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:clientIpAddress",
"127.0.0.1"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:contentLength",
"1806"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:clientFqdn",
"localhost"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:serverIpAddress",
"127.0.0.1"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:serverPort",
"8080"},
{"urn:fedora:names:fedora:2.1:environment:currentDateTime",
"2007-01-30T15:46:36.470Z"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:messageProtocol",
"urn:fedora:names:fedora:2.1:environment:httpRequest:messageProtocol-soap"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:contentType",
"text/xml; charset=utf-8"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:method",
"POST"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:protocol",
"HTTP/1.1"},
{
"urn:fedora:names:fedora:2.1:environment:httpRequest:serverFqdn",
"localhost"}};
private static final String[][] SUBJECT_3 =
new String[][] {
{"fedoraRole", "administrator"},
{"urn:fedora:names:fedora:2.1:subject:loginId",
"fedoraAdmin"}};
private static final String[][] RESOURCE_3 =
new String[][] {
{
"urn:fedora:names:fedora:2.1:resource:datastream:newState",
"A"},
{
"urn:fedora:names:fedora:2.1:resource:datastream:newFormatUri",
"\n"},
{
"urn:fedora:names:fedora:2.1:resource:datastream:newMimeType",
"text/html"},
{
"urn:fedora:names:fedora:2.1:resource:datastream:newLocation",
"http://myserver.edu/mydir/aDifferentFile.html"},
{"urn:fedora:names:fedora:2.1:resource:datastream:id",
"DS1"}};
/**
* Make sure that the other constants have been initialized before this
* static block appears.
*/
static {
ENTRY_1 = createSampleEntry1();
ENTRY_1A = createSampleEntry1a();
ENTRY_2 = createSampleEntry2();
ENTRY_3 = createSampleEntry3();
ALL_ENTRIES =
Collections.unmodifiableList(Arrays
.asList(new CreatorJournalEntry[] {ENTRY_1, ENTRY_1A,
ENTRY_2, ENTRY_3}));
}
private static CreatorJournalEntry createSampleEntry1() {
try {
JournalEntryContext context =
buildContext("somePassword",
false,
DATE_1,
ENVIRONMENT_1,
SUBJECT_1,
EMPTY,
RESOURCE_1,
EMPTY);
CreatorJournalEntry entry =
new CreatorJournalEntry("modifyDatastreamByValue", context);
entry.addArgument("pid", "hdl:2200%2F20061003155524381T");
entry.addArgument("dsId", "format_nsdl_dc");
entry.addArgument("altIds", new String[0]);
entry.addArgument("dsLabel", "format_nsdl_dc data stream");
entry.addArgument("versionable", true);
entry.addArgument("mimeType", "application/xml");
entry.addArgument("formatUri", "unknown");
entry.addArgument("dsContent", buildInputStream(CONTENT_1));
entry.addArgument("dsState", "A");
entry.addArgument("message", "Modified by NSDL API");
entry.addArgument("force", true);
return entry;
} catch (JournalException e) {
return null;
}
}
/**
* Try entry 1 again, with null input stream.
*/
private static CreatorJournalEntry createSampleEntry1a() {
try {
JournalEntryContext context =
buildContext("somePassword",
false,
new Date(),
ENVIRONMENT_1,
SUBJECT_1,
EMPTY,
RESOURCE_1,
EMPTY);
CreatorJournalEntry entry =
new CreatorJournalEntry("modifyDatastreamByValue", context);
entry.addArgument("pid", "hdl:2200%2F20061003155524381T");
entry.addArgument("dsId", "format_nsdl_dc");
entry.addArgument("altIds", new String[0]);
entry.addArgument("dsLabel", "format_nsdl_dc data stream");
entry.addArgument("versionable", true);
entry.addArgument("mimeType", "application/xml");
entry.addArgument("formatUri", "unknown");
entry.addArgument("dsContent", null);
entry.addArgument("dsState", "A");
entry.addArgument("message", "Modified by NSDL API");
entry.addArgument("force", true);
return entry;
} catch (JournalException e) {
return null;
}
}
private static CreatorJournalEntry createSampleEntry2() {
try {
JournalEntryContext context =
buildContext("bogusStuff",
false,
new Date(),
ENVIRONMENT_2,
SUBJECT_2,
EMPTY,
RESOURCE_2,
RECOVERY_2);
CreatorJournalEntry entry =
new CreatorJournalEntry("ingestObject", context);
entry.addArgument("serialization", buildInputStream(CONTENT_2));
entry.addArgument("message", "Metadata provider added by NSDL API");
entry.addArgument("format", "foxml1.0");
entry.addArgument("encoding", "UTF-8");
entry.addArgument("newPid", true);
return entry;
} catch (JournalException e) {
return null;
}
}
private static CreatorJournalEntry createSampleEntry3() {
JournalEntryContext context =
buildContext("mySecretWord",
false,
new Date(),
ENVIRONMENT_3,
SUBJECT_3,
EMPTY,
RESOURCE_3,
EMPTY);
CreatorJournalEntry entry =
new CreatorJournalEntry("modifyDatastreamByReference", context);
entry.addArgument("pid", "demo:19");
entry.addArgument("dsId", "DS1");
entry.addArgument("altIds", new String[] {"this", "that", "another"});
entry.addArgument("dsLabel", "A different source and some AltIDs");
entry.addArgument("versionable", true);
entry.addArgument("mimeType", "text/html");
entry.addArgument("formatUri", "\n");
entry.addArgument("dsLocation",
"http://myserver.edu/mydir/aDifferentFile.html");
entry.addArgument("dsState", "A");
entry.addArgument("message", "Modify by Reference with AltIDs");
entry.addArgument("force", false);
return entry;
}
private static JournalEntryContext buildContext(String password,
boolean noop,
Date now,
String[][] environment,
String[][] subject,
String[][] action,
String[][] resource,
String[][] recovery) {
JournalEntryContext context = new JournalEntryContext();
context.setPassword(password);
context.setNoOp(noop);
context.setNow(now);
context.setEnvironmentAttributes(buildMultiMap(environment));
context.setSubjectAttributes(buildMultiMap(subject));
context.setActionAttributes(buildMultiMap(action));
context.setResourceAttributes(buildMultiMap(resource));
context.setRecoveryAttributes(buildMultiMap(recovery));
return context;
}
private static ByteArrayInputStream buildInputStream(String content) {
return new ByteArrayInputStream(content.getBytes());
}
private static MultiValueMap buildMultiMap(String[][] pairs) {
MultiValueMap map = new MultiValueMap();
for (String[] pair : pairs) {
try {
map.set(pair[0], pair[1]);
} catch (Exception e) {
e.printStackTrace();
// Just eat the stupid Exception!!
}
}
return map;
}
private static Date createDate(String dateString) {
try {
SimpleDateFormat parser =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
return parser.parse(dateString);
} catch (ParseException e) {
// eat the exception
e.printStackTrace();
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy