本文整理汇总了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());
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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();
}
}
示例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);
}
}
}
}
}
}
示例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);
}
}