当前位置: 首页>>代码示例>>Java>>正文


Java Resource.getMediaType方法代码示例

本文整理汇总了Java中org.wso2.carbon.registry.core.Resource.getMediaType方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getMediaType方法的具体用法?Java Resource.getMediaType怎么用?Java Resource.getMediaType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.registry.core.Resource的用法示例。


在下文中一共展示了Resource.getMediaType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateDavResourceMimeType

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void updateDavResourceMimeType(RegistryResource resource) {
    Resource r = resource.getUnderLineResource();
    if (r.getMediaType() == null) {
        Metadata metadata = metadataMap.get(r.getPath());
        if (null != metadata) {
            final String mimeType = metadata.getValue();
            long currentSysTime = System.currentTimeMillis();
            //fetch the media type from the session, ONLY if the time laps is less than 15s, not for newly created files
            // with no extensions.
            if ((currentSysTime - metadata.getLastUpdatedTime()) < 15000 && null != mimeType) {
                r.setMediaType(mimeType);
            }
            metadataMap.remove(r.getPath());
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:17,代码来源:RegistryWebDavContext.java

示例2: handleDelete

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public boolean handleDelete(RequestContext requestContext) throws RegistryException {
    Resource resource = requestContext.getResource();
    if (resource == null) {
        resource =
                requestContext.getRepository().get(requestContext.getResourcePath().getPath());
        requestContext.setResource(resource);
    }

    if (resource != null) {
        String mType = resource.getMediaType();
        if (mType != null){
            Matcher matcher = pattern.matcher(mType);
            return  matcher.matches();
        }
    }

    return false;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:20,代码来源:MediaTypeFilter.java

示例3: handlePut

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public boolean handlePut(RequestContext requestContext) throws RegistryException {
    Resource resource = requestContext.getResource();
    if (resource != null) {
        String mType = resource.getMediaType();
        return mType != null && (invert != mType.equals(getMediaType()));
    }
    return false;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:10,代码来源:RegistryPolicyMediaTypeMatcher.java

示例4: handlePut

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public boolean handlePut(RequestContext requestContext) throws RegistryException {
    Resource resource = requestContext.getResource();
    if (resource == null) {
        return false;
    }

    String mType = resource.getMediaType();
    if (mType != null){
        Matcher matcher = pattern.matcher(mType);
        return  matcher.matches();
    }
    return false;

}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:16,代码来源:MediaTypeFilter.java

示例5: handleImportResource

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public boolean handleImportResource(RequestContext requestContext) throws RegistryException {
    Resource resource = requestContext.getResource();
    if (resource == null) {
        return false;
    }

    String mType = resource.getMediaType();
    if (mType != null){
        Matcher matcher = pattern.matcher(mType);
        return  matcher.matches();
    }
    return false;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:15,代码来源:MediaTypeFilter.java

示例6: handleAddAssociation

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public boolean handleAddAssociation(RequestContext requestContext)
        throws RegistryException {
    Resource resource =  requestContext.getRepository().get(requestContext.getSourcePath());

    if (resource != null) {
        String mType = resource.getMediaType();
        if (mType != null && (invert != mType.equals(CommonConstants.ENDPOINT_MEDIA_TYPE))) {
            return true;
        }
    }

    return false;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:14,代码来源:EndpointMediaTypeMatcher.java

示例7: handleRemoveAssociation

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public boolean handleRemoveAssociation(RequestContext requestContext)
        throws RegistryException {
    Resource resource =  requestContext.getRepository().get(requestContext.getSourcePath());

    if (resource != null) {
        String mType = resource.getMediaType();
        if (mType != null && (invert != mType.equals(CommonConstants.ENDPOINT_MEDIA_TYPE))) {
            return true;
        }
    }

    return false;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:14,代码来源:EndpointMediaTypeMatcher.java

示例8: ResourceModel

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public ResourceModel(Resource resource) throws RegistryException 
{
	this.mediaType = resource.getMediaType();
	this.uuid = resource.getUUID();
	this.authorUsername = resource.getAuthorUserName();
	this.lastModifiedUsername = resource.getLastUpdaterUserName();
	this.description = resource.getDescription();
	this.createdTime = resource.getCreatedTime().toGMTString();
	this.lastModifiedTime = resource.getLastModified().toGMTString();		
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:11,代码来源:ResourceModel.java

示例9: updateTextContent

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static void updateTextContent(String path, String contentText, Registry registry)
        throws Exception {

    try {
        Resource resource = registry.get(path);
        String mediaType = resource.getMediaType();
        if (resource.getProperty(RegistryConstants.REGISTRY_LINK) != null &&
                (CommonConstants.WSDL_MEDIA_TYPE.equals(mediaType) ||
                        CommonConstants.SCHEMA_MEDIA_TYPE.equals(mediaType))) {
            String description = resource.getDescription();
            Properties properties = (Properties) resource.getProperties().clone();
            resource = registry.newResource();
            resource.setMediaType(mediaType);
            resource.setDescription(description);
            resource.setProperties(properties);
        }
        resource.setContent(RegistryUtils.encodeString(contentText));
        registry.put(path, resource);
        resource.discard();

    } catch (RegistryException e) {

        String msg = "Could not update the content of the resource " +
                path + ". Caused by: " + ((e.getCause() instanceof SQLException) ?
                "" : e.getMessage());
        log.error(msg, e);
        throw new RegistryException(msg, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:30,代码来源:UpdateTextContentUtil.java

示例10: clearPreFetchArtifact

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 *  Clear meta data cache
 * @param requestContext RequestContext
 */
private void clearPreFetchArtifact(RequestContext requestContext) throws RegistryException {
    if(!CommonUtil.isMetaDataClearLockAvailable()){
        return;
    }
    CommonUtil.acquireMetaDataClearLock();
    try{
        Resource resource = requestContext.getResource();
        if (resource == null || resource.getUUID() == null) {
           return;
        }
    String mediaType = resource.getMediaType();
    String artifactPath = null;
    try {
        artifactPath = GovernanceUtils.getDirectArtifactPath(requestContext.getRegistry(), resource.getUUID());
    } catch (GovernanceException e) {
        String msg = "Failed to get path of artifact id = " + resource.getUUID();
        log.error(msg, e);
        throw new RegistryException(msg, e);
    }

    if (mediaType == null || artifactPath == null) {
        return;
    }
    if (mediaType.matches("application/.[a-zA-Z0-9.-]+\\+xml")) {
        ArtifactCache artifactCache =
                ArtifactCacheManager.getCacheManager().
                        getTenantArtifactCache(CurrentSession.getTenantId());
        String cachePath = RegistryUtils.getRelativePathToOriginal(artifactPath,
                RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
        if (artifactCache != null) {
            if (artifactCache.getArtifact(cachePath) != null) {
                artifactCache.invalidateArtifact(cachePath);
            }
        }
    }
    }finally {
        CommonUtil.releaseMetaDataClearLock();
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:44,代码来源:MetaDataCacheHandler.java

示例11: loadDetails

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Method to load the details into this artifact.
 *
 * @throws GovernanceException if the operation failed.
 */
public void loadDetails() throws GovernanceException {
    checkRegistryResourceAssociation();
    Registry registry = getAssociatedRegistry();
    String path = getPath();
    String id = getId();
    Resource resource;
    try {
        resource = registry.get(path);
        this.content = (byte[]) resource.getContent();
        this.mediaType = resource.getMediaType();
    } catch (RegistryException e) {
        throw new GovernanceException("Error in getting the qualified name for the artifact. " +
                "artifact id: " + id + ", " + "path: " + path + ".", e);
    }
    // get the target namespace.
    String fileName = RegistryUtils.getResourceName(path);
    this.qName = new QName(null, fileName);

    // and then iterate all the properties and add.
    Properties properties = resource.getProperties();
    if (properties != null) {
        Set keySet = properties.keySet();
        if (keySet != null) {
            for (Object keyObj : keySet) {
                String key = (String) keyObj;
                List values = (List) properties.get(key);
                if (values != null) {
                    for (Object valueObj : values) {
                        String value = (String) valueObj;
                        addAttribute(key, value);
                    }
                }
            }
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:42,代码来源:GenericArtifactImpl.java

示例12: addMember

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void addMember(DavResource resource, InputContext inputContext)
			throws DavException {
//        if (isLocked(this) || isLocked(member)) {
//            throw new DavException(DavServletResponse.SC_LOCKED);
//        }
        try {
            if (resource instanceof RegistryResource) {
                if (getUnderlineResource() instanceof Collection) {
                    if (resource.getResourcePath().contains(path)) {

                        Resource resourceImpl = ((RegistryResource) resource).getUnderLineResource();
                        boolean isCollection = resourceImpl instanceof Collection;
                        // 'resourceImpl == null' indicates it's a new non-collection resource created by the client
                        // @see:  org.wso2.carbon.registry.webdav.RegistryServlet.doMkCol()
                        if (null == resourceImpl) {
                            resourceImpl = isCollection ? new CollectionImpl() : new ResourceImpl();
                            //setting path and underline resource only for newly created resources
                            ((ResourceImpl) resourceImpl).setPath(resource.getResourcePath());
                            ((RegistryResource) resource).setUnderLineResource(resourceImpl);
                            //if (!isCollection) {
                            resourceCache.updateDavResourceMimeType((RegistryResource) resource);
                            // setting the media type to text/plain as the default for newly created resources with
                            // no extensions.
                            if( null == resourceImpl.getMediaType() && resourceImpl.getPath().indexOf('.') == -1) {
                                resourceImpl.setMediaType("text/plain");
                            }
                            //}
                        }
                        if (!isCollection) {
                            resourceImpl.setContentStream(inputContext.getInputStream());
                        }
                        resourceCache.getRegistry().put(resource.getResourcePath(), resourceImpl);
					} else {
						throw new DavException(DavServletResponse.SC_BAD_REQUEST,
						"Internal Error, Parent and target path does not match");
					}
				} else {
					throw new DavException(DavServletResponse.SC_BAD_REQUEST,
							"Only add resources to Collections");
				}
			} else {
				throw new DavException(DavServletResponse.SC_BAD_REQUEST,
						"Only support " + RegistryResource.class + " as members");
			}
		} catch (RegistryException e) {
			e.printStackTrace();
			throw new DavException(DavServletResponse.SC_BAD_REQUEST,e);
		}

	}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:51,代码来源:RegistryResource.java


注:本文中的org.wso2.carbon.registry.core.Resource.getMediaType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。