31 lines
1006 B
Java
31 lines
1006 B
Java
package org.gcube.nlphub.legacy;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
public class Constants {
|
|
public static String DEFAULT_DESCRIPTION = "NlpHub upload";
|
|
public static String TOKEN_PARAMETER = "gcube-token";
|
|
public static String TEST_TOKEN = "df2cc5f5-63ee-48c1-b2a6-1210030c57b8-843339462";
|
|
public static String MIME_TEXT = "text/plain";
|
|
public static String CONTENT_TYPE = "Content-Type";
|
|
|
|
|
|
public static String getToken(HttpServletRequest request, boolean devMode) {
|
|
String token = request.getParameter(TOKEN_PARAMETER);
|
|
if(devMode) {
|
|
if(token == null) token = TEST_TOKEN;
|
|
}
|
|
return token;
|
|
}
|
|
|
|
public static String hexDump(byte[] bytes) {
|
|
char[] hexArray = "0123456789ABCDEF".toCharArray();
|
|
char[] hexChars = new char[bytes.length * 3];
|
|
for (int j = 0; j < bytes.length; j++) {
|
|
hexChars[3*j] = hexArray[bytes[j] / 16];
|
|
hexChars[3*j+1] = hexArray[bytes[j] % 16];
|
|
hexChars[3*j+2] = ' ';
|
|
}
|
|
return new String(hexChars);
|
|
}
|
|
}
|