Example usage for javax.activation MimeType getBaseType

List of usage examples for javax.activation MimeType getBaseType

Introduction

In this page you can find the example usage for javax.activation MimeType getBaseType.

Prototype

public String getBaseType() 

Source Link

Document

Return a String representation of this object without the parameter list.

Usage

From source file:org.codice.ddf.catalog.ui.metacard.impl.BaseLocator.java

private boolean filterByMimeType(Set<MimeType> serviceMimeTypes, Map<String, Object> serviceProperties,
        MimeType targetMimeType) {

    Set<String> serviceBaseTypes = serviceMimeTypes.stream().map(MimeType::getBaseType)
            .collect(Collectors.toSet());

    String targetServiceId = targetMimeType.getParameter(Constants.SERVICE_ID);

    String targetBaseType = targetMimeType.getBaseType();

    String serviceId = getServiceId(serviceProperties);

    return serviceBaseTypes.contains(targetBaseType)
            && (targetServiceId == null || StringUtils.equals(targetServiceId, serviceId));
}

From source file:org.kalypso.model.wspm.pdb.internal.wspm.DocumentPictureComparator.java

/**
 * Brings images to top.<br/>/*from   w  w  w. j  a va  2  s  . c  om*/
 * TODO: we might define a map from mime-types to categories.
 */
private int findCategory(final Document doc) {
    final MimeType mt = MimeTypeUtils.createQuietly(doc.getMimetype());

    if (mt == null)
        return CATEGORY_NO_IMAGE;

    final boolean isImage = MimeTypeMapper.isImageType(mt.getBaseType());
    if (isImage)
        return CATEGORY_IMAGE;

    return CATEGORY_NO_IMAGE;
}

From source file:org.kalypso.ogc.gml.featureview.control.ImageFeatureControl.java

private String loadImage(final String imgPath) {
    if (imgPath == null)
        return Messages.getString("org.kalypso.ogc.gml.featureview.control.ImageFeatureControl.2") //$NON-NLS-1$
                + getFeatureTypeProperty();

    if (imgPath.length() == 0)
        return StringUtils.EMPTY;

    try {/*w  w  w  . ja  v  a 2s  .c  o m*/
        final Feature feature = getFeature();

        if (feature instanceof org.kalypsodeegree_impl.gml.binding.commons.Image) {
            final MimeType mimeType = ((org.kalypsodeegree_impl.gml.binding.commons.Image) feature)
                    .getMimeType();
            if (mimeType != null) {
                final String baseType = mimeType.getBaseType();
                if (!MimeTypeMapper.isImageType(baseType))
                    return Messages.getString("ImageFeatureControl.0"); //$NON-NLS-1$
            }
        }

        final URL url = resolveImagePath(imgPath);
        updateImageUrl(url);
        return null;
    } catch (final MalformedURLException | URISyntaxException e) {
        e.printStackTrace();

        return Messages.getString("org.kalypso.ogc.gml.featureview.control.ImageFeatureControl.5") + imgPath; //$NON-NLS-1$
    }
}