/// <summary> /// Impostazione della visibilità su un fascicolo /// (e dell'ownership, nel caso l'utente / ruolo rimosso fosse il proprietario) /// </summary> /// <param name="infoDiritto"></param> /// <returns></returns> public bool AddPermission(DocsPaVO.fascicolazione.DirittoOggetto infoDiritto) { bool added = false; // se si revocano i diritti all'utente proprietario, // si revocano anche al ruolo proprietario e viceversa. // Il proprietario del documento diventa l'utente e il ruolo del revocante try { // Reperimento utente proprietario string ownerUser = TypeUtente.NormalizeUserName(DocsPaQueryHelper.getCodiceRubricaProprietario(infoDiritto.idObj, true)); // Modifica ownership del fascicolo if (this.SetOwnershipFascicolo(infoDiritto.idObj, ownerUser)) { CustomServices.AclDefinition aclDefinition = Dfs4DocsPa.getAclDefinition(infoDiritto.idObj, ObjectTypes.FASCICOLO, this.InfoUtente); CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); aclService.ClearAndGrant(aclDefinition, infoDiritto.idObj); added = true; } } catch (Exception ex) { added = false; logger.Debug(string.Format("Errore in Documentum.RemovePermission:\n{0}", ex.ToString())); } return(added); }
/// <summary> /// Verifica credenziali utente /// </summary> /// <param name="userName"></param> protected virtual bool VerifyCredentials(string userName, string authenticationToken, out DocsPaVO.utente.UserLogin.LoginResult loginResult) { bool retValue = false; loginResult = UserLogin.LoginResult.APPLICATION_ERROR; try { ObjectIdentity identity = Dfs4DocsPa.getUserHomeFolderIdentity(userName); IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(authenticationToken); logger.Debug("Inizio richiamo authenticationToken"); DataPackage dataPackage = objectService.Get(new ObjectIdentitySet(identity), null); logger.Debug("Fine chiamata authenticationToken"); retValue = (dataPackage != null); } /* * catch (Emc.Documentum.FS.Runtime.AuthenticationException exAuth) * { * //AuthenticationException - Exception in com.emc.documentum.fs.rt * //Exception which is raised when authentication errors occur * loginResult = DocsPaVO.utente.UserLogin.LoginResult.UNKNOWN_DTCM_USER; * retValue = false; * * logger.Debug(string.Format("Credenziali utente DTCM non valide: '{0}'", userName)); * } */ catch (Emc.Documentum.FS.Runtime.ServiceInvocationException exServiceInvocation) { //AuthenticationException - Exception in com.emc.documentum.fs.rt //Exception which is raised when authentication errors occur loginResult = DocsPaVO.utente.UserLogin.LoginResult.DTCM_SERVICE_NO_CONTACT; retValue = false; logger.Debug(string.Format("Errore nel tentativo di contattare i servizi DOCUMENTUM: '{0}'", userName)); } /* * catch (Emc.Documentum.FS.Runtime.ServiceException exService) * { * //AuthenticationException - Exception in com.emc.documentum.fs.rt * //Exception which is raised when authentication errors occur * loginResult = DocsPaVO.utente.UserLogin.LoginResult.DTCM_SERVICE_NO_CONTACT; * retValue = false; * * logger.Debug(string.Format("Errore nel tentativo di contattare i servizi DTCM: '{0}'", userName)); * } */ catch (Exception ex) { //AuthenticationException - Exception in com.emc.documentum.fs.rt //Exception which is raised when authentication errors occur loginResult = DocsPaVO.utente.UserLogin.LoginResult.UNKNOWN_USER; retValue = false; logger.DebugFormat("Credenziali utente non DCTM valide: '{0}' msg {1} stk {2}", userName, ex.Message, ex.StackTrace); } return(retValue); }
/// <summary> /// Aggiornamento visibilità di più ruoli su un titolario /// </summary> /// <param name="nodoTitolario"></param> /// <param name="ruoliTitolario"></param> /// <returns></returns> public DocsPaVO.amministrazione.EsitoOperazione[] SetAclNodoTitolario(OrgNodoTitolario nodoTitolario, OrgRuoloTitolario[] ruoliTitolario) { // Per documentum, viene riportato un'unico EsitoOperazione // contenente i dettagli relativi all'esito dell'intera operazione effettuata // (a differenza di etdocs, l'aggiornamento è effetuato in un'unica operazione) EsitoOperazione retValue = new EsitoOperazione(); try { // Reperimento ACL del nodo titolario CustomServices.AclDefinition aclData = Dfs4DocsPa.getAclDefinition(nodoTitolario.ID, ObjectTypes.NODO_TITOLARIO, nodoTitolario.CodiceAmministrazione); CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); // Aggiornamento della visibilità dei ruoli sul nodo titolario aclService.ClearAndGrant(aclData); retValue.Codice = 0; retValue.Descrizione = string.Format("Aggiornamento dei ruoli nel nodo titolario '{0}' terminato correttamente", nodoTitolario.Codice); } catch (Exception ex) { retValue.Codice = -1; retValue.Descrizione = string.Format("Errore in Documentum nell'aggiornamento dei ruoli nel nodo titolario '{0}'", nodoTitolario.Codice); logger.Debug("Errore in Documentum.SetAclNodoTitolario: " + ex.ToString()); } return(new EsitoOperazione[1] { retValue }); }
/// <summary> /// Cancellazione di un folder in DocsPa /// </summary> /// <param name="idProject">Identificativo univoco del folder</param> /// <remarks> /// /// PreCondizioni: /// Il folder è stato rimosso correttamente in DocsPa /// /// PostCondizioni: /// Il corrispondente oggetto in documentum per il folder /// è stato rimosso correttamente /// /// </remarks> /// <returns></returns> public bool DeleteFolder(DocsPaVO.fascicolazione.Folder folder) { bool retValue = false; try { DeleteProfile deleteProfile = new DeleteProfile(); deleteProfile.IsDeepDeleteFolders = true; deleteProfile.IsDeepDeleteChildrenInFolders = true; IObjectService objectService = this.GetServiceInstance <IObjectService>(false); OperationOptions opts = new OperationOptions(); opts.DeleteProfile = deleteProfile; // Reperimento identity per il sottofascicolo ObjectIdentity identity = Dfs4DocsPa.getSottofascicoloIdentityById(folder.systemID); objectService.Delete(new ObjectIdentitySet(identity), opts); retValue = true; logger.Debug(string.Format("Documentum.DeleteFolder: rimosso sottofascicolo con id {0}", folder.systemID)); } catch (Exception ex) { retValue = false; logger.Debug(string.Format("Errore in Documentum.DeleteFolder:\n{0}", ex.ToString())); } return(retValue); }
/// <summary> /// Modifica dei dati di un folder /// </summary> /// <param name="folder"></param> /// <returns></returns> public bool ModifyFolder(DocsPaVO.fascicolazione.Folder folder) { bool retValue = false; try { // Reperimento identity per il sottofascicolo ObjectIdentity identity = Dfs4DocsPa.getSottofascicoloIdentityById(folder.systemID); DataObject dataObject = new DataObject(identity, ObjectTypes.SOTTOFASCICOLO); // Reperimento properties del sottofascicolo dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getSottoFascicoloProperties(folder)); DataPackage dataPackage = new DataPackage(dataObject); IObjectService objectService = this.GetServiceInstance <IObjectService>(true); dataPackage = objectService.Update(dataPackage, null); retValue = (dataPackage.DataObjects.Count == 1); if (retValue) { logger.Debug(string.Format("Documentum.ModifyFolder: modificato sottofascicolo con id {0}", folder.systemID)); } } catch (Exception ex) { retValue = false; logger.Debug(string.Format("Errore in Documentum.ModifyFolder:\n{0}", ex.ToString())); } return(retValue); }
/// <summary> /// Creazione ACL per l'amministrazione /// </summary> /// <param name="info"></param> /// <returns></returns> protected virtual CustomServices.AclDefinition CreateAclAdmin(InfoAmministrazione info) { CustomServices.AclDefinition aclData = null; try { // Reperimento ACL per gli oggetti visibili da tutta l'amministrazione aclData = Dfs4DocsPa.getAclDefinitionAmministrazione(info.Codice); CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); CustomServices.ObjectIdentity aclIdentity = aclService.Create(aclData); if (aclIdentity == null) { throw new ApplicationException(string.Concat("Errore nella creazione dell'ACL per l'amministrazione con ID '{0}'", info.IDAmm)); } } catch (Exception ex) { string errorMessage = string.Format("Errore in Documentum.CreateAclAdmin:\n{0}", ex.ToString()); logger.Debug(errorMessage); throw new ApplicationException(errorMessage); } return(aclData); }
/// <summary> /// Creazione delle ACL per il nodo titolario /// </summary> /// <param name="nodoTitolario"></param> /// <returns>ACL creata, ma ancora non associata al nodo titolario</returns> protected virtual CustomServices.AclDefinition CreateAclNodoTitolario(DocsPaVO.amministrazione.OrgNodoTitolario nodoTitolario) { CustomServices.AclDefinition aclData = null; try { // Reperimento ACL nodo titolario aclData = Dfs4DocsPa.getAclDefinition(nodoTitolario.ID, ObjectTypes.NODO_TITOLARIO, nodoTitolario.CodiceAmministrazione); CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); CustomServices.ObjectIdentity aclIdentity = aclService.Create(aclData); if (aclIdentity == null) { throw new ApplicationException(string.Concat("Errore nella creazione dell'ACL per il nodo titolario con ID '{0}'", nodoTitolario.ID)); } } catch (Exception ex) { string errorMessage = string.Format("Errore in Documentum.CreateAclNodoTitolario:\n{0}", ex.ToString()); logger.Debug(errorMessage); throw new ApplicationException(errorMessage); } return(aclData); }
/// <summary> /// Creazione delle ACL per il fascicolo /// NOTA: RW di DocsPA equivale a DELETE di Documentum /// </summary> /// <param name="fascicolo"></param> /// <param name="ruoloCreatore"></param> /// <returns>ACL creata, ma ancora non associata al documento</returns> protected virtual CustomServices.AclDefinition CreateAclFascicolo(DocsPaVO.fascicolazione.Fascicolo fascicolo, DocsPaVO.utente.Ruolo ruoloCreatore) { CustomServices.AclDefinition aclData = null; try { // Reperimento ACL per il fascicolo aclData = Dfs4DocsPa.getAclDefinition(fascicolo.systemID, ObjectTypes.FASCICOLO, this.InfoUtente); // istanziamo ACLservice in modalità super-user per poter comunque creare una acl di sistema // nota: questo non sarebbe strettamente necessario (si potrebbe usare una user-acl, di tipo public) // ma si ritiene che non sia bello avere le acl di proprietà degli utenti creatori del documento CustomServices.IAclService aclSvcSuper = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); CustomServices.ObjectIdentity aclIdentity = aclSvcSuper.Create(aclData); if (aclIdentity == null) { throw new ApplicationException(string.Concat("Errore nella creazione dell'ACL per il fascicolo con id '{0}'", fascicolo.systemID)); } } catch (Exception ex) { string errorMessage = string.Format("Errore in Documentum.CreateAclFascicolo:\n{0}", ex.ToString()); logger.Debug(errorMessage); throw new ApplicationException(errorMessage); } return(aclData); }
/// <summary> /// Caricamento dei valori delle properties relative allo stato checkout per il documento /// </summary> /// <param name="documentNumber"></param> /// <param name="isStampaRegistro"></param> /// <returns></returns> protected virtual PropertySet LoadCheckOutProperties(string documentNumber, bool isStampaRegistro) { ObjectIdentity identity = null; if (isStampaRegistro) { identity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(documentNumber); } else { identity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(documentNumber); } List <string> filters = new List <string>(); filters.Add("r_object_id"); filters.Add("object_name"); filters.Add("r_lock_owner"); filters.Add("r_lock_date"); filters.Add(TypeDocumento.CHECKOUT_LOCAL_FILE_PATH); filters.Add(TypeDocumento.CHECKOUT_MACHINE_NAME); if (!isStampaRegistro) { // Caricamento informazioni di checkout specifiche per documenti non di tipo stampa registro filters.Add(TypeDocumento.TIPO_PROTOCOLLO); } IObjectService service = this.GetServiceInstance <IObjectService>(true); DataObject dataObject = DfsHelper.getAllPropsAndFolders(service, identity, filters, false); return(dataObject.Properties); }
/// <summary> /// Revoca della visibilità su un documento (e dell'ownership, nel caso l'utente / ruolo rimosso è proprietario) /// </summary> /// <param name="documentInfo"></param> /// <returns></returns> public bool RemovePermission(DocsPaVO.fascicolazione.DirittoOggetto infoDiritto) { bool removed = false; try { // Reperimento utente proprietario string ownerUser = TypeUtente.NormalizeUserName(DocsPaQueryHelper.getCodiceRubricaProprietario(infoDiritto.idObj, true)); if (this.SetOwnershipFascicolo(infoDiritto.idObj, ownerUser)) { CustomServices.AclDefinition aclDefinition = Dfs4DocsPa.getAclDefinition(infoDiritto.idObj, ObjectTypes.FASCICOLO, this.InfoUtente); CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); aclService.ClearAndGrant(aclDefinition, infoDiritto.idObj); } removed = true; } catch (Exception ex) { removed = false; logger.Debug(string.Format("Errore in Documentum.RemovePermission:\n{0}", ex.ToString())); } return(removed); }
/// <summary> /// Implementazione di un workaround per il checkin dei singoli allegati di un documento (se presenti) /// </summary> /// <param name="docNumber"></param> protected void UndoCheckOutAllegati(string docNumber) { ObjectIdentitySet identitySet = new ObjectIdentitySet(); identitySet.Identities.AddRange(Dfs4DocsPa.getAllegatiDocumentoIdentities(this.GetServiceInstance <IQueryService>(false), docNumber)); if (identitySet.Identities.Count > 0) { this.GetServiceInstance <IVersionControlService>(false).CancelCheckout(identitySet); } }
/// <summary> /// /// </summary> /// <param name="titolario"></param> protected void ClearAclFascicoliTitolario(OrgTitolario titolario) { foreach (string idFascicolo in DocsPaQueryHelper.getFascicoliProcedimentaliTitolario(titolario.ID)) { // Reperimento e cancellazione ACL per il fascicolo procedimentale CustomServices.AclDefinition aclDefinition = Dfs4DocsPa.getAclDefinition(idFascicolo, ObjectTypes.FASCICOLO, this.InfoUtente); this.DeleteAcl(aclDefinition); } }
/// <summary> /// Inserimento nuovo ruolo in amministrazione /// </summary> /// <param name="ruolo"></param> /// <returns></returns> public EsitoOperazione InserisciRuolo(OrgRuolo ruolo, bool computeAtipicita) { EsitoOperazione ret = new EsitoOperazione(); string logMsg; IObjectService objSrvc = null; String repositoryName = DctmConfigurations.GetRepositoryName(); // test sui campi obbligatori if (string.IsNullOrEmpty(ruolo.Codice) || string.IsNullOrEmpty(ruolo.Descrizione)) { ret.Codice = -1; logMsg = ERR_HEADER + "InserisciRuolo: dati insufficienti"; ret.Descrizione = logMsg; logger.Debug(logMsg); return(ret); } // il campo Codice corrisponde a: // (ETDOCS) DPA_CORR_GLOBALI.VAR_COD_RUBRICA varchar(128) // (DCTM) dm_group.group_name string(32) // se mi viene passato un codice di lunghezza > 32 lancio un'eccezione if (ruolo.Codice.Length > 32) { ret.Codice = -1; logMsg = ERR_HEADER + "InserisciRuolo: campo CODICE supera la lunghezza massima (32)"; ret.Descrizione = logMsg; logger.Debug(logMsg); return(ret); } try { objSrvc = this.GetObjectServiceInstance(); ObjectIdentity userIdentity = new ObjectIdentity(repositoryName); DataObject groupData = new DataObject(userIdentity, ObjectTypes.GRUPPO); groupData.Properties.Properties.AddRange(Dfs4DocsPa.getGroupProperties(ruolo, false)); DataPackage pkg = new DataPackage(groupData); objSrvc.Create(pkg, null); logger.Debug(DEBUG_HEADER + "InserisciRuolo completata con SUCCESSO"); return(ret); } catch (Exception ex) { String st = ex.ToString(); logger.Debug(DEBUG_HEADER + "InserisciRuolo FALLITA, Exception=" + st); ret.Codice = -1; ret.Descrizione = ERR_HEADER + "InserisciRuolo"; return(ret); } }
/// <summary> /// Aggiornamento delle proprietà dell'oggetto "p3_document" /// </summary> /// <param name="idCheckOut"></param> /// <param name="documentNumber"></param> /// <param name="machineName"></param> /// <param name="documentLocation"></param> /// <returns></returns> private bool SaveCheckOutDocumentProperties(string idCheckOut, string documentNumber, string documentLocation, string machineName) { bool retValue = false; try { // Determina se il documento da bloccare è di tipo stampa registro bool isStampaRegistro = (DocsPaQueryHelper.isStampaRegistro(documentNumber)); ObjectIdentity identity = null; if (!string.IsNullOrEmpty(idCheckOut)) { identity = DfsHelper.createObjectIdentityObjId(idCheckOut); } else { if (DocsPaQueryHelper.isStampaRegistro(documentNumber)) { identity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(documentNumber); } else { identity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(documentNumber); } } DataObject dataObject = new DataObject(identity); dataObject.Properties = new PropertySet(); List <Property> propertyList = new List <Property>(); propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_LOCAL_FILE_PATH, documentLocation)); propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_MACHINE_NAME, machineName)); dataObject.Properties.Properties.AddRange(propertyList); DataPackage dataPackage = new DataPackage(dataObject); dataPackage.RepositoryName = dataObject.Identity.RepositoryName; IObjectService service = this.GetServiceInstance <IObjectService>(false); dataPackage = service.Update(dataPackage, null); retValue = (dataPackage.DataObjects.Count > 0); } catch (Exception ex) { retValue = false; logger.Debug("Errore in Documentum. SaveCheckOutDocumentProperties: " + ex.ToString()); } return(retValue); }
/// <summary> /// Elimina un utente in amministrazione /// </summary> /// <param name="utente"></param> /// <returns></returns> public EsitoOperazione EliminaUtenteAmm(OrgUtente utente) { EsitoOperazione ret = new EsitoOperazione(); string logMsg; IObjectService objSrvc = null; String repositoryName = DctmConfigurations.GetRepositoryName(); // test sui campi obbligatori if (string.IsNullOrEmpty(utente.UserId)) { logMsg = ERR_HEADER + "EliminaUtente: dati insufficienti"; ret.Codice = -1; ret.Descrizione = logMsg; logger.Debug(logMsg); return(ret); } try { // verifica se esistono più di un'occorrenza per utente if (CountGroupsByUser(utente.UserId) > 1) { // rimuove l'utente dal gruppo di root EliminaUtenteDaRuoloAmm(utente.UserId, utente.IDAmministrazione); } else { ObjectIdentitySet identitySet = new ObjectIdentitySet(); objSrvc = this.GetObjectServiceInstance(); ObjectIdentity userIdentity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.getUserName(utente)); // Cancellazione dell'home cabinet per l'utente identitySet.AddIdentity(Dfs4DocsPa.getUserHomeFolderIdentity(utente.UserId)); identitySet.AddIdentity(userIdentity); OperationOptions opts = new OperationOptions(); opts.DeleteProfile = new DeleteProfile(); opts.DeleteProfile.IsPopulateWithReferences = true; objSrvc.Delete(identitySet, opts); logger.Debug(DEBUG_HEADER + "EliminaUtente completata con SUCCESSO"); } return(ret); } catch (Exception ex) { String st = ex.ToString(); logger.Debug(DEBUG_HEADER + "EliminaUtente FALLITA, Exception=" + st); ret.Codice = -1; ret.Descrizione = ERR_HEADER + "EliminaUtente"; return(ret); } }
/// <summary> /// UndoCheckout di un documento in stato checkout /// </summary> /// <param name="checkOutStatus"></param> /// <param name="library"></param> /// <returns></returns> public bool UndoCheckOut(DocsPaVO.CheckInOut.CheckOutStatus checkOutStatus) { bool retValue = false; try { ObjectIdentity identity = null; // Reperimento identity del documento da sbloccare if (DocsPaQueryHelper.isStampaRegistro(checkOutStatus.DocumentNumber)) { identity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(checkOutStatus.DocumentNumber); } else { identity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(checkOutStatus.DocumentNumber); } ObjectIdentitySet identitySet = new ObjectIdentitySet(); identitySet.Identities.Add(identity); // Reperimento degli ObjectIdentity per ciascun allegato del documento identitySet.Identities.AddRange(Dfs4DocsPa.getAllegatiDocumentoIdentities(this.GetServiceInstance <IQueryService>(false), checkOutStatus.DocumentNumber)); IVersionControlService service = this.GetServiceInstance <IVersionControlService>(false); service.CancelCheckout(identitySet); retValue = true; if (retValue) { this.ClearCheckOutStatusObject(checkOutStatus); retValue = this.SaveCheckOutDocumentProperties(checkOutStatus); if (retValue) { logger.Debug(string.Format("Documentum.UndoCheckOut: effettuato l'undocheckout del documento con id {0} e docnumber {1}", checkOutStatus.IDDocument, checkOutStatus.DocumentNumber)); } } } catch (Exception ex) { retValue = false; logger.Debug("Errore in Documentum.UndoCheckOut: " + ex.ToString()); } return(retValue); }
/// <summary> /// Handler dell'evento di avvenuta accettazione / rifiuto di una trasmissione di un documento / fascicolo /// </summary> /// <param name="trasmissione"></param> /// <param name="ruolo"></param> /// <param name="tipoRisposta"></param> public void TrasmissioneAccettataRifiutataEventHandler(DocsPaVO.trasmissione.Trasmissione trasmissione, DocsPaVO.utente.Ruolo ruolo, DocsPaVO.trasmissione.TipoRisposta tipoRisposta) { CustomServices.AclDefinition aclData = null; DateTime startDate = DateTime.Now; // Aggiornamento ACL in DCTM, con le credenziali di superuser CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); if (trasmissione.tipoOggetto == DocsPaVO.trasmissione.TipoOggetto.DOCUMENTO) { // Reperimento della lista delle ACL aggiornata nella tabella security di docspa aclData = Dfs4DocsPa.getAclDefinition(trasmissione.infoDocumento.docNumber, DocsPaObjectTypes.ObjectTypes.DOCUMENTO, this.InfoUtente); aclService.ClearAndGrant(aclData, trasmissione.infoDocumento.idProfile); } else if (trasmissione.tipoOggetto == DocsPaVO.trasmissione.TipoOggetto.FASCICOLO) { DateTime startDateFasc = DateTime.Now; // Reperimento della lista delle ACL aggiornata nella tabella security di docspa aclData = Dfs4DocsPa.getAclDefinition(trasmissione.infoFascicolo.idFascicolo, DocsPaObjectTypes.ObjectTypes.FASCICOLO, this.InfoUtente); aclService.ClearAndGrant(aclData, trasmissione.infoFascicolo.idFascicolo); logger.Debug("Tot sec. FASC: " + DateTime.Now.Subtract(startDateFasc).TotalSeconds.ToString()); string[] idProfiles = DocsPaQueryHelper.getDocumentiInFascicolo(trasmissione.infoFascicolo.idFascicolo); //PORKING: nonè necessario farlo ora, perchè le aCL di Documenti vengono rimappate se necesario quando gli utenti o i ruoli faranno // GetDettaglio con il metedo RefreshAcl if (idProfiles != null && idProfiles.Length < 20) { foreach (string idProfile in idProfiles) { DateTime startDateDoc = DateTime.Now; // Aggiornamento delle ACL per tutti i documenti nel fascicolo (compresi eventuali sottofascicoli) // Aggiornamento delle ACL per tutti i documenti nel fascicolo (compresi eventuali sottofascicoli) //DCTM è usato solo con PITRE e in PITRE storicamente il idprofile è sempre uguale a docnumber quindi posso togliere questa query //DocsPaQueryHelper.getDocNumber(idProfile) è passare in input direttamente idProfile al metodo getAclDefinition aclData = Dfs4DocsPa.getAclDefinition(idProfile, DocsPaObjectTypes.ObjectTypes.DOCUMENTO, this.InfoUtente); aclService.ClearAndGrant(aclData, idProfile); logger.DebugFormat("Tot sec. DOC_{0}: {1}", idProfile, DateTime.Now.Subtract(startDateDoc).TotalSeconds.ToString()); } } } logger.Debug("Tot sec.: " + DateTime.Now.Subtract(startDate).TotalSeconds.ToString()); }
/// <summary> /// Modifica dei metadati di un fascicolo /// </summary> /// <param name="fascicolo"></param> /// <param name="refreshAclIfUpdate"> /// Se true, indica di aggiornare le entries dell'ACL associata al nodo titolario /// </param> /// <returns></returns> public bool ModifyProject(DocsPaVO.fascicolazione.Fascicolo fascicolo, bool refreshAclIfUpdate) { bool retValue = false; try { // Solo gli attributi del fascicolo procedimentale può essere modificato in documentum if (fascicolo.tipo == "P") { // Reperimento identity del fascicolo procedimentale ObjectIdentity identity = Dfs4DocsPa.getFascicoloProcedimentaleIdentityById(fascicolo.systemID); DataObject dataObject = new DataObject(identity); // Impostazione proprietà fascicolo dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getFascicoloProcedimentaleProperties(fascicolo)); DataPackage dataPackage = new DataPackage(dataObject); IObjectService objectService = this.GetServiceInstance <IObjectService>(true); dataPackage = objectService.Update(dataPackage, null); retValue = (dataPackage.DataObjects.Count == 1); if (retValue) { if (refreshAclIfUpdate) { // Aggiornamento delle entries dell'acl associata al fascicolo this.RefreshAclFascicolo(fascicolo); } logger.Debug(string.Format("Documentum.ModifyProject: modificato fascicolo con id {0}", fascicolo.systemID)); } } else { retValue = true; } } catch (Exception ex) { retValue = false; logger.Debug(string.Format("Errore in Documentum.ModifyProject:\n{0}", ex.ToString())); } return(retValue); }
/// <summary> /// Verifica se un utente è contenuto in un gruppo DCTM /// </summary> /// <param name="groupName"></param> /// <param name="userId"></param> /// <returns></returns> public bool ContainsGroupUser(string groupName, string userId) { IQueryService queryServices = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser()); userId = DocsPaObjectTypes.TypeUtente.NormalizeUserName(userId); foreach (string user in Dfs4DocsPa.getUsersGroup(DocsPaObjectTypes.TypeGruppo.NormalizeGroupName(groupName), queryServices)) { if (user == userId) { return(true); } } return(false); }
/// <summary> /// Aggiornamento delle fascicolazioni /// </summary> /// <param name="idFolder"></param> public virtual bool UpdateFascicolazioni(string idFolder) { bool retValue = false; // Reperimento record di tipo "C" string idFolderC = DocsPaQueryHelper.getIdFolderCType(idFolder); try { IQueryService queryService = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser()); // 1. Reperimento di tutti i documenti contenuti in fascicolo in DCTM List <string> documentiInDctm = new List <string>(Dfs4DocsPa.getIdDocumentiInFascicolo(queryService, idFolder)); // 2. Reperimento di tutti i documenti contenuti in fascicolo in PITRE foreach (string idDocumento in DocsPaQueryHelper.getDocumentiInFolder(idFolderC)) { // 3. Per ogni documento contenuto nel fascicolo, verifica se esiste nel corrispondente fascicolo in DCTM if (!documentiInDctm.Contains(idDocumento)) { // 4. Verifica se il documento esiste in DCTM if (!Dfs4DocsPa.containsDocumento(idDocumento, queryService)) { throw new ApplicationException(string.Format("Documento con id '{0}' non esistente in Documentum", idDocumento)); } // 4. Inserimento del documento nel fascicolo in DCTM se non esiste if (!this.AddDocumentInFolder(idDocumento, idFolderC)) { throw new ApplicationException(string.Format("Errore in inserimento del documento con id '{0}' nel fascicolo con id '{1}'", idDocumento, idFolderC)); } } } retValue = true; } catch (Exception ex) { retValue = false; logger.Debug(string.Format("Errore in Documentum.UpdateFascicolazioni:\n{0}", ex.ToString())); } return(retValue); }
/// <summary> /// Aggiornamento delle entries dell'acl associata al nodo di titolario /// </summary> /// <param name="nodoTitolario"></param> /// <returns></returns> protected virtual void RefreshAclNodoTitolario(DocsPaVO.amministrazione.OrgNodoTitolario nodoTitolario) { try { // Reperimento ACL nodo titolario CustomServices.AclDefinition aclData = Dfs4DocsPa.getAclDefinition(nodoTitolario.ID, ObjectTypes.NODO_TITOLARIO, nodoTitolario.CodiceAmministrazione); CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); aclService.ClearAndGrant(aclData); } catch (Exception ex) { string errorMessage = string.Format("Errore in Documentum.CreateAclNodoTitolario:\n{0}", ex.ToString()); logger.Debug(errorMessage); throw new ApplicationException(errorMessage); } }
/// <summary> /// Eliminazione di un nodo di titolario /// </summary> /// <param name="nodoTitolario"></param> /// <returns></returns> public bool DeleteNodoTitolario(OrgNodoTitolario nodoTitolario) { bool retValue = false; try { IObjectService objSrvc = this.GetObjectServiceInstance(); DeleteProfile deleteProfile = new DeleteProfile(); deleteProfile.IsDeepDeleteFolders = true; deleteProfile.IsDeepDeleteChildrenInFolders = true; OperationOptions opts = new OperationOptions(); opts.Profiles = new List <Profile>(); opts.Profiles.Add(deleteProfile); ObjectIdentitySet identitySet = new ObjectIdentitySet(); identitySet.Identities = new List <ObjectIdentity>(); identitySet.Identities.Add(Dfs4DocsPa.getNodoTitolarioIdentity(nodoTitolario.ID)); objSrvc.Delete(identitySet, opts); // Rimozione ACL nodo titolario this.DeleteAclNodoTitolario(nodoTitolario); // Rimozione di tutte le ACL degli eventuali // fascicoli procedimentali contenuti nel titolario this.ClearAclFascicoliNodoTitolario(nodoTitolario); retValue = true; logger.Debug(string.Format("Documentum.DeleteNodoTitolario: rimosso nodo di titolario con id {0}", nodoTitolario.ID)); } catch (Exception ex) { retValue = false; logger.Debug("Errore in Documentum.DeleteNodoTitolario: " + ex.ToString()); } return(retValue); }
/// <summary> /// Modifica password utente /// </summary> /// <param name="oldPassword"/></param> /// <param name="user"></param> ///// <returns></returns> public ValidationResultInfo ChangeUserPwd(DocsPaVO.utente.UserLogin user, string oldPassword) { ValidationResultInfo retValue = new ValidationResultInfo(); try { // La password deve essere modificata con le credenziali di superuser IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(UserManager.ImpersonateSuperUser()); ObjectIdentity identity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.NormalizeUserName(user.UserName)); DataObject userDataObject = new DataObject(identity, ObjectTypes.UTENTE); userDataObject.Properties.Set <string>("user_password", user.Password); DataPackage dataPackage = new DataPackage(userDataObject); dataPackage = objectService.Update(dataPackage, null); retValue.Value = (dataPackage.DataObjects.Count > 0); if (!retValue.Value) { throw new ApplicationException("Password non aggiornata"); } else { RepositoryIdentity newIdentity = DctmRepositoryIdentityHelper.GetIdentity(DctmConfigurations.GetRepositoryName(), user.UserName, user.Password, string.Empty); user.DST = DctmRepositoryIdentityHelper.CreateAuthenticationToken(newIdentity); logger.Debug(string.Format("Documentum.ChangePassword: password modificata per l'utente {0}", user.UserName)); } } catch (Exception ex) { logger.Debug(string.Format("Errore in Documentum.ChangePassword:\n{0}", ex.ToString())); retValue.BrokenRules.Add(new BrokenRule("ChangePassword_ERROR", "Errore nella modifica della password per il documentale DOCUMENTUM", DocsPaVO.Validations.BrokenRule.BrokenRuleLevelEnum.Error)); } retValue.Value = (retValue.BrokenRules.Count == 0); return(retValue); }
/// <summary> /// Impostazione dell'ownership sul documento /// </summary> /// <param name="idProject"></param> /// <param name="ownerName"></param> /// <returns></returns> public virtual bool SetOwnershipFascicolo(string idFascicolo, string ownerName) { // Modifica del campo "owner_name" per il fascicolo e tutti gli eventuali sottofascicoli bool retValue = false; try { // Creazione queryservice con credenziali di superutente Dfs4DocsPa.setOwnershipFascicolo(idFascicolo, ownerName, DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser())); retValue = true; } catch (Exception ex) { retValue = false; logger.Debug(string.Format("Errore in Documentum.SetOwnershipFascicolo:\n{0}", ex.ToString())); } return(retValue); }
/// <summary> /// Cancellazione di un ruolo in amministrazione /// </summary> /// <param name="ruolo"></param> /// <returns></returns> public EsitoOperazione EliminaRuolo(OrgRuolo ruolo) { EsitoOperazione ret = new EsitoOperazione(); string logMsg; IObjectService objSrvc = null; String repositoryName = DctmConfigurations.GetRepositoryName(); // test sui campi obbligatori if (string.IsNullOrEmpty(ruolo.Codice)) { logMsg = ERR_HEADER + "EliminaRuolo: dati insufficienti"; ret.Codice = -1; ret.Descrizione = logMsg; logger.Debug(logMsg); return(ret); } try { objSrvc = this.GetObjectServiceInstance(); ObjectIdentity groupIdentity = Dfs4DocsPa.getGroupIdentityByName(TypeGruppo.GetGroupName(ruolo)); checkReference(TypeGruppo.GetGroupName(ruolo), ObjectTypes.UTENTE, "user_group_name", false); ObjectIdentitySet s = new ObjectIdentitySet(groupIdentity); objSrvc.Delete(s, null); logger.Debug(DEBUG_HEADER + "EliminaRuolo completata con SUCCESSO"); return(ret); } catch (Exception ex) { String st = ex.ToString(); logger.Debug(DEBUG_HEADER + "EliminaRuolo FALLITA, Exception=" + st); ret.Codice = -1; ret.Descrizione = ERR_HEADER + "EliminaRuolo"; return(ret); } }
/// <summary> /// Aggiornamento delle entries dell'acl del fascicolo /// </summary> /// <param name="fascicolo"></param> protected virtual void RefreshAclFascicolo(DocsPaVO.fascicolazione.Fascicolo fascicolo) { try { // Reperimento ACL per il fascicolo CustomServices.AclDefinition aclData = Dfs4DocsPa.getAclDefinition(fascicolo.systemID, ObjectTypes.FASCICOLO, this.InfoUtente); // istanziamo ACLservice in modalità super-user per poter comunque creare una acl di sistema // nota: questo non sarebbe strettamente necessario (si potrebbe usare una user-acl, di tipo public) // ma si ritiene che non sia bello avere le acl di proprietà degli utenti creatori del documento CustomServices.IAclService aclSvcSuper = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); aclSvcSuper.ClearAndGrant(aclData, fascicolo.systemID); } catch (Exception ex) { string errorMessage = string.Format("Errore in Documentum.RefreshAclFascicolo:\n{0}", ex.ToString()); logger.Debug(errorMessage); throw new ApplicationException(errorMessage); } }
/// <summary> /// Rimozione di un fascicolo in un DCTM /// </summary> /// <param name="fascicolo"></param> /// <returns></returns> public bool DeleteProject(Fascicolo fascicolo) { bool retValue = false; try { // Rimozione oggetto fascicolo in DCTM DeleteProfile deleteProfile = new DeleteProfile(); deleteProfile.IsDeepDeleteFolders = true; deleteProfile.IsDeepDeleteChildrenInFolders = true; deleteProfile.IsDeepDeleteVdmInFolders = true; OperationOptions opts = new OperationOptions(); opts.DeleteProfile = deleteProfile; // Reperimento identity per il fascicolo ObjectIdentity identity = Dfs4DocsPa.getFascicoloProcedimentaleIdentityById(fascicolo.systemID); // Rimozione del fascicolo IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(UserManager.ImpersonateSuperUser()); objectService.Delete(new ObjectIdentitySet(identity), opts); // Rimozione dell'ACL associata al fascicolo this.DeleteAcl(Dfs4DocsPa.getAclDefinition(fascicolo.systemID, ObjectTypes.FASCICOLO, this.InfoUtente)); retValue = true; logger.Debug(string.Format("Documentum.DeleteFolder: rimosso fascicolo con id {0}", fascicolo.systemID)); } catch (Exception ex) { retValue = false; logger.Debug(string.Format("Errore in Documentum.DeleteProject:\n{0}", ex.ToString())); } return(retValue); }
private bool undoCreateUser(OrgUtente utente) { try { ObjectIdentity userIdentity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.getUserName(utente)); ObjectIdentitySet idSet = new ObjectIdentitySet(userIdentity); IObjectService objSrvc = this.GetObjectServiceInstance(); objSrvc.Delete(idSet, null); return(true); } catch (Exception ex) { //se siamo arrivati qui, significa che siamo già in una condizione di errore //se si verifica un'eccezione qui, siamo nei guai: non riusciamo a fare un clean //in ogni caso è inutile rilanciare l'eccezione: già il chiamante è in gestione di una ecc. logger.Debug(DEBUG_HEADER + "GRAVE: impossibile annullare l'inserimento utente"); return(false); } }
/// <summary> /// Reperimento ACL associate al sottofascicolo /// </summary> /// <param name="folder"></param> /// <returns></returns> protected virtual CustomServices.AclDefinition GetAclDefinitionSottoFascicolo(DocsPaVO.fascicolazione.Folder folder) { // Reperimento ACL del fascicolo di appartenenza e associazione al sottofascicolo CustomServices.AclDefinition aclDefinition = null; if (DocsPaQueryHelper.isFascicoloGenerale(folder.idFascicolo)) { // Determina se il fascicolo in cui si sta inserendo il folder è un fascicolo generale; // in tal caso l'acl da assegnare è la stessa del nodo titolario di appartenenza string idNodoTitolario = DocsPaQueryHelper.getIdNodoTitolario(folder.idFascicolo); aclDefinition = Dfs4DocsPa.getAclDefinition(idNodoTitolario, ObjectTypes.NODO_TITOLARIO, this.InfoUtente); } else { // Nel caso di inserimento di un folder in un fascicolo procedimentale, // l'acl del folder sarà quella del fascicolo di appartenenza aclDefinition = Dfs4DocsPa.getAclDefinition(folder.idFascicolo, ObjectTypes.FASCICOLO, this.InfoUtente); } return(aclDefinition); }
/// <summary> /// Aggiornamento Acl per il documento /// </summary> /// <param name="idProfile"></param> protected virtual CustomServices.AclDefinition UpdateAclDocumento(string idProfile, string docNumber) { bool stamparegistro = DocsPaQueryHelper.isStampaRegistro(docNumber) && !DocsPaQueryHelper.isStampaRegistroRepertorio(docNumber); CustomServices.AclDefinition aclData = null; if (stamparegistro) { aclData = Dfs4DocsPa.getAclDefinition(idProfile, ObjectTypes.DOCUMENTO_STAMPA_REGISTRO, this.InfoUtente); } else { aclData = Dfs4DocsPa.getAclDefinition(idProfile, ObjectTypes.DOCUMENTO, this.InfoUtente); } // istanziamo ACLservice in modalità super-user per poter comunque creare una acl di sistema // nota: questo non sarebbe strettamente necessario (si potrebbe usare una user-acl, di tipo public) // ma si ritiene che non sia bello avere le acl di proprietà degli utenti creatori del documento CustomServices.IAclService aclSvcSuper = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser()); // Aggiornamento ACL aclSvcSuper.ClearAndGrant(aclData, idProfile); return(aclData); }