Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 protected IQueryService GetQueryServiceInstance()
 {
     if (this._queryServiceInstance == null)
     {
         this._queryServiceInstance = DctmServiceFactory.GetServiceInstance <IQueryService>(this.InfoUtente.dst);
     }
     return(this._queryServiceInstance);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Reperimento istanza IObjectService
 /// </summary>
 /// <returns></returns>
 protected IObjectService GetObjectServiceInstance()
 {
     if (this._objectServiceInstance == null)
     {
         this._objectServiceInstance = DctmServiceFactory.GetServiceInstance <IObjectService>(this.InfoUtente.dst);
     }
     return(this._objectServiceInstance);
 }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 protected IQueryService GetQueryServiceInstance()
 {
     if (this._queryServiceInstance == null)
     {
         this._queryServiceInstance = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser());
     }
     return(this._queryServiceInstance);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Reperimento istanza servizio
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="asSuperUser">
        /// Se true, si collega con le credenziali da superamministratore
        /// </param>
        /// <returns></returns>
        protected virtual T GetServiceInstance <T>(bool asSuperUser)
        {
            string dst = string.Empty;

            if (asSuperUser)
            {
                dst = UserManager.ImpersonateSuperUser();
            }
            else
            {
                dst = this.InfoUtente.dst;
            }

            return(DctmServiceFactory.GetServiceInstance <T>(dst));
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <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);
        }
Ejemplo n.º 8
0
        /// <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);
        }
Ejemplo n.º 9
0
        /// <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);
        }
Ejemplo n.º 10
0
        /// <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);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Conta il numero di gruppi di appartenenza per un utente DCTM
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public int CountGroupsByUser(string userId)
        {
            IQueryService queryServices = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser());

            return(Dfs4DocsPa.countGroupsByUserId(userId, queryServices));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Verifica dell'esistenza del gruppo in DCTM
        /// </summary>
        /// <param name="groupName"></param>
        /// <returns></returns>
        public bool ContainsGroup(string groupName)
        {
            IQueryService queryServices = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser());

            return(Dfs4DocsPa.containsGroup(groupName, queryServices));
        }
