use of org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl in project cool-jconon by consiglionazionaledellericerche.
the class CallService method save.
public Folder save(Session cmisSession, BindingSession bindingSession, String contextURL, Locale locale, String userId, Map<String, Object> properties, Map<String, Object> aspectProperties) {
Folder call;
properties.putAll(aspectProperties);
String codiceBando = (String) properties.get(JCONONPropertyIds.CALL_CODICE.value());
/**
* Verifico inizialmente se sto in creazione del Bando
*/
if (codiceBando == null)
throw new ClientMessageException("message.error.required.codice");
if (!isAlphaNumeric(codiceBando)) {
throw new ClientMessageException("message.error.codice.not.valid");
}
String name = Optional.ofNullable(i18NService.getLabel("call.name", locale)).orElse("").concat(codiceBando);
if (properties.get(JCONONPropertyIds.CALL_SEDE.value()) != null)
name = name.concat(" - ").concat(properties.get(JCONONPropertyIds.CALL_SEDE.value()).toString());
properties.put(PropertyIds.NAME, folderService.integrityChecker(name));
GregorianCalendar dataInizioInvioDomande = (GregorianCalendar) properties.get(JCONONPropertyIds.CALL_DATA_INIZIO_INVIO_DOMANDE.value());
Map<String, Object> otherProperties = new HashMap<String, Object>();
if (properties.get(PropertyIds.OBJECT_ID) == null) {
if (properties.get(PropertyIds.PARENT_ID) == null)
properties.put(PropertyIds.PARENT_ID, competitionService.getCompetitionFolder().get("id"));
call = (Folder) cmisSession.getObject(cmisSession.createFolder(properties, new ObjectIdImpl((String) properties.get(PropertyIds.PARENT_ID))));
aclService.setInheritedPermission(bindingSession, call.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString(), false);
if (dataInizioInvioDomande != null && properties.get(PropertyIds.PARENT_ID) == null) {
moveCall(cmisSession, dataInizioInvioDomande, call);
}
} else {
call = (Folder) cmisSession.getObject((String) properties.get(PropertyIds.OBJECT_ID));
CMISUser user = userService.loadUserForConfirm(userId);
if ((Boolean) call.getPropertyValue(JCONONPropertyIds.CALL_PUBBLICATO.value()) && !(user.isAdmin() || isMemberOfConcorsiGroup(user))) {
if (!existsProvvedimentoProrogaTermini(cmisSession, call))
throw new ClientMessageException("message.error.call.cannnot.modify");
}
call.updateProperties(properties, true);
if (!call.getParentId().equals(properties.get(PropertyIds.PARENT_ID)) && properties.get(PropertyIds.PARENT_ID) != null)
call.move(call.getFolderParent(), new ObjectIdImpl((String) properties.get(PropertyIds.PARENT_ID)));
}
otherProperties.put(JCONONPropertyIds.CALL_HAS_MACRO_CALL.value(), cmisSession.getObject(call.getParentId()).getType().getId().equals(call.getType().getId()));
List<Object> secondaryTypes = call.getProperty(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
if (!typeService.hasSecondaryType(call, JCONONPolicyType.JCONON_MACRO_CALL.value())) {
secondaryTypes.add(JCONONPolicyType.JCONON_CALL_SUBMIT_APPLICATION.value());
} else {
secondaryTypes.remove(JCONONPolicyType.JCONON_CALL_SUBMIT_APPLICATION.value());
}
otherProperties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
call.updateProperties(otherProperties);
creaGruppoRdP(call, userId);
Map<String, ACLType> aces = new HashMap<String, ACLType>();
aces.put(JcononGroups.CONCORSI.group(), ACLType.Coordinator);
aclService.addAcl(bindingSession, call.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString(), aces);
return call;
}
use of org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl in project cool-jconon by consiglionazionaledellericerche.
the class HelpDeskServiceTest method before.
@BeforeEach
@Disabled
public void before() throws ParseException, InterruptedException, CoolUserFactoryException {
// Seleziono uno dei bandi attivi
OperationContext oc = new OperationContextImpl(cmisDefaultOperationContext);
oc.setMaxItemsPerPage(1);
Session adminSession = cmisService.createAdminSession();
Calendar startDate = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Criteria criteria = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_CALL.queryName());
ItemIterable<QueryResult> queryResult = criteria.executeQuery(adminSession, false, oc);
MockHttpServletRequest req = new MockHttpServletRequest();
BindingSession bindingSession = cmisService.getAdminSession();
cmisUser = userService.loadUser("admin", bindingSession);
for (QueryResult qr : queryResult) {
call = (Folder) adminSession.getObject(new ObjectIdImpl(qr.getPropertyValueById(PropertyIds.OBJECT_ID)));
CALL = call.getName();
break;
}
postMap = new HashMap<String, String>();
postMap.put("firstName", cmisUser.getFirstName());
postMap.put("lastName", cmisUser.getLastName());
postMap.put("phoneNumber", cmisUser.getTelephone());
postMap.put("email", cmisUser.getEmail());
postMap.put("confirmEmail", cmisUser.getEmail());
postMap.put("category", ID_CATEGORY);
postMap.put("subject", SUBJECT);
postMap.put("message", MESSAGE);
postMap.put("problemType", PROBLEM_TYPE);
postMap.put("matricola", MATRICOLA);
postMap.put("call", CALL);
}
use of org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl in project cool-jconon by consiglionazionaledellericerche.
the class DocumentController method delete.
@DeleteMapping(value = "/delete")
public ResponseEntity<Boolean> delete(HttpServletRequest req, @RequestParam("objectId") String objectId) {
Session session = cmisService.getCurrentCMISSession(req);
session.delete(new ObjectIdImpl(objectId));
return ResponseEntity.ok(Boolean.TRUE);
}
use of org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl in project cool-jconon by consiglionazionaledellericerche.
the class ManageCall method copyLabels.
@GET
@Path("copy-labels")
public Response copyLabels(@Context HttpServletRequest request, @QueryParam("callFrom") String callFrom, @QueryParam("callId") String callId, @CookieParam("__lang") String __lang) {
ResponseBuilder rb;
Properties labels = new Properties();
try {
final Session currentCMISSession = cmisService.getCurrentCMISSession(request);
competitionService.copyLabels(currentCMISSession, callFrom, callId);
labels = competitionService.getDynamicLabels(new ObjectIdImpl(callId), currentCMISSession);
rb = Response.ok(labels);
} catch (ClientMessageException e) {
LOGGER.error("error loading labels {}", callId, e);
rb = Response.status(Status.INTERNAL_SERVER_ERROR).entity(Collections.singletonMap("message", e.getMessage()));
}
return rb.build();
}
use of org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl in project manifoldcf by apache.
the class CmisOutputConnector method addOrReplaceDocumentWithException.
@Override
public int addOrReplaceDocumentWithException(String documentURI, VersionContext pipelineDescription, RepositoryDocument document, String authorityNameString, IOutputAddActivity activities) throws ManifoldCFException, ServiceInterruption, IOException {
getSession();
boolean isDropZoneFolder = isDropZoneFolder(cmisQuery);
long startTime = System.currentTimeMillis();
String resultDescription = StringUtils.EMPTY;
Folder leafParent = null;
String fileName = StringUtils.EMPTY;
InputStream inputStream = null;
ReplayableInputStream replayableInputStream = null;
ContentStream contentStream = null;
// properties
// (minimal set: name and object type id)
Map<String, Object> properties = new HashMap<String, Object>();
Long binaryLength = null;
String mimeType = StringUtils.EMPTY;
try {
if (isDropZoneFolder) {
// Creation of the new Repository Node
fileName = document.getFileName();
Date creationDate = document.getCreatedDate();
Date lastModificationDate = document.getModifiedDate();
String objectId = StringUtils.EMPTY;
mimeType = document.getMimeType();
binaryLength = document.getBinaryLength();
// check if the repository connector includes the content path
String primaryPath = StringUtils.EMPTY;
List<String> sourcePath = document.getSourcePath();
if (sourcePath != null && !sourcePath.isEmpty()) {
primaryPath = sourcePath.get(0);
}
// if the source is CMIS Repository Connector we override the objectId for synchronizing with removeDocument method
if (isSourceRepoCmisCompliant(document)) {
String[] cmisObjectIdArray = (String[]) document.getField(PropertyIds.OBJECT_ID);
if (cmisObjectIdArray != null && cmisObjectIdArray.length > 0) {
objectId = cmisObjectIdArray[0];
}
// Mapping all the CMIS properties ...
/*
Iterator<String> fields = document.getFields();
while (fields.hasNext()) {
String field = (String) fields.next();
if(!StringUtils.equals(field, "cm:lastThumbnailModification")
|| !StringUtils.equals(field, "cmis:secondaryObjectTypeIds")) {
String[] valuesArray = (String[]) document.getField(field);
properties.put(field,valuesArray);
}
}
*/
}
// Agnostic metadata
properties.put(PropertyIds.OBJECT_TYPE_ID, EnumBaseObjectTypeIds.CMIS_DOCUMENT.value());
properties.put(PropertyIds.NAME, fileName);
properties.put(PropertyIds.CREATION_DATE, creationDate);
properties.put(PropertyIds.LAST_MODIFICATION_DATE, lastModificationDate);
// check objectId
if (StringUtils.isNotEmpty(objectId)) {
ObjectId objId = new ObjectIdImpl(objectId);
properties.put(PropertyIds.OBJECT_ID, objId);
}
// Content Stream
inputStream = document.getBinaryStream();
replayableInputStream = new ReplayableInputStream(inputStream);
contentStream = new ContentStreamImpl(fileName, BigInteger.valueOf(binaryLength), mimeType, replayableInputStream);
// create a new content
leafParent = getOrCreateLeafParent(parentDropZoneFolder, creationDate, Boolean.valueOf(createTimestampTree), primaryPath);
leafParent.createDocument(properties, contentStream, versioningState);
resultDescription = DOCUMENT_STATUS_ACCEPTED_DESC;
return DOCUMENT_STATUS_ACCEPTED;
} else {
resultDescription = DOCUMENT_STATUS_REJECTED_DESC;
return DOCUMENT_STATUS_REJECTED;
}
} catch (CmisContentAlreadyExistsException | CmisNameConstraintViolationException e) {
// updating the existing content
if (leafParent != null) {
String documentFullPath = leafParent.getPath() + CmisOutputConnectorUtils.SLASH + fileName;
String newFileName = fileName + System.currentTimeMillis();
Document currentContent = (Document) session.getObjectByPath(documentFullPath);
currentContent.updateProperties(properties);
replayableInputStream.restart(true);
contentStream = new ContentStreamImpl(newFileName, BigInteger.valueOf(binaryLength), mimeType, replayableInputStream);
currentContent.setContentStream(contentStream, true);
Logging.connectors.warn("CMIS: Document already exists - Updating: " + documentFullPath);
}
resultDescription = DOCUMENT_STATUS_ACCEPTED_DESC;
return DOCUMENT_STATUS_ACCEPTED;
} catch (Exception e) {
resultDescription = DOCUMENT_STATUS_REJECTED_DESC;
throw new ManifoldCFException(e.getMessage(), e);
} finally {
if (inputStream != null) {
inputStream.close();
}
activities.recordActivity(startTime, ACTIVITY_INJECTION, document.getBinaryLength(), documentURI, resultDescription, resultDescription);
}
}
Aggregations