- Timestamp:
- 2019-11-14T14:14:28+13:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java
r33112 r33672 63 63 * perl scripts 64 64 * 65 * @author Katherine Don66 65 */ 67 66 public class GS2Construct extends ServiceRack … … 71 70 72 71 // default error message 73 private static final String NO_PERMISSIONS_ERROR = "This user does not have the required permissions to perform this action."; 74 72 private static final String NO_PERMISSIONS_ERROR = "auth.error.no_permissions"; 73 private static final String NO_METADATA_PERMISSIONS_ERROR = "auth.error.no_metadata_permissions"; 74 75 75 // services offered 76 76 private static final String NEW_SERVICE = "NewCollection"; … … 166 166 protected Element processNewCollection(Element request) 167 167 { 168 168 169 if (!userHasCollectionEditPermissions(request)) { 169 return errorResponse("processNewCollection", NO_PERMISSIONS_ERROR); 170 String lang = request.getAttribute(GSXML.LANG_ATT); 171 return errorResponse("processNewCollection", NO_PERMISSIONS_ERROR, lang); 170 172 } 171 173 return runCommand(request, GS2PerlConstructor.NEW); … … 176 178 { 177 179 if (!userHasCollectionEditPermissions(request)) { 178 return errorResponse("processAddDocument", NO_PERMISSIONS_ERROR); 180 String lang = request.getAttribute(GSXML.LANG_ATT); 181 return errorResponse("processAddDocument", NO_PERMISSIONS_ERROR, lang); 179 182 } 180 183 … … 198 201 // check permissions 199 202 if (!userHasCollectionEditPermissions(request)) { 200 return errorResponse("processBuildAndActivateCollection", NO_PERMISSIONS_ERROR); 203 String lang = request.getAttribute(GSXML.LANG_ATT); 204 return errorResponse("processBuildAndActivateCollection", NO_PERMISSIONS_ERROR, lang); 201 205 } 202 206 … … 237 241 { 238 242 if (!userHasCollectionEditPermissions(request)) { 239 return errorResponse("processImportCollection", NO_PERMISSIONS_ERROR); 243 String lang = request.getAttribute(GSXML.LANG_ATT); 244 return errorResponse("processImportCollection", NO_PERMISSIONS_ERROR, lang); 240 245 } 241 246 … … 304 309 { 305 310 if (!userHasCollectionEditPermissions(request)) { 306 return errorResponse("processBuildCollection", NO_PERMISSIONS_ERROR); 311 String lang = request.getAttribute(GSXML.LANG_ATT); 312 return errorResponse("processBuildCollection", NO_PERMISSIONS_ERROR, lang); 307 313 } 308 314 … … 341 347 342 348 UserContext context = new UserContext(request); 349 String lang = request.getAttribute(GSXML.LANG_ATT); 343 350 if (context.getUsername().equals("")) { 344 351 345 return errorResponse("processModifyMetadata", "Cannot modify any metadata when not logged in.");352 return errorResponse("processModifyMetadata", NO_METADATA_PERMISSIONS_ERROR, lang); 346 353 } else { // User is logged in at least, see whether they can do any restricted set-meta ops 347 354 // that are open to regular users (those without permissions to edit this collection). … … 366 373 if(!isAddingUserComments) { // logged in user is attempting to set meta outside restricted set, 367 374 // In this case, they're attempting to set meta not related to user comments 368 return errorResponse("processModifyMetadata", NO_PERMISSIONS_ERROR);375 return errorResponse("processModifyMetadata", NO_PERMISSIONS_ERROR, lang); 369 376 } 370 377 } … … 433 440 { 434 441 442 String lang = request.getAttribute(GSXML.LANG_ATT); 435 443 if (!userHasCollectionEditPermissions(request)) { 436 return errorResponse("processActivateCollection", NO_PERMISSIONS_ERROR);444 return errorResponse("processActivateCollection", NO_PERMISSIONS_ERROR, lang); 437 445 } 438 446 … … 442 450 HashMap<String, Serializable> params = GSXML.extractParams(param_list, false); 443 451 String coll_name = (String) params.get(COL_PARAM); 444 String lang = request.getAttribute(GSXML.LANG_ATT);452 445 453 446 454 UserContext userContext = new UserContext(request); … … 508 516 protected Element processDeleteCollection(Element request) 509 517 { 518 510 519 if (!userHasCollectionEditPermissions(request)) { 511 return errorResponse("processDeleteCollection", NO_PERMISSIONS_ERROR); 520 String lang = request.getAttribute(GSXML.LANG_ATT); 521 return errorResponse("processDeleteCollection", NO_PERMISSIONS_ERROR, lang); 512 522 } 513 523 … … 570 580 { 571 581 if (!userHasCollectionEditPermissions(request)) { 572 return errorResponse("processReloadCollection", NO_PERMISSIONS_ERROR); 582 String lang = request.getAttribute(GSXML.LANG_ATT); 583 return errorResponse("processReloadCollection", NO_PERMISSIONS_ERROR, lang); 573 584 } 574 585 … … 1162 1173 } 1163 1174 1164 protected Element errorResponse(String serviceName, String errorMsg) { 1175 protected Element errorResponse(String serviceName, String errorKey, String lang) { 1176 String error_message = getTextString(errorKey, lang, "ServiceRack"); 1165 1177 Document result_doc = XMLConverter.newDOM(); 1166 1178 Element result = GSXML.createBasicResponse(result_doc, serviceName); 1167 GSXML.addError(result, error Msg);1179 GSXML.addError(result, error_message); 1168 1180 return result; 1169 1181 }
Note:
See TracChangeset
for help on using the changeset viewer.