Esempio n. 1
0
        /// <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);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// Modifica dei metadati di un ruolo
        /// </summary>
        /// <param name="ruolo"></param>
        /// <returns></returns>
        public EsitoOperazione ModificaRuolo(OrgRuolo ruolo)
        {
            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 + "ModificaRuolo: 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 + "ModificaRuolo: campo CODICE supera la lunghezza massima (32)";
                ret.Descrizione = logMsg;
                logger.Debug(logMsg);
                return(ret);
            }

            try
            {
                objSrvc = this.GetObjectServiceInstance();

                ObjectIdentity groupIdentity = Dfs4DocsPa.getGroupIdentityByName(TypeGruppo.GetGroupName(ruolo));

                // non è possibile cambiare il nome di un gruppo
                //List<string> filters = new List<string>();
                //filters.Add("group_name");
                //DataObject oldData = DfsHelper.getAllPropsAndFolders(objSrvc, groupIdentity, filters, false);
                //Property oldName = oldData.Properties.Get("group_name");
                //if (oldName == null)
                //{
                //    ret.Codice = -1;
                //    logMsg = ERR_HEADER + "ModificaRuolo: impossibile leggere il vecchio nome del gruppo";
                //    ret.Descrizione = logMsg;
                //    logger.Debug(logMsg);
                //    return ret;
                //}
                //if (!oldName.GetValueAsString().Equals(ruolo.Codice, StringComparison.OrdinalIgnoreCase))
                //{
                //    ret.Codice = -1;
                //    logMsg = ERR_HEADER + "ModificaRuolo: non è possibile modificare il nome del gruppo";
                //    ret.Descrizione = logMsg;
                //    logger.Debug(logMsg);
                //    return ret;
                //}

                DataObject dataObject = new DataObject(groupIdentity, ObjectTypes.GRUPPO);
                dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getGroupProperties(ruolo, true));

                DataPackage dataPackage = new DataPackage(dataObject);
                dataPackage = objSrvc.Update(dataPackage, null);

                if (dataPackage.DataObjects.Count > 0)
                {
                    ret.Codice      = 0;
                    ret.Descrizione = string.Empty;

                    logger.Debug(DEBUG_HEADER + "ModificaRuolo completata con SUCCESSO");

                    return(ret);
                }
                else
                {
                    throw new ApplicationException();
                }
            }
            catch (Exception ex)
            {
                string st = ex.ToString();
                logger.Debug(DEBUG_HEADER + "ModificaRuolo FALLITA, Exception=" + st);
                ret.Codice      = -1;
                ret.Descrizione = ERR_HEADER + "ModificaRuolo";
                return(ret);
            }
        }