use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class ObjectActor method setContent.
private JSONObject setContent(PostRequest request) throws CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String objectId = request.getObjectId();
String changeToken = request.getParameter(QueryGetRequest.PARAM_CHANGE_TOKEN);
Boolean overwriteFlag = request.getBooleanParameter(QueryGetRequest.PARAM_OVERWRITE_FLAG);
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
Holder<String> objectIdHolder = new Holder<String>(objectId);
Holder<String> changeTokenHolder = (changeToken == null ? null : new Holder<String>(changeToken));
if (request.getContentStream() == null) {
CmisObjectService.Impl.setContentStream(request.getRepositoryId(), objectIdHolder, overwriteFlag, changeTokenHolder, null);
} else {
CmisObjectService.Impl.setContentStream(request.getRepositoryId(), objectIdHolder, overwriteFlag, changeTokenHolder, request.getContentStream());
}
String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_DOCUMENT);
if (object == null) {
MetricsInputs.markUploadErrorMeter();
throw new CmisRuntimeException("Object is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class PolicyActor method removePolicy.
private JSONObject removePolicy(PostRequest request) throws CmisInvalidArgumentException, CmisObjectNotFoundException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String objectId = request.getObjectId();
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
CmisPolicyService.Impl.removePolicy(request.getRepositoryId(), request.getPolicyId(), objectId, request.getUserObject().getUserDN());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), objectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_POLICY);
if (object == null) {
throw new CmisRuntimeException("Object is null!");
}
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class RepositoryActor method getTypeDefinition.
private JSONObject getTypeDefinition(QueryGetRequest request) throws CmisRuntimeException, IllegalArgumentException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String typeId = request.getParameter(QueryGetRequest.PARAM_TYPE_ID);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
TypeDefinition type = CmisTypeServices.Impl.getTypeDefinition(request.getRepositoryId(), typeId, null);
JSONObject resultType = JSONConverter.convert(type, dateTimeFormat);
return resultType;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject 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 org.apache.chemistry.opencmis.commons.impl.json.JSONObject 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;
}
Aggregations