Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public static string Generate(string userName)
        {
            try
            {
                string token = string.Empty;

                string serviceUrl = DctmConfigurations.GetDocumentumTokenFactoryServiceUrl();

                if (string.IsNullOrEmpty(serviceUrl))
                {
                    throw new ApplicationException("Chiave di configurazione 'DocumentumTokenFactoryServiceUrl' non definita");
                }

                using (Custom.TicketFactory tokenFactory = new Custom.TicketFactory(serviceUrl))
                {
                    // Utilizzo del servizio web per la creazione del token di autenticazione per l'utente richiesto.
                    // NB: é necessario fornire le credenziali dell'utente superamministratore e il nome del repository.
                    token = tokenFactory.getTicket(DctmConfigurations.GetDocumentumSuperUser(),
                                                   DctmConfigurations.GetDocumentumSuperUserPwd(),
                                                   userName,
                                                   DctmConfigurations.GetRepositoryName());
                }

                return(token);
            }
            catch (Exception ex)
            {
                string message = string.Format("Errore nella generazione del DM_TOKEN per l'autenticazione dell'utente '{0}' in documentum", userName);
                logger.Error(message, ex);

                throw new ApplicationException(message, ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reperimento formato file documentum
        /// </summary>
        /// <param name="queryService"></param>
        /// <param name="mimeType"></param>
        /// <returns></returns>
        public static string getDctmFileFormat(IQueryService queryService, string fileExtension)
        {
            string fileFormat = string.Empty;

            PassthroughQuery passthroughQuery = new PassthroughQuery();

            passthroughQuery.QueryString  = string.Format("SELECT name FROM dm_format WHERE dos_extension = '{0}'", replaceInvalidFileExtension(fileExtension).ToLower());
            passthroughQuery.Repositories = new List <string>();
            passthroughQuery.Repositories.Add(DctmConfigurations.GetRepositoryName());

            QueryExecution queryExecution = new QueryExecution();

            queryExecution.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY;
            queryExecution.MaxResultCount    = 1;

            QueryResult queryResult = queryService.Execute(passthroughQuery, queryExecution, null);

            if (queryResult.DataPackage.DataObjects != null &&
                queryResult.DataPackage.DataObjects.Count > 0)
            {
                DataObject dataObj = queryResult.DataPackage.DataObjects[0];

                fileFormat = ((StringProperty)dataObj.Properties.Properties[0]).Value;
            }

            return(fileFormat);
        }
Ejemplo n.º 3
0
        public static string getDctmObjectId(IQueryService querySvc, Qualification qualification)
        {
            string result = string.Empty;

            PassthroughQuery passthroughQuery = new PassthroughQuery();

            passthroughQuery.QueryString  = "SELECT r_object_id  FROM " + qualification.GetValueAsString();
            passthroughQuery.Repositories = new List <string>();
            passthroughQuery.Repositories.Add(DctmConfigurations.GetRepositoryName());

            QueryExecution queryExecution = new QueryExecution();

            queryExecution.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY;
            queryExecution.MaxResultCount    = 1;

            QueryResult queryResult = querySvc.Execute(passthroughQuery, queryExecution, null);

            if (queryResult.DataPackage.DataObjects != null && queryResult.DataPackage.DataObjects.Count > 0)
            {
                DataObject dataObj = queryResult.DataPackage.DataObjects[0];
                result = ((ObjectId)dataObj.Identity.Value).Id;
            }

            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Costruttore di ObjecyIdentity[Qualification]
        /// </summary>
        /// <param name="qual"></param>
        /// <returns></returns>
        public static ObjectIdentity createObjectIdentityByQualification(Qualification qual)
        {
            ObjectIdentity objectIdentity = new ObjectIdentity(qual, DctmConfigurations.GetRepositoryName());

            objectIdentity.ValueType          = ObjectIdentityType.QUALIFICATION;
            objectIdentity.valueTypeSpecified = true;
            return(objectIdentity);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static ObjectIdentity createObjectIdentityByPath(ObjectPath path)
        {
            ObjectIdentity objectIdentity = new ObjectIdentity(path, DctmConfigurations.GetRepositoryName());

            objectIdentity.ValueType          = ObjectIdentityType.OBJECT_PATH;
            objectIdentity.valueTypeSpecified = true;
            return(objectIdentity);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectId"></param>
        /// <returns></returns>
        public static ObjectIdentity createObjectIdentityObjId(ObjectId objectId)
        {
            ObjectIdentity objectIdentity = new ObjectIdentity(objectId, DctmConfigurations.GetRepositoryName());

            objectIdentity.ValueType          = ObjectIdentityType.OBJECT_ID;
            objectIdentity.valueTypeSpecified = true;
            return(objectIdentity);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creazione di un nuovo oggetto AclDefinition necessario
        /// per gestire quei casi in cui un oggetto deve essere
        /// visibile a tutti i gruppi di un'amministrazione.
        /// NB: La creazione dell'acl globale deve essere effettuata
        /// all'atto della creazione di una nuova amministrazione
        /// </summary>
        /// <param name="codiceAmministrazione"></param>
        /// <returns></returns>
        public static AclDefinition getAclDefinition(string codiceAmministrazione)
        {
            AclDefinition aclData = new AclDefinition();

            aclData.repository  = DctmConfigurations.GetRepositoryName();
            aclData.name        = getAclName(codiceAmministrazione);
            aclData.description = aclData.name;
            aclData.entries     = new AclEntry[0];
            return(aclData);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Impostazione proprietà oggetto per associazione con un'ACL
 /// </summary>
 /// <param name="propertySet"></param>
 /// <param name="aclDefinition"></param>
 public static void setAclObjectProperties(DataModel.Properties.PropertySet propertySet, AclDefinition aclDefinition)
 {
     propertySet.Set <string>("acl_name", aclDefinition.name);
     if (aclDefinition.domain != null)
     {
         propertySet.Set <string>("acl_domain", aclDefinition.domain);
     }
     else
     {
         // "dm_dbo"
         // NB: sembra che (bug dctm??) non sempre "dm_dbo" viene risolto correttamente
         // nel nome del repository owner. Per questo, utilizziamo il nome del repository
         // configurato con l'istanza docspa, che DEVE coincidere (ma in minuscolo)
         propertySet.Set <string>("acl_domain", DctmConfigurations.GetRepositoryName().ToLowerInvariant());
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Esegue una DQL di tipo UPDATE o DDL (ALTER...)
        /// </summary>
        /// <param name="qrySrvc"></param>
        /// <param name="dql"></param>
        /// <returns></returns>
        public static QueryResult executePassThrough(IQueryService qrySrvc, string dql)
        {
            string           repositoryName = DctmConfigurations.GetRepositoryName();
            PassthroughQuery query          = new PassthroughQuery();

            query.QueryString = dql;
            query.AddRepository(repositoryName);
            QueryExecution queryEx = new QueryExecution();

            queryEx.MaxResultCount     = -1; // Nessun limite di risultati restituiti
            queryEx.MaxResultPerSource = -1;
            queryEx.CacheStrategyType  = CacheStrategyType.NO_CACHE_STRATEGY;
            OperationOptions operationOptions = null;

            return(qrySrvc.Execute(query, queryEx, operationOptions));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Creazione di un nuovo oggetto AclDefinition
        /// associato ad un oggetto DocsPa in DCTM
        /// </summary>
        /// <param name="codiceAmministrazione"></param>
        /// <param name="idDocsPa"></param>
        /// <param name="objectType"></param>
        /// <remarks>
        /// Restituisce solo la parte di "intestazione", non le entries
        /// </remarks>
        /// <returns></returns>
        public static AclDefinition getAclDefinition(string codiceAmministrazione, string idDocsPa, string objectType)
        {
            AclDefinition aclData = new AclDefinition();

            aclData.repository  = DctmConfigurations.GetRepositoryName();
            aclData.name        = getAclName(codiceAmministrazione, idDocsPa, objectType);
            aclData.description = aclData.name;

            const int MAX_ACL_DESCRIPTION = 128;

            if (aclData.description.Length > MAX_ACL_DESCRIPTION)
            {
                aclData.description = aclData.description.Substring(0, MAX_ACL_DESCRIPTION);
            }

            aclData.entries = new AclEntry[0];
            return(aclData);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creazione di un oggetto Service di documentum, a partire da un token di autenticazione utente
        /// </summary>
        /// <param name="authenticationToken">Token di autenticazione utente</param>
        /// <param name="serviceModule"></param>
        /// <returns></returns>
        private static T GetServiceInstance <T>(string authenticationToken, string serviceModule)
        {
            IServiceContext context = DctmServiceContextHelper.GetCurrent();

            //ContentTransferProfile contentTransferProfile = new ContentTransferProfile();
            //contentTransferProfile.TransferMode = ContentTransferMode.BASE64;
            //OperationOptions streamOptions = new OperationOptions();
            //ContentProfile contentProfile = streamOptions.ContentProfile;
            //contentProfile.FormatFilter = FormatFilter.ANY;
            //contentProfile.formatFilterSpecified = true;
            //context.SetProfile(contentProfile);

            // Reperimento oggetto identity dal token di autenticazione
            context.AddIdentity(DctmRepositoryIdentityHelper.GetIdentity(authenticationToken));

            // Reperimento url del servizio
            string serviceUrl = DctmConfigurations.GetDocumentumServerUrl();

            return(ServiceFactory.Instance.GetRemoteService <T>(context, serviceModule, serviceUrl));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Restituisce il numero dei gruppi di un utente documentum.
        /// </summary>
        public static int getDctmCountGroupsByUserId(IQueryService querySvc, string userId)
        {
            int result = 0;

            PassthroughQuery passthroughQuery = new PassthroughQuery();

            passthroughQuery.QueryString = string.Format("SELECT group_name FROM dm_group WHERE any users_names IN ( SELECT user_name FROM dm_user WHERE user_os_name = '{0}')", userId);

            passthroughQuery.Repositories = new List <string>();
            passthroughQuery.Repositories.Add(DctmConfigurations.GetRepositoryName());

            QueryExecution queryExecution = new QueryExecution();

            queryExecution.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY;

            QueryResult queryResult = querySvc.Execute(passthroughQuery, queryExecution, null);

            if (queryResult.DataPackage.DataObjects != null && queryResult.DataPackage.DataObjects.Count > 0)
            {
                result = queryResult.DataPackage.DataObjects.Count;
            }

            return(result);
        }