Search in sources :

Example 1 with IRepository

use of com.pogeyan.cmis.api.repo.IRepository in project copper-cms by PogeyanOSS.

the class RepositoryActor method getRepositoryInfo.

private JSONObject getRepositoryInfo(QueryGetRequest t) throws CmisRuntimeException {
    String permission = t.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "get")) {
        throw new CmisRuntimeException(t.getUserName() + " is not authorized to applyAcl.");
    }
    // call DB and get the repositoryInfo
    String rootId = CmisObjectService.Impl.addRootFolder(t.getRepositoryId(), t.getUserName());
    IRepository repository = RepositoryManagerFactory.getInstance().getRepositoryStore().getRepository(t.getRepositoryId());
    RepositoryInfo repo = createRepositoryInfo(t.getRepositoryId(), repository.getRepositoryName() == null ? "" : repository.getRepositoryName(), CmisVersion.CMIS_1_1, rootId, repository.getDescription() == null ? "" : repository.getDescription());
    String repositoryUrl = HttpUtils.compileRepositoryUrl(t.getBaseUrl(), t.getScheme(), t.getServerName(), t.getServerPort(), t.getContextPath(), t.getServletPath(), repo.getId()).toString();
    String rootUrl = HttpUtils.compileRootUrl(t.getBaseUrl(), t.getScheme(), t.getServerName(), t.getServerPort(), t.getContextPath(), t.getServletPath(), repo.getId()).toString();
    JSONObject result = new JSONObject();
    result.put(repo.getId(), JSONConverter.convert(repo, repositoryUrl, rootUrl, true));
    return result;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) RepositoryInfo(org.apache.chemistry.opencmis.commons.data.RepositoryInfo) IRepository(com.pogeyan.cmis.api.repo.IRepository)

Example 2 with IRepository

use of com.pogeyan.cmis.api.repo.IRepository in project copper-cms by PogeyanOSS.

the class RepositoryActor method getRepositories.

private JSONObject getRepositories(QueryGetRequest request) throws MongoException, CmisRuntimeException {
    List<RepositoryInfo> infoDataList = new ArrayList<RepositoryInfo>() {

        private static final long serialVersionUID = 1L;

        {
            List<IRepository> respositoryList = RepositoryManagerFactory.getInstance().getRepositoryStore().getRepositories(request.getRepositoryId());
            if (respositoryList != null && !respositoryList.isEmpty()) {
                for (IRepository repository : respositoryList) {
                    CmisTypeServices.Impl.addBaseType(repository.getRepositoryId(), request.getUserName());
                    String rootId = CmisObjectService.Impl.addRootFolder(repository.getRepositoryId(), request.getUserName());
                    add(createRepositoryInfo(repository.getRepositoryId(), repository.getRepositoryName(), CmisVersion.CMIS_1_1, rootId, repository.getDescription() == null ? "" : repository.getDescription()));
                }
            }
        }
    };
    JSONObject result = new JSONObject();
    for (RepositoryInfo ri : infoDataList) {
        String repositoryUrl = HttpUtils.compileRepositoryUrl(request.getBaseUrl(), request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath(), request.getServletPath(), ri.getId()).toString();
        String rootUrl = HttpUtils.compileRootUrl(request.getBaseUrl(), request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath(), request.getServletPath(), ri.getId()).toString();
        result.put(ri.getId(), JSONConverter.convert(ri, repositoryUrl, rootUrl, true));
    }
    return result;
}
Also used : JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) RepositoryInfo(org.apache.chemistry.opencmis.commons.data.RepositoryInfo) ArrayList(java.util.ArrayList) IRepository(com.pogeyan.cmis.api.repo.IRepository)

Example 3 with IRepository

use of com.pogeyan.cmis.api.repo.IRepository in project copper-cms by PogeyanOSS.

the class MongoClientFactory method getContentDBMongoClient.

