protected boolean validatePropertyOfResource(Resource resource) { if (propertyName != null && propertyValue != null) { if (!isMultiValued) { return propertyValue.equals(resource.getProperty(propertyName)); } List<String> resourceProperties = resource.getPropertyValues(propertyName); if (resourceProperties == null) { throw new RuntimeException("Error in lifecycle configuration. " + "Invalid property found: " + propertyName); } for (String value : resourceProperties) { if (propertyValue.equals(value)) { return true; } } return false; } return true; } }
public static Hold[] getHoldsFromRegistry(RegistrySession session, String s) throws RepositoryException { Resource resource = null; List<Hold> holdList = new ArrayList<Hold>(); try { resource = session.getUserRegistry().get(s); List holds = resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds"); if (holds != null) { for (Object hold : holds) { String[] vals = hold.toString().split(";"); holdList.add(new RegistryHold(vals[0], Boolean.valueOf(vals[1]))); } } } catch (RegistryException e) { throw new RepositoryException("Registry level exception when setting retention policy at " + s); } return holdList.toArray(new RegistryHold[0]); }
public static NativeArray jsFunction_getPropertyValues(Context cx, Scriptable thisObj, Object[] arguments, Function funObj) throws CarbonException { ResourceHostObject resourceHostObject = (ResourceHostObject) thisObj; if (arguments.length == 1) { if (arguments[0] instanceof String) { return new NativeArray(resourceHostObject.resource.getPropertyValues((String) arguments[0]).toArray()); } else { throw new CarbonException("Invalid argument type for getProperty() method"); } } else { throw new CarbonException("Invalid no. of arguments for getProperty() method"); } }
public static Hold addHoldsToRegistry(RegistrySession session, String s, String s1, boolean b) throws RepositoryException { Resource resource = null; try { resource = session.getUserRegistry().get(s); if (resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds") == null) { List list = new ArrayList(); list.add(s1 + ";" + String.valueOf(b)); resource.setProperty("org.wso2.carbon.registry.jcr.retention.holds", list); } else { resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds"). add(s1 + ";" + String.valueOf(b)); } session.getUserRegistry().put(s, resource); } catch (RegistryException e) { throw new RepositoryException("Registry level exception when setting retention policy at " + s); } return new RegistryHold(s1, b); }
String resourcePropertyNameForItem = LifecycleConstants.REGISTRY_CUSTOM_LIFECYCLE_VOTES_OPTION + aspectName + "." + order + LifecycleConstants.VOTE; List<String> list = resource.getPropertyValues(resourcePropertyNameForItem); for (String value : list) { if (value.startsWith("current:")) {
private List<String> getVersionList(String nodePath) throws RegistryException { String confPath = RegistryJCRSpecificStandardLoderUtil. getSystemConfigVersionPath((RegistrySession) session); return ((RegistrySession) session).getUserRegistry().get(confPath).getPropertyValues(nodePath); }
public void removeMixin(String s) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException { RegistryJCRItemOperationUtil.checkRetentionHold(registrySession, getPath()); try { Resource resource = registrySession.getUserRegistry().get(nodePath); if (resource.getPropertyValues("jcr:mixinTypes").contains(s)) { resource.getPropertyValues("jcr:mixinTypes").remove(s); } else { throw new NoSuchNodeTypeException("No such mix node type to remove"); } registrySession.getUserRegistry().put(nodePath, resource); } catch (RegistryException e) { String msg = "failed to resolve the path of the given node or violation of repository syntax " + this; log.debug(msg); throw new RepositoryException(msg, e); } isModified = true; }
public static void removeHoldFromRegistry(RegistrySession session, String s, Hold hold) throws RepositoryException { Resource resource = null; try { resource = session.getUserRegistry().get(s); List holds = resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds"); List<Hold> holdList = new ArrayList<Hold>(); String refHold = hold.getName() + ";" + hold.isDeep(); if (holds != null) { for (Object _hold : holds) { if (_hold.equals(refHold)) { resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds").remove(_hold); } } } session.getUserRegistry().put(s, resource); } catch (RegistryException e) { throw new RepositoryException("Registry level exception when setting retention policy at " + s); } }
/** * This method is used to update checkpoint current state duration information. * * @param resource registry resource. * @param nextState next lifecycle state. * @throws RegistryException */ private void updateCheckpointProperties(Resource resource, String nextState) throws RegistryException { String checkpointProperty = LifecycleConstants.REGISTRY_LIFECYCLE + aspectName + LifecycleConstants.CHECKPOINT; List<String> checkpoints = resource.getPropertyValues(checkpointProperty); if (checkpoints != null && !checkpoints.isEmpty()) { for (String checkpoint : checkpoints) { resource.removeProperty(checkpointProperty + LifecycleConstants.DOT + checkpoint); } } resource.removeProperty(checkpointProperty); addCheckPointProperties(resource, nextState); } }
/** * Remove a property from a GREG node */ public static void removeProperty(Registry repository,Resource resource, PropertyData<?> propertyData) throws RegistryException { String id = propertyData.getId(); if(resource.getPropertyValues(id) != null ){ //has property resource.removeProperty(id); repository.put(resource.getPath(), resource); } }
public NodeType[] getMixinNodeTypes() throws RepositoryException { List<NodeType> nodeTypeList = new ArrayList<NodeType>(); try { Resource resource = registrySession.getUserRegistry().get(nodePath); List<String> mixNames = resource.getPropertyValues("jcr:mixinTypes"); if (mixNames != null) { for (String name : mixNames) { NodeType nt = registrySession.getWorkspace().getNodeTypeManager().getNodeType(name); nodeTypeList.add(nt); } } } catch (RegistryException e) { throw new RepositoryException("Error while getting mix node types from registry " + e.getMessage()); } if (nodeTypeList.size() == 0) { return new NodeType[0]; } else { return nodeTypeList.toArray(new NodeType[0]); } }
private Integer[] getTenantsWithIndexes() throws RegistryException { ConfigurationContext superTenantContext = ServiceHolder.getConfigurationContextService(). getServerConfigContext(); UserRegistry superTenantRegistry = ServiceHolder.getRegistryService(). getConfigSystemRegistry(SuperTenantCarbonContext. getCurrentContext(superTenantContext).getTenantId()); Resource tenantTrackerResource; String trackerPath = PersistencyConstants.INDEX_TRACKER_PATH; List<Integer> tenantsWithIndexes = new ArrayList<Integer>(); if (superTenantRegistry.resourceExists(trackerPath)) { tenantTrackerResource = superTenantRegistry.get(trackerPath); List<String> propertyValues = tenantTrackerResource.getPropertyValues( PersistencyConstants.TENANTS_PROPERTY); if (propertyValues == null) { propertyValues = new ArrayList<String>(); } for (String propertyValue : propertyValues) { tenantsWithIndexes.add(Integer.valueOf(propertyValue)); } } return tenantsWithIndexes.toArray(new Integer[]{}); }
if (superTenantRegistry.resourceExists(trackerPath)) { tenantTrackerResource = superTenantRegistry.get(trackerPath); List<String> propertyValues = tenantTrackerResource.getPropertyValues( PersistencyConstants.TENANTS_PROPERTY); if (propertyValues == null) {
private void addVersionToHistory(String nodePath, String nodeVersion) { try { String confPath = RegistryJCRSpecificStandardLoderUtil. getSystemConfigVersionPath((RegistrySession) session); Resource resource = ((RegistrySession) session).getUserRegistry().get(confPath); if (resource.getProperty(nodePath) != null) { resource.getPropertyValues(nodePath).add(nodeVersion); } else { List<String> list = new ArrayList<String>(); list.add(nodeVersion); resource.setProperty(nodePath, list); } ((RegistrySession) session).getUserRegistry().put(confPath, resource); } catch (RegistryException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
if (superTenantRegistry.resourceExists(trackerPath)) { tenantTrackerResource = superTenantRegistry.get(trackerPath); List<String> propertyValues = tenantTrackerResource.getPropertyValues( AnalyzerConfigConstants.TENANTS_PROPERTY); if (propertyValues == null) {
if (superTenantRegistry.resourceExists(trackerPath)) { tenantTrackerResource = superTenantRegistry.get(trackerPath); List<String> propertyValues = tenantTrackerResource.getPropertyValues( AnalyzerConfigConstants.TENANTS_PROPERTY); if (propertyValues == null) {
if (superTenantRegistry.resourceExists(analyzerTrackerPath)) { tenantTrackerResource = superTenantRegistry.get(analyzerTrackerPath); List<String> propertyValues = tenantTrackerResource.getPropertyValues( AnalyzerConfigConstants.TENANTS_PROPERTY); if (propertyValues == null) {
if (superTenantRegistry.resourceExists(analyzerTrackerPath)) { tenantTrackerResource = superTenantRegistry.get(analyzerTrackerPath); List<String> propertyValues = tenantTrackerResource.getPropertyValues( AnalyzerConfigConstants.TENANTS_PROPERTY); if (propertyValues == null) {
@Override public void delete(RequestContext requestContext) throws RegistryException { if (!CommonUtil.isUpdateLockAvailable()) { return; } CommonUtil.acquireUpdateLock(); try { Resource resource = requestContext.getRegistry().get( requestContext.getResourcePath().getPath()); List<String> symlinkPaths = resource.getPropertyValues("registry.resource.symlink.path"); if (symlinkPaths != null && symlinkPaths.size() > 0) { for (String symlinkPath : symlinkPaths) { if (symlinkPath != null) { if (requestContext.getRegistry() .resourceExists(symlinkPath)) { requestContext.getRegistry().delete(symlinkPath); } } } } } finally { CommonUtil.releaseUpdateLock(); } } }
bean.setPathWithVersion(resourcePath.getPathWithVersion()); bean.setAbsent(resource.getProperty("registry.absent")); List mountPoints = resource.getPropertyValues("registry.mountpoint"); List targetPoints = resource.getPropertyValues("registry.targetpoint"); List actualPaths = resource.getPropertyValues("registry.actualpath"); String user = resource.getProperty("registry.user");