public MailboxResource(Context context, Request request, Response response) { super(context, request, response); final String mailboxId = Reference.decode( (String) request.getAttributes().get("mailboxId"), CharacterSet.ISO_8859_1); this.mailbox = getObjectsFacade().getMailboxById(mailboxId); System.out.println(Reference.encode(mailboxId)); if (this.mailbox != null) { getVariants().add(new Variant(MediaType.TEXT_HTML)); } // Avoid anonymous to update this resource. setModifiable(true); }
/** Initialize the name resolver, the epoch and the object name. */ @Override public final void doInit() { super.doInit(); Validation validationForm = new InputsValidation(getRequest().getResourceRef().getQueryAsForm().getValuesMap()); validationForm = new NotNullAndNotEmptyValidation(validationForm, "nameResolver"); validationForm = new NotNullAndNotEmptyValidation(validationForm, "epoch"); final StatusValidation statusValidationForm = validationForm.validate(); if (statusValidationForm.isValid()) { final Map<String, String> userInputParameters = validationForm.getMap(); this.nameResolver = userInputParameters.get("nameResolver"); this.epoch = userInputParameters.get("epoch"); } else { this.nameResolver = getParameterValue("nameResolver"); this.epoch = getParameterValue("epoch"); } if (!getRequest().getMethod().equals(Method.OPTIONS)) { Validation validationAttributes = new InputsAttributesValidation(getRequestAttributes()); validationAttributes = new NotNullAndNotEmptyValidation(validationAttributes, "objectName"); validationAttributes = new NotNullAndNotEmptyValidation(validationAttributes, "coordSystem"); final StatusValidation status = validationAttributes.validate(); if (status.isValid()) { final Map<String, String> requestInputs = validationAttributes.getMap(); this.objectName = Reference.decode(requestInputs.get("objectName")); final String coordinatesSystem = requestInputs.get("coordSystem"); if (coordinatesSystem.equalsIgnoreCase(CoordinateSystem.EQUATORIAL.name())) { this.coordSystem = CoordinateSystem.EQUATORIAL; } else if (coordinatesSystem.equalsIgnoreCase(CoordinateSystem.GALACTIC.name())) { this.coordSystem = CoordinateSystem.GALACTIC; } else { LOG.log(Level.WARNING, "Name resolver service - Wrong parameter: {0}", coordinatesSystem); throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST, coordinatesSystem + " must be either EQUATORIAL or GALACTIC"); } } else { LOG.log(Level.WARNING, "Name resolver service - Wrong parameters"); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Check your input parameters"); } } }