Revision 9475
Added by Jing Tao about 9 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
715 | 715 |
String ctype = request.getContentType(); |
716 | 716 |
|
717 | 717 |
if (ctype != null && ctype.startsWith("multipart/form-data")) { |
718 |
if(isReadOnly(response)) { |
|
719 |
return; |
|
720 |
} |
|
718 | 721 |
handler.handleMultipartForm(request, response); |
719 | 722 |
return; |
720 | 723 |
} |
... | ... | |
909 | 912 |
handler.handleReadInlineDataAction(params, request, response, userName, password, |
910 | 913 |
groupNames); |
911 | 914 |
} else if (action.equals("insert") || action.equals("update")) { |
915 |
if(isReadOnly(response)) { |
|
916 |
return; |
|
917 |
} |
|
912 | 918 |
PrintWriter out = response.getWriter(); |
913 | 919 |
if ((userName != null) && !userName.equals("public")) { |
914 | 920 |
handler.handleInsertOrUpdateAction(request.getRemoteAddr(), request.getHeader("User-Agent"), response, out, params, userName, |
... | ... | |
923 | 929 |
} |
924 | 930 |
out.close(); |
925 | 931 |
} else if (action.equals("delete")) { |
932 |
if(isReadOnly(response)) { |
|
933 |
return; |
|
934 |
} |
|
926 | 935 |
PrintWriter out = response.getWriter(); |
927 | 936 |
if ((userName != null) && !userName.equals("public")) { |
928 | 937 |
handler.handleDeleteAction(out, params, request, response, userName, |
... | ... | |
941 | 950 |
handler.handleValidateAction(out, params); |
942 | 951 |
out.close(); |
943 | 952 |
} else if (action.equals("setaccess")) { |
953 |
if(isReadOnly(response)) { |
|
954 |
return; |
|
955 |
} |
|
944 | 956 |
PrintWriter out = response.getWriter(); |
945 | 957 |
handler.handleSetAccessAction(out, params, userName, request, response); |
946 | 958 |
out.close(); |
... | ... | |
1011 | 1023 |
out.println("\n</user>\n"); |
1012 | 1024 |
out.close(); |
1013 | 1025 |
} else if (action.equals("buildindex")) { |
1026 |
if(isReadOnly(response)) { |
|
1027 |
return; |
|
1028 |
} |
|
1014 | 1029 |
handler.handleBuildIndexAction(params, request, response, userName, groupNames); |
1015 | 1030 |
} else if (action.equals("reindex")) { |
1031 |
if(isReadOnly(response)) { |
|
1032 |
return; |
|
1033 |
} |
|
1016 | 1034 |
handler.handleReindexAction(params, request, response, userName, groupNames); |
1017 | 1035 |
} else if (action.equals("reindexall")) { |
1036 |
if(isReadOnly(response)) { |
|
1037 |
return; |
|
1038 |
} |
|
1018 | 1039 |
handler.handleReindexAllAction(params, request, response, userName, groupNames); |
1019 | 1040 |
} else if (action.equals("login") || action.equals("logout")) { |
1020 | 1041 |
/* |
... | ... | |
1053 | 1074 |
ServiceService.refreshService("XMLSchemaService"); |
1054 | 1075 |
return; |
1055 | 1076 |
} else if (action.equals("scheduleWorkflow")) { |
1077 |
if(isReadOnly(response)) { |
|
1078 |
return; |
|
1079 |
} |
|
1056 | 1080 |
try { |
1057 | 1081 |
WorkflowSchedulerClient.getInstance().scheduleJob(request, response, |
1058 | 1082 |
params, userName, groupNames); |
... | ... | |
1063 | 1087 |
return; |
1064 | 1088 |
} |
1065 | 1089 |
} else if (action.equals("unscheduleWorkflow")) { |
1090 |
if(isReadOnly(response)) { |
|
1091 |
return; |
|
1092 |
} |
|
1066 | 1093 |
try { |
1067 | 1094 |
WorkflowSchedulerClient.getInstance().unScheduleJob(request, |
1068 | 1095 |
response, params, userName, groupNames); |
... | ... | |
1073 | 1100 |
return; |
1074 | 1101 |
} |
1075 | 1102 |
} else if (action.equals("rescheduleWorkflow")) { |
1103 |
if(isReadOnly(response)) { |
|
1104 |
return; |
|
1105 |
} |
|
1076 | 1106 |
try { |
1077 | 1107 |
WorkflowSchedulerClient.getInstance().reScheduleJob(request, |
1078 | 1108 |
response, params, userName, groupNames); |
... | ... | |
1093 | 1123 |
return; |
1094 | 1124 |
} |
1095 | 1125 |
} else if (action.equals("deleteScheduledWorkflow")) { |
1126 |
if(isReadOnly(response)) { |
|
1127 |
return; |
|
1128 |
} |
|
1096 | 1129 |
try { |
1097 | 1130 |
WorkflowSchedulerClient.getInstance().deleteJob(request, response, |
1098 | 1131 |
params, userName, groupNames); |
... | ... | |
1130 | 1163 |
//try the plugin handler if it has an entry for handling this action |
1131 | 1164 |
MetacatHandlerPlugin handlerPlugin = MetacatHandlerPluginManager.getInstance().getHandler(action); |
1132 | 1165 |
if (handlerPlugin != null) { |
1166 |
if(isReadOnly(response)) { |
|
1167 |
return; |
|
1168 |
} |
|
1133 | 1169 |
handlerPlugin.handleAction(action, params, request, response, userName, groupNames, sessionId); |
1134 | 1170 |
} |
1135 | 1171 |
else { |
... | ... | |
1181 | 1217 |
public static boolean isFullyInitialized() { |
1182 | 1218 |
return _fullyInitialized; |
1183 | 1219 |
} |
1220 |
|
|
1221 |
private boolean isReadOnly(HttpServletResponse response) throws IOException { |
|
1222 |
boolean readOnly = false; |
|
1223 |
ReadOnlyChecker checker = new ReadOnlyChecker(); |
|
1224 |
readOnly = checker.isReadOnly(); |
|
1225 |
if(readOnly) { |
|
1226 |
PrintWriter out = response.getWriter(); |
|
1227 |
response.setContentType("text/xml"); |
|
1228 |
out.println("<?xml version=\"1.0\"?>"); |
|
1229 |
out.println("<error>"); |
|
1230 |
out.println("The Metacat is on the read-only mode and your request can't be fulfiled. Please try again later."); |
|
1231 |
out.println("</error>"); |
|
1232 |
out.close(); |
|
1233 |
} |
|
1234 |
return readOnly; |
|
1235 |
} |
|
1184 | 1236 |
} |
Also available in: Unified diff
Add the code to handle the read-only mode.