@@ -21,7 +21,6 @@ |
import javax.ws.rs.*; |
import javax.ws.rs.core.Context; |
import javax.ws.rs.core.MediaType; |
-import javax.ws.rs.core.UriInfo; |
import org.codehaus.jettison.json.JSONArray; |
import org.codehaus.jettison.json.JSONException; |
import org.codehaus.jettison.json.JSONObject; |
@@ -59,9 +58,15 @@ |
} |
for (Class<?> c : r.getServices()) { |
JSONObject m = new JSONObject(); |
- String url = host + r.getServicePath(c); |
- m.put(ModelDataService.KEY_NAME, r.getServiceName(c)); |
- m.put(ModelDataService.KEY_DESC, r.getServiceDescription(c)); |
+ String url = host + Utils.getServicePath(c); |
+ String state = Utils.getServiceState(c); |
+ if (state != null) { |
+ state = " (" + state + ")"; |
+ } else { |
+ state = ""; |
+ } |
+ m.put(ModelDataService.KEY_NAME, (Utils.getServiceName(c) != null ? Utils.getServiceName(c) : "") + state); |
+ m.put(ModelDataService.KEY_DESC, Utils.getServiceDescription(c) != null ? Utils.getServiceDescription(c) : ""); |
m.put(ModelDataService.KEY_URL, url); |
o.put(m); |
} |
@@ -20,7 +20,6 @@ |
import static csip.Config.CSIP_SNAPSHOT; |
import static csip.Config.CSIP_TIMEZONE; |
import static csip.Config.CSIP_VERSION; |
-import csip.ResultStore; |
import csip.annotations.*; |
|
import csip.utils.*; |
@@ -81,7 +80,8 @@ |
public static final String KEY_EXPIRATION_DATE = "expiration_date"; |
public static final String KEY_TSTAMP = "tstamp"; //? |
public static final String KEY_TZ = "tz"; // timezone |
- public static final String KEY_PROGRESS = "progress"; // timezone |
+ public static final String KEY_PROGRESS = "progress"; |
+ public static final String KEY_STATE = "state"; |
|
// parameter keys |
public static final String KEY_NAME = "name"; |
@@ -173,6 +173,8 @@ |
// The progress (message) during execution. |
private String progress = null; |
|
+ private String state = null; |
+ |
// file stuff |
private List<File> fres; |
private Map<File, String> fdesc; |
@@ -378,6 +380,17 @@ |
|
|
/** |
+ * Provide the state if this service. It picks up the @Deprecated or the |
+ * @State annotation. |
+ * |
+ * @return the state, or null if not defined. |
+ */ |
+ private final String getState() { |
+ return Utils.getServiceState(getClass()); |
+ } |
+ |
+ |
+ /** |
* Get the complete request URL |
* @return the full request URL |
*/ |
@@ -2270,6 +2283,7 @@ |
if (start == null) { |
start = new Date(); |
processOptions(); |
+ state = getState(); |
} |
|
if (LOG.isLoggable(Level.INFO)) { |
@@ -2804,6 +2818,9 @@ |
if (v != null) { |
metainfo.put(reqContext + ".version", v); |
} |
+ if (state != null) { |
+ metainfo.put(KEY_STATE, state); |
+ } |
metainfo.put(CSIP_VERSION, Config.getString(CSIP_VERSION)); |
if (progress != null) { |
metainfo.put(KEY_PROGRESS, progress); |
@@ -47,7 +47,8 @@ |
Utils.callStaticMethodIfExist(c, "onContextInit"); |
} |
}); |
- Collections.sort(s, (Class<?> o1, Class<?> o2) -> getServiceName(o1).compareTo(getServiceName(o2))); |
+ Collections.sort(s, (Class<?> o1, Class<?> o2) |
+ -> Utils.getServiceName(o1).compareTo(Utils.getServiceName(o2))); |
Config.LOG.info(">>>>>>>> Registered " + s.size() + " CSIP services."); |
} |
|
@@ -69,22 +70,4 @@ |
return s; |
} |
|
- |
- String getServicePath(Class<?> c) { |
- Path p = c.getAnnotation(Path.class); |
- return (p == null) ? "" : p.value(); |
- } |
- |
- |
- String getServiceName(Class<?> c) { |
- Name p = c.getAnnotation(Name.class); |
- return (p == null) ? "" : p.value(); |
- } |
- |
- |
- String getServiceDescription(Class<?> c) { |
- Description p = c.getAnnotation(Description.class); |
- return (p == null) ? "" : p.value(); |
- } |
- |
} |
@@ -11,6 +11,7 @@ |
*/ |
package csip; |
|
+import csip.annotations.State; |
import java.lang.reflect.InvocationTargetException; |
import java.lang.reflect.Method; |
import java.net.UnknownHostException; |
@@ -19,8 +20,11 @@ |
import java.util.Set; |
import java.util.logging.Level; |
import javax.servlet.http.HttpServletRequest; |
+import javax.ws.rs.Path; |
import javax.ws.rs.WebApplicationException; |
import javax.ws.rs.core.Response; |
+import oms3.annotations.Description; |
+import oms3.annotations.Name; |
import org.apache.commons.net.util.SubnetUtils; |
|
/** |
@@ -153,6 +157,37 @@ |
} |
|
|
+ static String getServiceDescription(Class<?> c) { |
+ Description p = c.getAnnotation(Description.class); |
+ return (p != null) ? p.value() : null; |
+ } |
+ |
+ |
+ static String getServicePath(Class<?> c) { |
+ Path p = c.getAnnotation(Path.class); |
+ return (p != null) ? p.value() : null; |
+ } |
+ |
+ |
+ static String getServiceName(Class<?> c) { |
+ Name p = c.getAnnotation(Name.class); |
+ return (p != null) ? p.value() : null; |
+ } |
+ |
+ |
+ static String getServiceState(Class<?> c) { |
+ Deprecated d = c.getAnnotation(Deprecated.class); |
+ if (d != null) { |
+ return State.DEPRECATED; |
+ } |
+ State p = c.getAnnotation(State.class); |
+ if (p != null) { |
+ return p.value(); |
+ } |
+ return null; |
+ } |
+ |
+ |
public static void main(String[] args) throws UnknownHostException { |
System.out.println(Utils.isInSubnet("101.2.228.68", "101.2.228.0/8")); |
} |