public CswNbtResourceCollection GetCollection(string metadataname) { CswNbtAPIGenericRequest Req = new CswNbtAPIGenericRequest(metadataname, string.Empty); CswNbtResourceCollection Ret = new CswNbtResourceCollection(); Req.PropertyFilters = _Context.Request.QueryString; var SvcDriver = new CswWebSvcDriver <CswNbtResourceCollection, CswNbtAPIGenericRequest>( CswWebSvcResourceInitializer: new CswWebSvcResourceInitializerNbt(_Context, null), ReturnObj: Ret, WebSvcMethodPtr: CswNbtWebServiceREAD.GetCollection, ParamObj: Req ); SvcDriver.run(); WebOperationContext ctx = WebOperationContext.Current; ctx.OutgoingResponse.StatusCode = Ret.Status; if (ctx.OutgoingResponse.StatusCode != HttpStatusCode.OK) { Ret = null; } return(Ret); }
public CswNbtResourceCollection Search(string searchtype, string query) { CswNbtApiSearchRequest Req = new CswNbtApiSearchRequest(query, searchtype); CswNbtResourceCollection Ret = new CswNbtResourceCollection(); //Look for optional params Req.NodeType = _Context.Request.Params["nodetype"] ?? string.Empty; var SvcDriver = new CswWebSvcDriver <CswNbtResourceCollection, CswNbtApiSearchRequest>( CswWebSvcResourceInitializer: new CswWebSvcResourceInitializerNbt(_Context, null), ReturnObj: Ret, WebSvcMethodPtr: CswNbtWebServiceApiSearch.Search, ParamObj: Req ); SvcDriver.run(); WebOperationContext ctx = WebOperationContext.Current; ctx.OutgoingResponse.StatusCode = Ret.Status; if (ctx.OutgoingResponse.StatusCode != HttpStatusCode.OK) { Ret = null; } return(Ret); }
public void TestCollectionGET() { const string RoleName = "CISPro_Admin"; const string TestUsername1 = "MyRestUser1"; const int TestPageSize1 = 15; const string TestLanguage1 = "da"; CswNbtObjClassUser testUser1 = _createTestUser(TestUsername1, RoleName, TestPageSize1, TestLanguage1); const string TestUsername2 = "MyRestUser2"; const int TestPageSize2 = 25; const string TestLanguage2 = "es"; CswNbtObjClassUser testUser2 = _createTestUser(TestUsername2, RoleName, TestPageSize2, TestLanguage2); CswNbtResourceCollection resourceCollection = new CswNbtResourceCollection(); CswNbtAPIGenericRequest request = new CswNbtAPIGenericRequest("User", string.Empty); string error = string.Empty; try { CswNbtWebServiceREAD.GetCollection(TestData.CswNbtResources, resourceCollection, request); } catch (Exception ex) { error = ex.Message; } Assert.IsEmpty(error, "GETing a collection failed with exception: " + error); bool Found1 = false; bool Found2 = false; foreach (CswNbtResource resource in resourceCollection.getEntities()) { if (resource.NodeId == testUser1.NodeId) { Found1 = true; } else if (resource.NodeId == testUser2.NodeId) { Found2 = true; } } Assert.IsTrue(Found1, "GETing Resource did not contain the first test user when it should have."); Assert.IsTrue(Found2, "GETing Resource did not contain the second test user when it should have."); }
public void GetCollection(CswNbtResourceCollection Return, CswNbtAPIGenericRequest GenericRequest) { if (hasPermission(GenericRequest, Return)) { try { CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(GenericRequest.MetaDataName); if (null != NodeType) { CswNbtView GetNodeTypeView = new CswNbtView(_CswNbtResources); GetNodeTypeView.AddViewRelationship(NodeType, false); ICswNbtTree tree = _CswNbtResources.Trees.getTreeFromView(GetNodeTypeView, true, false, false); for (int i = 0; i < tree.getChildNodeCount(); i++) { tree.goToNthChild(i); CswNbtNodeKey nodeKey = tree.getNodeKeyForCurrentPosition(); CswPrimaryKey nodeId = tree.getNodeIdForCurrentPosition(); CswNbtMetaDataObjectClass objectClass = _CswNbtResources.MetaData.getObjectClass(nodeKey.ObjectClassId); CswNbtMetaDataPropertySet propSet = objectClass.getPropertySet(); string propSetStr = string.Empty; if (null != propSet) { propSetStr = propSet.Name; } string nodeName = tree.getNodeNameForCurrentPosition(); Return.Add(nodeName, nodeId, NodeType.NodeTypeName, objectClass.ObjectClassName, propSetStr, BuildURI(NodeType.NodeTypeName, nodeKey.NodeId.PrimaryKey)); tree.goToParentNode(); } } else { Return.Status = HttpStatusCode.NotFound; } } catch (Exception) { Return.Status = HttpStatusCode.InternalServerError; } } }
public void Search(CswNbtResourceCollection Return, CswNbtApiSearchRequest SearchRequest) { try { int filter_nt_id = Int32.MinValue; if (false == String.IsNullOrEmpty(SearchRequest.NodeType)) { filter_nt_id = _CswNbtResources.MetaData.getNodeType(SearchRequest.NodeType).NodeTypeId; } CswNbtWebServiceSearch searchService = new CswNbtWebServiceSearch(_CswNbtResources, null); CswNbtSearch search = searchService.getSearch(SearchRequest.Query, SearchRequest.SearchType, filter_nt_id, Int32.MinValue, Int32.MinValue); ICswNbtTree results = search.Results(); for (int i = 0; i < results.getChildNodeCount(); i++) { results.goToNthChild(i); CswNbtNodeKey NodeKey = results.getNodeKeyForCurrentPosition(); string Name = results.getNodeNameForCurrentPosition(); CswNbtMetaDataNodeType nt = _CswNbtResources.MetaData.getNodeType(NodeKey.NodeTypeId); CswNbtMetaDataObjectClass oc = nt.getObjectClass(); CswNbtMetaDataPropertySet propSet = oc.getPropertySet(); string PropSetName = string.Empty; if (null != propSet) { PropSetName = propSet.Name; } Return.Add(Name, NodeKey.NodeId, nt.NodeTypeName, oc.ObjectClassName, PropSetName, BuildURI(nt.NodeTypeName, NodeKey.NodeId.PrimaryKey)); results.goToParentNode(); } Return.Status = HttpStatusCode.OK; } catch (Exception) { Return.Status = HttpStatusCode.InternalServerError; } }
public CswNbtExplorerRelatingReturn() { Data = new CswNbtResourceCollection(); }
public static void GetCollection(ICswResources CswResources, CswNbtResourceCollection Return, CswNbtAPIGenericRequest GenericRequest) { CswNbtWebServiceREAD GET = new CswNbtWebServiceREAD((CswNbtResources)CswResources); GET.GetCollection(Return, GenericRequest); }
public static void Search(ICswResources CswResources, CswNbtResourceCollection Return, CswNbtApiSearchRequest SearchRequest) { CswNbtWebServiceApiSearch SEARCH = new CswNbtWebServiceApiSearch((CswNbtResources)CswResources); SEARCH.Search(Return, SearchRequest); }