当前位置: 首页>>代码示例>>Java>>正文


Java Property.remove方法代码示例

本文整理汇总了Java中javax.jcr.Property.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Property.remove方法的具体用法?Java Property.remove怎么用?Java Property.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jcr.Property的用法示例。


在下文中一共展示了Property.remove方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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.");
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:25,代码来源:SaveTemplateFormAction.java

示例2: 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;
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:32,代码来源:PhaseController.java

示例3: updateInternalSettings

import javax.jcr.Property; //导入方法依赖的package包/类
private void updateInternalSettings() throws RepositoryException {
	// find all internalSettings nodes from DASHBOARDS and change chartId property in entityId
	String statement = "/jcr:root" + ISO9075.encodePath(StorageConstants.DASHBOARDS_ROOT) + "//*[fn:name()='internalSettings']";
    QueryResult queryResult = getTemplate().query(statement);
    NodeIterator nodes = queryResult.getNodes();
    LOG.info("Found " + nodes.getSize() +  " internalSettings nodes");
    while (nodes.hasNext()) {
    	Node node = nodes.nextNode();
    	try {
    		Property prop = node.getProperty("chartId");
    		node.setProperty("entityId", prop.getValue());
    		prop.remove();
    	} catch (PathNotFoundException ex) {
    		// if property not found we have nothing to do
    	}
    } 	
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:18,代码来源:StorageUpdate8.java

示例4: setProperty

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Sets the Value for the given name. If a value existed, it is replaced,
 * if not it is created.
 *
 * @param relPath The relative path to the property or the property name.
 * @param value The property value.
 * @throws RepositoryException If the specified name defines a property
 * that needs to be modified by this user API or setting the corresponding
 * JCR property fails.
 * @see Authorizable#setProperty(String, Value)
 */
public synchronized void setProperty(String relPath, Value value) throws RepositoryException {
    String name = Text.getName(relPath);
    String intermediate = (relPath.equals(name)) ? null : Text.getRelativeParent(relPath, 1);
    checkProtectedProperty(name);
    try {
        Node n = getOrCreateTargetNode(intermediate);
        // check if the property has already been created as multi valued
        // property before -> in this case remove in order to avoid
        // ValueFormatException.
        if (n.hasProperty(name)) {
            Property p = n.getProperty(name);
            if (p.isMultiple()) {
                p.remove();
            }
        }
        n.setProperty(name, value);
        if (entityManager.isAutoSave()) {
            node.save();
        }
    } catch (RepositoryException e) {
        log.debug("Failed to set Property " + name + " for " + this, e);
        node.refresh(false);
        throw e;
    }
}
 
开发者ID:hlta,项目名称:playweb,代码行数:37,代码来源:EntityImpl.java

示例5: removeProperty

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * @see Entity#removeProperty(String)
 */
public synchronized boolean removeProperty(String relPath) throws RepositoryException {
    String name = Text.getName(relPath);        
    checkProtectedProperty(name);
    try {
        if (node.hasProperty(relPath)) {
            Property p = node.getProperty(relPath);
            if (isEntityProperty(p, true)) {
                p.remove();
                if (entityManager.isAutoSave()) {
                    node.save();
                }
                return true;
            }
        }
        // no such property or wasn't a property of this entity.
        return false;
    } catch (RepositoryException e) {
        log.debug("Failed to remove Property " + relPath + " from " + this, e);
        node.refresh(false);
        throw e;
    }
}
 
开发者ID:hlta,项目名称:playweb,代码行数:26,代码来源:EntityImpl.java

示例6: 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();
                }
            }
            setProperty(node, "required", item);
            setProperty(node, "type", item);

            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.");
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:28,代码来源:SaveFieldFormAction.java

