JcrService extends AbstractCmisService implements CallContextAwareCmisService { private String workspace(String repositoryId) { CheckArg.isNotNull(repositoryId, "repositoryId"); repositoryId = repositoryId.trim(); String[] parts = repositoryId.split(":"); int numParts = parts.length; if (numParts > 1) { return parts[1].trim(); } return null; } JcrService(Map<String, JcrRepository> jcrRepositories); @Override void close(); @Override void setCallContext(CallContext context); @Override CallContext getCallContext(); @Override RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension); @Override List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension); @Override TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
            BigInteger maxItems, BigInteger skipCount, ExtensionsData extension); @Override TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension); @Override List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
            Boolean includePropertyDefinitions, ExtensionsData extension); @Override ObjectInFolderList getChildren(String repositoryId, String folderId, String filter, String orderBy,
            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
            Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension); @Override List<ObjectInFolderContainer> getDescendants(String repositoryId, String folderId, BigInteger depth,
            String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
            String renditionFilter, Boolean includePathSegment, ExtensionsData extension); @Override ObjectData getFolderParent(String repositoryId, String folderId, String filter, ExtensionsData extension); @Override List<ObjectInFolderContainer> getFolderTree(String repositoryId, String folderId, BigInteger depth,
            String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
            String renditionFilter, Boolean includePathSegment, ExtensionsData extension); @Override List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter,
            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
            Boolean includeRelativePathSegment, ExtensionsData extension); @Override ObjectList getCheckedOutDocs(String repositoryId, String folderId, String filter, String orderBy,
            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
            BigInteger maxItems, BigInteger skipCount, ExtensionsData extension); @Override String createDocument(String repositoryId, Properties properties, String folderId,
            ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
            Acl removeAces, ExtensionsData extension); @Override String createDocumentFromSource(String repositoryId, String sourceId, Properties properties,
            String folderId, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces,
            ExtensionsData extension); @Override void setContentStream(String repositoryId, Holder<String> objectId, Boolean overwriteFlag,
            Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension); @Override void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
            ExtensionsData extension); @Override String createFolder(String repositoryId, Properties properties, String folderId, List<String> policies,
            Acl addAces, Acl removeAces, ExtensionsData extension); @Override void deleteObjectOrCancelCheckOut(String repositoryId, String objectId, Boolean allVersions,
            ExtensionsData extension); @Override FailedToDeleteData deleteTree(String repositoryId, String folderId, Boolean allVersions,
            UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension); @Override AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension); @Override ContentStream getContentStream(String repositoryId, String objectId, String streamId, BigInteger offset,
            BigInteger length, ExtensionsData extension); @Override ObjectData getObject(String repositoryId, String objectId, String filter, Boolean includeAllowableActions,
            IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
            Boolean includeAcl, ExtensionsData extension); @Override ObjectData getObjectByPath(String repositoryId, String path, String filter, Boolean includeAllowableActions,
            IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
            Boolean includeAcl, ExtensionsData extension); @Override Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData extension); @Override void moveObject(String repositoryId, Holder<String> objectId, String targetFolderId, String sourceFolderId,
            ExtensionsData extension); @Override void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
            Properties properties, ExtensionsData extension); @Override void checkOut(String repositoryId, Holder<String> objectId, ExtensionsData extension,
            Holder<Boolean> contentCopied); @Override void cancelCheckOut(String repositoryId, String objectId, ExtensionsData extension); @Override void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
            ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
            ExtensionsData extension); @Override List<ObjectData> getAllVersions(String repositoryId, String objectId, String versionSeriesId, String filter,
            Boolean includeAllowableActions, ExtensionsData extension); @Override ObjectData getObjectOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
            Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
            String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension); @Override Properties getPropertiesOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
            Boolean major, String filter, ExtensionsData extension); @Override ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
            BigInteger maxItems, BigInteger skipCount, ExtensionsData extension);  }
@Test public void testWorkspace() { String[] names = {"foo", "", "baz", "a"}; JcrRepository mockRepo = mock(JcrRepository.class); Map<String, JcrRepository> jrs = new HashMap<String, JcrRepository>(); for (String name : names) { jrs.put(name, mockRepo); } JcrService js = new JcrService(jrs); js.setCallContext(mock(CallContext.class)); js.login("foo"); verify(mockRepo).login(null, null); js.login("foo:"); verify(mockRepo, times(2)).login(null, null); js.login("foo:bar"); verify(mockRepo).login(any(Credentials.class), eq("bar")); js.login(":quux"); verify(mockRepo).login(any(Credentials.class), eq("quux")); js.login("a:b:c"); verify(mockRepo).login(any(Credentials.class), eq("b")); }