private void createTestVirtualDocument() { // create a new DataObject to use as the parent node ObjectIdentity emptyIdentity = new ObjectIdentity(DefaultRepository); DataObject parentDO = new DataObject(emptyIdentity); parentDO.Type = "dm_document"; PropertySet parentProperties = new PropertySet(); parentProperties.Set("object_name", SampleContentManager.testVdmObjectName); parentDO.Properties = parentProperties; // link into a folder ObjectPath objectPath = new ObjectPath(SampleContentManager.sourcePath); ObjectIdentity sampleFolderIdentity = new ObjectIdentity(objectPath, DefaultRepository); ReferenceRelationship sampleFolderRelationship = new ReferenceRelationship(); sampleFolderRelationship.Name = Relationship.RELATIONSHIP_FOLDER; sampleFolderRelationship.Target = sampleFolderIdentity; sampleFolderRelationship.TargetRole = Relationship.ROLE_PARENT; parentDO.Relationships.Add(sampleFolderRelationship); // get id of document to use for first child node ObjectIdentity child0Id = new ObjectIdentity(); child0Id.RepositoryName = DefaultRepository; child0Id.Value = new Qualification(SampleContentManager.gifImageQualString); // get id of document to use for second child node ObjectIdentity child1Id = new ObjectIdentity(); child1Id.RepositoryName = DefaultRepository; child1Id.Value = new Qualification(SampleContentManager.gifImage1QualString); ObjectIdentitySet childNodes = new ObjectIdentitySet(); childNodes.AddIdentity(child0Id); childNodes.AddIdentity(child1Id); virtualDocumentServiceDemo.AddChildNodes(parentDO, childNodes); }
public void ShowObjectIdentitySet() { String repName = "MyRepositoryName"; ObjectIdentitySet objIdSet = new ObjectIdentitySet(); ObjectIdentity[] objectIdentities = new ObjectIdentity[4]; // add some ObjectIdentity instances ObjectId objId = new ObjectId("090007d280075180"); objIdSet.AddIdentity(new ObjectIdentity(objId, repName)); Qualification qualification = new Qualification("dm_document where object_name = 'bl_upwind.gif'"); objIdSet.AddIdentity(new ObjectIdentity(qualification, repName)); ObjectPath objPath = new ObjectPath("/testCabinet/testFolder/testDoc"); objIdSet.AddIdentity(new ObjectIdentity(objPath, repName)); // walk through and see what we have IEnumerator <ObjectIdentity> identityEnumerator = objIdSet.Identities.GetEnumerator(); while (identityEnumerator.MoveNext()) { Console.WriteLine("Object Identity: " + identityEnumerator.Current); } }
public void VersionSampleObjects() { Console.WriteLine("Creating versions of sample data for VersionControlService samples."); ServiceFactory serviceFactory = ServiceFactory.Instance; IVersionControlService versionSvc = serviceFactory.GetRemoteService <IVersionControlService>(serviceDemo.DemoServiceContext); ObjectIdentitySet objIdSet = new ObjectIdentitySet(); ObjectIdentity docObjId = new ObjectIdentity(); docObjId.RepositoryName = serviceDemo.DefaultRepository; docObjId.Value = new ObjectPath(gifImageObjPath); ObjectIdentity doc1ObjId = new ObjectIdentity(); doc1ObjId.RepositoryName = serviceDemo.DefaultRepository; doc1ObjId.Value = new ObjectPath(gifImage1ObjPath); objIdSet.AddIdentity(docObjId); objIdSet.AddIdentity(doc1ObjId); OperationOptions operationOptions = new OperationOptions(); ContentProfile contentProfile = new ContentProfile(FormatFilter.ANY, null, PageFilter.ANY, -1, PageModifierFilter.ANY, null); operationOptions.ContentProfile = contentProfile; DataPackage checkinPackage = versionSvc.Checkout(objIdSet, operationOptions); Console.WriteLine("Checked out sample objects."); for (int i = 0; i <= 1; i++) { DataObject checkinObj = checkinPackage.DataObjects[i]; checkinObj.Contents = null; FileContent newContent = new FileContent(); newContent.LocalPath = gifImageFilePath; newContent.RenditionType = RenditionType.PRIMARY; newContent.Format = "gif"; checkinObj.Contents.Add(newContent); } bool retainLock = false; List <String> labels = new List <String>(); labels.Add("test_version"); versionSvc.Checkin(checkinPackage, VersionStrategy.NEXT_MINOR, retainLock, labels, operationOptions); Console.WriteLine("Checked in sample object with label 'test_version'"); }
/// <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); } }
private void createTestVirtualDocument() { // create a new DataObject to use as the parent node ObjectIdentity emptyIdentity = new ObjectIdentity(DefaultRepository); DataObject parentDO = new DataObject(emptyIdentity); parentDO.Type = "dm_document"; PropertySet parentProperties = new PropertySet(); parentProperties.Set("object_name", SampleContentManager.testVdmObjectName); parentDO.Properties = parentProperties; // link into a folder ObjectPath objectPath = new ObjectPath(SampleContentManager.sourcePath); ObjectIdentity sampleFolderIdentity = new ObjectIdentity(objectPath, DefaultRepository); ReferenceRelationship sampleFolderRelationship = new ReferenceRelationship(); sampleFolderRelationship.Name = Relationship.RELATIONSHIP_FOLDER; sampleFolderRelationship.Target = sampleFolderIdentity; sampleFolderRelationship.TargetRole = Relationship.ROLE_PARENT; parentDO.Relationships.Add(sampleFolderRelationship); // get id of document to use for first child node ObjectIdentity child0Id = new ObjectIdentity(); child0Id.RepositoryName = DefaultRepository; child0Id.Value = new Qualification(SampleContentManager.gifImageQualString); // get id of document to use for second child node ObjectIdentity child1Id = new ObjectIdentity(); child1Id.RepositoryName = DefaultRepository; child1Id.Value = new Qualification(SampleContentManager.gifImage1QualString); ObjectIdentitySet childNodes = new ObjectIdentitySet(); childNodes.AddIdentity(child0Id); childNodes.AddIdentity(child1Id); virtualDocumentServiceDemo.AddChildNodes(parentDO, childNodes); }
public void ShowObjectIdentitySet() { String repName = "MyRepositoryName"; ObjectIdentitySet objIdSet = new ObjectIdentitySet(); ObjectIdentity[] objectIdentities = new ObjectIdentity[4]; // add some ObjectIdentity instances ObjectId objId = new ObjectId("090007d280075180"); objIdSet.AddIdentity(new ObjectIdentity(objId, repName)); Qualification qualification = new Qualification("dm_document where object_name = 'bl_upwind.gif'"); objIdSet.AddIdentity(new ObjectIdentity(qualification, repName)); ObjectPath objPath = new ObjectPath("/testCabinet/testFolder/testDoc"); objIdSet.AddIdentity(new ObjectIdentity(objPath, repName)); // walk through and see what we have IEnumerator<ObjectIdentity> identityEnumerator = objIdSet.Identities.GetEnumerator(); while (identityEnumerator.MoveNext()) { Console.WriteLine("Object Identity: " + identityEnumerator.Current); } }
public void DeleteTestCabinet(String repository) { if (!isDataCleanedUp) { Console.WriteLine("Test cabinet, folders, and sample images will not be deleted because SampleContentManager.isDataCleanedUp = false"); return; } DeleteProfile deleteProfile = new DeleteProfile(); deleteProfile.IsDeepDeleteFolders = true; deleteProfile.IsDeepDeleteChildrenInFolders = true; OperationOptions operationOptions = new OperationOptions(); operationOptions.DeleteProfile = deleteProfile; ObjectPath objectPath = new ObjectPath(testCabinetPath); ObjectIdentity sampleCabinetIdentity = new ObjectIdentity(objectPath, repository); ObjectIdentitySet objIdSet = new ObjectIdentitySet(); objIdSet.AddIdentity(sampleCabinetIdentity); objectService.Delete(objIdSet, operationOptions); Console.WriteLine("Deleted test cabinet " + testCabinetPath + " on " + repository); }
public void DeleteTestCabinet(String repository) { if (!isDataCleanedUp) { Console.WriteLine("Test cabinet, folders, and sample images will not be deleted because SampleContentManager.isDataCleanedUp = false"); return; } DeleteProfile deleteProfile = new DeleteProfile(); deleteProfile.IsDeepDeleteFolders = true; deleteProfile.IsDeepDeleteChildrenInFolders = true; OperationOptions operationOptions = new OperationOptions(); operationOptions.DeleteProfile = deleteProfile; ObjectPath objectPath = new ObjectPath(testCabinetPath); ObjectIdentity sampleCabinetIdentity = new ObjectIdentity(objectPath, repository); ObjectIdentitySet objIdSet = new ObjectIdentitySet(); objIdSet.AddIdentity(sampleCabinetIdentity); objectService.Delete(objIdSet, operationOptions); Console.WriteLine("Deleted test cabinet " + testCabinetPath + " on " + repository); }
/// <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); }
/////// <summary> /////// Reperimento di tutti gli utenti dell'amministrazione /////// </summary> /////// <param name="infoUtente"></param> /////// <param name="amministrazione"></param> /////// <returns></returns> ////private static string[] GetUtenti(InfoAmministrazione amm) ////{ //// List<string> list = new List<string>(); //// using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider()) //// { //// string commandText = string.Format("SELECT user_id FROM PEOPLE WHERE id_amm = {0}", amm.IDAmm); //// using (System.Data.IDataReader reader = dbProvider.ExecuteReader(commandText)) //// { //// while (reader.Read()) //// { //// list.Add(DocsPaUtils.Data.DataReaderHelper.GetValue<string>(reader, "user_id", false)); //// } //// } //// } //// return list.ToArray(); ////} /// <summary> /// Cancellazione di un'amministrazione nel documentale. /// NB: L'operazione di rimozione deve essere effettuata con le credenziali /// dell'utente superuser /// </summary> /// <param name="info"></param> /// <param name="ruoliAmministrazione"> /// Ruoli docspa da rimuovere in documentum /// </param> /// <returns></returns> public EsitoOperazione Delete(InfoAmministrazione info, string[] ruoliAmministrazione) { logger.Debug(string.Format("Documentum.DeleteAmministrazione: inizio rimozione amministrazione. Codice: '{0}'", info.Codice)); EsitoOperazione retValue = new EsitoOperazione(); try { ObjectIdentitySet identitySet = new ObjectIdentitySet(); // Reperimento degli oggetti Identity relativi a tutti i gruppi e gli utenti dell'amministrazione IQueryService queryService = DctmServiceFactory.GetServiceInstance <IQueryService>(this.InfoUtente.dst); string[] users = Dfs4DocsPa.getUsersSystemGroup(info.Codice, queryService); // Cancellazione di tutti gli utenti legati al cabinet / amministrazione foreach (string userId in users) { string normalizedUserId = TypeUtente.NormalizeUserName(userId); // Reperimento oggetto identity per ogni utente identitySet.AddIdentity(Dfs4DocsPa.getUserIdentityByName(normalizedUserId)); // Cancellazione dell'home cabinet per ogni 'utente identitySet.AddIdentity(Dfs4DocsPa.getUserHomeFolderIdentity(normalizedUserId)); logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione utente '{0}'", normalizedUserId)); } //foreach (string userId in GetUtenti(info)) //{ // string normalizedUserId = TypeUtente.NormalizeUserName(userId); // ObjectIdentity id = Dfs4DocsPa.getUserIdentityByName(normalizedUserId, queryService); // if (id != null) // { // identitySet.AddIdentity(id); // // Cancellazione dell'home cabinet per ogni 'utente // identitySet.AddIdentity(Dfs4DocsPa.getUserHomeFolderIdentity(normalizedUserId)); // } //} // Cancellazione del ruolo di sistema dell'amministrazione ObjectIdentity identity = Dfs4DocsPa.getSystemGroupIdentity(info.Codice, queryService); if (identity != null) { identitySet.AddIdentity(identity); } // Cancellazione del ruolo di sistema degli amministratori dell'amministrazione identity = Dfs4DocsPa.getAmmSystemGroupIdentity(info.Codice, queryService); if (identity != null) { identitySet.AddIdentity(identity); } // Cancellazione di tutti gli gruppi legati al cabinet / amministrazione foreach (string docspaGroupName in ruoliAmministrazione) { string normalizedGroupName = TypeGruppo.NormalizeGroupName(docspaGroupName); ObjectIdentity groupIdentity = Dfs4DocsPa.getGroupIdentityByName(normalizedGroupName, queryService); if (groupIdentity != null) { identitySet.AddIdentity(groupIdentity); logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione ruolo '{0}'", normalizedGroupName)); } } // Reperimento oggetto Identity relativamente al cabinet da rimuovere identitySet.AddIdentity(Dfs4DocsPa.getCabinetIdentity(info.Codice)); OperationOptions opts = new OperationOptions(); opts.DeleteProfile = this.CreateDeleteProfile(); IObjectService objectService = this.GetObjectServiceInstance(); objectService.Delete(identitySet, opts); logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione amministrazione. Codice: '{0}'", info.Codice)); // Cancellazione di tutte le ACL create per gli oggetti dell'amministrazione this.DeleteAcl(info); logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione ACL amministrazione. Codice: '{0}'", info.Codice)); } catch (Exception ex) { logger.Debug(string.Format("Errore in Documentum.DeleteAmministrazione:\n{0}", ex.ToString())); retValue.Codice = -1; retValue.Descrizione = string.Format("Errore nella rimozione del cabinet {0} in Documentum", info.Codice); } return(retValue); }
public void VersionSampleObjects() { Console.WriteLine("Creating versions of sample data for VersionControlService samples."); ServiceFactory serviceFactory = ServiceFactory.Instance; IVersionControlService versionSvc = serviceFactory.GetRemoteService<IVersionControlService>(serviceDemo.DemoServiceContext); ObjectIdentitySet objIdSet = new ObjectIdentitySet(); ObjectIdentity docObjId = new ObjectIdentity(); docObjId.RepositoryName = serviceDemo.DefaultRepository; docObjId.Value = new ObjectPath(gifImageObjPath); ObjectIdentity doc1ObjId = new ObjectIdentity(); doc1ObjId.RepositoryName = serviceDemo.DefaultRepository; doc1ObjId.Value = new ObjectPath(gifImage1ObjPath); objIdSet.AddIdentity(docObjId); objIdSet.AddIdentity(doc1ObjId); OperationOptions operationOptions = new OperationOptions(); ContentProfile contentProfile = new ContentProfile(FormatFilter.ANY, null, PageFilter.ANY, -1, PageModifierFilter.ANY, null); operationOptions.ContentProfile = contentProfile; DataPackage checkinPackage = versionSvc.Checkout(objIdSet, operationOptions); Console.WriteLine("Checked out sample objects."); for (int i = 0; i <= 1; i++) { DataObject checkinObj = checkinPackage.DataObjects[i]; checkinObj.Contents = null; FileContent newContent = new FileContent(); newContent.LocalPath = gifImageFilePath; newContent.RenditionType = RenditionType.PRIMARY; newContent.Format = "gif"; checkinObj.Contents.Add(newContent); } bool retainLock = false; List<String> labels = new List<String>(); labels.Add("test_version"); versionSvc.Checkin(checkinPackage, VersionStrategy.NEXT_MINOR, retainLock, labels, operationOptions); Console.WriteLine("Checked in sample object with label 'test_version'"); }