示例7: 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 actions = node.addNode("actions", NodeTypes.ContentNode.NAME);
            setAction(node, actions, "commit", "info.magnolia.ui.form.action.SaveFormActionDefinition");
            setAction(node, actions, "cancel", "info.magnolia.ui.form.action.CancelFormActionDefinition");

            Node tabs = node.addNode("form", NodeTypes.ContentNode.NAME).addNode("tabs", NodeTypes.ContentNode.NAME);
            for (Node n : in((Iterator<Node>) node.getNodes("tabs*"))) {
                if (n.hasProperty("field")) {
                    String name = n.getProperty("field").getString();

                    Node tab = tabs.addNode(Path.getUniqueLabel(tabs, Path.getValidatedLabel(name)), NodeTypes.ContentNode.NAME);
                    tab.setProperty("label", StringUtils.capitalize(name));
                    tab.addNode("fields", NodeTypes.ContentNode.NAME);
                }
                n.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.");
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:40,代码来源:SaveDialogFormAction.java

示例8: setAction

import javax.jcr.Property; //导入方法依赖的package包/类
private void setAction(final Node node, Node actions, String actionName, String implClass) throws RepositoryException, PathNotFoundException, ValueFormatException, VersionException, LockException, ConstraintViolationException, ItemExistsException, AccessDeniedException {
    String propName = "default" + StringUtils.capitalize(actionName);
    if (node.hasProperty(propName)) {
        Property defaultAction = node.getProperty(propName);
        if (defaultAction.getBoolean()) {
            actions.addNode(actionName, NodeTypes.ContentNode.NAME).setProperty("class", implClass);
        }
        defaultAction.remove();
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:11,代码来源:SaveDialogFormAction.java

示例9: deletePropertyByPath

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Delete a property by it's path
 *
 * @param path the path to the node
 * @return the Response status
 * @throws RepositoryException
 */
@DELETE
@Path("{path:.*}")
@ApiOperation(value = "Delete a property", notes = "Deletes a property")
@ApiResponses(value = {
        @ApiResponse(code = 204, message = ResponseConstants.STATUS_MESSAGE_DELETED),
        @ApiResponse(code = 404, message = ResponseConstants.STATUS_MESSAGE_NODE_NOT_FOUND),
        @ApiResponse(code = 500, message = ResponseConstants.STATUS_MESSAGE_ERROR_OCCURRED)
})
public Response deletePropertyByPath(@ApiParam(required = true, value = "Path of the property to delete e.g. '/content/hippostd:foldertype'.")
                                     @PathParam("path") String path) throws RepositoryException {
    try {
        Session session = JcrSessionUtil.getSessionFromRequest(request);
        String absolutePath = path;

        if (!absolutePath.startsWith("/")) {
            absolutePath = "/" + absolutePath;
        }

        if (StringUtils.isBlank(path)) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        if (!session.propertyExists(absolutePath)) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        final Property property = session.getProperty(absolutePath);
        property.remove();
        session.save();
    } catch (Exception e) {
        log.error("Error: {}", e);
        throw new WebApplicationException(e);
    }
    return Response.noContent().build();

}
 
开发者ID:jreijn,项目名称:hippo-addon-restful-webservices,代码行数:44,代码来源:PropertiesResource.java

示例10: setProperty

import javax.jcr.Property; //导入方法依赖的package包/类
void setProperty( final Session session,
                  final Node node,
                  final String name,
                  final Object... values ) throws Exception {
    final ValueFactory factory = session.getValueFactory();

    try {
        final boolean exists = node.hasProperty( name );

        // remove property
        if ( values == null ) {
            if ( exists ) {
                node.getProperty( name ).remove();
            } else {
                throw new ModelspaceException( ModelspaceI18n.localize( UNABLE_TO_REMOVE_PROPERTY_THAT_DOES_NOT_EXIST,
                                                                        name,
                                                                        node.getName() ) );
            }
        } else {
            // must be an array at this point
            final int count = values.length;

            if ( exists ) {
                final Property property = node.getProperty( name );
                final int type = property.getType();
                final boolean multiple = property.isMultiple();

                if ( count == 0 ) {
                    if ( multiple ) {
                        property.remove();
                    } else {
                        throw new ModelspaceException( ModelspaceI18n.localize( UNABLE_TO_REMOVE_SINGLE_VALUE_PROPERTY_WITH_EMPTY_ARRAY,
                                                                                name,
                                                                                node.getName() ) );
                    }
                } else if ( count > 1 ) {
                    if ( multiple ) {
                        setMultiValuedProperty( session, node, factory, name, values, type );
                    } else {
                        throw new ModelspaceException( ModelspaceI18n.localize( UNABLE_TO_SET_SINGLE_VALUE_PROPERTY_WITH_MULTIPLE_VALUES,
                                                                                name,
                                                                                node.getName() ) );
                    }
                } else {
                    // only one value so set property
                    if ( multiple ) {
                        setMultiValuedProperty( session, node, factory, name, values, type );
                    } else {
                        node.setProperty( name, ModelProperty.Util.createValue( factory, values[ 0 ] ) );
                    }
                }
            } else {
                // property does not exist and no values being set
                if ( count == 0 ) {
                    throw new ModelspaceException( ModelspaceI18n.localize( UNABLE_TO_REMOVE_PROPERTY_THAT_DOES_NOT_EXIST,
                                                                            name,
                                                                            node.getName() ) );
                }

                if ( count > 1 ) {
                    setMultiValuedProperty( session, node, factory, name, values, PropertyType.UNDEFINED );
                } else {
                    node.setProperty( name, ModelProperty.Util.createValue( factory, values[ 0 ] ) );
                }
            }
        }
    } catch ( final ConstraintViolationException | PathNotFoundException | ValueFormatException e ) {
        throw new IllegalArgumentException( e );
    }
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:71,代码来源:ModelObjectImpl.java

示例11: removeNodeProperty

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Given a JCR node, property and value, remove the value (if it exists)
 * from the property, and remove the
 * property if no values remove
 *
 * @param node the JCR node
 * @param propertyName a name of a JCR property (either pre-existing or
 *   otherwise)
 * @param valueToRemove the JCR value to remove
 * @throws RepositoryException if repository exception occurred
 */
public void removeNodeProperty(final Node node, final String propertyName, final Value valueToRemove)
    throws RepositoryException {
    LOGGER.debug("Request to remove {}", valueToRemove);
    // if the property doesn't exist, we don't need to worry about it.
    if (node.hasProperty(propertyName)) {

        final Property property = node.getProperty(propertyName);
        final String strValueToRemove = valueToRemove.getString();
        final String strValueToRemoveWithoutStringType = removeStringTypes(strValueToRemove);

        if (property.isMultiple()) {
            final AtomicBoolean remove = new AtomicBoolean();
            final Value[] newValues = stream(node.getProperty(propertyName).getValues()).filter(uncheck(v -> {
                final String strVal = removeStringTypes(v.getString());

                LOGGER.debug("v is '{}', valueToRemove is '{}'", v, strValueToRemove );
                if (strVal.equals(strValueToRemoveWithoutStringType)) {
                    remove.set(true);
                    return false;
                }

                return true;
            })).toArray(Value[]::new);

            // we only need to update the property if we did anything.
            if (remove.get()) {
                if (newValues.length == 0) {
                    LOGGER.debug("Removing property '{}'", propertyName);
                    property.remove();
                } else {
                    LOGGER.debug("Removing value '{}' from property '{}'", strValueToRemove, propertyName);
                    property.setValue(newValues);
                }
            } else {
                LOGGER.debug("Value not removed from property name '{}' (value '{}')", propertyName,
                        strValueToRemove);
            }
        } else {

            final String strPropVal = property.getValue().getString();
            final String strPropValWithoutStringType = removeStringTypes(strPropVal);

            LOGGER.debug("Removing string '{}'", strValueToRemove);
            if (StringUtils.equals(strPropValWithoutStringType, strValueToRemoveWithoutStringType)) {
                LOGGER.debug("single value: Removing value from property '{}'", propertyName);
                property.remove();
            } else {
                LOGGER.debug("Value not removed from property name '{}' (property value: '{}';compare value: '{}')",
                        propertyName, strPropVal, strValueToRemove);
                throw new RepositoryException("Property '" + propertyName + "': Unable to remove value '" +
                        StringUtils.substring(strValueToRemove, 0, 50) + "'");
            }
        }
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:67,代码来源:NodePropertiesTools.java


注:本文中的javax.jcr.Property.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。