Esempio n. 1
0
        /// <summary>
        /// Creazione oggetto PassthroughQuery
        /// </summary>
        /// <param name="queryText"></param>
        /// <returns></returns>
        protected virtual PassthroughQuery CreatePassthroughQuery(string queryText)
        {
            PassthroughQuery query = new PassthroughQuery();

            query.QueryString = queryText;
            query.Repositories.Add(DctmConfigurations.GetRepositoryName());
            return(query);
        }
Esempio n. 2
0
        /// <summary>
        /// Rimozione delle ACL per tutti gli oggetti dell'amministrazione
        /// </summary>
        /// <param name="info"></param>
        protected virtual void DeleteAcl(InfoAmministrazione info)
        {
            // Creazione servizio ACL (con credenziali da superamministratore)
            CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser());

            // Rimozione di tutte le ACL di tutti gli oggetti dell'amministrazione
            // NB: Il parametro force + per ogni evenienza, ma sarebbe da evitarne l'uso: può creare inconsistenze nel DB di Documentum
            int affectedRows = aclService.DeleteAll(DctmConfigurations.GetRepositoryName(), AclHelper.getAclName(info.Codice), true);

            logger.Debug(string.Format("Rimozione ACL per tutti gli oggetti dell'amministrazione. Rimossi {0} oggetti", affectedRows.ToString()));
        }
Esempio n. 3
0
        /// <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);
            }
        }
Esempio n. 4
0
        /// <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);
            }
        }
Esempio n. 5
0
 private void undoCreateHomeFolder(OrgUtente utente)
 {
     try
     {
         IObjectService objSrvc      = this.GetObjectServiceInstance();
         string         homePath     = "/" + TypeUtente.getHomeFolderName(utente.UserId);
         ObjectIdentity homeIdentity =
             new ObjectIdentity(new ObjectPath(homePath),
                                DctmConfigurations.GetRepositoryName());
         ObjectIdentitySet idSet = new ObjectIdentitySet(homeIdentity);
         objSrvc.Delete(idSet, null);
     }
     catch (Exception ex)
     {
         //se siamo arrivati qui, significa che siamo già in una condizione di errore
         //non è così grave: rimane un folder, che non pregiudica un eventuale nuovo tentativo dei definire l'utente
         //in ogni caso è inutile rilanciare l'eccezione: già il chiamante è in gestione di una ecc.
         logger.Debug(DEBUG_HEADER + "Impossibile annullare l'inserimento dell'home folder: " + ex.ToString());
     }
 }