public <T> T getContentDBMongoClient(String repositoryId, Function<Datastore, T> fun) {
    Datastore clientDatastore = this.clientDatastores.get(repositoryId);
    if (clientDatastore == null) {
        IRepository repository = RepositoryManagerFactory.getInstance().getRepository(repositoryId);
        String dataBaseName = repository.getDBName().get("connectionString");
        List<String> properties = getClientProperties(dataBaseName);
        int port = Integer.valueOf(properties.get(1));
        String[] columnsToIndex = new String[] { "name", "path" };
        Map<Object, Object> indexIds = new HashMap<>();
        Stream<String> indexId = Arrays.stream(columnsToIndex);
        indexId.forEach(x -> indexIds.put(x, 1));
        MongoClient mongoClient = getMongoClient(repositoryId, properties.get(0), port);
        MongoCollection<Document> objectDataCollection = mongoClient.getDatabase(properties.get(2)).getCollection("objectData");
        objectDataCollection.createIndex(new BasicDBObject(indexIds));
        clientDatastore = morphia.createDatastore(mongoClient, properties.get(2));
        this.clientDatastores.put(repositoryId, clientDatastore);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Host Name: {}, Content DB: {}", properties.get(0), properties.get(2));
        }
    }
    return fun.apply(clientDatastore);
}
Also used : HashMap(java.util.HashMap) Document(org.bson.Document) MongoClient(com.mongodb.MongoClient) BasicDBObject(com.mongodb.BasicDBObject) Datastore(org.mongodb.morphia.Datastore) MTypeObject(com.pogeyan.cmis.data.mongo.MTypeObject) MDocumentObject(com.pogeyan.cmis.data.mongo.MDocumentObject) BasicDBObject(com.mongodb.BasicDBObject) MTypeDocumentObject(com.pogeyan.cmis.data.mongo.MTypeDocumentObject) JSONObject(org.json.simple.JSONObject) MBaseObject(com.pogeyan.cmis.data.mongo.MBaseObject) IRepository(com.pogeyan.cmis.api.repo.IRepository)

Example 4 with IRepository

use of com.pogeyan.cmis.api.repo.IRepository in project copper-cms by PogeyanOSS.

the class MongoClientFactory method addIndex.

@Override
public void addIndex(String repositoryId, String[] columnsToIndex) {
    IRepository repository = RepositoryManagerFactory.getInstance().getRepository(repositoryId);
    String dataBaseName = repository.getDBName().get("connectionString");
    List<String> properties = getClientProperties(dataBaseName);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Host Name: {}, Content DB: {}", properties.get(0), properties.get(2));
    }
    Map<Object, Object> indexIds = new HashMap<>();
    Stream<String> indexId = Arrays.stream(columnsToIndex);
    indexId.forEach(x -> indexIds.put(x, 1));
    MongoCollection<Document> contentMongoClient = getMongoClient(repositoryId, properties.get(0), Integer.valueOf(properties.get(1))).getDatabase(properties.get(2)).getCollection("objectData");
    contentMongoClient.createIndex(new BasicDBObject(indexIds));
}
Also used : BasicDBObject(com.mongodb.BasicDBObject) HashMap(java.util.HashMap) MTypeObject(com.pogeyan.cmis.data.mongo.MTypeObject) MDocumentObject(com.pogeyan.cmis.data.mongo.MDocumentObject) BasicDBObject(com.mongodb.BasicDBObject) MTypeDocumentObject(com.pogeyan.cmis.data.mongo.MTypeDocumentObject) JSONObject(org.json.simple.JSONObject) MBaseObject(com.pogeyan.cmis.data.mongo.MBaseObject) IRepository(com.pogeyan.cmis.api.repo.IRepository) Document(org.bson.Document)

Example 5 with IRepository

use of com.pogeyan.cmis.api.repo.IRepository in project copper-cms by PogeyanOSS.

the class MongoDBRepositoryStore method getRepositories.

@Override
public List<IRepository> getRepositories(String repositoryId) {
    Datastore mongoStore = getMasterDBInstance();
    if (mongoStore != null) {
        Query<MRepository> query = mongoStore.createQuery(MRepository.class);
        List<MRepository> respositoryList = query.asList();
        List<IRepository> respository = respositoryList.stream().collect(Collectors.toCollection(ArrayList::new));
        return respository;
    }
    return null;
}
Also used : Datastore(org.mongodb.morphia.Datastore) IRepository(com.pogeyan.cmis.api.repo.IRepository)

Aggregations

IRepository (com.pogeyan.cmis.api.repo.IRepository)6 BasicDBObject (com.mongodb.BasicDBObject)2 MBaseObject (com.pogeyan.cmis.data.mongo.MBaseObject)2 MDocumentObject (com.pogeyan.cmis.data.mongo.MDocumentObject)2 MTypeDocumentObject (com.pogeyan.cmis.data.mongo.MTypeDocumentObject)2 MTypeObject (com.pogeyan.cmis.data.mongo.MTypeObject)2 HashMap (java.util.HashMap)2 RepositoryInfo (org.apache.chemistry.opencmis.commons.data.RepositoryInfo)2 JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)2 Document (org.bson.Document)2 JSONObject (org.json.simple.JSONObject)2 Datastore (org.mongodb.morphia.Datastore)2 MongoClient (com.mongodb.MongoClient)1 ArrayList (java.util.ArrayList)1 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)1