本文整理汇总了Java中javax.jcr.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于javax.jcr包,在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyNode
import javax.jcr.Property; //导入依赖的package包/类
/**
* Copies nodes.
*
* @param node Node to copy
* @param destinationParent Destination parent node
* @throws RepositoryException if problem with jcr repository occurred
*/
public void copyNode(Node node, Node destinationParent) throws RepositoryException {
LOG.debug("Copying node '{}' into '{}'", node.getPath(), destinationParent.getPath());
Node newNode = destinationParent.addNode(node.getName(), node.getPrimaryNodeType().getName());
PropertyIterator it = node.getProperties();
while (it.hasNext()) {
Property property = it.nextProperty();
if (!property.getDefinition().isProtected()) {
newNode
.setProperty(property.getName(), property.getValue().getString(), property.getType());
}
}
NodeIterator nodeIterator = node.getNodes();
while (nodeIterator.hasNext()) {
copyNode(nodeIterator.nextNode(), newNode);
}
}
示例2: getSinglePropertyAs
import javax.jcr.Property; //导入依赖的package包/类
/**
* Takes type, resource, and propertyName and returns its value of the object based on the given type
*
* @param type This is type parameter
* @param resource The resource to fetch the value from
* @param propertyName The property name to be used to fetch the value from the resource
* @return value The value of the object based on the given type
*/
private static <T> T getSinglePropertyAs(Class<T> type, Resource resource, String propertyName) {
T val = null;
try {
if (null != resource) {
Node node = resource.adaptTo(Node.class);
if (null != node) {
if (node.hasProperty(propertyName)) {
Property property = node.getProperty(propertyName);
if (!property.isMultiple()) {
Value value = property.getValue();
val = PropertyUtils.as(type, value);
}
}
}
}
} catch (Exception e) {
LOG.error(ERROR, e);
}
return val;
}
示例3: getMultiplePropertyAs
import javax.jcr.Property; //导入依赖的package包/类
/**
* Takes type, resource, and property name and returns the list of value of the object based on the given type
*
* @param type This is type parameter
* @param resource The resource to fetch the value from
* @param propertyName The property name to be used to fetch the value from the resource
* @return valueList The list of values of the object based on the given type
*/
private static <T> List<T> getMultiplePropertyAs(Class<T> type, Resource resource, String propertyName) {
List<T> val = Collections.EMPTY_LIST;
try {
if (null != resource) {
Node node = resource.adaptTo(Node.class);
if (null != node) {
if (node.hasProperty(propertyName)) {
Property property = node.getProperty(propertyName);
if (property.isMultiple()) {
Value[] value = property.getValues();
val = PropertyUtils.as(type, value);
}
}
}
}
} catch (Exception e) {
LOG.error(ERROR, e);
}
return val;
}
示例4: readFile
import javax.jcr.Property; //导入依赖的package包/类
@Override
public InputStream readFile(String path,String version) throws Exception{
if(StringUtils.isNotBlank(version)){
repositoryInteceptor.readFile(path+":"+version);
return readVersionFile(path, version);
}
repositoryInteceptor.readFile(path);
Node rootNode=getRootNode();
int colonPos = path.lastIndexOf(":");
if (colonPos > -1) {
version = path.substring(colonPos + 1, path.length());
path = path.substring(0, colonPos);
return readFile(path, version);
}
path = processPath(path);
if (!rootNode.hasNode(path)) {
throw new RuleException("File [" + path + "] not exist.");
}
Node fileNode = rootNode.getNode(path);
Property property = fileNode.getProperty(DATA);
Binary fileBinary = property.getBinary();
return fileBinary.getStream();
}
示例5: loadResourceSecurityConfigs
import javax.jcr.Property; //导入依赖的package包/类
@Override
public List<UserPermission> loadResourceSecurityConfigs(String companyId) throws Exception{
List<UserPermission> configs=new ArrayList<UserPermission>();
String filePath=RESOURCE_SECURITY_CONFIG_FILE+(companyId == null ? "" : companyId);
Node rootNode=getRootNode();
Node fileNode = rootNode.getNode(filePath);
Property property = fileNode.getProperty(DATA);
Binary fileBinary = property.getBinary();
InputStream inputStream = fileBinary.getStream();
String content = IOUtils.toString(inputStream, "utf-8");
inputStream.close();
Document document = DocumentHelper.parseText(content);
Element rootElement = document.getRootElement();
for (Object obj : rootElement.elements()) {
if (!(obj instanceof Element)) {
continue;
}
Element element = (Element) obj;
if (!element.getName().equals("user-permission")) {
continue;
}
UserPermission userResource=new UserPermission();
userResource.setUsername(element.attributeValue("username"));
userResource.setProjectConfigs(parseProjectConfigs(element));
configs.add(userResource);
}
return configs;
}
示例6: reportsNoValidationViolations_forPopulatedUploadField
import javax.jcr.Property; //导入依赖的package包/类
@Test
public void reportsNoValidationViolations_forPopulatedUploadField() throws Exception {
// given
final Node attachmentNode = mock(Node.class);
given(attachmentNodeModel.getNode()).willReturn(attachmentNode);
final Property attachmentFileNameProperty = mock(Property.class);
final String validFileName = newRandomString();
given(attachmentFileNameProperty.getString()).willReturn(validFileName);
given(attachmentNode.getProperty(HIPPO_FILENAME_PROPERTY_NAME)).willReturn(attachmentFileNameProperty);
// when
final Set<Violation> actualValidationViolations =
blankAttachmentFieldValidator.validate(fieldValidator, documentNodeModel, attachmentNodeModel);
// then
then(attachmentNode).should().getProperty(HIPPO_FILENAME_PROPERTY_NAME);
assertThat("No violation has been reported.", actualValidationViolations, is(empty()));
}
示例7: reportsNoValidationViolations_forPopulatedLinkUrlField
import javax.jcr.Property; //导入依赖的package包/类
@Test
public void reportsNoValidationViolations_forPopulatedLinkUrlField() throws Exception {
// given
final Node relatedLinkNode = mock(Node.class);
given(relatedLinkNodeModel.getNode()).willReturn(relatedLinkNode);
final Property relatedLinkUrlProperty = mock(Property.class);
given(relatedLinkUrlProperty.getString()).willReturn(VALID_URL);
given(relatedLinkNode.getProperty(HIPPO_RELATED_LINK_URL_PROPERTY_NAME)).willReturn(relatedLinkUrlProperty);
// when
final Set<Violation> actualValidationViolations =
blankRelatedLinkFieldValidator.validate(fieldValidator, documentNodeModel, relatedLinkNodeModel);
// then
then(relatedLinkNode).should().getProperty(HIPPO_RELATED_LINK_URL_PROPERTY_NAME);
assertThat("No violation has been reported.", actualValidationViolations, is(empty()));
}
示例8: setPropertyStringValueArrayWithStringValues
import javax.jcr.Property; //导入依赖的package包/类
@Test
public void setPropertyStringValueArrayWithStringValues() throws Exception {
Node testObj = aNode();
Property expected = testObj.setProperty("zip", new Value[] { new StringValue("zap"), new StringValue("zup") });
assertArrayEquals(expected.getValues(), testObj.getProperty("zip").getValues());
assertEquals(expected, testObj.getProperty("zip"));
}
示例9: getPropertyValues
import javax.jcr.Property; //导入依赖的package包/类
private Value[] getPropertyValues(Node node, String propertyName) throws RepositoryException {
if (node.hasProperty(propertyName)) {
Property prop = node.getProperty(propertyName);
Value[] values;
// This check is necessary to ensure a multi-valued field is applied...
if (prop.isMultiple()) {
values = prop.getValues();
} else {
values = new Value[1];
values[0] = prop.getValue();
}
return values;
}
return new Value[0];
}
示例10: setProperty
import javax.jcr.Property; //导入依赖的package包/类
private void setProperty(Node node, String propertyName, AbstractJcrNodeAdapter nodeAdapter) throws RepositoryException {
com.vaadin.data.Property prop = nodeAdapter.getItemProperty(propertyName);
if (prop == null || prop.getValue() == null) {
// someone didn't set the property
return;
}
Object val = prop.getValue();
if (val instanceof String) {
node.setProperty(propertyName, StringUtils.trimToEmpty(((String) prop.getValue())));
} else if (val instanceof Boolean) {
node.setProperty(propertyName, ((Boolean) val).toString());
} else {
node.setProperty(propertyName, prop.getValue().toString());
}
}
示例11: execute
import javax.jcr.Property; //导入依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
// First Validate
validator.showValidation(true);
if (validator.isValid()) {
try {
final Node node = item.applyChanges();
// Set the Node name.
setNodeName(node, item);
// WTF was whomever at JR dev team thinking?
for (Property prop : in((Iterator<Property>) node.getProperties())) {
if (prop.getType() == PropertyType.STRING && StringUtils.isEmpty(prop.getValue().getString())) {
prop.remove();
}
}
node.getSession().save();
} catch (final RepositoryException e) {
throw new ActionExecutionException(e);
}
callback.onSuccess(getDefinition().getName());
} else {
log.info("Validation error(s) occurred. No save performed.");
}
}
示例12: accepts
import javax.jcr.Property; //导入依赖的package包/类
@Override
public boolean accepts(final Property property) {
try {
// Example: Reject properties whose names are "secretData" or "privateData"
if (!ArrayUtils.contains(new String[]{ "secretData", "privateData" }, property.getName())) {
// Maintain the filteredPaths list whenever accepts returns false
filteredPaths.add(property.getPath());
return false;
}
} catch (RepositoryException e) {
log.error("Repository exception occurred. Do not accept this Property. {}", e);
}
// Default behavior is to return true
return true;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-samples,代码行数:17,代码来源:SampleReplicationContentFilter.java
示例13: curePhase
import javax.jcr.Property; //导入依赖的package包/类
/**
* The purpose of this method is to check for some conditions which may break Phases.
*
* @param boardId
* @param phaseId
* @return
* @throws Exception
*/
@PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
@RequestMapping(value = "/{phaseId}/cure", method=RequestMethod.GET)
public @ResponseBody Boolean curePhase(@PathVariable String boardId,
@PathVariable String phaseId) throws Exception {
Session session = ocmFactory.getOcm().getSession();
try{
Node node = session.getNode(String.format(URI.PHASES_URI, boardId, phaseId));
Property property = node.getProperty("cards");
// If there is a property we need to kill it.
property.remove();
session.save();
} catch (PathNotFoundException e){
// This is expected - there should be no property.
} finally {
session.logout();
}
this.cacheInvalidationManager.invalidate(BoardController.BOARD, boardId);
return true;
}
示例14: getTasksComplete
import javax.jcr.Property; //导入依赖的package包/类
public void getTasksComplete(Card card) throws Exception {
ObjectContentManager ocm = ocmFactory.getOcm();
try{
Node node = ocm.getSession().getNode(String.format(URI.TASKS_URI, card.getBoard(), card.getPhase(), card.getId().toString(),""));
int complete = 0;
NodeIterator nodes = node.getNodes();
while(nodes.hasNext()){
Node nextNode = nodes.nextNode();
Property property = nextNode.getProperty("complete");
if( property!=null && property.getBoolean() ){
complete++;
}
}
card.setCompleteTasks(Long.valueOf(complete));
} finally {
ocm.logout();
}
}
示例15: getFieldsForCard
import javax.jcr.Property; //导入依赖的package包/类
public Map<String, Object> getFieldsForCard(Card card,
ObjectContentManager ocm) throws RepositoryException {
Map<String, Object> result = new HashMap<String, Object>();
Node node = ocm.getSession().getNode(
String.format(URI.FIELDS_URI, card.getBoard(), card.getPhase(),
card.getId()));
if(node==null){
return result;
}
PropertyIterator properties = node.getProperties();
while (properties.hasNext()) {
Property property = properties.nextProperty();
Object value = getRealValue(property);
result.put(property.getName(), value);
}
return result;
}