public void restore(RequestContext requestContext) throws RegistryException { log.warn("Skipping restoration to path: " + requestContext.getResourcePath().getPath()); }
private String getPathWithoutVersion(String pathWithVersion) { ResourcePath path = new ResourcePath(pathWithVersion); return path.getPath(); }
private boolean isIdentityPolicyPath(RequestContext requestContext) { if (requestContext.getResourcePath() != null && requestContext.getResourcePath().getCompletePath().contains(identityPolicyPath)) { return true; } return false; } }
ResourcePath resourcePath = new ResourcePath(path); Resource resource = registry.get(path); Association[] asso = CommonUtil.getAssociations(registry, (resourcePath.isCurrentVersion() ? resourcePath.getPath() : resourcePath.getPathWithVersion()));
@Override public boolean handleGet(RequestContext requestContext) throws RegistryException { // check if the request is for new resource ResourcePath resourcePath = requestContext.getResourcePath(); if (resourcePath.parameterExists("new")) { String mediaType = resourcePath.getParameterValue("mediaType"); if (mediaType != null){ Matcher matcher = pattern.matcher(mediaType); return matcher.matches(); } } Resource resource = requestContext.getResource(); if (resource == null) { VersionedPath versionedPath = RegistryUtils.getVersionedPath(requestContext.getResourcePath()); if (versionedPath.getVersion() == -1) { resource = requestContext.getRepository(). get(requestContext.getResourcePath().getPath()); requestContext.setResource(resource); } } if (resource != null) { String mType = resource.getMediaType(); if (mType != null){ Matcher matcher = pattern.matcher(mType); return matcher.matches(); } } return false; }
public static MetadataBean populate(String purePath, UserRegistry registry) throws Exception { ResourcePath path = new ResourcePath(purePath); Resource resource = registry.get(path.getPathWithVersion()); MetadataBean bean = new MetadataBean(); bean.setActiveResourcePath(path.getPath()); if (path.parameterExists("version")) { bean.setVersionView(true); bean.setPermalink(path.getCompletePath()); } else { bean.setVersionView(false); bean.setNavigatablePaths(constructNavigatablePaths(path.getCompletePath())); bean.setContentPath(path.getCompletePath()); bean.setServerBaseURL("carbon registry base URL."); if (path.parameterExists("version")) { versionPath = path.getPath() + RegistryConstants.URL_SEPARATOR + "version" + RegistryConstants.URL_PARAMETER_SEPARATOR + path.getParameterValue("version"); } else { versionPath = path.getPath(); AuthorizationManager authorizer = registry.getUserRealm().getAuthorizationManager(); boolean putAllowed = authorizer. isUserAuthorized(userName, path.getPath(), ActionConstants.PUT); bean.setPutAllowed(putAllowed);
versionPath.setActiveResourcePath(path); ResourcePath resourcePath = new ResourcePath(version); if (!resourcePath.isCurrentVersion()) { long versionNumber = Long.parseLong(resourcePath. getParameterValue(RegistryConstants.VERSION_PARAMETER_NAME)); versionPath.setVersionNumber(versionNumber); versionsBean.setLoggedIn(!RegistryConstants.ANONYMOUS_USER.equals(userName)); ResourcePath resourcePath = new ResourcePath(path); try { AuthorizationManager authorizer = userRegistry.getUserRealm().getAuthorizationManager(); boolean putAllowed = authorizer. isUserAuthorized(userName, resourcePath.getPath(), ActionConstants.PUT); boolean deleteAllowed = authorizer.isUserAuthorized(userName,resourcePath.getPath(),ActionConstants.DELETE); versionsBean.setPutAllowed(putAllowed); versionsBean.setDeletePermissionAllowed(deleteAllowed);
ResourcePath resourcePath = new ResourcePath(path); String userName = resource.getProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME); if (userName == null) { if(!resourcePath.isCurrentVersion()){ String originalPath = resourcePath.getPath(); resource = registry.get(originalPath);
String parentPath = RegistryUtils.getParentPath(requestContext.getResourcePath().getPath()); String resourcePath = requestContext.getResourcePath().getCompletePath();
public static ContentBean getContent(String path, UserRegistry registry) throws Exception { ResourcePath resourcePath = new ResourcePath(path); ContentBean bean = new ContentBean(); bean.setCollection(resource instanceof Collection); bean.setLoggedIn(!RegistryConstants.ANONYMOUS_USER.equals(registry.getUserName())); bean.setPathWithVersion(resourcePath.getPathWithVersion()); bean.setAbsent(resource.getProperty("registry.absent")); List mountPoints = resource.getPropertyValues("registry.mountpoint"); bean.setVersionView(!resourcePath.isCurrentVersion()); bean.setContentPath(resourcePath.getCompletePath()); resource.discard();
throws RegistryException { Resource resource = registry.get(path); ResourcePath resourcePath = new ResourcePath(path); PropertiesBean propertiesBean = new PropertiesBean(); boolean isPutAllowed = false; propertiesBean.setLifecycleProperties(lifecycleProperties.toArray(new String[lifecycleProperties.size()])); propertiesBean.setVersionView(!resourcePath.isCurrentVersion()); propertiesBean.setPathWithVersion(resourcePath.getPathWithVersion()); if (!isPutAllowed) { isPutAllowed = UserUtil.isPutAllowed(registry.getUserName(), path, registry);
requestContext.setResourcePath(new ResourcePath(actualPath)); if (resource.getProperty(CommonConstants.SOURCE_PROPERTY) == null){ resource.setProperty(CommonConstants.SOURCE_PROPERTY, CommonConstants.SOURCE_AUTO);
public static DependenciesBean populate(UserRegistry userRegistry, String path) { ResourcePath resourcePath = new ResourcePath(path); try { Association[] asso = CommonUtil.getAssociations(userRegistry, (resourcePath.isCurrentVersion() ? resourcePath.getPath() : resourcePath.getPathWithVersion())); Resource resource = userRegistry.get(path); dependenciesBean.setVersionView(!resourcePath.isCurrentVersion()); dependenciesBean.setPathWithVersion(resourcePath.getPathWithVersion()); List mountPoints = resource.getPropertyValues("registry.mountpoint"); List targetPoints = resource.getPropertyValues("registry.targetpoint");
String resourcePath = requestContext.getResourcePath().getPath(); String policyFileName = resourcePath.substring(resourcePath.lastIndexOf(RegistryConstants.PATH_SEPARATOR) + 1); Registry systemRegistry = CommonUtil.getUnchrootedSystemRegistry(requestContext); policyPath = requestContext.getResourcePath().getCompletePath(); } else{ policyPath = getPolicyLocation(requestContext, policyFileName,commonLocation, resourcePath,version);
public static PermissionBean getPermissions(UserRegistry userRegistry, String path) throws Exception { ResourcePath resourcePath = new ResourcePath(path); String userName = userRegistry.getUserName(); PermissionBean permissionsBean = new PermissionBean(); permissionsBean.setPathWithVersion(resourcePath.getPathWithVersion()); permissionsBean.setVersionView(!resourcePath.isCurrentVersion());
requestContext.setResourcePath(new ResourcePath(path)); WSDLValidationInfo validationInfo; try {
public void put(RequestContext requestContext) throws RegistryException { String path = requestContext.getResourcePath().getPath(); String[] pathFragments = path.split(RegistryConstants.PATH_SEPARATOR); for (String pathFragment : pathFragments) { if (pathFragment.matches(CommonConstants.SERVICE_VERSION_REGEX.replace("$", "(-[a-zA-Z0-9]+)?$")) && !pathFragment.matches(expression)) { throw new RegistryException("The version " + pathFragment + " is not valid. " + "Please specify a version in the format " + exampleFormat + "."); } } } }
public void restoreVersion(RequestContext requestContext) throws RegistryException { checkWriteLock(new ResourcePath(requestContext.getVersionPath()).getPath(), requestContext); }
ResourcePath resourcePath = new ResourcePath(path); bean.setPathWithVersion(resourcePath.getPathWithVersion()); bean.setVersionView(!resourcePath.isCurrentVersion());
@Override public boolean handleDelete(RequestContext requestContext) throws RegistryException { Resource resource = requestContext.getResource(); if (resource != null) { String mType = resource.getMediaType(); return mType != null && (invert != mType.equals(getMediaType())); } else if (requestContext.getResourcePath() != null) { resource = requestContext.getRegistry().get(requestContext. getResourcePath().getCompletePath()); if (resource != null) { String mType = resource.getMediaType(); return mType != null && (invert != mType.equals(getMediaType())); } } return false; } }