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;
}
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;
}
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);
}
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));
}
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;
}
Aggregations