public ServiceParser(File source) throws FileNotFoundException {
input = new BufferedReader(new FileReader(source));
}
public void uploadService() throws IOException, ClipsException {
DirectoryServicesGroup dirGroup =
(DirectoryServicesGroup) DirectoryLocator.getDirectory(DirectoryServicesGroup.class, false);
DirectoryService dirService =
(DirectoryService) DirectoryLocator.getDirectory(DirectoryService.class, false);
DirectoryServicesGroupItem parent = null;
DirectoryServicesGroupItem group = null;
DirectoryServiceItem service = null;
String line = input.readLine();
while (line != null) {
if (!line.trim().isEmpty()) {
int pos = line.indexOf('|');
if (pos > -1) {
String code = line.substring(0, pos);
String title = line.substring(pos + 1);
if (code.length() == 2) {
ServiceGroupDetails parDetails = new ServiceGroupDetails();
parDetails.code = code;
parDetails.parentItem = 0;
parDetails.title = title;
parent = new DirectoryServicesGroupItem(parDetails);
dirGroup.getItems().append(parent);
System.out.println(code + " " + title);
}
else if (code.length() == 6) {
code = code.substring(3, 6);
ServiceGroupDetails grDetails = new ServiceGroupDetails();
grDetails.code = code;
grDetails.parentItem = parent.getID();
grDetails.title = title;
group = new DirectoryServicesGroupItem(grDetails);
dirGroup.getItems().append(group);
System.out.println(" " +code + " " + title);
}
else if (code.length() == 9) {
code = code.substring(7);