Skip to content

Commit

Permalink
Merge pull request #173 from bioinformatics-ua/imp/priorityCSTORE
Browse files Browse the repository at this point in the history
Handler to support Priority Queue: C-STORE service
  • Loading branch information
bastiao committed Dec 29, 2015
2 parents 49820f9 + 2167c43 commit 9ecced1
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 171 deletions.
33 changes: 23 additions & 10 deletions dicoogle/src/main/java/pt/ua/dicoogle/core/ServerSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@

import pt.ua.dicoogle.sdk.datastructs.MoveDestination;
import java.net.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import org.dcm4che2.data.UID;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -171,6 +167,8 @@ public class ServerSettings implements ServerSettingsReader

ArrayList<MoveDestination> dest = new ArrayList<>();

private Set<String> priorityAETitles = new HashSet<>();

private boolean indexAnonymous = false;

private boolean indexZIPFiles = true;
Expand Down Expand Up @@ -890,6 +888,21 @@ public ArrayList<MoveDestination> getMoves()
{
return this.dest ;
}

@Override
public Set<String> getPriorityAETitles() {
return priorityAETitles;
}

public void addPriorityAETitle(String aet)
{
this.priorityAETitles.add(aet);
}
public void removePriorityAETitle(String aet)
{
this.priorityAETitles.remove(aet);
}

public void setMoves(ArrayList<MoveDestination> moves)
{
if(moves != null)
Expand Down Expand Up @@ -950,8 +963,8 @@ public void setAutoStartPlugin(String name, boolean value)
// remove the previous setting, if there is one
autoStartPlugin.remove(name);

// insert the new setting
autoStartPlugin.put(name, value);
// insert the new setting
autoStartPlugin.put(name, value);
}

