use of org.apache.chemistry.opencmis.commons.impl.UrlBuilder in project cool-jconon by consiglionazionaledellericerche.
the class ApplicationService method reopenApplication.
public void reopenApplication(Session currentCMISSession, final String applicationSourceId, final String contextURL, Locale locale, String userId) {
/**
* Load application source with user session if user cannot access to application
* throw an exception
*/
try {
OperationContext oc = new OperationContextImpl(currentCMISSession.getDefaultContext());
oc.setFilterString(PropertyIds.OBJECT_ID);
currentCMISSession.getObject(applicationSourceId, oc);
} catch (CmisPermissionDeniedException _ex) {
throw new ClientMessageException("user.cannot.access.to.application", _ex);
}
final Folder newApplication = loadApplicationById(currentCMISSession, applicationSourceId, null);
final Folder call = loadCallById(currentCMISSession, newApplication.getParentId(), null);
if (newApplication.getPropertyValue(JCONONPropertyIds.APPLICATION_DATA_DOMANDA.value()) == null || !newApplication.getPropertyValue(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value()).equals(StatoDomanda.CONFERMATA.getValue())) {
throw new ClientMessageException("message.error.domanda.no.confermata");
}
try {
callService.isBandoInCorso(call, userService.loadUserForConfirm(userId));
} catch (CoolUserFactoryException e) {
throw new CMISApplicationException("Error loading user: " + userId, e);
}
String link = cmisService.getBaseURL().concat("service/cnr/jconon/manage-application/reopen");
UrlBuilder url = new UrlBuilder(link);
Response resp = cmisService.getHttpInvoker(cmisService.getAdminSession()).invokePOST(url, MimeTypes.JSON.mimetype(), new Output() {
@Override
public void write(OutputStream out) throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("applicationSourceId", newApplication.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString());
jsonObject.put("groupRdP", "GROUP_" + call.getPropertyValue(JCONONPropertyIds.CALL_RDP.value()));
jsonObject.put("groupConsumer", JcononGroups.APPLICATION_CONSUMER.group());
out.write(jsonObject.toString().getBytes());
}
}, cmisService.getAdminSession());
int status = resp.getResponseCode();
if (status == HttpStatus.SC_NOT_FOUND || status == HttpStatus.SC_BAD_REQUEST || status == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
throw new CMISApplicationException("Reopen Application error. Exception: " + resp.getErrorContent());
}
addToQueueForPrint(applicationSourceId, contextURL, emailOnReopen);
}
use of org.apache.chemistry.opencmis.commons.impl.UrlBuilder in project cool-jconon by consiglionazionaledellericerche.
the class ApplicationService method paste.
public String paste(Session currentCMISSession, final String applicationSourceId, final String callTargetId, String userId) {
/**
* Load application source with user session if user cannot access to application
* throw an exception
*/
try {
OperationContext oc = new OperationContextImpl(currentCMISSession.getDefaultContext());
oc.setFilterString(PropertyIds.OBJECT_ID);
currentCMISSession.getObject(applicationSourceId, oc);
} catch (CmisPermissionDeniedException _ex) {
throw new ClientMessageException("user.cannot.access.to.application", _ex);
}
final Folder application = loadApplicationById(currentCMISSession, applicationSourceId, null);
final Folder call = loadCallById(currentCMISSession, callTargetId, null);
try {
callService.isBandoInCorso(call, userService.loadUserForConfirm(userId));
} catch (CoolUserFactoryException e) {
throw new CMISApplicationException("Error loading user: " + userId, e);
}
String link = cmisService.getBaseURL().concat("service/cnr/jconon/manage-application/paste");
UrlBuilder url = new UrlBuilder(link);
Response resp = cmisService.getHttpInvoker(cmisService.getAdminSession()).invokePOST(url, MimeTypes.JSON.mimetype(), new Output() {
@Override
public void write(OutputStream out) throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("applicationSourceId", application.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString());
jsonObject.put("callTargetId", call.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString());
out.write(jsonObject.toString().getBytes());
}
}, cmisService.getAdminSession());
int stato = resp.getResponseCode();
if (stato == HttpStatus.SC_BAD_REQUEST || stato == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
try {
JSONObject jsonObject = new JSONObject(resp.getErrorContent());
throw new ClientMessageException(jsonObject.getString("message"));
} catch (JSONException e) {
throw new ClientMessageException("message.application.for.copy.alredy.exists", e);
}
}
if (stato == HttpStatus.SC_NOT_FOUND) {
throw new ClientMessageException("Paste Application error. Exception: " + resp.getErrorContent());
}
try {
JSONObject jsonObject = new JSONObject(StringUtil.convertStreamToString(resp.getStream()));
return jsonObject.getString("cmis:objectId");
} catch (JSONException e) {
throw new ClientMessageException("Paste Application error. Exception: " + resp.getErrorContent(), e);
}
}
use of org.apache.chemistry.opencmis.commons.impl.UrlBuilder in project cool-jconon by consiglionazionaledellericerche.
the class CallService method creaGruppoRdP.
protected void creaGruppoRdP(final Folder call, String userId) {
if (call.getPropertyValue(JCONONPropertyIds.CALL_RDP.value()) != null)
return;
// Creazione del gruppo per i Responsabili del Procedimento
final String groupRdPName = createGroupRdPName(call);
try {
String link = cmisService.getBaseURL().concat("service/cnr/groups/group");
UrlBuilder url = new UrlBuilder(link);
Response response = CmisBindingsHelper.getHttpInvoker(cmisService.getAdminSession()).invokePOST(url, MimeTypes.JSON.mimetype(), new Output() {
@Override
public void write(OutputStream out) throws Exception {
String groupJson = "{";
groupJson = groupJson.concat("\"parent_group_name\":\"" + JcononGroups.RDP_CONCORSO.group() + "\",");
groupJson = groupJson.concat("\"group_name\":\"" + groupRdPName + "\",");
groupJson = groupJson.concat("\"display_name\":\"" + "RESPONSABILI BANDO [".concat(call.getPropertyValue(JCONONPropertyIds.CALL_CODICE.value())) + "]\",");
groupJson = groupJson.concat("\"zones\":[\"AUTH.ALF\",\"APP.DEFAULT\"]");
groupJson = groupJson.concat("}");
out.write(groupJson.getBytes());
}
}, cmisService.getAdminSession());
JSONObject jsonObject = new JSONObject(StringUtil.convertStreamToString(response.getStream()));
String nodeRefRdP = jsonObject.optString("nodeRef");
if (nodeRefRdP == "")
return;
/**
* Aggiorno il bando con il NodeRef del gruppo commissione
*/
Map<String, Object> propertiesRdP = new HashMap<String, Object>();
propertiesRdP.put(JCONONPropertyIds.CALL_RDP.value(), groupRdPName);
call.updateProperties(propertiesRdP, true);
/**
* Il Gruppo dei responsabili del procedimento deve avere il controllo completo sul bando
*/
addCoordinatorRdp(groupRdPName, call.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString());
Map<String, ACLType> acesGroup = new HashMap<String, ACLType>();
acesGroup.put(userId, ACLType.FullControl);
acesGroup.put(JcononGroups.CONCORSI.group(), ACLType.FullControl);
aclService.addAcl(cmisService.getAdminSession(), nodeRefRdP, acesGroup);
} catch (Exception e) {
LOGGER.error("ACL error", e);
}
}
use of org.apache.chemistry.opencmis.commons.impl.UrlBuilder in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method checkInPrint.
protected String checkInPrint(BindingSession cmisSession, final String applicationPrintId, final InputStream is, final String name) {
String link = cmisService.getBaseURL().concat("service/cnr/jconon/manage-application/checkIn");
UrlBuilder url = new UrlBuilder(link);
url = url.addParameter("applicationPrintId", applicationPrintId);
url = url.addParameter("name", name);
Response resp = cmisService.getHttpInvoker(cmisSession).invokePOST(url, MimeTypes.JSON.mimetype(), new Output() {
@Override
public void write(OutputStream out) throws Exception {
IOUtils.copy(is, out);
}
}, cmisSession);
int status = resp.getResponseCode();
if (status == HttpStatus.SC_NOT_FOUND || status == HttpStatus.SC_BAD_REQUEST || status == HttpStatus.SC_INTERNAL_SERVER_ERROR)
throw new CMISApplicationException("ChechIn Application error. Exception: " + resp.getErrorContent());
try {
return new JSONObject(IOUtils.toString(resp.getStream())).getString("objectId");
} catch (JSONException | IOException e) {
throw new CMISApplicationException("ChechIn Application error.", e);
}
}
use of org.apache.chemistry.opencmis.commons.impl.UrlBuilder in project cool-jconon by consiglionazionaledellericerche.
the class CacheRepository method createGroup.
protected void createGroup(final String parent_group_name, final String group_name, final String display_name, final String zones, final String extraProperty) {
String link = cmisService.getBaseURL().concat("service/cnr/groups/group");
UrlBuilder url = new UrlBuilder(link);
Response response = CmisBindingsHelper.getHttpInvoker(cmisService.getAdminSession()).invokePOST(url, MimeTypes.JSON.mimetype(), new Output() {
@Override
public void write(OutputStream out) throws Exception {
String groupJson = "{";
if (parent_group_name != null) {
groupJson = groupJson.concat("\"parent_group_name\":\"" + parent_group_name + "\",");
}
groupJson = groupJson.concat("\"group_name\":\"" + group_name + "\",");
groupJson = groupJson.concat("\"display_name\":\"" + display_name + "\",");
if (extraProperty != null)
groupJson = groupJson.concat("\"extraProperty\":" + extraProperty + ",");
if (zones == null)
groupJson = groupJson.concat("\"zones\":[\"AUTH.ALF\",\"APP.DEFAULT\"]");
else
groupJson = groupJson.concat("\"zones\":" + zones);
groupJson = groupJson.concat("}");
out.write(groupJson.getBytes());
}
}, cmisService.getAdminSession());
if (response.getErrorContent() != null)
LOGGER.error(response.getErrorContent());
}
Aggregations