Esempio n. 1
0
  public static TCDocumentObject create(TCReferencedInstance ref) throws Exception {

    Instance instance =
        ((TCQueryLocal) JNDIUtils.lookup(TCQueryLocal.JNDI_NAME))
            .findInstanceByUID(ref.getInstanceUID());

    if (instance == null) {
      return null;
    }

    DicomObject attrs = instance.getAttributes(false);

    MimeType mimeType = null;
    String mimeTypeStr = attrs.getString(Tag.MIMETypeOfEncapsulatedDocument);
    if (mimeTypeStr != null) {
      mimeType = MimeType.get(mimeTypeStr);
    }
    if (mimeType == null) {
      mimeType = getDocumentMimeTypeFromLabel(attrs.getString(Tag.ContentLabel));
    }

    if (mimeType != null) {
      DocumentType docType = mimeType.getDocumentType();

      if (TCImageDocument.DOC_TYPES.contains(docType)) {
        return TCImageDocument.create(ref);
      } else if (TCEncapsulatedDocument.DOC_TYPES.contains(docType)) {
        return TCEncapsulatedDocument.create(ref);
      }
    }

    throw new Exception(
        "Unable to create TC encapsulated object: Mime type not supported (" + mimeTypeStr + ")");
  }
Esempio n. 2
0
  public static TCDocumentObject create(
      TCObject tc, MimeType mimeType, String filename, InputStream in, String description)
      throws Exception {
    if (mimeType != null) {
      DocumentType docType = mimeType.getDocumentType();

      if (TCImageDocument.DOC_TYPES.contains(docType)) {
        return TCImageDocument.create(tc, mimeType, filename, in, description);
      } else if (TCEncapsulatedDocument.DOC_TYPES.contains(docType)) {
        return TCEncapsulatedDocument.create(tc, mimeType, filename, in, description);
      }
    }

    throw new Exception(
        "Unable to create TC encapsulated object: MimeType not supported ("
            + mimeType
            + ")"); //$NON-NLS-1$ //$NON-NLS-2$
  }