/**
Expand All @@ -967,9 +980,9 @@ public boolean getAutoStartPlugin(String name)
{
Boolean result = autoStartPlugin.get(name);

// if there is not such setting return the default value
if (result == null) return true; // by default start the plugin
return result.booleanValue();
// if there is not such setting return the default value
if (result == null) return true; // by default start the plugin
return result.booleanValue();
}

/**
Expand Down
206 changes: 119 additions & 87 deletions dicoogle/src/main/java/pt/ua/dicoogle/core/XMLSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@


import pt.ua.dicoogle.sdk.datastructs.MoveDestination;
import pt.ua.dicoogle.sdk.settings.types.ServerDirectoryPath;
import pt.ua.dicoogle.server.*;

import java.io.*;
Expand Down Expand Up @@ -130,6 +131,8 @@ public class XMLSupport extends DefaultHandler
private String description;
private String isPublic;

private boolean priorityAET = false;


private String currentService;

Expand Down Expand Up @@ -366,6 +369,18 @@ else if (destinations && localName.equals("dest"))
this.port, this.isPublic.contains("true"), this.description);
s.add(tmp);
}

else if(localName.equals("CSTOREPriorities"))
{
this.priorityAET = true ;
}
else if (priorityAET && localName.equals("aetitle"))
{
String aet = this.resolveAttrib("aetitle", attribs, localName);
//ServerSettings.getInstance().addPriorityAETitle(aet);
}


else if (localName.equals("web"))
{
this.isWeb = true ;
Expand Down Expand Up @@ -615,6 +630,13 @@ else if (this.options && localName.equals("destinations"))
this.destinations = false ;
}

else if (this.options && localName.equals("CSTOREPriorities"))
{
this.priorityAET = false ;
}



else if (isWeb && localName.equals("web"))
{
this.isWeb = false ;
Expand All @@ -632,25 +654,23 @@ else if(localName.equals("RGUIExtIP"))
}

@Override
public void characters( char[] data, int start, int length )
{
if(isIndexEffort){
String sEffort = new String(data, start, length);
s.setIndexerEffort(Integer.parseInt(sEffort));
return;
}
if(isPort && !isQRConfigs)
{
String sPort = new String(data, start, length);
s.setStoragePort(Integer.parseInt(sPort));
return;
}
if(isPort && isQRConfigs){
String sPort = new String(data, start, length);
s.setWlsPort(Integer.parseInt(sPort));
return;
}
if(isEncrypt){
public void characters( char[] data, int start, int length ) {
if (isIndexEffort) {
String sEffort = new String(data, start, length);
s.setIndexerEffort(Integer.parseInt(sEffort));
return;
}
if (isPort && !isQRConfigs) {
String sPort = new String(data, start, length);
s.setStoragePort(Integer.parseInt(sPort));
return;
}
if (isPort && isQRConfigs) {
String sPort = new String(data, start, length);
s.setWlsPort(Integer.parseInt(sPort));
return;
}
if (isEncrypt) {
String sView = new String(data, start, length);
boolean result = false;

Expand All @@ -659,89 +679,84 @@ public void characters( char[] data, int start, int length )

s.setEncryptUsersFile(result);
return;
}
}


if (isZIPFile)
{
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)

if (isZIPFile) {
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)
result = true;
s.setIndexZIPFiles(result);
return;
}

if (isGZIPStorage)
{
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)
s.setIndexZIPFiles(result);
return;
}

if (isGZIPStorage) {
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)
result = true;
s.setGzipStorage(result);
return;

}

if (isIndexAnonymous)
{
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)
s.setGzipStorage(result);
return;

}

if (isIndexAnonymous) {
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)
result = true;
s.setIndexAnonymous(result);
return;
}

if (isMonitorWatcher)
{
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)
s.setIndexAnonymous(result);
return;
}

if (isMonitorWatcher) {
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)
result = true;
s.setMonitorWatcher(result);
return;
}
if(isP2P)
{
s.setMonitorWatcher(result);
return;
}
if (isP2P) {

if (autoConnect)
{
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)
if (autoConnect) {
String sView = new String(data, start, length);
boolean result = false;
if (sView.compareToIgnoreCase("true") == 0)
result = true;
// s.setP2P(result);
return;
return;

}
else if (maxmsg)
{
String max = new String(data, start, length);
} else if (maxmsg) {
String max = new String(data, start, length);


int maxMsg = Integer.valueOf(max);
s.setMaxMessages(maxMsg);
return;
int maxMsg = Integer.valueOf(max);
s.setMaxMessages(maxMsg);
return;

}
else if (isNode && isNodeName)
{
String nodeName = new String(data, start, length);
s.setNodeName(nodeName);
}
else if (isNode && isDefined)
{
String tmp = new String(data, start, length);
boolean result = false;
if (tmp.compareToIgnoreCase("true") == 0)
} else if (isNode && isNodeName) {
String nodeName = new String(data, start, length);
s.setNodeName(nodeName);
} else if (isNode && isDefined) {
String tmp = new String(data, start, length);
boolean result = false;
if (tmp.compareToIgnoreCase("true") == 0)
result = true;
s.setNodeNameDefined(result);
return;
}
s.setNodeNameDefined(result);
return;
}
}

if (priorityAET)
{
String aetitle = new String(data, start, length);
s.addPriorityAETitle(aetitle);
return;

}

}
if(isStorage)
{
String sView = new String(data, start, length);
Expand Down Expand Up @@ -1569,6 +1584,23 @@ public void printXML()
hd.endElement("", "", "destinations");


// CSTOREPriorities

hd.startElement("", "", "CSTOREPriorities", atts);

for (String aet : ServerSettings.getInstance().getPriorityAETitles())
{
atts.clear();
hd.startElement("", "", "aetitle", atts);
hd.characters(aet.toCharArray(), 0, aet.length());
hd.endElement("", "", "aetitle");
}

hd.endElement("", "", "CSTOREPriorities");




hd.endElement("", "", "options");

hd.endElement("", "", "QueryRetrieve");
Expand Down
Loading

0 comments on commit 9ecced1

Please sign in to comment.