本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentData.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java ContentData.getSize方法的具体用法?Java ContentData.getSize怎么用?Java ContentData.getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.repository.ContentData
的用法示例。
在下文中一共展示了ContentData.getSize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addContent
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
*
*/
public void addContent(ContentData data) throws TransferException
{
logger.debug("add content size:" + data.getSize());
buffer.add(data);
/**
* work out whether the buffer has filled up and needs to be flushed
*/
Iterator<ContentData> iter = buffer.iterator();
long totalContentSize = 0;
while (iter.hasNext())
{
ContentData x = (ContentData)iter.next();
totalContentSize += x.getSize();
}
if(logger.isDebugEnabled())
{
logger.debug("elements " + buffer.size() + ", totalContentSize:" + totalContentSize);
}
if(totalContentSize >= chunkSize)
{
flush();
}
}
示例2: getDAVPropertyValue
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
* Return the Alfresco property value for the specified WebDAV property
*
* @param davPropName String
* @return Object
*/
public static Object getDAVPropertyValue( Map<QName, Serializable> props, String davPropName)
{
// Convert the WebDAV property name to the corresponding Alfresco property
QName propName = _propertyNameMap.get( davPropName);
if ( propName == null)
throw new AlfrescoRuntimeException("No mapping for WebDAV property " + davPropName);
// Return the property value
Object value = props.get(propName);
if (value instanceof ContentData)
{
ContentData contentData = (ContentData) value;
if (davPropName.equals(WebDAV.XML_GET_CONTENT_TYPE))
{
value = contentData.getMimetype();
}
else if (davPropName.equals(WebDAV.XML_GET_CONTENT_LENGTH))
{
value = new Long(contentData.getSize());
}
}
return value;
}
示例3: Document
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
public Document(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
{
super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);
Serializable val = nodeProps.get(ContentModel.PROP_CONTENT);
if ((val != null) && (val instanceof ContentData)) {
ContentData cd = (ContentData)val;
String mimeType = cd.getMimetype();
String mimeTypeName = sr.getMimetypeService().getDisplaysByMimetype().get(mimeType);
contentInfo = new ContentInfo(mimeType, mimeTypeName, cd.getSize(), cd.getEncoding());
}
setIsFolder(false);
setIsFile(true);
}
示例4: toApiRendition
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
protected Rendition toApiRendition(NodeRef renditionNodeRef)
{
Rendition apiRendition = new Rendition();
String renditionName = (String) nodeService.getProperty(renditionNodeRef, ContentModel.PROP_NAME);
apiRendition.setId(renditionName);
ContentData contentData = getContentData(renditionNodeRef, false);
ContentInfo contentInfo = null;
if (contentData != null)
{
contentInfo = new ContentInfo(contentData.getMimetype(),
getMimeTypeDisplayName(contentData.getMimetype()),
contentData.getSize(),
contentData.getEncoding());
}
apiRendition.setContent(contentInfo);
apiRendition.setStatus(RenditionStatus.CREATED);
return apiRendition;
}
示例5: NodeContentData
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
* Construct
*/
public NodeContentData(NodeRef nodeRef, ContentData contentData)
{
super(contentData.getContentUrl(), contentData.getMimetype(), contentData.getSize(),
contentData.getEncoding(), contentData.getLocale());
this.nodeRef = nodeRef;
}
示例6: onCreateNode
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
public void onCreateNode(ChildAssociationRef childAssocRef)
{
NodeRef nodeRef = childAssocRef.getChildRef();
if (stores.contains(tenantService.getBaseName(nodeRef.getStoreRef()).toString()) && (! alreadyCreated(nodeRef)))
{
// TODO use data dictionary to get content property
ContentData contentData = (ContentData)nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
if (contentData != null)
{
long contentSize = contentData.getSize();
// Get owner/creator
String owner = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_OWNER);
if ((owner == null) || (owner.equals(OwnableService.NO_OWNER)))
{
owner = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_CREATOR);
}
if (contentSize != 0 && owner != null)
{
// increment usage if node is being created
if (logger.isDebugEnabled()) logger.debug("onCreateNode: nodeRef="+nodeRef+", owner="+owner+", contentSize="+contentSize);
incrementUserUsage(owner, contentSize, nodeRef);
recordCreate(nodeRef);
}
}
}
}
示例7: beforeDeleteNode
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
* Called before a node is deleted.
*
* @param nodeRef the node reference
*/
public void beforeDeleteNode(NodeRef nodeRef)
{
if (stores.contains(tenantService.getBaseName(nodeRef.getStoreRef()).toString()) && (! alreadyDeleted(nodeRef)))
{
// TODO use data dictionary to get content property
ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
if (contentData != null)
{
long contentSize = contentData.getSize();
// Get owner/creator
String owner = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_ARCHIVED_ORIGINAL_OWNER); // allow for case where someone else is deleting the node
if (owner == null || owner.equals(OwnableService.NO_OWNER))
{
owner = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_OWNER);
if ((owner == null) || (owner.equals(OwnableService.NO_OWNER)))
{
owner = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_CREATOR);
}
}
if (contentSize != 0 && owner != null)
{
// decrement usage if node is being deleted
if (logger.isDebugEnabled()) logger.debug("beforeDeleteNode: nodeRef="+nodeRef+", owner="+owner+", contentSize="+contentSize);
decrementUserUsage(owner, contentSize, nodeRef);
recordDelete(nodeRef);
}
}
}
}
示例8: getValueInternal
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
ContentData contentData = getContentData(nodeInfo);
if (contentData != null)
{
return contentData.getSize();
}
return null;
}
示例9: hasContent
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
* Check that a property contains (non-empty) content, i.e. content with
* size > 0
*
* @param contentQName Which property to check
* @return The created node assertion object
*/
public NodeAssert hasContent(final QName contentQName) {
isNotNull();
exists();
final Serializable prop = nodeService.getProperty(actual, contentQName);
if (prop != null) {
final ContentData content = (ContentData) prop;
if (content.getSize() == 0) {
failWithMessage("Node <%s> should have content with size > 0 ", actual);
}
} else {
failWithMessage("Node <%s> should have content ", actual);
}
return this;
}
示例10: executeImpl
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
// Check if thumbnailing is generally disabled
if (!thumbnailService.getThumbnailsEnabled())
{
if (logger.isDebugEnabled())
{
logger.debug("Thumbnail transformations are not enabled");
}
return;
}
// Get the thumbnail
NodeRef thumbnailNodeRef = (NodeRef)action.getParameterValue(PARAM_THUMBNAIL_NODE);
if (thumbnailNodeRef == null)
{
thumbnailNodeRef = actionedUponNodeRef;
}
if (this.nodeService.exists(thumbnailNodeRef) == true &&
renditionService.isRendition(thumbnailNodeRef))
{
// Get the thumbnail Name
ChildAssociationRef parent = renditionService.getSourceNode(thumbnailNodeRef);
String thumbnailName = parent.getQName().getLocalName();
// Get the details of the thumbnail
ThumbnailRegistry registry = this.thumbnailService.getThumbnailRegistry();
ThumbnailDefinition details = registry.getThumbnailDefinition(thumbnailName);
if (details == null)
{
throw new AlfrescoRuntimeException("The thumbnail name '" + thumbnailName + "' is not registered");
}
// Get the content property
QName contentProperty = (QName)action.getParameterValue(PARAM_CONTENT_PROPERTY);
if (contentProperty == null)
{
contentProperty = ContentModel.PROP_CONTENT;
}
Serializable contentProp = nodeService.getProperty(actionedUponNodeRef, contentProperty);
if (contentProp == null)
{
logger.info("Creation of thumbnail, null content for " + details.getName());
return;
}
if(contentProp instanceof ContentData)
{
ContentData content = (ContentData)contentProp;
String mimetype = content.getMimetype();
if (mimetypeMaxSourceSizeKBytes != null)
{
Long maxSourceSizeKBytes = mimetypeMaxSourceSizeKBytes.get(mimetype);
if (maxSourceSizeKBytes != null && maxSourceSizeKBytes >= 0 && maxSourceSizeKBytes < (content.getSize()/1024L))
{
logger.debug("Unable to create thumbnail '" + details.getName() + "' for " +
mimetype + " as content is too large ("+(content.getSize()/1024L)+"K > "+maxSourceSizeKBytes+"K)");
return; //avoid transform
}
}
}
// Create the thumbnail
this.thumbnailService.updateThumbnail(thumbnailNodeRef, details.getTransformationOptions());
}
}
示例11: contentImpl
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
@Override
protected void contentImpl(NodeRef nodeRef, QName property, InputStream content, ContentData contentData, int index)
{
size = size + contentData.getSize();
fileCount = fileCount + 1;
}
示例12: createContentDataEntity
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
* Translates the {@link ContentData} into persistable values using the helper DAOs
*/
protected ContentDataEntity createContentDataEntity(ContentData contentData)
{
// Resolve the content URL
Long contentUrlId = null;
String contentUrl = contentData.getContentUrl();
long size = contentData.getSize();
if (contentUrl != null)
{
ContentUrlEntity contentUrlEntity = new ContentUrlEntity();
contentUrlEntity.setContentUrl(contentUrl);
contentUrlEntity.setSize(size);
Pair<Long, ContentUrlEntity> pair = contentUrlCache.createOrGetByValue(contentUrlEntity, controlDAO);
contentUrlId = pair.getFirst();
}
// Resolve the mimetype
Long mimetypeId = null;
String mimetype = contentData.getMimetype();
if (mimetype != null)
{
mimetypeId = mimetypeDAO.getOrCreateMimetype(mimetype).getFirst();
}
// Resolve the encoding
Long encodingId = null;
String encoding = contentData.getEncoding();
if (encoding != null)
{
encodingId = encodingDAO.getOrCreateEncoding(encoding).getFirst();
}
// Resolve the locale
Long localeId = null;
Locale locale = contentData.getLocale();
if (locale != null)
{
localeId = localeDAO.getOrCreateLocalePair(locale).getFirst();
}
// Create ContentDataEntity
ContentDataEntity contentDataEntity = createContentDataEntity(contentUrlId, mimetypeId, encodingId, localeId);
// Done
return contentDataEntity;
}
示例13: getContent
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
@Override
public BinaryResource getContent(NodeRef nodeRef, Parameters parameters, boolean recordActivity)
{
if (!nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_CONTENT), null, false))
{
throw new InvalidArgumentException("NodeId of content is expected: " + nodeRef.getId());
}
Map<QName, Serializable> nodeProps = nodeService.getProperties(nodeRef);
ContentData cd = (ContentData) nodeProps.get(ContentModel.PROP_CONTENT);
String name = (String) nodeProps.get(ContentModel.PROP_NAME);
org.alfresco.rest.framework.resource.content.ContentInfo ci = null;
String mimeType = null;
if (cd != null)
{
mimeType = cd.getMimetype();
ci = new org.alfresco.rest.framework.resource.content.ContentInfoImpl(mimeType, cd.getEncoding(), cd.getSize(), cd.getLocale());
}
// By default set attachment header (with filename) unless attachment=false *and* content type is pre-configured as non-attach
boolean attach = true;
String attachment = parameters.getParameter("attachment");
if (attachment != null)
{
Boolean a = Boolean.valueOf(attachment);
if (!a)
{
if (nonAttachContentTypes.contains(mimeType))
{
attach = false;
}
else
{
logger.warn("Ignored attachment=false for "+nodeRef.getId()+" since "+mimeType+" is not in the whitelist for non-attach content types");
}
}
}
String attachFileName = (attach ? name : null);
if (recordActivity)
{
final ActivityInfo activityInfo = getActivityInfo(getParentNodeRef(nodeRef), nodeRef);
postActivity(Activity_Type.DOWNLOADED, activityInfo, true);
}
return new NodeBinaryResource(nodeRef, ContentModel.PROP_CONTENT, ci, attachFileName);
}
示例14: getQuickShareInfo
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
private QuickShareLink getQuickShareInfo(NodeRef nodeRef, Map<String, Object> map, boolean noAuth, List<String> includeParam)
{
String sharedId = (String)map.get("sharedId");
try
{
Map<QName, Serializable> nodeProps = nodeService.getProperties(nodeRef);
ContentData cd = (ContentData)nodeProps.get(ContentModel.PROP_CONTENT);
String mimeType = cd.getMimetype();
String mimeTypeName = mimeTypeService.getDisplaysByMimetype().get(mimeType);
ContentInfo contentInfo = new ContentInfo(mimeType, mimeTypeName, cd.getSize(), cd.getEncoding());
Map<String, UserInfo> mapUserInfo = new HashMap<>(2);
// note: if noAuth mode then don't return userids (to limit disclosure and be consistent with v0 internal)
boolean displayNameOnly = noAuth;
UserInfo modifiedByUser = Node.lookupUserInfo((String)nodeProps.get(ContentModel.PROP_MODIFIER), mapUserInfo, personService, displayNameOnly);
// TODO review - should we return sharedByUser for authenticated users only ?? (not exposed by V0 but needed for "find")
String sharedByUserId = (String)nodeProps.get(QuickShareModel.PROP_QSHARE_SHAREDBY);
UserInfo sharedByUser = Node.lookupUserInfo(sharedByUserId, mapUserInfo, personService, displayNameOnly);
QuickShareLink qs = new QuickShareLink(sharedId, nodeRef.getId());
qs.setName((String) map.get("name"));
qs.setTitle((String) map.get("title"));
qs.setDescription((String) map.get("description"));
qs.setContent(contentInfo);
qs.setModifiedAt((Date) map.get("modified"));
qs.setModifiedByUser(modifiedByUser);
qs.setSharedByUser(sharedByUser);
qs.setExpiresAt((Date) map.get("expiryDate"));
// note: if noAuth mode then do not return allowable operations (eg. but can be optionally returned when finding shared links)
if (!noAuth)
{
if (includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS))
{
if (quickShareService.canDeleteSharedLink(nodeRef, sharedByUserId))
{
// the allowable operations for the shared link
qs.setAllowableOperations(Collections.singletonList(Nodes.OP_DELETE));
}
Node doc = nodes.getFolderOrDocument(nodeRef, null, null, includeParam, null);
List<String> allowableOps = doc.getAllowableOperations();
// the allowable operations for the actual file being shared
qs.setAllowableOperationsOnTarget(allowableOps);
}
// in noAuth mode we don't return the path info
if (includeParam.contains(PARAM_INCLUDE_PATH))
{
qs.setPath(nodes.lookupPathInfo(nodeRef, null));
}
}
return qs;
}
catch (InvalidSharedIdException ex)
{
logger.warn("Unable to find: " + sharedId);
throw new EntityNotFoundException(sharedId);
}
catch (InvalidNodeRefException inre)
{
logger.warn("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
throw new EntityNotFoundException(sharedId);
}
}