private void addSubscriptionAvailableProperty(Resource newResource) throws RegistryException { newResource.setProperty(GovernanceConstants.REGISTRY_IS_ENVIRONMENT_CHANGE, "true"); }
public void associate(Resource resource, Registry registry) throws RegistryException { // We start off in the CREATED phase resource.setProperty(PHASE_PROPERTY, PHASE_CREATED); }
private void addSubscriptionAvailableProperty(Resource newResource) throws RegistryException { newResource.setProperty(GovernanceConstants.REGISTRY_IS_ENVIRONMENT_CHANGE, "true"); }
public void associate(Resource resource, Registry registry) throws RegistryException { resource.setProperty(stateProperty, states.get(0)); resource.setProperty(lifecyleProperty, aspectName); }
private void copyAllParameters(String wsdlPath, Resource wsdlResource) throws RegistryException { if(registry.resourceExists(wsdlPath)){ // we are copying all the properties, rather than using the exisint pointer Resource oldWsdlResource = registry.get(wsdlPath); Properties properties = oldWsdlResource.getProperties(); for (Map.Entry<Object, Object> e : properties.entrySet()) { if (e.getValue() instanceof String) { wsdlResource.setProperty((String) e.getKey(), (String) e.getValue()); } else { wsdlResource.setProperty((String) e.getKey(), (List<String>) e.getValue()); } } }} @SuppressWarnings("unchecked")
private void writeLastAccessTime() { try { if (lastAccessTime.size() > 0) { Resource resource = registry.newResource(); for (Map.Entry<Integer, Date> e : lastAccessTime.entrySet()) { resource.setProperty(String.valueOf(e.getKey()), String.valueOf(e.getValue().getTime())); } registry.put(getLastAccessTimeLocation(), resource); } } catch (RegistryException e) { log.error("Could not write last activity time when stopping indexing", e); } }
public static void jsFunction_setProperty(Context cx, Scriptable thisObj, Object[] arguments, Function funObj) throws CarbonException { ResourceHostObject resourceHostObject = (ResourceHostObject) thisObj; if (arguments.length == 2) { if (arguments[0] instanceof String && arguments[1] instanceof String) { resourceHostObject.resource.setProperty((String) arguments[0], (String) arguments[1]); } else if (arguments[0] instanceof String && arguments[1] instanceof NativeArray) { resourceHostObject.resource.setProperty((String) arguments[0], (List) Context.jsToJava( arguments[1], List.class)); } else { throw new CarbonException("Invalid argument types for setProperty() method"); } } else { throw new CarbonException("Invalid no. of arguments for setProperty() method"); } }
/** * Method to make an aspect to default. * @param path path of the resource * @param aspect the aspect to be removed. * @param registry registry instance to be used */ public static void setDefaultLifeCycle(String path, String aspect, Registry registry) throws RegistryException { Resource resource = registry.get(path); if(resource != null) { resource.setProperty("registry.LC.name", aspect); registry.put(path, resource); } }
public static void addScripts(String state, Resource resource, List<ScriptBean> scriptList, String aspectName) { if (scriptList != null) { for (ScriptBean scriptBean : scriptList) { if (scriptBean.isConsole()) { List<String> items = new ArrayList<String>(); items.add(scriptBean.getScript()); items.add(scriptBean.getFunctionName()); String resourcePropertyNameForScript = LifecycleConstants.REGISTRY_CUSTOM_LIFECYCLE_CHECKLIST_JS_SCRIPT_CONSOLE + aspectName + "." + state + "." + scriptBean.getEventName(); resource.setProperty(resourcePropertyNameForScript, items); } } } }
private void encodeProperty(Resource resource, String propKey) { try { if (resource.getProperty(propKey) != null) { resource.setProperty(propKey, CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode( resource.getProperty(propKey).getBytes())); } } catch (CryptoException e) { log.error("Unable to encrypt property key: " + propKey + " for resource " + "path: " + resource.getPath(), e); } }
private void decodeProperty(Resource resource, String propKey) { try { if(resource.getProperty(propKey)!=null){ resource.setProperty(propKey, new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt( resource.getProperty(propKey)))); } } catch (CryptoException e) { log.error("Unable to decrypt property key: " + propKey + " for resource " + "path: " + resource.getPath(), e); } } }
public void checkout(String s) throws UnsupportedRepositoryOperationException, LockException, RepositoryException { if (!isNodeTypeVersionable(s)) { throw new UnsupportedRepositoryOperationException("Cannot apply checkout for non versionalbe nodes .!!!"); } try { Resource resource = ((RegistrySession) session).getUserRegistry().get(s); resource.setProperty("jcr:checkedOut", "true"); // no need both.But as in JCR spec there are two properties to set resource.setProperty("jcr:isCheckedOut", "true"); ((RegistrySession) session).getUserRegistry().put(s, resource); } catch (RegistryException e) { throw new RepositoryException("Exception occurred at Registry level"); } }
private static void createSystemConfigNodeTypes(UserRegistry userReg,String workspaceRoot) throws RegistryException { String confVerPath = workspaceRoot + JCR_SYSTEM_CONFIG + "/" + JCR_SYSTEM_CONFIG_NODE_TYPES; if (!userReg.resourceExists(confVerPath)) { Resource resource = (CollectionImpl)userReg.newCollection(); resource.setDescription("sys:config-jcr-storage"); resource.setProperty("sys:config","true"); userReg.put(confVerPath, resource); } }
private static void createSystemConfigVersionLabelStore(UserRegistry userReg,String workspaceRoot) throws RegistryException { String confVerPath = workspaceRoot + JCR_SYSTEM_CONFIG + "/" + JCR_SYSTEM_VERSION_LABELS; if (!userReg.resourceExists(confVerPath)) { Resource resource = (CollectionImpl)userReg.newCollection(); resource.setDescription("sys:config-jcr-storage"); resource.setProperty("sys:config","true"); userReg.put(confVerPath, resource); } }
private static void createSystemConfigVersion(UserRegistry userReg,String workspaceRoot) throws RegistryException { String confVerPath = workspaceRoot + JCR_SYSTEM_CONFIG + "/" + JCR_SYSTEM_CONFIG_VERSION; if (!userReg.resourceExists(confVerPath)) { Resource resource = (CollectionImpl)userReg.newCollection(); resource.setDescription("sys:config-jcr-storage"); resource.setProperty("sys:config","true"); userReg.put(confVerPath, resource); } }
public Resource get(RequestContext requestContext) throws RegistryException { Resource resource = requestContext.getRepository().get(requestContext.getResourcePath().getPath()); resource.setProperty("registry.externalLink", "true"); requestContext.setProcessingComplete(true); return resource; } }
public static void setRetentionPolicyToRegistry(RegistrySession session, String s, RetentionPolicy retentionPolicy) throws RepositoryException { Resource resource = null; try { resource = session.getUserRegistry().get(s); resource.setProperty("org.wso2.carbon.registry.jcr.retention.policy", retentionPolicy.getName()); session.getUserRegistry().put(s, resource); } catch (RegistryException e) { throw new RepositoryException("Registry level exception when setting retention policy at " + s); } }
public void setPrimaryType(String s) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException { // Check if node type already exists registrySession.getWorkspace().getNodeTypeManager().getNodeType(s); // if(s!= null && s.startsWith("mix")) { // throw new ConstraintViolationException("Cannpot set mixin as primary types"); // } try { Resource resource = registrySession.getUserRegistry().get(nodePath); resource.setProperty("jcr:primaryType", s); 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); } } //TODO overall, always do a registry get on a resource and do stuff other than using the ref
public static void loadRetentionPolicies(RegistrySession session) throws RepositoryException { try { if(!session.getUserRegistry().resourceExists("/jcr_system/workspaces/default_workspace/test_policy_holder")){ session.getRootNode().addNode("test_policy_holder"); } Resource r = session.getUserRegistry().get("/jcr_system/workspaces/default_workspace/test_policy_holder"); r.setProperty("org.wso2.carbon.registry.jcr.retention.policy","fullLocked"); session.getUserRegistry().put("/jcr_system/workspaces/default_workspace/test_policy_holder",r); } catch (RegistryException e) { throw new RepositoryException("Unable to load TCK test data"); } catch (RepositoryException e) { throw new RepositoryException("Unable to load TCK test data"); } }
public void addVersionLabel(String s, String s1, boolean b) throws LabelExistsVersionException, VersionException, RepositoryException { try { Resource res = ((RegistrySession) session).getUserRegistry().get( RegistryJCRSpecificStandardLoderUtil. getSystemConfigVersionLabelPath((RegistrySession) session)); res.setProperty(s1, s); ((RegistrySession) session).getUserRegistry().put(RegistryJCRSpecificStandardLoderUtil. getSystemConfigVersionLabelPath((RegistrySession) session), res); } catch (RegistryException e) { throw new RepositoryException("Exception occurred in registry level " + s); } }