added importer for system scopes

pull/650/head
Justin Richer 2014-05-13 16:40:19 -04:00
parent eea852cebe
commit a562e103c6
1 changed files with 39 additions and 2 deletions

View File

@ -652,11 +652,48 @@ public class MITREidDataService_1_0 implements MITREidDataService {
} }
/** /**
* Read the list of system scopes from the reader and insert them
* into the scope repository.
* @param reader * @param reader
* @throws IOException * @throws IOException
*/ */
private void readSystemScopes(JsonReader reader) throws IOException { private void readSystemScopes(JsonReader reader) throws IOException {
// TODO Auto-generated method stub reader.beginArray();
while (reader.hasNext()) {
SystemScope scope = new SystemScope();
reader.beginObject();
while (reader.hasNext()) {
switch (reader.peek()) {
case END_OBJECT:
continue;
case NAME:
String name = reader.nextName();
if (name.equals("value")) {
scope.setValue(reader.nextString());
} else if (name.equals("description")) {
scope.setDescription(reader.nextString());
} else if (name.equals("allowDynReg")) {
scope.setAllowDynReg(reader.nextBoolean());
} else if (name.equals("defaultScope")) {
scope.setDefaultScope(reader.nextBoolean());
} else if (name.equals("icon")) {
scope.setIcon(reader.nextString());
} else {
logger.debug("found unexpected entry");
reader.skipValue(); reader.skipValue();
} }
break;
default:
logger.debug("Found unexpected entry");
reader.skipValue();
continue;
}
}
reader.endObject();
sysScopeRepository.save(scope);
}
reader.endArray();
logger.info("Done reading system scopes.");
}
} }