Ejemplo n.º 1
0
  @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();
  }
Ejemplo n.º 2
0
  @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();
  }