Esempio n. 6
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. 7
0
        ///// <summary>
        ///// Reperimento dipendenze per l'oggetto richiesto
        ///// </summary>
        ///// <param name="fieldValue"></param>
        ///// <param name="tableName"></param>
        ///// <param name="fieldName"></param>
        ///// <param name="repeating"></param>
        ///// <returns></returns>
        //protected ObjectIdentity[] GetObjectDependencies(string fieldValue, string tableName, string fieldName, bool repeating)
        //{
        //    List<ObjectIdentity> list = new List<ObjectIdentity>();

        //    PassthroughQuery query = new PassthroughQuery();
        //    string dql = null;
        //    if (repeating)
        //        dql = "SELECT r_object_id FROM {0} WHERE ANY upper({1}) = upper('{2}')";
        //    else
        //        dql = "SELECT r_object_id FROM {0} WHERE upper({1}) = upper('{2}')";

        //    query.QueryString = string.Format(dql, tableName, fieldName,
        //                                        fieldValue.Replace("'", "''"));

        //    query.AddRepository(DctmConfigurations.GetRepositoryName());

        //    QueryExecution queryEx = new QueryExecution();
        //    queryEx.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY;
        //    OperationOptions operationOptions = null;

        //    QueryResult queryResult = this.GetQueryServiceInstance().Execute(query, queryEx, operationOptions);

        //    if (queryResult.DataObjects.Count > 0)
        //    {
        //        ObjectId objId = (ObjectId)queryResult.DataObjects[0].Identity.Value;

        //        list.Add(DfsHelper.createObjectIdentityObjId(objId));
        //    }

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

        protected void checkReference(string fieldValue, string tableName, string fieldName, bool repeating)
        {
            IQueryService qrySrvc        = null;
            string        repositoryName = DctmConfigurations.GetRepositoryName();

            qrySrvc = this.GetQueryServiceInstance();

            PassthroughQuery query = new PassthroughQuery();
            string           dql   = null;

            if (repeating)
            {
                dql = "SELECT r_object_id FROM {0} WHERE ANY lower({1}) = lower('{2}')";
            }
            else
            {
                dql = "SELECT r_object_id FROM {0} WHERE lower({1}) = lower('{2}')";
            }

            query.QueryString = string.Format(dql, tableName, fieldName,
                                              fieldValue.Replace("'", "''"));
            query.AddRepository(repositoryName);
            QueryExecution queryEx = new QueryExecution();

            queryEx.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY;
            OperationOptions operationOptions = null;
            QueryResult      queryResult      = qrySrvc.Execute(query, queryEx, operationOptions);

            // il risultato dovrebbe essere vuoto
            if (queryResult.DataObjects.Count > 0)
            {
                ObjectId objId = (ObjectId)queryResult.DataObjects[0].Identity.Value;

                throw new Exception(string.Format("Non è possibile cancellare {0}, in quanto referenziato l'oggetto con id={1}", fieldValue, objId.Id));
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Creazione di un nuovo fascicolo in DCTM
        /// </summary>
        /// <remarks>
        ///
        /// PreCondizioni:
        ///     Il fascicolo è stato inserito correttamente in DocsPa
        ///     ed è stato generato un'identificativo univoco
        ///
        /// PostCondizioni:
        ///     Creato un oggetto in Documentum corrispondente all'oggetto
        ///     fascicolo di DocsPa. L'oggetto avrà i metadati del fascicolo
        ///     per la sola consultazione in documentum.
        ///
        /// </remarks>
        /// <param name="classifica"></param>
        /// <param name="fascicolo"></param>
        /// <param name="ruolo"></param>
        /// <param name="enableUfficioReferente"></param>
        /// <returns></returns>
        public bool CreateProject(Classificazione classifica, Fascicolo fascicolo, Ruolo ruolo, bool enableUfficioReferente, out ResultCreazioneFascicolo result)
        {
            logger.Info("BEGIN");
            bool retValue = false;

            result = ResultCreazioneFascicolo.GENERIC_ERROR;

            CustomServices.AclDefinition aclFascicolo = null;

            try
            {
                //fascicolo.systemID  viene SEMPRE valorizzato da ETDOCS; se così non è --> ERRORE
                if (string.IsNullOrEmpty(fascicolo.systemID))
                {
                    logger.Debug("Errore passaggio dati da ETDOCS.");
                }
                else
                {
                    // Reperimento dell'objectidentity relativo al nodo titolario in cui andrà inserito il fascicolo
                    ObjectIdentity nodoTitolarioIdentity = Dfs4DocsPa.getNodoTitolarioIdentity(fascicolo.idClassificazione);

                    // Reperimento properties del fascicolo procedimentale
                    PropertySet props = new PropertySet();
                    props.Properties.AddRange(Dfs4DocsPa.getFascicoloProcedimentaleProperties(fascicolo));

                    // Creazione delle ACL per il fascicolo
                    aclFascicolo = this.CreateAclFascicolo(fascicolo, ruolo);

                    // Associazione delle ACL al fascicolo da creare
                    AclHelper.setAclObjectProperties(props, aclFascicolo);

                    ObjectIdentity identity   = new ObjectIdentity(DctmConfigurations.GetRepositoryName());
                    DataObject     dataObject = new DataObject(identity, ObjectTypes.FASCICOLO_PROCEDIMENTALE);
                    dataObject.Properties = props;
                    dataObject.Relationships.Add(DfsHelper.createParentFolderRelationship(nodoTitolarioIdentity));

                    DataPackage dataPackage = new DataPackage(dataObject);

                    IObjectService objectService = this.GetServiceInstance <IObjectService>(false);
                    dataPackage = objectService.Create(dataPackage, null);

                    retValue = (dataPackage.DataObjects.Count == 1);

                    if (retValue)
                    {
                        result = ResultCreazioneFascicolo.OK;

                        logger.Debug(string.Format("Documentum.CreateProject: creato fascicolo con id {0}", fascicolo.systemID));
                    }
                }
            }
            catch (Exception ex)
            {
                retValue = false;
                result   = ResultCreazioneFascicolo.GENERIC_ERROR;

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

                if (aclFascicolo != null)
                {
                    // Rimozione ACL fascicolo in caso di errore
                    this.DeleteAcl(aclFascicolo);
                }
            }
            logger.Info("END");
            return(retValue);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        /// <summary>
        /// Attivazione di un titolario
        /// </summary>
        /// <param name="titolario"></param>
        /// <returns></returns>
        public bool AttivaTitolario(OrgTitolario titolario)
        {
            bool retValue = true;

            try
            {
                // Verifica della presenza di un titolario attivo
                string repositoryName = DctmConfigurations.GetRepositoryName();

                IObjectService objSrvc = this.GetObjectServiceInstance();

                // Verifica se in documentum è presente un titolario attivo
                bool existTitolarioAttivo = (Dfs4DocsPa.containsTitolarioAttivo(titolario.CodiceAmministrazione, this.GetQueryServiceInstance()));

                DataObject dataObjectTitolarioAttivo = null;

                if (existTitolarioAttivo)
                {
                    // Reperimento oggetto identity per il titolario attivo
                    ObjectIdentity identity = Dfs4DocsPa.getTitolarioAttivoIdentity(titolario.CodiceAmministrazione);

                    // Reperimento oggetto DataObject relativo al titolario attivo (se presente)
                    List <string> filters = new List <string>();
                    filters.Add(TypeTitolario.ID_DOCSPA);
                    dataObjectTitolarioAttivo = DfsHelper.getAllPropsAndFolders(objSrvc, identity, filters, false);
                    string idDocsPa = dataObjectTitolarioAttivo.Properties.Get(TypeTitolario.ID_DOCSPA).GetValueAsString();

                    // Reperimento del titolario appena chiuso in docspa, cui corrisponde il titolario da chiudere in documentum
                    OrgTitolario titolarioChiuso = DocsPaQueryHelper.getTitolario(idDocsPa);

                    dataObjectTitolarioAttivo            = new DataObject();
                    dataObjectTitolarioAttivo.Identity   = Dfs4DocsPa.getTitolarioIdentity(titolarioChiuso.ID);
                    dataObjectTitolarioAttivo.Type       = ObjectTypes.TITOLARIO;
                    dataObjectTitolarioAttivo.Properties = new PropertySet();
                    dataObjectTitolarioAttivo.Properties.Properties.AddRange(Dfs4DocsPa.getTitolarioProperties(titolarioChiuso));
                }

                // Reperimento identity titolario in definizione
                ObjectIdentity identityTitolarioInDef   = Dfs4DocsPa.getTitolarioIdentity(titolario.ID);
                DataObject     dataObjectTitolarioInDef = new DataObject();
                dataObjectTitolarioInDef.Identity   = identityTitolarioInDef;
                dataObjectTitolarioInDef.Type       = ObjectTypes.TITOLARIO;
                dataObjectTitolarioInDef.Properties = new PropertySet();
                dataObjectTitolarioInDef.Properties.Properties.AddRange(Dfs4DocsPa.getTitolarioProperties(titolario));

                List <DataObject> dataObjectList = new List <DataObject>();

                if (existTitolarioAttivo)
                {
                    dataObjectList.Add(dataObjectTitolarioAttivo);
                }

                dataObjectList.Add(dataObjectTitolarioInDef);

                // Creazione oggetto DataPackage
                DataPackage dataPackage = new DataPackage();
                dataPackage.DataObjects.AddRange(dataObjectList);

                dataPackage = objSrvc.Update(dataPackage, null);

                string objectId = ((ObjectId)dataPackage.DataObjects[0].Identity.Value).Id.ToString();

                retValue = (!string.IsNullOrEmpty(objectId));

                if (retValue)
                {
                    logger.Debug(string.Format("Documentum.AttivaTitolario: attivato titolario con id {0}", titolario.ID));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum.AttivaTitolario: " + ex.ToString());
            }

            return(retValue);
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nodoTitolario"></param>
        /// <param name="refreshAclIfUpdate">
        /// Se true, indica di aggiornare le entries dell'ACL associata al nodo titolario
        /// </param>
        /// <returns></returns>
        public bool SaveNodoTitolario(OrgNodoTitolario nodoTitolario, bool refreshAclIfUpdate)
        {
            bool retValue = false;

            bool aclCreated = false;

            try
            {
                //titolario.ID  viene SEMPRE valorizzato da ETDOCS; se così non è --> ERRORE
                if (string.IsNullOrEmpty(nodoTitolario.ID))
                {
                    retValue = false;

                    logger.Debug("Errore passaggio dati da ETDOCS: ID nodo titolario mancante");
                }
                else
                {
                    IQueryService querySrvc = this.GetQueryServiceInstance();

                    DataObject dataObject = new DataObject();
                    dataObject.Type = ObjectTypes.NODO_TITOLARIO;

                    DataObject dataObjectFascicoloGenerale = null;

                    // Reperimento oggetto identity per il titolario corrente
                    ObjectIdentity nodoTitolarioIdentity = Dfs4DocsPa.getNodoTitolarioIdentity(nodoTitolario.ID);

                    // Verifica esistenza nodo titolario
                    bool insertMode = (!Dfs4DocsPa.containsNodoTitolario(nodoTitolario.ID, querySrvc));

                    IObjectService objSrvc = this.GetObjectServiceInstance();

                    if (insertMode)
                    {
                        // Modalità di inserimento
                        // Creazione oggetto identity per nuovo inserimento
                        dataObject.Identity = new ObjectIdentity(DctmConfigurations.GetRepositoryName());

                        // Determinazione dell'oggetto parent del nodo di titolario da inserire
                        ObjectIdentity parentIdentity = null;

                        if (nodoTitolario.Livello == "1")
                        {
                            // Se nodo di primo livello, deve essere legato alla struttura di titolario
                            parentIdentity = Dfs4DocsPa.getTitolarioIdentity(nodoTitolario.ID_Titolario);
                        }
                        else
                        {
                            // Se nodo figlio di un altro nodo, lo lega al padre
                            parentIdentity = Dfs4DocsPa.getNodoTitolarioIdentity(nodoTitolario.IDParentNodoTitolario);
                        }

                        dataObject.Relationships = new List <Relationship>();
                        dataObject.Relationships.Add(DfsHelper.createParentFolderRelationship(parentIdentity));

                        // Creazione fascicolo generale, figlio nodo del titolario da creare
                        dataObjectFascicoloGenerale          = new DataObject();
                        dataObjectFascicoloGenerale.Type     = ObjectTypes.FASCICOLO_GENERALE;
                        dataObjectFascicoloGenerale.Identity = new ObjectIdentity(DctmConfigurations.GetRepositoryName());

                        // Creazione oggetto relationship
                        dataObjectFascicoloGenerale.Relationships = new List <Relationship>();
                        dataObjectFascicoloGenerale.Relationships.Add(DfsHelper.createParentFolderRelationship(nodoTitolarioIdentity));

                        dataObjectFascicoloGenerale.Properties = new PropertySet();
                        dataObjectFascicoloGenerale.Properties.Properties.AddRange(Dfs4DocsPa.getFascicoloGeneraleProperties(nodoTitolario));
                    }
                    else
                    {
                        // Modalità di aggiornamento

                        // Reperimento oggetto identity per nodo titolario da modificare
                        dataObject.Identity = nodoTitolarioIdentity;
                    }

                    // Impostazione proprietà nodo titolario
                    dataObject.Properties = new PropertySet();
                    dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getNodoTitolarioProperties(nodoTitolario));

                    List <DataObject> dataObjectList = new List <DataObject>();
                    dataObjectList.Add(dataObject);
                    if (dataObjectFascicoloGenerale != null)
                    {
                        // Inserimento DataObject relativo al fascicolo generale
                        dataObjectList.Add(dataObjectFascicoloGenerale);
                    }

                    // Creazione oggetto DataPackage
                    DataPackage dataPackage = new DataPackage();
                    dataPackage.DataObjects.AddRange(dataObjectList);
                    dataPackage.RepositoryName = DctmConfigurations.GetRepositoryName();

                    // Save oggetto nodo titolario in documentum
                    if (insertMode)
                    {
                        // Creazione ACL, comune sia per il nodo titolario che per il fascicolo generale in esso contenuto
                        CustomServices.AclDefinition aclDefinition = this.CreateAclNodoTitolario(nodoTitolario);

                        // ACL del titolario creata
                        aclCreated = true;

                        // Impostazione delle properties relative all'acl per il nodo titolario
                        AclHelper.setAclObjectProperties(dataObject.Properties, aclDefinition);

                        // Impostazione delle properties relative all'acl per il fascicolo generale
                        AclHelper.setAclObjectProperties(dataObjectFascicoloGenerale.Properties, aclDefinition);

                        dataPackage = objSrvc.Create(dataPackage, null);
                    }
                    else
                    {
                        dataPackage = objSrvc.Update(dataPackage, null);

                        if (refreshAclIfUpdate)
                        {
                            // Aggiornamento delle entries dell'acl associata al nodo
                            this.RefreshAclNodoTitolario(nodoTitolario);
                        }
                    }

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

                    if (retValue)
                    {
                        logger.Debug(string.Format("Documentum.SaveNodoTitolario: salvato nodo di titolario con id {0}", nodoTitolario.ID));
                    }
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum.SaveNodoTitolario: " + ex.ToString());

                if (aclCreated)
                {
                    // Se l'ACL è stata creata, viene rimossa
                    this.DeleteAclNodoTitolario(nodoTitolario);
                }
            }

            return(retValue);
        }
Esempio n. 12
0
        /// <summary>
        /// Inserimento o aggiornamento dei metadati generali relativi
        /// all’intera struttura di classificazione dei documenti
        /// </summary>
        /// <param name="titolario"></param>
        /// <returns></returns>
        public bool SaveTitolario(OrgTitolario titolario)
        {
            bool retValue = false;

            try
            {
                //titolario.ID viene SEMPRE valorizzato da ETDOCS; se così non è --> ERRORE
                if (string.IsNullOrEmpty(titolario.ID))
                {
                    logger.Debug("Errore passaggio dati da ETDOCS: ID Titolario mancante");
                }
                else
                {
                    // Reperimento istanza objectservice
                    IObjectService objSrvc = GetObjectServiceInstance();

                    DataObject dataObject = new DataObject();
                    dataObject.Type = ObjectTypes.TITOLARIO;

                    // Reperimento oggetto identity per il titolario corrente
                    ObjectIdentity titolarioIdentity = Dfs4DocsPa.getTitolarioIdentity(titolario.ID);

                    IQueryService querySrvc = this.GetQueryServiceInstance();

                    // Verifica se il titolario è già esistente
                    bool insertMode = (!Dfs4DocsPa.containsTitolario(titolario.ID, querySrvc));

                    if (insertMode)
                    {
                        // Creazione oggetto identity per nuovo inserimento
                        dataObject.Identity = new ObjectIdentity(DctmConfigurations.GetRepositoryName());

                        // Modalità di in inserimento, creazione oggetto Identity parent e oggetto relationship
                        ObjectIdentity parentIdentity = DfsHelper.createObjectIdentityByPath(DocsPaAdminCabinet.getRootTitolario(titolario.CodiceAmministrazione));

                        dataObject.Relationships = new List <Relationship>();
                        dataObject.Relationships.Add(DfsHelper.createParentFolderRelationship(parentIdentity));
                    }
                    else
                    {
                        // Reperimento oggetto identity per titolario da modificare
                        dataObject.Identity = titolarioIdentity;
                    }

                    // Impostazione proprietà titolario
                    dataObject.Properties = new PropertySet();
                    dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getTitolarioProperties(titolario));

                    DataPackage dataPackage = new DataPackage(dataObject);
                    dataPackage.RepositoryName = DctmConfigurations.GetRepositoryName();

                    // Save oggetto titolario in documentum
                    if (insertMode)
                    {
                        // Reperimento ACL dell'amministrazione da associare al titolario
                        CustomServices.AclDefinition aclDefinition = Dfs4DocsPa.getAclDefinitionAmministrazione(titolario.CodiceAmministrazione);

                        // Impostazione delle properties relative all'acl per il nodo titolario
                        AclHelper.setAclObjectProperties(dataObject.Properties, aclDefinition);

                        dataPackage = objSrvc.Create(dataPackage, null);
                    }
                    else
                    {
                        dataPackage = objSrvc.Update(dataPackage, null);
                    }

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

                    if (retValue)
                    {
                        logger.Debug(string.Format("Documentum.SaveTitolario: salvato titolario con id {0}", titolario.ID));
                    }
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum.SaveTitolario: " + ex.ToString());
            }

            return(retValue);
        }
Esempio n. 13
0
        /// <summary>
        /// Login al sistema documentale
        /// </summary>
        /// <param name="utente"></param>
        /// <param name="loginResult"></param>
        /// <returns></returns>
        public bool LoginUser(DocsPaVO.utente.UserLogin userLogin, out DocsPaVO.utente.Utente utente, out DocsPaVO.utente.UserLogin.LoginResult loginResult)
        {
            bool retValue = false;

            utente      = null;
            loginResult = UserLogin.LoginResult.UNKNOWN_USER;

            try
            {
                string userName     = TypeUtente.NormalizeUserName(userLogin.UserName);
                string userPassword = string.Empty;
                // Modifica 21-12-2012, recupero ticket documentum se login tramite token.
                //if (DocsPaServices.DocsPaQueryHelper.isUtenteDominioOrLdap(userLogin))
                if (userLogin.SSOLogin)
                {
                    // L'utente è agganciato in amministrazione ad un dominio,
                    // pertanto viene richiamato il servizio documentum per la generazione del ticket di autenticazione
                    userPassword = DctmTokenFactoryHelper.Generate(userName);
                }
                else
                {
                    userPassword = userLogin.Password;
                }

                RepositoryIdentity identity = DctmServices.DctmRepositoryIdentityHelper.GetIdentity(
                    DctmConfigurations.GetRepositoryName(),
                    userName,
                    userPassword,
                    userLogin.Dominio);

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

                // Verifica validità credenziali
                if (this.VerifyCredentials(userName, token, out loginResult))
                {
                    utente      = new Utente();
                    utente.dst  = token;
                    loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;
                }

                //per LDAP oppure per SHIBBOLETH
                if (userLogin.SSOLogin)
                {
                    utente.dst = UserManager.ImpersonateSuperUser();
                }
                //FINE per LDAP oppure per SHIBBOLETH


                retValue = (loginResult == DocsPaVO.utente.UserLogin.LoginResult.OK);
            }
            catch (Exception ex)
            {
                retValue    = false;
                utente      = null;
                loginResult = UserLogin.LoginResult.UNKNOWN_USER;

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

            return(retValue);
        }
Esempio n. 14
0
        /// <summary>
        /// Impersonate come utente superuser documentum
        /// </summary>
        /// <returns></returns>
        internal static string ImpersonateSuperUser()
        {
            // Per creare il folder per contenere i documenti, è necessario fare l'impersonate come utente amministratore (superuser in dctm)
            RepositoryIdentity superIdentity = DctmRepositoryIdentityHelper.GetIdentity(DctmConfigurations.GetRepositoryName(),
                                                                                        DctmConfigurations.GetDocumentumSuperUser(),
                                                                                        DctmConfigurations.GetDocumentumSuperUserPwd(),
                                                                                        string.Empty);

            return(DctmRepositoryIdentityHelper.CreateAuthenticationToken(superIdentity));
        }
Esempio n. 15
0
        /// <summary>
        /// Inserimento di una nuova amministrazione nel documentale
        ///
        /// Problema delle DFS:
        /// come da documentazione, inizialmente gli inserimenti venivano effettuati
        /// tutti in un'unica operazione. Il problema è che le cartelle DNC e StampaRegistro
        /// venivano create nel folder HomeCabinet (oltre che normalmente nel cabinet dell'amministrazione).
        /// Ciò sicuramente è dovuto al fatto di inserire tutto in un'unica richiesta.
        /// Per ovviare a questo inconveniente, si è scelto di inserire le cartelle in 2 fasi:
        /// 1. inserimento cabinet 2. inserimento cartelle sottostanti
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public EsitoOperazione Insert(InfoAmministrazione info)
        {
            EsitoOperazione retValue = new EsitoOperazione();

            // ACL per l'amministrazione
            CustomServices.AclDefinition aclDefinition = null;

            // Identity del cabinet dell'amministrazione
            ObjectIdentity cabinetIdentity = null;

            // Identity del gruppo di sistema associato all'amministrazione
            ObjectIdentity groupIdentity = null;

            // Identity del gruppo di sistema che contiene gli amministratori dell'amministrazione
            ObjectIdentity adminGroupIdentity = null;

            try
            {
                // Creazione del cabinet per l'amministrazione
                ObjectPath cabinetPath = this.GetCabinetPath(info);
                logger.Debug("cabinetPath " + cabinetPath);
                cabinetIdentity = this.GetObjectServiceInstance().CreatePath(cabinetPath, DctmConfigurations.GetRepositoryName());

                // Creazione documenti
                ObjectIdentity documentiIdentity   = new ObjectIdentity(DctmConfigurations.GetRepositoryName());
                DataObject     dataObjectDocumenti = new DataObject(documentiIdentity, "dm_folder");
                dataObjectDocumenti.Properties.Set <string>("object_name", DocsPaAdminCabinet.FOLDER_DOCUMENTI);
                dataObjectDocumenti.Relationships.Add(new ReferenceRelationship(cabinetIdentity, Relationship.RELATIONSHIP_FOLDER, Relationship.ROLE_PARENT));

                // Creazione folder titolario
                ObjectIdentity titolarioIdentity   = new ObjectIdentity(DctmConfigurations.GetRepositoryName());
                DataObject     dataObjectTitolario = new DataObject(titolarioIdentity, "dm_folder");
                dataObjectTitolario.Properties.Set <string>("object_name", DocsPaAdminCabinet.FOLDER_TITOLARIO);
                dataObjectTitolario.Relationships.Add(new ReferenceRelationship(cabinetIdentity, Relationship.RELATIONSHIP_FOLDER, Relationship.ROLE_PARENT));

                // Creazione del gruppo di sistema associato all'amministrazione
                groupIdentity = new ObjectIdentity(DctmConfigurations.GetRepositoryName());
                DataObject groupData = new DataObject(groupIdentity, ObjectTypes.GRUPPO);
                groupData.Properties.Set <string>("group_name", TypeGruppo.GetGroupNameForAmministrazione(info.Codice));
                groupData.Properties.Set <string>("description", "Gruppo di sistema: tutti gli utenti dell'amministrazione " + info.Codice);
                groupData.Properties.Set <string>("group_class", "group");

                // Creazione del gruppo di sistema che contiene gli amministratori dell'amministrazione
                //adminGroupIdentity = new ObjectIdentity(DctmConfigurations.GetRepositoryName().ToLower());  //<- PERCHE' TO LOWER!? (Vecchio 6.0)
                adminGroupIdentity = new ObjectIdentity(DctmConfigurations.GetRepositoryName());
                DataObject adminGroupData = new DataObject(adminGroupIdentity, ObjectTypes.GRUPPO);
                adminGroupData.Properties.Set <string>("group_name", TypeGruppo.GetGroupNameForSysAdminAmministrazione(info.Codice));
                adminGroupData.Properties.Set <string>("description", "Gruppo di sistema: sysadmin dell'amministrazione " + info.Codice);
                adminGroupData.Properties.Set <string>("group_class", "group");

                DataPackage dataPackage = new DataPackage();
                dataPackage.AddDataObject(dataObjectDocumenti);
                dataPackage.AddDataObject(dataObjectTitolario);
                dataPackage.AddDataObject(groupData);
                dataPackage.AddDataObject(adminGroupData);

                dataPackage = this.GetObjectServiceInstance().Create(dataPackage, null);

                if (dataPackage.DataObjects.Count == 0)
                {
                    throw new ApplicationException("Nessun oggetto creato");
                }
                else
                {
                    dataObjectDocumenti = dataPackage.DataObjects[0];
                    dataObjectTitolario = dataPackage.DataObjects[1];
                    groupIdentity       = dataPackage.DataObjects[2].Identity;
                    adminGroupIdentity  = dataPackage.DataObjects[3].Identity;

                    // Creazione AclDefinition per tutti gli oggetti dell'amministrazione
                    aclDefinition = this.CreateAclAdmin(info);

                    // Associazione dell'ACL appena creata con gli oggetti dell'amministrazione
                    AclHelper.setAclObjectProperties(dataObjectDocumenti.Properties, aclDefinition);
                    AclHelper.setAclObjectProperties(dataObjectTitolario.Properties, aclDefinition);

                    dataPackage = new DataPackage();
                    dataPackage.AddDataObject(dataObjectDocumenti);
                    dataPackage.AddDataObject(dataObjectTitolario);
                    dataPackage = this.GetObjectServiceInstance().Update(dataPackage, null);

                    logger.Debug(string.Format("Documentum.InsertAmministrazione: {0} oggetti creati per nuova amministrazione {1}, CabinetPath {2}", dataPackage.DataObjects.Count.ToString(), info.Codice, cabinetPath.Path));
                }
            }
            catch (Exception ex)
            {
                // In caso di errore, viene annullata la procedura
                // rimuovendo gli oggetti finora inseriti
                if (aclDefinition != null)
                {
                    try
                    {
                        // Rimozione ACL appena inserita
                        this.DeleteAclAdmin(aclDefinition);
                    }
                    catch (Exception exInner)
                    {
                        logger.Debug(string.Format("Documentum.InsertAmministrazione: errore in rimozione acl '{0}'", aclDefinition.name));
                    }
                }

                // Inserimento nell'identityset degli oggetti da rimuovere
                ObjectIdentitySet createdObjects = new ObjectIdentitySet();

                if (cabinetIdentity != null && cabinetIdentity.ValueType == ObjectIdentityType.OBJECT_ID)
                {
                    createdObjects.AddIdentity(cabinetIdentity);
                }

                if (groupIdentity != null && groupIdentity.ValueType == ObjectIdentityType.OBJECT_ID)
                {
                    createdObjects.AddIdentity(groupIdentity);
                }

                if (adminGroupIdentity != null && adminGroupIdentity.ValueType == ObjectIdentityType.OBJECT_ID)
                {
                    createdObjects.AddIdentity(adminGroupIdentity);
                }

                if (createdObjects.Identities.Count > 0)
                {
                    OperationOptions opts = new OperationOptions();
                    opts.DeleteProfile = this.CreateDeleteProfile();

                    try
                    {
                        // Rimozione di tutti gli oggetti creati per l'amministrazione
                        this.GetObjectServiceInstance().Delete(createdObjects, opts);
                    }
                    catch (Exception exInner)
                    {
                        logger.Debug(string.Format("Documentum.InsertAmministrazione: errore in rimozione cabinet amministrazione '{0}'", info.Codice));
                    }
                }

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

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

            return(retValue);
        }
Esempio n. 16
0
        /// <summary>
        /// Modifica dei dati di un utente in amministrazione
        /// </summary>
        /// <param name="utente"></param>
        /// <returns></returns>
        public EsitoOperazione ModificaUtente(OrgUtente utente)
        {
            EsitoOperazione ret            = new EsitoOperazione();
            string          logMsg         = string.Empty;
            IObjectService  objSrvc        = null;
            IQueryService   qrySvc         = null;
            string          repositoryName = DctmConfigurations.GetRepositoryName();
            bool            wasSysAdmin    = false;
            bool            isSysAdmin     = false;
            string          gruppoSysAdm;
            string          codiceAmm;

            // test sui campi obbligatori
            if (string.IsNullOrEmpty(utente.Codice) ||
                string.IsNullOrEmpty(utente.Email) ||
                string.IsNullOrEmpty(utente.IDPeople) ||
                string.IsNullOrEmpty(utente.UserId))
            {
                logMsg          = ERR_HEADER + "ModificaUtente: dati insufficienti";
                ret.Codice      = -1;
                ret.Descrizione = logMsg;
                logger.Debug(logMsg);
                return(ret);
            }

            try
            {
                objSrvc = this.GetObjectServiceInstance();
                qrySvc  = this.GetQueryServiceInstance();

                ObjectIdentity userIdentity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.getUserName(utente));

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

                // dobbiamo capire se prima dell'update era sysAdmin oppure no
                codiceAmm    = DocsPaQueryHelper.getCodiceAmministrazione(utente.IDAmministrazione);
                gruppoSysAdm = TypeGruppo.GetGroupNameForSysAdminAmministrazione(codiceAmm);
                wasSysAdmin  = DfsHelper.isUserMemberOf(TypeUtente.getUserName(utente), gruppoSysAdm, qrySvc);
                isSysAdmin   = (utente.Amministratore != null && utente.Amministratore != "0");

                // verifico se sia stata modificata la password o meno
                //     if (!string.IsNullOrEmpty(utente.Password))
                //     {

                // eliminato controllo su presenza password, gli altri dati dell'utente devono essere modificati
                // anche senza un cambio password (speriamo almeno..) Necessario per replicare stato attivazione rispetto a docspa.
                // il campo password non viene passato se non è valorizzato

                DataObject userData = new DataObject(userIdentity, ObjectTypes.UTENTE);

                // Reperimento properties utente
                userData.Properties.Properties.AddRange(Dfs4DocsPa.getUserProperties(utente));

                DataPackage pkg = new DataPackage(userData);
                pkg = objSrvc.Update(pkg, null);

                if (pkg.DataObjects.Count > 0)
                {
                    // eventuale inserimento nel gruppo dei syadmin
                    if (isSysAdmin && !wasSysAdmin)
                    {
                        DfsHelper.insertUserInGroup(TypeUtente.getUserName(utente), gruppoSysAdm, qrySvc);
                    }
                    else if (wasSysAdmin && !isSysAdmin)
                    {
                        DfsHelper.removeUserFromGroup(TypeUtente.getUserName(utente), gruppoSysAdm, qrySvc);
                    }

                    ret.Codice      = 0;
                    ret.Descrizione = string.Empty;

                    logger.Debug(DEBUG_HEADER + "ModificaUtente completata con SUCCESSO");
                }
                else
                {
                    throw new ApplicationException();
                }

                /**  }
                 * else
                 * {
                 *    ret.Codice = 0;
                 *    ret.Descrizione = string.Empty;
                 *
                 *    logger.Debug(DEBUG_HEADER + "ModificaUtente completata con SUCCESSO");
                 * } */
                return(ret);
            }
            catch (Exception ex)
            {
                String st = ex.ToString();
                logger.Error(DEBUG_HEADER + "ModificaUtente FALLITA, Exception=" + st);
                ret.Codice      = -1;
                ret.Descrizione = ERR_HEADER + "ModificaUtente";
                return(ret);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Inserimento di un nuovo utente in amministrazione
        /// </summary>
        /// <param name="utente"></param>
        /// <returns></returns>
        public EsitoOperazione InserisciUtente(OrgUtente utente)
        {
            EsitoOperazione retValue = new EsitoOperazione();

            string logMsg      = string.Empty;
            bool   userCreated = false;
            bool   pathCreated = false;

            // test sui campi obbligatori
            if (string.IsNullOrEmpty(utente.Codice) ||
                string.IsNullOrEmpty(utente.Email) ||
                string.IsNullOrEmpty(utente.IDPeople) ||
                string.IsNullOrEmpty(utente.UserId))
            {
                retValue.Codice      = -1;
                retValue.Descrizione = ERR_HEADER + "InserisciUtente: dati insufficienti";
                logger.Debug(retValue.Descrizione);
            }
            else
            {
                try
                {
                    IObjectService objSrvc = this.GetObjectServiceInstance();
                    string         repo    = DctmConfigurations.GetRepositoryName();

                    string         homePath            = string.Concat("/", TypeUtente.getHomeFolderName(utente.UserId));
                    ObjectIdentity identityHomeCabinet = objSrvc.CreatePath(new ObjectPath(homePath), repo);
                    pathCreated = true;

                    ObjectIdentity userIdentity = new ObjectIdentity(repo);
                    DataObject     userData     = new DataObject(userIdentity, ObjectTypes.UTENTE);

                    // Reperimento properties utente
                    userData.Properties.Properties.AddRange(Dfs4DocsPa.getUserProperties(utente));
                    userData.Properties.Set <string>("default_folder", homePath);

                    DataPackage dataPackage = new DataPackage(userData);

                    dataPackage = objSrvc.Create(dataPackage, null);

                    if (dataPackage.DataObjects.Count > 0)
                    {
                        userCreated = true;

                        // Impotazione proprietà "is_private = 1", per fare in modo
                        // che il cabinet sia visibile solamente all'utente che l'ha creato
                        // e 'owner_name' con il nome dell'utente
                        DataObject homeCabinetData = new DataObject(identityHomeCabinet, "dm_cabinet");
                        //homeCabinetData.Properties.Set<int>("is_private", 1);  //Vecchio 6.0
                        homeCabinetData.Properties.Set <string>("is_private", "1");
                        homeCabinetData.Properties.Set <string>("owner_name", TypeUtente.getUserName(utente));

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

                        if (dataPackage.DataObjects.Count > 0)
                        {
                            this.inserisciUtenteInAmministrazione(utente, userData);

                            retValue.Codice      = 0;
                            retValue.Descrizione = string.Empty;
                            logger.Debug(DEBUG_HEADER + "InserisciUtente completata con SUCCESSO");
                        }
                        else
                        {
                            throw new ApplicationException();
                        }
                    }
                    else
                    {
                        undoCreateHomeFolder(utente);
                        pathCreated = false;
                        throw new ApplicationException();
                    }
                }
                catch (Exception ex)
                {
                    string errorMessage = string.Format("Errore in {0}: {1}", DEBUG_HEADER, ex.ToString());

                    logger.Debug(errorMessage);
                    retValue.Codice      = -1;
                    retValue.Descrizione = ERR_HEADER + "InserisciUtente";

                    if (pathCreated)
                    {
                        this.undoCreateHomeFolder(utente);
                    }

                    if (userCreated)
                    {
                        this.undoCreateUser(utente);
                    }
                }
            }

            return(retValue);
        }
Esempio n. 18
0
        /// <summary>
        /// Creazione nuovo sottofascicolo
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="ruolo"></param>
        /// <param name="result"></param>
        /// <param name="ruoliSuperiori">
        /// Ruoli superiori cui è impostata la visibilità del sottofascicolo
        /// </param>
        /// <returns></returns>
        public bool CreateFolder(DocsPaVO.fascicolazione.Folder folder, DocsPaVO.utente.Ruolo ruolo, out DocsPaVO.fascicolazione.ResultCreazioneFolder result, out DocsPaVO.utente.Ruolo[] ruoliSuperiori)
        {
            bool retValue = false;

            result         = ResultCreazioneFolder.GENERIC_ERROR;
            ruoliSuperiori = null;

            try
            {
                // Recuperare l'ID del padre del folder: dato che la modalità è diversa se il padre
                // è Fascicolo o Sottofascicolo, è necessario verificare la casistica

                // Caso in cui il parent del sottofascicolo è un sottofascicolo stesso
                Qualification qualSottoFascicoloParent = Dfs4DocsPa.getSottofascicoloQualificationById(folder.idParent);
                string        parentId = DfsHelper.getDctmObjectId(this.GetServiceInstance <IQueryService>(false), qualSottoFascicoloParent);

                if (string.IsNullOrEmpty(parentId))
                {
                    // Caso in cui il parent del sottofascicolo è un fascicolo stesso
                    qualSottoFascicoloParent = Dfs4DocsPa.getFascicoloQualificationById(folder.idFascicolo);
                    parentId = DfsHelper.getDctmObjectId(this.GetServiceInstance <IQueryService>(false), qualSottoFascicoloParent);
                }

                if (!string.IsNullOrEmpty(parentId))
                {
                    ObjectIdentity parentIdentity = new ObjectIdentity(new ObjectId(parentId), DctmConfigurations.GetRepositoryName());

                    ObjectIdentity identity   = new ObjectIdentity(DctmConfigurations.GetRepositoryName());
                    DataObject     dataObject = new DataObject(identity, ObjectTypes.SOTTOFASCICOLO);
                    dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getSottoFascicoloProperties(folder));
                    dataObject.Relationships.Add(DfsHelper.createParentFolderRelationship(parentIdentity));

                    // Reperimento ACL del fascicolo di appartenenza e associazione al sottofascicolo
                    CustomServices.AclDefinition aclDefinition = this.GetAclDefinitionSottoFascicolo(folder);
                    AclHelper.setAclObjectProperties(dataObject.Properties, aclDefinition);

                    DataPackage dataPackage = new DataPackage(dataObject);
                    dataPackage = this.GetServiceInstance <IObjectService>(false).Create(dataPackage, null);

                    retValue = (dataPackage.DataObjects.Count == 1);

                    if (retValue)
                    {
                        result = ResultCreazioneFolder.OK;

                        logger.Debug(string.Format("Documentum.CreateFolder: creato sottofascicolo con id {0}", folder.systemID));
                    }
                }
                else
                {
                    throw new ApplicationException(string.Format("Non è stato possibile reperire l'oggetto parent per il folder con id '{0}'", folder.systemID));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

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

            return(retValue);
        }
Esempio n. 19
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);
        }
Esempio n. 20
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);
        }
Esempio n. 21
0
        /// <summary>
        /// Checkin di un documento in stato checkout
        /// </summary>
        /// <param name="checkOutStatus"></param>
        /// <param name="library"></param>
        /// <returns></returns>
        public bool CheckIn(DocsPaVO.CheckInOut.CheckOutStatus checkOutStatus, byte[] content, string checkInComments)
        {
            bool retValue = false;

            try
            {
                // Creazione di un nuovo DataObject che rappresenta il documento da sbloccare
                DataObject dataObject = new DataObject();
                dataObject.Type = ObjectTypes.DOCUMENTO;

                // Reperimento identity del documento da sbloccare
                if (DocsPaQueryHelper.isStampaRegistro(checkOutStatus.DocumentNumber))
                {
                    dataObject.Identity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(checkOutStatus.DocumentNumber);
                }
                else
                {
                    dataObject.Identity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(checkOutStatus.DocumentNumber);
                }

                List <Property> propertyList = new List <Property>();

                // Impostazione numero versione
                propertyList.Add(new NumberProperty(TypeDocumento.NUMERO_VERSIONE, DocsPaQueryHelper.getDocumentNextVersionId(checkOutStatus.IDDocument)));

                // Rimozione valore proprietà p3_locked_filepath
                propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_LOCAL_FILE_PATH, string.Empty));

                // Rimozione valore proprietà p3_locked_file_machinename
                propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_MACHINE_NAME, string.Empty));

                dataObject.Properties = new PropertySet();
                dataObject.Properties.Properties.AddRange(propertyList);

                // Temporaneo, inserimento contentuto file
                OperationOptions opts = new OperationOptions();

                CheckinProfile checkInProfile = new CheckinProfile();
                checkInProfile.MakeCurrent         = true;
                checkInProfile.DeleteLocalFileHint = true;

                opts.Profiles.Add(checkInProfile);

                // Creazione di un nuovo oggetto BinaryContent
                BinaryContent binaryContent = new BinaryContent();
                binaryContent.Value = content;

                string ext = System.IO.Path.GetExtension(checkOutStatus.DocumentLocation);
                if (ext.StartsWith("."))
                {
                    ext = ext.Substring(1);
                }
                string fileFormat = DfsHelper.getDctmFileFormat(this.GetServiceInstance <IQueryService>(false), ext);

                binaryContent.Format = fileFormat;

                dataObject.Contents.Add(binaryContent);

                DataPackage dataPackage = new DataPackage(dataObject);
                dataPackage.RepositoryName = DctmConfigurations.GetRepositoryName();

                IVersionControlService service = this.GetServiceInstance <IVersionControlService>(false);

                VersionStrategy strategy = VersionStrategy.IMPLIED;
                if (!DocsPaQueryHelper.isDocumentAcquisito(checkOutStatus.IDDocument))
                {
                    strategy = VersionStrategy.SAME_VERSION;
                }

                dataPackage = service.Checkin(dataPackage, strategy, false, null, opts);

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

                if (retValue)
                {
                    logger.Debug(string.Format("Documentum.CheckIn: effettuato il checkin del documento con id {0} e docnumber {1}", checkOutStatus.IDDocument, checkOutStatus.DocumentNumber));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum.CheckIn: " + ex.ToString());
            }

            return(retValue);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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);
            }
        }