/** * Creates a {@link Response} wrapper instance. * * @param response the response to wrap */ private ResponseContainer(final Response response) { ensureNonNull("response", response); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(response.toString()); } this.response = response; }
@Override public void run(TableLoadOption... tableLoadOptions) throws OseeCoreException { List<Artifact> activeTeams = new LinkedList<>(); for (Artifact agTeam : ArtifactQuery.getArtifactListFromType( AtsArtifactTypes.AgileTeam, AtsUtilCore.getAtsBranch())) { if (agTeam.getSoleAttributeValue(AtsAttributeTypes.Active, true)) { activeTeams.add(agTeam); } } FilteredTreeArtifactDialog dialog = new FilteredTreeArtifactDialog( getName(), "Select Agile Team", activeTeams, new ArtifactTreeContentProvider(), new ArtifactLabelProvider()); if (dialog.open() == 0) { EntryDialog ed = new EntryDialog(getName(), "Enter new Agile Sprint name(s) (comma delimited)"); if (ed.open() == 0) { if (Strings.isValid(ed.getEntry())) { try { AgileEndpointApi ageilEp = AtsClientService.getAgileEndpoint(); JaxNewAgileSprint newSprint = new JaxNewAgileSprint(); int teamUuid = ((Artifact) dialog.getSelectedFirst()).getArtId(); for (String name : ed.getEntry().split(",")) { newSprint.setName(name); newSprint.setTeamUuid(teamUuid); Response response = ageilEp.createSprint(new Long(teamUuid), newSprint); JaxAgileSprint sprint = response.readEntity(JaxAgileSprint.class); if (sprint != null) { long uuid = sprint.getUuid(); Artifact sprintArt = ArtifactQuery.getArtifactFromId( new Long(uuid).intValue(), AtsUtilCore.getAtsBranch()); sprintArt.getParent().reloadAttributesAndRelations(); AtsUtil.openArtifact(sprintArt.getGuid(), OseeCmEditor.CmPcrEditor); } else { AWorkbench.popup("Error creating Agile Team [%s]", response.toString()); return; } } } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } } } } }
/** * Ensures that the response has a "success" status code {@code 2xx}. * * @throws HttpResponseException if the response does not have a {@code 2xx} status code * @throws IOException if the response entity parsing has failed */ public void ensure2xxStatus() throws HttpResponseException, IOException { if (response.getStatus() / 100 != 2) { final String message; if (MediaType.TEXT_PLAIN_TYPE.equals(response.getMediaType())) { message = response.readEntity(String.class); } else if (MediaType.TEXT_XML_TYPE.equals(response.getMediaType()) || MediaType.APPLICATION_XML_TYPE.equals(response.getMediaType()) || MediaType.APPLICATION_JSON_TYPE.equals(response.getMediaType())) { message = response.readEntity(AcknowlegementType.class).getMessage(); } else { message = response.toString(); } throw new HttpResponseException(response.getStatus(), message); } }
/** {@inheritDoc} */ @Override public String toString() { return response.toString(); }
ConnectorResponseErrorException(Response response) { super(response.toString()); this.status = response.getStatus(); this.error = readError(response); response.close(); }