Java Code Examples for org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl#setLastModificationDate()

The following examples show how to use org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl#setLastModificationDate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CmisRepository.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Reads and adds properties.
 */
private void readCustomProperties(Node node, PropertiesImpl properties, Set<String> filter, ObjectInfoImpl objectInfo) {
	ObjectData obj = new ObjectDataImpl();

	if (obj.getProperties() != null) {
		// add it to properties
		for (PropertyData<?> prop : obj.getProperties().getPropertyList()) {
			// overwrite object info
			if (prop instanceof PropertyString) {
				String firstValueStr = ((PropertyString) prop).getFirstValue();
				if (PropertyIds.NAME.equals(prop.getId())) {
					objectInfo.setName(firstValueStr);
				} else if (PropertyIds.OBJECT_TYPE_ID.equals(prop.getId())) {
					objectInfo.setTypeId(firstValueStr);
				} else if (PropertyIds.CREATED_BY.equals(prop.getId())) {
					objectInfo.setCreatedBy(firstValueStr);
				} else if (PropertyIds.CONTENT_STREAM_MIME_TYPE.equals(prop.getId())) {
					objectInfo.setContentType(firstValueStr);
				} else if (PropertyIds.CONTENT_STREAM_FILE_NAME.equals(prop.getId())) {
					objectInfo.setFileName(firstValueStr);
				}
			}

			if (prop instanceof PropertyDateTime) {
				GregorianCalendar firstValueCal = ((PropertyDateTime) prop).getFirstValue();
				if (PropertyIds.CREATION_DATE.equals(prop.getId())) {
					objectInfo.setCreationDate(firstValueCal);
				} else if (PropertyIds.LAST_MODIFICATION_DATE.equals(prop.getId())) {
					objectInfo.setLastModificationDate(firstValueCal);
				}
			}

			// check filter
			if (filter != null) {
				if (!filter.contains(prop.getId())) {
					continue;
				} else {
					filter.remove(prop.getId());
				}
			}

			// don't overwrite id
			if (PropertyIds.OBJECT_ID.equals(prop.getId())) {
				continue;
			}

			// don't overwrite base type
			if (PropertyIds.BASE_TYPE_ID.equals(prop.getId())) {
				continue;
			}

			// add it
			properties.replaceProperty(prop);
		}
	}
}