private WadoClientResponse fetch( ApplicationEntity localAE, ApplicationEntity remoteAE, String studyInstanceUID, String seriesInstanceUID, String sopInstanceUID, InstanceAvailableCallback callback) { setCallBack(callback); WadoClient client = createClient(); WebServiceAEExtension wsAEExt = remoteAE.getAEExtension(WebServiceAEExtension.class); try { return client.fetch( localAE.getAETitle(), remoteAE.getAETitle(), studyInstanceUID, seriesInstanceUID, sopInstanceUID, wsAEExt.getWadoRSBaseURL()); } catch (IOException e) { LOG.error( "Error fetching Study {}, from AE {}" + " check baseurl configuration for WadoRS", studyInstanceUID, remoteAE.getAETitle()); } return null; }
public Association connect(ApplicationEntity remote, AAssociateRQ rq) throws IOException, InterruptedException, IncompatibleConnectionException, GeneralSecurityException { CompatibleConnection cc = findCompatibelConnection(remote); if (rq.getCalledAET() == null) rq.setCalledAET(remote.getAETitle()); return connect(cc.getLocalConnection(), cc.getRemoteConnection(), rq); }
@GET @Path("/whoami") @Produces(MediaType.TEXT_HTML) public Response whoami() throws ConfigurationException { HttpSource source = new HttpSource(request); ApplicationEntity ae = hostAECache.findAE(source); Device callerDevice = ae.getDevice(); return Response.ok( "<div>Calling Device: <br>Host:" + request.getRemoteHost() + "<br>AETitle: " + ae.getAETitle() + "<br>Device Name: " + callerDevice.getDeviceName() + "</div>") .build(); }
private void init() { this.ae = device.getApplicationEntity(aeTitle); if (ae == null || !ae.isInstalled() || (arcAE = ae.getAEExtension(ArchiveAEExtension.class)) == null) throw new WebApplicationException(Response.Status.SERVICE_UNAVAILABLE); this.boundary = contentType.getParameters().get("boundary"); if (boundary == null) throw new WebApplicationException("Missing Boundary Parameter", Response.Status.BAD_REQUEST); if (contentType.isCompatible(MediaTypes.MULTIPART_RELATED_TYPE)) { String type = contentType.getParameters().get("type"); if (type == null) throw new WebApplicationException("Missing Type Parameter", Response.Status.BAD_REQUEST); try { MediaType rootBodyMediaType = MediaType.valueOf(type); if (rootBodyMediaType.isCompatible(MediaTypes.APPLICATION_DICOM_TYPE)) creatorType = CreatorType.BINARY; else if (rootBodyMediaType.isCompatible(MediaTypes.APPLICATION_DICOM_XML_TYPE)) { creatorType = CreatorType.XML_BULKDATA; metadata = new ArrayList<MetaDataPathTSTuple>(); bulkdata = new HashMap<String, BulkdataPath>(); } else if (rootBodyMediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE)) { creatorType = CreatorType.JSON_BULKDATA; metadata = new ArrayList<MetaDataPathTSTuple>(); bulkdata = new HashMap<String, BulkdataPath>(); } else throw new WebApplicationException(Response.Status.UNSUPPORTED_MEDIA_TYPE); } catch (IllegalArgumentException e) { throw new WebApplicationException(e, Response.Status.BAD_REQUEST); } } else { creatorType = CreatorType.BINARY; } wadoURL = uriInfo.getBaseUri() + "wado/" + ae.getAETitle() + "/studies/"; if (studyInstanceUID != null) response.setString(Tag.RetrieveURL, VR.UR, wadoURL + studyInstanceUID); else response.setNull(Tag.RetrieveURL, VR.UR); sopSequence = response.newSequence(Tag.ReferencedSOPSequence, 10); }
@POST @Path("/studies") @Consumes({"multipart/related", "multipart/form-data"}) public Response storeInstances(InputStream in) throws Exception { String str = req.toString(); LOG.info(str); init(); final StoreSession session = storeService.createStoreSession(storeService); session.setSource(new HttpSource(request)); ApplicationEntity sourceAE = aeCache.findAE(new HttpSource(request)); session.setRemoteAET( sourceAE != null ? sourceAE.getAETitle() : null); // add AE for the web source session.setArchiveAEExtension(arcAE); storeService.initStorageSystem(session); storeService.initSpoolDirectory(session); storeService.initMetaDataStorageSystem(session); try { new MultipartParser(boundary) .parse( in, new MultipartParser.Handler() { @Override public void bodyPart(int partNumber, MultipartInputStream in) throws IOException { Map<String, List<String>> headerParams = in.readHeaderParams(); String transferSyntax = null; LOG.info("storeInstances: Extract Part #{}{}", partNumber, headerParams); String contentType = getHeaderParamValue(headerParams, "content-type"); String contentLocation = getHeaderParamValue(headerParams, "content-location"); MediaType mediaType; try { mediaType = contentType == null ? MediaType.TEXT_PLAIN_TYPE : MediaType.valueOf(contentType); } catch (IllegalArgumentException e) { LOG.info( "storeInstances: Ignore Part with illegal Content-Type={}", contentType); in.skipAll(); return; } // check for metadata transfer syntax if (contentLocation == null) { transferSyntax = contentType.contains("transfer-syntax=") ? contentType.split("transfer-syntax=")[1] : null; } if (!creatorType.readBodyPart( StowRS.this, session, in, mediaType, contentLocation, transferSyntax)) { LOG.info("storeInstances: Ignore Part with Content-Type={}", mediaType); in.skipAll(); } } }); creatorType.storeMetadataAndBulkdata(this, session); } finally { storeService.onClose(session); } return buildResponse(); }