Ejemplo n.º 13
0
        /////// <summary>
        /////// Reperimento di tutti gli utenti dell'amministrazione
        /////// </summary>
        /////// <param name="infoUtente"></param>
        /////// <param name="amministrazione"></param>
        /////// <returns></returns>
        ////private static string[] GetUtenti(InfoAmministrazione amm)
        ////{
        ////    List<string> list = new List<string>();

        ////    using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider())
        ////    {
        ////        string commandText = string.Format("SELECT user_id FROM PEOPLE WHERE id_amm = {0}", amm.IDAmm);

        ////        using (System.Data.IDataReader reader = dbProvider.ExecuteReader(commandText))
        ////        {
        ////            while (reader.Read())
        ////            {
        ////                list.Add(DocsPaUtils.Data.DataReaderHelper.GetValue<string>(reader, "user_id", false));
        ////            }
        ////        }
        ////    }

        ////    return list.ToArray();
        ////}

        /// <summary>
        /// Cancellazione di un'amministrazione nel documentale.
        /// NB: L'operazione di rimozione deve essere effettuata con le credenziali
        /// dell'utente superuser
        /// </summary>
        /// <param name="info"></param>
        /// <param name="ruoliAmministrazione">
        /// Ruoli docspa da rimuovere in documentum
        /// </param>
        /// <returns></returns>
        public EsitoOperazione Delete(InfoAmministrazione info, string[] ruoliAmministrazione)
        {
            logger.Debug(string.Format("Documentum.DeleteAmministrazione: inizio rimozione amministrazione. Codice: '{0}'", info.Codice));

            EsitoOperazione retValue = new EsitoOperazione();

            try
            {
                ObjectIdentitySet identitySet = new ObjectIdentitySet();

                // Reperimento degli oggetti Identity relativi a tutti i gruppi e gli utenti dell'amministrazione
                IQueryService queryService = DctmServiceFactory.GetServiceInstance <IQueryService>(this.InfoUtente.dst);
                string[]      users        = Dfs4DocsPa.getUsersSystemGroup(info.Codice, queryService);

                // Cancellazione di tutti gli utenti legati al cabinet / amministrazione
                foreach (string userId in users)
                {
                    string normalizedUserId = TypeUtente.NormalizeUserName(userId);

                    // Reperimento oggetto identity per ogni utente
                    identitySet.AddIdentity(Dfs4DocsPa.getUserIdentityByName(normalizedUserId));

                    // Cancellazione dell'home cabinet per ogni 'utente
                    identitySet.AddIdentity(Dfs4DocsPa.getUserHomeFolderIdentity(normalizedUserId));

                    logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione utente '{0}'", normalizedUserId));
                }

                //foreach (string userId in GetUtenti(info))
                //{
                //    string normalizedUserId = TypeUtente.NormalizeUserName(userId);

                //    ObjectIdentity id = Dfs4DocsPa.getUserIdentityByName(normalizedUserId, queryService);

                //    if (id != null)
                //    {
                //        identitySet.AddIdentity(id);

                //        // Cancellazione dell'home cabinet per ogni 'utente
                //        identitySet.AddIdentity(Dfs4DocsPa.getUserHomeFolderIdentity(normalizedUserId));
                //    }
                //}

                // Cancellazione del ruolo di sistema dell'amministrazione
                ObjectIdentity identity = Dfs4DocsPa.getSystemGroupIdentity(info.Codice, queryService);

                if (identity != null)
                {
                    identitySet.AddIdentity(identity);
                }

                // Cancellazione del ruolo di sistema degli amministratori dell'amministrazione
                identity = Dfs4DocsPa.getAmmSystemGroupIdentity(info.Codice, queryService);

                if (identity != null)
                {
                    identitySet.AddIdentity(identity);
                }

                // Cancellazione di tutti gli gruppi legati al cabinet / amministrazione
                foreach (string docspaGroupName in ruoliAmministrazione)
                {
                    string normalizedGroupName = TypeGruppo.NormalizeGroupName(docspaGroupName);

                    ObjectIdentity groupIdentity = Dfs4DocsPa.getGroupIdentityByName(normalizedGroupName, queryService);

                    if (groupIdentity != null)
                    {
                        identitySet.AddIdentity(groupIdentity);

                        logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione ruolo '{0}'", normalizedGroupName));
                    }
                }

                // Reperimento oggetto Identity relativamente al cabinet da rimuovere
                identitySet.AddIdentity(Dfs4DocsPa.getCabinetIdentity(info.Codice));

                OperationOptions opts = new OperationOptions();
                opts.DeleteProfile = this.CreateDeleteProfile();

                IObjectService objectService = this.GetObjectServiceInstance();
                objectService.Delete(identitySet, opts);

                logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione amministrazione. Codice: '{0}'", info.Codice));

                // Cancellazione di tutte le ACL create per gli oggetti dell'amministrazione
                this.DeleteAcl(info);
                logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione ACL amministrazione. Codice: '{0}'", info.Codice));
            }
            catch (Exception ex)
            {
                logger.Debug(string.Format("Errore in Documentum.DeleteAmministrazione:\n{0}", ex.ToString()));

                retValue.Codice      = -1;
                retValue.Descrizione = string.Format("Errore nella rimozione del cabinet {0} in Documentum", info.Codice);
            }

            return(retValue);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Ricerca fulltext nell'oggetto document
        ///
        /// nb: da fare anche ricerca allegati
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public ArrayList FullTextSearch(ref FullTextSearchContext context)
        {
            ArrayList result = new ArrayList();

            try
            {
                List <string> fullTextResult = null;

                if (context.SearchResultList != null && context.SearchResultList.Length > 0)
                {
                    // Ricerca già effettuata, reperimento dall'oggetto di contesto
                    // dei risultati precedenti evitando così una dispendiosa
                    // chiamata al sistema documentale
                    fullTextResult = new List <string>(context.SearchResultList);
                }
                else
                {
                    StructuredQuery strQuery = new StructuredQuery();

                    strQuery.AddRepository(DctmConfigurations.GetRepositoryName());
                    strQuery.ObjectType = ObjectTypes.DOCUMENTO;

                    strQuery.IsDatabaseSearch     = false;
                    strQuery.IsIncludeAllVersions = false;
                    strQuery.IsIncludeHidden      = false;

                    // Inserisce nella ricerca il solo cabinet dell'amministrazione
                    RepositoryScope repositoryScope = new RepositoryScope();
                    repositoryScope.RepositoryName = DctmConfigurations.GetRepositoryName();
                    repositoryScope.LocationPath   = DocsPaAdminCabinet.getRootAmministrazione(this.InfoUtente);
                    repositoryScope.IsDescend      = true;
                    strQuery.Scopes.Add(repositoryScope);

                    ExpressionSet set = new ExpressionSet();
                    set.AddExpression(new FullTextExpression(context.TextToSearch));
                    strQuery.RootExpressionSet = set;

                    // Query execution
                    int            startIndex = (context.RequestedPageNumber * PAGE_SIZE) - PAGE_SIZE;
                    int            maxResults = this.GetMaxRowCount();
                    QueryExecution queryExec  = new QueryExecution(startIndex, maxResults, maxResults);

                    ISearchService searchService = DctmServiceFactory.GetServiceInstance <ISearchService>(this.InfoUtente.dst);
                    QueryResult    queryResult   = searchService.Execute(strQuery, queryExec, null);

                    QueryStatus          queryStatus   = queryResult.QueryStatus;
                    RepositoryStatusInfo repStatusInfo = queryResult.QueryStatus.RepositoryStatusInfos[0];

                    if (repStatusInfo.Status == Status.FAILURE)
                    {
                        throw new ApplicationException("QueryResult: Status.FAILURE");
                    }

                    fullTextResult = new List <string>();

                    foreach (DataObject dataObject in queryResult.DataObjects)
                    {
                        // Reperimento docnumber
                        string docNumber = dataObject.Properties.Get(TypeDocumento.DOC_NUMBER).GetValueAsString();

                        if (!fullTextResult.Contains(docNumber)) // Eliminazione dei risultati duplicati
                        {
                            fullTextResult.Add(docNumber);
                        }
                    }

                    context.SearchResultList = fullTextResult.ToArray();
                    context.TotalPageNumber  = (fullTextResult.Count / PAGE_SIZE);
                    context.TotalRecordCount = fullTextResult.Count;
                }

                // Paginazione dei risultati
                if (fullTextResult != null && fullTextResult.Count > 0)
                {
                    int startIndex = (context.RequestedPageNumber * PAGE_SIZE) - PAGE_SIZE;
                    int count      = PAGE_SIZE;
                    if (fullTextResult.Count < count)
                    {
                        count = fullTextResult.Count;
                    }
                    List <string> pageContent = fullTextResult.GetRange(startIndex, count);
                    result = this.GetDocuments(pageContent.ToArray(), InfoUtente);
                }
            }
            catch (Exception ex)
            {
                result.Clear();
                logger.Debug(string.Format("Errore in Documentum.FullTextSearch:\n{0}", ex.ToString()));
            }

            return(result);
        }
Ejemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idSottofascicolo"></param>
        /// <returns></returns>
        public bool ContainsSottofascicolo(string idSottofascicolo)
        {
            IQueryService queryService = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser());

            return(Dfs4DocsPa.containsSottofascicolo(idSottofascicolo, queryService));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Verifica dell'esistenza in dctm di un nodo di titolario
        /// </summary>
        /// <param name="idNodoTitolario"></param>
        /// <returns></returns>
        public bool ContainsNodoTitolario(string idNodoTitolario)
        {
            IQueryService queryService = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser());

            return(Dfs4DocsPa.containsNodoTitolario(idNodoTitolario, queryService));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Verifica dell'esistenza di un titolario attivo in amministrazione
        /// </summary>
        /// <param name="codiceAmministrazione"></param>
        /// <returns></returns>
        public bool ContainsTitolarioAttivo(string codiceAmministrazione)
        {
            IQueryService queryService = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser());

            return(Dfs4DocsPa.containsTitolarioAttivo(codiceAmministrazione, queryService));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Handler dell'evento di avvenuta trasmissione di un documento / fascicolo
        /// </summary>
        /// <param name="trasmissione"></param>
        /// <param name="infoSecurity">
        /// Oggetto contenente i metadati relativi alla tipologia di ACL
        /// impostata nella trasmissione di un documento / fascicolo
        /// </param>
        public void TrasmissioneCompletataEventHandler(DocsPaVO.trasmissione.Trasmissione trasmissione, DocsPaVO.trasmissione.infoSecurity[] infoSecurityList)
        {
            // In caso di trasmissione con cessione diritti,
            // viene modificata l'ownership del documento / fascicolo trasmesso
            // se il documento era di proprietà del cedente
            if (trasmissione.cessione != null && trasmissione.cessione.docCeduto)
            {
                // imposta l'Ownership solo se è stato impostato il nuovo utente che diventerà proprietario del doc/fas.
                // Questo avviene quando si stanno cedendo i diritti di proprietà (P).
                // Se si stanno cedendo i diritti acquisiti (A o T o F) questo blocco viene saltato.
                if (trasmissione.cessione.idPeopleNewPropr != null && trasmissione.cessione.idPeopleNewPropr != "")
                {
                    IQueryService queryService = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser());

                    // Reperimento nome utente e ruolo cui viene impostata l'ownership del documento
                    string ownerUser = DocsPaObjectTypes.TypeUtente.NormalizeUserName(DocsPaQueryHelper.getCodiceUtente(trasmissione.cessione.idPeopleNewPropr));

                    if (trasmissione.tipoOggetto == DocsPaVO.trasmissione.TipoOggetto.DOCUMENTO)
                    {
                        string ownerRole = DocsPaObjectTypes.TypeGruppo.NormalizeGroupName(DocsPaQueryHelper.getCodiceRuoloFromIdGroups(trasmissione.cessione.idRuoloNewPropr));

                        Dfs4DocsPa.setOwnershipDocumento(trasmissione.infoDocumento.idProfile, ownerUser, ownerRole, queryService);
                    }
                    else if (trasmissione.tipoOggetto == DocsPaVO.trasmissione.TipoOggetto.FASCICOLO)
                    {
                        Dfs4DocsPa.setOwnershipFascicolo(trasmissione.infoFascicolo.idFascicolo, ownerUser, queryService);
                    }
                }
            }

            CustomServices.AclDefinition aclData = null;

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

                // Aggiornamento ACL in DCTM, con le credenziali di superuser
                CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser());
                aclService.ClearAndGrant(aclData, trasmissione.infoDocumento.idProfile);
            }
            else if (trasmissione.tipoOggetto == DocsPaVO.trasmissione.TipoOggetto.FASCICOLO)
            {
                // Reperimento della lista delle ACL aggiornata nella tabella security di docspa
                aclData = Dfs4DocsPa.getAclDefinition(trasmissione.infoFascicolo.idFascicolo, DocsPaObjectTypes.ObjectTypes.FASCICOLO, this.InfoUtente);

                // Aggiornamento ACL in DCTM, con le credenziali di superuser
                CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser());
                aclService.ClearAndGrant(aclData, trasmissione.infoFascicolo.idFascicolo);

                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)
                    {
                        // 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);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Verifica dell'esistenza dell'utente in DCTM
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool ContainsUser(string userId)
        {
            IQueryService queryServices = DctmServiceFactory.GetServiceInstance <IQueryService>(UserManager.ImpersonateSuperUser());

            return(Dfs4DocsPa.containsUser(userId, queryServices));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Rimozione di un documento da un folder
        /// </summary>
        /// <param name="idProfile"></param>
        /// <param name="folder"></param>
        /// <returns></returns>
        public bool RemoveDocumentFromFolder(string idProfile, DocsPaVO.fascicolazione.Folder folder)
        {
            bool retValue = false;

            // Reperimento docNumber da idProfile
            logger.Debug("Reperimento docNumber da idProfile");
            string docNumber = DocsPaQueryHelper.getDocNumber(idProfile);

            bool isStampaRegistro = DocsPaQueryHelper.isStampaRegistroRepertorio(docNumber);

            try
            {
                logger.Debug("getDocumentoIdentityByDocNumber");
                ObjectIdentity documentIdentity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(docNumber);

                if (isStampaRegistro)
                {
                    documentIdentity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(docNumber);
                }

                ObjectIdentity folderIdentity = null;

                // Verifica se l'id è relativo ad un fascicolo o a un sottofascicolo
                logger.Debug("Verifica se l'id è relativo ad un fascicolo o a un sottofascicolo");
                if (!DocsPaQueryHelper.isSottofascicolo(folder.systemID))
                {
                    folderIdentity = Dfs4DocsPa.getFascicoloIdentityBySystemId(folder.idFascicolo);
                }
                else
                {
                    folderIdentity = DctmServices.Dfs4DocsPa.getSottofascicoloIdentityById(folder.systemID);
                }

                logger.Debug("createRemoveParentFolder");
                ReferenceRelationship removeRelationship = DctmServices.DfsHelper.createRemoveParentFolder(folderIdentity);

                logger.Debug("updatedDoc.Relationships");
                DataObject updatedDoc = new DataObject(documentIdentity);
                updatedDoc.Relationships.Add(removeRelationship);

                DataPackage dp = new DataPackage(updatedDoc);

                logger.Debug("update");
                IObjectService objSrvc = DctmServiceFactory.GetServiceInstance <IObjectService>(UserManager.ImpersonateSuperUser());
                DataPackage    retDp   = objSrvc.Update(dp, null);

                retValue = (retDp.DataObjects.Count > 0);

                if (retValue)
                {
                    logger.Debug(string.Format("Documentum.RemoveDocumentFromFolder: rimosso documento con docnumber {0} dal sottofascicolo con id {0}", idProfile, folder.systemID));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug(string.Format("Errore in Documentum.RemoveDocumentFromFolder:\n{0}", ex.ToString()));
            }

            return(retValue);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Rimozione di un documento dal fascicolo (in generale, da tutti i folder presenti nel fascicolo)
        /// </summary>
        /// <param name="idProfile"></param>
        /// <param name="folder"></param>
        /// <returns></returns>
        public bool RemoveDocumentFromProject(string idProfile, DocsPaVO.fascicolazione.Folder folder)
        {
            logger.Debug(string.Format("RemoveDocumentFromProject - IdProfile: {0} - IdFolder: {1} - IdFascicolo: {2}", idProfile, folder.systemID, folder.idFascicolo));

            // 1. recuperare tutti link del documento
            // 2. identificare quelli da rimuovere (tutti quelli sotto il folder in input)
            // 3. aggiungere eventualmente il link a documenti non classificati
            //    (se non c'è neanche più un link residuo)

            bool           retValue = false;
            IObjectService objSrvc  = null;

            // Reperimento docNumber da idProfile
            string docNumber = DocsPaQueryHelper.getDocNumber(idProfile);

            bool isStampaRegistro = DocsPaQueryHelper.isStampaRegistroRepertorio(docNumber);

            try
            {
                string repositoryName = DctmConfigurations.GetRepositoryName();
                //objSrvc = this.GetObjectServiceInstance();
                objSrvc = DctmServiceFactory.GetServiceInstance <IObjectService>(UserManager.ImpersonateSuperUser());
                List <Relationship> removeRelationships = new List <Relationship>();

                // 1. recuperare tutti link del documento:
                ObjectIdentity documentIdentity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(docNumber);
                if (isStampaRegistro)
                {
                    documentIdentity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(docNumber);
                }

                logger.Debug("RemoveDocumentFromProject: 1.recuperare tutti link del documento");

                List <string> filters = new List <string>();
                filters.Add("r_object_id");
                DataObject documentData = DfsHelper.getAllPropsAndFolders(objSrvc, documentIdentity, filters, true);

                // 2. identificare quelli da rimuovere (tutti quelli sotto il folder in input):
                if (documentData.Relationships != null && documentData.Relationships.Count > 0)
                {
                    logger.Debug("RemoveDocumentFromProject:  2. identificare quelli da rimuovere (tutti quelli sotto il folder in input)");

                    // 2a. recuperiamo la root del nodo associato a Folder:
                    ObjectIdentity folderIdentity = Dfs4DocsPa.getFascicoloIdentityBySystemId(folder.idFascicolo);

                    if (folderIdentity.ValueType == ObjectIdentityType.QUALIFICATION)
                    {
                        logger.Debug(((Qualification)folderIdentity.Value).GetValueAsString());
                    }

                    filters = new List <string>();
                    filters.Add("r_folder_path");
                    DataObject folderData = DfsHelper.getAllPropsAndFolders(objSrvc, folderIdentity, filters, false);
                    Property   p          = folderData.Properties.Get("r_folder_path");
                    if (p == null)
                    {
                        throw new Exception("Impossibile leggere r_folder_path");
                    }
                    string rootPath = p.GetValueAsString();

                    logger.Debug(string.Format("RemoveDocumentFromProject: RootPath: {0}", rootPath));

                    foreach (ReferenceRelationship r in documentData.Relationships)
                    {
                        // 2b. recuperiamo il path del folder in esame
                        // qui contiamo sul fatto che gli objectIdentity dei folder a cui è linkato vengano istanziati
                        // come OBJECT_ID
                        string targetDctmId = ((ObjectId)r.Target.Value).Id;

                        logger.Error(string.Format("LOG-DEBUG: RemoveDocumentFromProject: targetDctmId: {0}", targetDctmId));

                        ObjectIdentity targetIdentity = new ObjectIdentity(new ObjectId(targetDctmId), repositoryName);
                        DataObject     targetData     = DfsHelper.getAllPropsAndFolders(objSrvc, targetIdentity, filters, false);

                        Property prop = targetData.Properties.Properties.Find(e => e.Name == "r_folder_path");

                        if (prop != null)
                        {
                            string targetPath = targetData.Properties.Get("r_folder_path").GetValueAsString();

                            logger.Debug(string.Format("RemoveDocumentFromProject: targetPath: {0}", targetPath));

                            //se il target è sotto la root allora è da rimuovere
                            if (targetPath.StartsWith(rootPath))
                            {
                                removeRelationships.Add(DfsHelper.createRemoveParentFolder(targetIdentity));
                            }
                        }
                    }
                }

                // 3. committare il tutto
                DataObject updatedDoc = new DataObject(documentIdentity);
                updatedDoc.Relationships = removeRelationships;

                DataPackage dp    = new DataPackage(updatedDoc);
                DataPackage retDp = objSrvc.Update(dp, null);

                logger.Debug("RemoveDocumentFromProject: 3. committare il tutto");

                if (retDp.DataObjects.Count > 0)
                {
                    retValue = true;

                    logger.Debug(string.Format("Documentum.RemoveDocumentFromProject: rimosso documento con docnumber {0} dal fascicolo con id {0}", idProfile, folder.systemID));
                }
            }
            catch (Exception e)
            {
                retValue = false;

                logger.Debug(string.Format("Errore in Documentum.RemoveDocumentFromProject:\n{0}", e.ToString()));
            }

            return(retValue);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Inserimento di un documento in un folder
        /// </summary>
        /// <param name="idProfile"></param>
        /// <param name="idFolder"></param>
        /// <returns></returns>
        public bool AddDocumentInFolder(string idProfile, string idFolder)
        {
            logger.Info("BEGIN");
            bool retValue = false;

            // Reperimento idfolder per il record di tipo "C" in docspa (root folder)
            idFolder = DocsPaQueryHelper.getIdFolderCType(idFolder);

            // Reperimento docNumber da idProfile
            string docNumber = DocsPaQueryHelper.getDocNumber(idProfile);

            //bool stampaRegistro = DocsPaQueryHelper.isStampaRegistro(docNumber);
            bool stampaRegistro = DocsPaQueryHelper.isStampaRegistroRepertorio(docNumber);

            try
            {
                IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(UserManager.ImpersonateSuperUser());

                // 1. recuperare il documento con tutti i link a folder attuali

                ObjectIdentity documentIdentity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(docNumber);

                if (stampaRegistro)
                {
                    documentIdentity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(docNumber);
                }

                // 2. Creare il nuovo link al folder di classificazione
                ObjectIdentity folderIdentity = null;

                // Verifica se l'idFolder si riferisce ad un fascicolo o a un sottofascicolo
                if (!DocsPaQueryHelper.isSottofascicolo(idFolder))
                {
                    // Reperimento id del fascicolo dal folder (record tipo "C")
                    string tipoFascicolo;
                    string idFascicolo = DocsPaQueryHelper.getIdFascicoloFromFolder(idFolder, out tipoFascicolo);

                    folderIdentity = Dfs4DocsPa.getFascicoloIdentityBySystemId(idFascicolo);

                    //Effettuo un refresh dei permessi sul fascicolo per allineare le ACL con DOCUMENTUM
                    //Fascicolo fascicolo = DocsPaQueryHelper.getFascicolo(idFascicolo, this.InfoUtente);
                    //if (fascicolo != null)
                    //  RefreshAclFascicolo(fascicolo);
                }
                else
                {
                    folderIdentity = Dfs4DocsPa.getSottofascicoloIdentityById(idFolder);
                }

                ReferenceRelationship addRelationship = DfsHelper.createParentFolderRelationship(folderIdentity);
                //la aggiungeremo alla lista degli update nell'ultimo passo

                // 3. salvare
                DataObject updatedDoc = new DataObject(documentIdentity);
                updatedDoc.Relationships.Add(addRelationship);

                // 4. Allineamento ACL documento:
                //  per coerenza è necessario che, una volta che il documento
                //  viene inserito in un fascicolo, questo diventi visibile anche
                //  a tutti gli utenti che hanno la visibilità solo sul fascicolo e
                //  non sul documento
                this.UpdateAclDocumento(idProfile, docNumber);

                DataPackage dataPackage = new DataPackage(updatedDoc);
                dataPackage = objectService.Update(dataPackage, null);

                retValue = (dataPackage.DataObjects.Count > 0);

                if (retValue)
                {
                    logger.Debug(string.Format("Documentum.AddDocumentInFolder: inserito il documento con docnumber {0} nel folder con id {1}", idProfile, idFolder));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug(string.Format("Errore in Documentum.AddDocumentInFolder:\n{0}", ex.ToString()));
            }
            logger.Info("END");
            return(retValue);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// verifica che il server DCTM risponda correttamente, effettuando un controllo sulle credenziali dell'amministratore
        /// </summary>
        /// <returns></returns>
        public virtual bool Checkconnection()
        {
            bool   retValue = false;
            string userAdm  = DctmConfigurations.GetDocumentumSuperUser();

            //loginResult = UserLogin.LoginResult.APPLICATION_ERROR;

            try
            {
                RepositoryIdentity identity = DctmServices.DctmRepositoryIdentityHelper.GetIdentity(
                    DctmConfigurations.GetRepositoryName(),
                    userAdm,
                    DctmConfigurations.GetDocumentumSuperUserPwd(),
                    "");

                string token = DctmServices.DctmRepositoryIdentityHelper.CreateAuthenticationToken(identity);

                IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(token);

                Qualification qual = new Qualification("dm_docbaseid_map enable(RETURN_TOP 1)");

                ObjectIdentity objectIdentity = new ObjectIdentity(qual, DctmConfigurations.GetRepositoryName());
                objectIdentity.ValueType          = ObjectIdentityType.QUALIFICATION;
                objectIdentity.valueTypeSpecified = true;

                DataPackage dataPackage = objectService.Get(new ObjectIdentitySet(objectIdentity), null);

                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.Error(string.Format("Credenziali utente DTCM non valide: '{0}'", userAdm + " " + exAuth.Message));
             *          }
             */
            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.Error(string.Format("Errore nel tentativo di contattare i servizi DCTM: '{0}'", userAdm + " " + exServiceInvocation.Message));
            }

            /*
             *          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.Error(string.Format("Errore nel tentativo di contattare i servizi DTCM: '{0}'", userAdm + " " + exService.Message));
             *          }
             */
            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.Error(string.Format("Error durante il controllo checkpage utente : '{0}'", userAdm + " errore: " + ex.Message));
            }

            return(retValue);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Reperimento dell'utente creatore di un fascicolo in DCTM
        /// </summary>
        /// <param name="idFascicolo"></param>
        /// <param name="ownerRole"></param>
        /// <returns></returns>
        protected virtual void GetOwnershipFascicolo(string idFascicolo, out string ownerUser)
        {
            IQueryService queryService = DctmServiceFactory.GetServiceInstance <IQueryService>(this.InfoUtente.dst);

            Dfs4DocsPa.getOwnershipFascicolo(idFascicolo, out ownerUser, queryService);
        }