本文整理匯總了Java中javax.jcr.Node.setProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.setProperty方法的具體用法?Java Node.setProperty怎麽用?Java Node.setProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jcr.Node
的用法示例。
在下文中一共展示了Node.setProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: copyNode
import javax.jcr.Node; //導入方法依賴的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: setUpdateScriptJcrNode
import javax.jcr.Node; //導入方法依賴的package包/類
/**
* do the update or create a node of the groovy file
* this will not save the session
*
* @param parent parentnode of the Node te be
* @param file file to transform into a Node
* @return success
* @throws RepositoryException
*/
public static boolean setUpdateScriptJcrNode(Node parent, File file) throws RepositoryException {
ScriptClass scriptClass = getInterpretingClass(file);
if(!scriptClass.isValid()){
return false;
}
final Updater updater = scriptClass.getUpdater();
String name = updater.name();
if(parent.hasNode(name)){
parent.getNode(name).remove();
}
Node scriptNode = parent.addNode(name, HIPPOSYS_UPDATERINFO);
scriptNode.setProperty(HIPPOSYS_BATCHSIZE, updater.batchSize());
scriptNode.setProperty(HIPPOSYS_DESCRIPTION, updater.description());
scriptNode.setProperty(HIPPOSYS_PARAMETERS, updater.parameters());
scriptNode.setProperty(updater.xpath().isEmpty() ? HIPPOSYS_PATH : HIPPOSYS_QUERY,
updater.xpath().isEmpty() ? updater.path() : updater.xpath());
scriptNode.setProperty(HIPPOSYS_SCRIPT, scriptClass.getContent());
scriptNode.setProperty(HIPPOSYS_THROTTLE, updater.throttle());
return true;
}
示例3: setFieldExternalDocuments
import javax.jcr.Node; //導入方法依賴的package包/類
/**
* This method sets what data form the external source should be stored on the document.
* In this case it stores the entire json object as string
*
* @param context
* @param exdocs
*/
@Override
public void setFieldExternalDocuments(ExternalDocumentServiceContext context, ExternalDocumentCollection<JSONObject> exdocs) {
final String fieldName = context.getPluginConfig().getString(PARAM_EXTERNAL_DOCS_FIELD_NAME);
if (StringUtils.isBlank(fieldName)) {
throw new IllegalArgumentException("Invalid plugin configuration parameter for '" + PARAM_EXTERNAL_DOCS_FIELD_NAME + "': " + fieldName);
}
try {
final Node contextNode = context.getContextModel().getNode();
final List<String> docIds = new ArrayList<String>();
for (Iterator<? extends JSONObject> it = exdocs.iterator(); it.hasNext(); ) {
JSONObject doc = it.next();
docIds.add(doc.toString());
}
contextNode.setProperty(fieldName, docIds.toArray(new String[docIds.size()]));
} catch (RepositoryException e) {
log.error("Failed to set related exdoc array field.", e);
}
}
開發者ID:jenskooij,項目名稱:hippo-external-document-picker-example-implementation,代碼行數:30,代碼來源:DocumentServiceFacade.java
示例4: createProject
import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public RepositoryFile createProject(String projectName, User user,boolean classify) throws Exception{
if(!permissionService.isAdmin()){
throw new NoPermissionException();
}
repositoryInteceptor.createProject(projectName);
Node rootNode=getRootNode();
if(rootNode.hasNode(projectName)){
throw new RuleException("Project ["+projectName+"] already exist.");
}
Node projectNode=rootNode.addNode(projectName);
projectNode.addMixin("mix:versionable");
projectNode.setProperty(FILE, true);
projectNode.setProperty(CRATE_USER,user.getUsername());
projectNode.setProperty(COMPANY_ID, user.getCompanyId());
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
DateValue dateValue = new DateValue(calendar);
projectNode.setProperty(CRATE_DATE, dateValue);
session.save();
createResourcePackageFile(projectName,user);
createClientConfigFile(projectName, user);
RepositoryFile projectFileInfo=buildProjectFile(projectNode, null ,classify,null);
return projectFileInfo;
}
示例5: addMetadataFacet
import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
throws MetadataRepositoryException
{
try
{
Node repo = getOrAddRepositoryNode( repositoryId );
Node facets = JcrUtils.getOrAddNode( repo, "facets" );
String id = metadataFacet.getFacetId();
Node facetNode = JcrUtils.getOrAddNode( facets, id );
Node node = getOrAddNodeByPath( facetNode, metadataFacet.getName() );
for ( Map.Entry<String, String> entry : metadataFacet.toProperties().entrySet() )
{
node.setProperty( entry.getKey(), entry.getValue() );
}
}
catch ( RepositoryException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
示例6: setPropertyStringValueArrayWithStringValues
import javax.jcr.Node; //導入方法依賴的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"));
}
示例7: configureReplicationPublishAgent
import javax.jcr.Node; //導入方法依賴的package包/類
/**
* Configure the publish replication agent.
*
* Generally this would be done only on an author server.
*
* @param configs A list of potential configs. The first config that has run modes that are
* all satisfied by the current server will be applied. This allows a script
* to specify configs for all of the servers in an AEM ecosystem, applying the
* correct configs to each server.
* @throws RepositoryException
*/
protected void configureReplicationPublishAgent(List<PublishReplicationConfig> configs) throws RepositoryException {
boolean configured = false;
Set<String> serverRunModes = ServiceUtil.getRunModes();
for (PublishReplicationConfig config : configs) {
if (!configured && serverRunModes.containsAll(config.getRunModes())) {
logger.info("Configuring publish replication agent for run modes '{}'", StringUtils.join(config.getRunModes().toArray(), ","));
String replicationAgentPath = "/etc/replication/agents.author/publish/jcr:content";
Node replicationAgent = session.getNode(replicationAgentPath);
replicationAgent.setProperty("transportUri", config.getPublishHost() + "/bin/receive?sling:authRequestLogin=1");
replicationAgent.setProperty("enabled", config.isEnabled());
configured = true;
}
}
if (!configured) {
logger.info("No matching configs found for configuring publish replication agent on this server");
}
}
示例8: createFileNode
import javax.jcr.Node; //導入方法依賴的package包/類
private void createFileNode(String path, String content,User user,boolean isFile) throws Exception{
String createUser=user.getUsername();
repositoryInteceptor.createFile(path,content);
Node rootNode=getRootNode();
path = processPath(path);
try {
if (rootNode.hasNode(path)) {
throw new RuleException("File [" + path + "] already exist.");
}
Node fileNode = rootNode.addNode(path);
fileNode.addMixin("mix:versionable");
fileNode.addMixin("mix:lockable");
Binary fileBinary = new BinaryImpl(content.getBytes());
fileNode.setProperty(DATA, fileBinary);
if(isFile){
fileNode.setProperty(FILE, true);
}
fileNode.setProperty(CRATE_USER, createUser);
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
DateValue dateValue = new DateValue(calendar);
fileNode.setProperty(CRATE_DATE, dateValue);
session.save();
} catch (Exception ex) {
throw new RuleException(ex);
}
}
示例9: setSearchableFlag
import javax.jcr.Node; //導入方法依賴的package包/類
private void setSearchableFlag(Node document) {
try {
document.setProperty(
SEARCHABLE_FLAG,
isPubliclyAccessible(document)
);
} catch (RepositoryException ex) {
log.error("RepositoryException during read operation", ex);
}
}
示例10: setSearchableFlag
import javax.jcr.Node; //導入方法依賴的package包/類
private void setSearchableFlag(Node document, boolean searchable) {
try {
document.setProperty(SEARCHABLE_FLAG, searchable);
} catch (RepositoryException ex) {
log.error("RepositoryException during setting common:searchable flag", ex);
}
}
示例11: getJcrFromFixture
import javax.jcr.Node; //導入方法依賴的package包/類
public Session getJcrFromFixture(InputStream fixture) {
Repository repository = null;
Session session = null;
try {
repository = MockJcr.newRepository();
session = repository.login();
Node rootNode = session.getRootNode();
Yaml parser = new Yaml();
List<Map<String, Object>> nodes = (ArrayList<Map<String, Object>>) parser.load(fixture);
for (Map object: nodes) {
NodeYaml node = new NodeYaml(
(String) object.get("path"),
(String) object.get("primaryType"),
(Map<String, Object>) object.getOrDefault("properties", emptyMap())
);
Node n = rootNode.addNode(node.path, node.primaryType);
for (Map.Entry<String, Object> entry : node.properties.entrySet()) {
if (entry.getValue() instanceof Boolean) {
n.setProperty(entry.getKey(), (Boolean) entry.getValue());
} else {
n.setProperty(entry.getKey(), entry.getValue().toString());
}
}
}
session.save();
} catch (RepositoryException e) {
throw new RuntimeException("Failed to set property on JCR node", e);
}
return session;
}
示例12: updateNamespace
import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public void updateNamespace( String repositoryId, String namespace )
throws MetadataRepositoryException
{
try
{
Node node = getOrAddNamespaceNode( repositoryId, namespace );
node.setProperty( "namespace", namespace );
}
catch ( RepositoryException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
示例13: setPropertyWithStringReturnsValidProperty
import javax.jcr.Node; //導入方法依賴的package包/類
@Test
public void setPropertyWithStringReturnsValidProperty() throws Exception {
Node target = aNode();
target.setProperty("zip", "zap");
assertEquals("zap", target.getProperty("zip").getValue().getString());
}
示例14: updateResourceType
import javax.jcr.Node; //導入方法依賴的package包/類
/**
* Update the sling:resourceType of a node.
*
* @param node The node to update.
* @param resourceType The new sling:resourceType to be used.
*/
protected void updateResourceType(Node node, String resourceType) throws RepositoryException {
String currentResourceType = node.getProperty("sling:resourceType").getString();
if (!resourceType.equals(currentResourceType)) {
logger.info("Updating node at {} to resource type '{}'", node.getPath(), resourceType);
node.setProperty("sling:resourceType", resourceType);
} else {
logger.info("Node at {} is already resource type '{}'", node.getPath(), resourceType);
}
}
示例15: trackScriptEnd
import javax.jcr.Node; //導入方法依賴的package包/類
protected void trackScriptEnd(Session session, Node statusNode, String statusNodePath, String status) {
try {
statusNode.setProperty("status", status);
statusNode.setProperty("endDate", Calendar.getInstance());
session.save();
} catch (RepositoryException e) {
logger.warn("On-deploy script status node could not be updated: {} - status: {}", statusNodePath, status);
}
}