Fix the RDF backend P0 bugs

git-svn-id: svn://10.0.0.236/trunk@4932 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
guha 1998-07-02 22:45:01 +00:00
parent c755e95d1f
commit ee5c33a9bf
10 changed files with 112 additions and 53 deletions

View File

@ -733,9 +733,9 @@ CreateFSUnit (char *nname, PRBool isDirectoryFlag)
if (startsWith("file:///", nname))
{
if ((r = RDF_GetResource(NULL, nname, 0)) == NULL)
if ((r =(RDF_Resource)PL_HashTableLookup(resourceHash, nname)) == NULL)
{
if ((r = RDF_GetResource(NULL, nname, 1)) != NULL)
if ((r = NewRDFResource(nname)) != NULL)
{
setResourceType(r, LFS_RT);
setContainerp(r, isDirectoryFlag);
@ -743,4 +743,4 @@ CreateFSUnit (char *nname, PRBool isDirectoryFlag)
}
}
return(r);
}
}

View File

@ -373,11 +373,11 @@ updateNewHistItem (DBT *key, DBT *data)
HIST_COPY_INT32(&first, (time_t *)((char *)data->data + sizeof(int32)));
HIST_COPY_INT32(&numaccess, (time_t *)((char *)data->data + 2*sizeof(int32)));
if (hostHash) collateOneHist(grdf, gNavCenter->RDF_History,
if (hostHash) collateOneHist(grdf, gNavCenter->RDF_HistoryBySite,
(char*)key->data, /* url */
((char*)data->data + 4*sizeof(int32)), /* title */
last, first, numaccess, 0);
if (ByDateOpened) collateOneHist(grdf, gNavCenter->RDF_History,
if (ByDateOpened) collateOneHist(grdf, gNavCenter->RDF_HistoryByDate,
(char*)key->data, /* url */
((char*)data->data + 4*sizeof(int32)), /* title */
last, first, numaccess, 1);
@ -519,7 +519,7 @@ historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v,
RDF_Resource parents[5];
int8 n = 0;
Assertion as = u->rarg1;
memset(parents, '\0', 5 * sizeof(RDF_Resource));
memset(parents, '\0', 5 * sizeof(RDF_Resource));
while (as) {
if ((as->type == RDF_RESOURCE_TYPE) && (as->s == gCoreVocab->RDF_parent) &&
(resourceType((RDF_Resource)as->value) == HISTORY_RT) && (n < 5)) {
@ -527,14 +527,25 @@ historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v,
}
as = as->next;
}
GH_DeleteHistoryItem ( resourceID(u));
if (containerp(u)) {
Assertion as = u->rarg2;
while (as) {
if ((as->db == gHistoryStore) && (as->s == gCoreVocab->RDF_parent)) {
GH_DeleteHistoryItem (resourceID(as->u));
}
as = as->invNext;
}
} else {
GH_DeleteHistoryItem (resourceID(u));
}
while (n > 0) {
n = n - 1;
if (parents[n]) {
Assertion nas = remoteStoreRemove (gHistoryStore, u, gCoreVocab->RDF_parent,
parents[n], RDF_RESOURCE_TYPE);
freeMem(nas);
}
n = n - 1;
if (parents[n]) {
Assertion nas = remoteStoreRemove (gHistoryStore, u, gCoreVocab->RDF_parent,
parents[n], RDF_RESOURCE_TYPE);
freeMem(nas);
}
}
return 1;
}
@ -548,7 +559,7 @@ HistPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inverse
{
if ((s == gCoreVocab->RDF_parent) && inversep && (rdf == gHistoryStore) &&
((u == gNavCenter->RDF_HistoryByDate) || (u == gNavCenter->RDF_HistoryBySite))) {
/* collateHistory(rdf, gNavCenter->RDF_History, (u == gNavCenter->RDF_HistoryByDate)); */
collateHistory(rdf, u, (u == gNavCenter->RDF_HistoryByDate));
}
}
@ -571,10 +582,10 @@ MakeHistoryStore (char* url)
ntr->possiblyAccessFile = HistPossiblyAccessFile;
gHistoryStore = ntr;
ntr->url = copyString(url);
collateHistory(ntr, gNavCenter->RDF_History, 1);
/* collateHistory(ntr, gNavCenter->RDF_History, 1);
remoteStoreAdd(ntr, sep, gCoreVocab->RDF_parent, gNavCenter->RDF_History, RDF_RESOURCE_TYPE, 1);
bySite = 1;
collateHistory(ntr, gNavCenter->RDF_History, 0);
collateHistory(ntr, gNavCenter->RDF_History, 0); */
return ntr;
} else return gHistoryStore;
} else return NULL;

View File

@ -1172,7 +1172,7 @@ gNavCenterDataSources1[15] =
#endif
"rdf:lfs", "rdf:ht",
"rdf:columns", "rdf:CookieStore", "rdf:find", NULL
"rdf:columns", "rdf:find", NULL
};
static int32 htCounter = 0;

View File

@ -106,7 +106,7 @@ RDF_GetDB (const char** dataSources)
RDF r = (RDF) getMem(sizeof(struct RDF_DBStruct)) ;
RDFL nrl = (RDFL)getMem(sizeof(struct RDF_ListStruct));
while (*(dataSources + n++)) {}
r->translators = (RDFT*)getMem((n-1) * sizeof(RDFT));
r->translators = (RDFT*)getMem((n) * sizeof(RDFT));
n = 0;
while ((next = (char*) *(dataSources + n)) != NULL) {
RDFL rl = (RDFL)getMem(sizeof(struct RDF_ListStruct));
@ -122,7 +122,7 @@ RDF_GetDB (const char** dataSources)
n++;
}
r->numTranslators = m;
r->translatorArraySize = n-1;
r->translatorArraySize = n;
nrl->rdf = r;
nrl->next = gAllDBs;
gAllDBs = nrl;
@ -150,7 +150,7 @@ RDF_AddDataSource(RDF rdf, char* dataSource)
}
#endif
#endif
if (rdf->numTranslators == rdf->translatorArraySize) {
if (rdf->numTranslators >= rdf->translatorArraySize) {
RDFT* tmp = (RDFT*)getMem((rdf->numTranslators+5)*(sizeof(RDFT)));
memcpy(tmp, rdf->translators, (rdf->numTranslators * sizeof(RDFT)));
rdf->translatorArraySize = rdf->numTranslators + 5;
@ -449,32 +449,71 @@ resourceTypeFromID (char* id)
RDF_Resource
specialUrlResource (char* id)
{
if (strcmp(id, "NC:PersonalToolbar") == 0)
return RDFUtil_GetPTFolder();
return NULL;
}
RDF_Resource
NewRDFResource (char* id)
{
RDF_Resource existing;
if ((existing = (RDF_Resource)getMem(sizeof(struct RDF_ResourceStruct))) != NULL)
{
existing->url = copyString(id);
PL_HashTableAdd(resourceHash, existing->url, existing);
}
return(existing);
}
RDF_Resource
QuickGetResource (char* id)
{
RDF_Resource existing;
if ((existing = (RDF_Resource)PL_HashTableLookup(resourceHash, id)) == NULL)
{
existing = NewRDFResource(id);
}
return(existing);
}
PR_PUBLIC_API(RDF_Resource)
RDF_GetResource (RDF db, char* id, PRBool createp)
{
char* nid;
RDF_Resource existing;
if (id != NULL) {
existing = (RDF_Resource)PL_HashTableLookup(resourceHash, id);
if (existing != null) return addDep(db, existing);
if (!createp) {
return null;
} else {
nid = copyString(id);
}
} else if (createp != false) {
nid = makeNewID();
char* nid = NULL;
RDF_Resource existing = NULL;
if (id == NULL) {
if (!createp) {
return NULL;
} else {
id = nid = makeNewID();
}
}
existing = (RDF_Resource)getMem(sizeof(struct RDF_ResourceStruct));
existing->url = nid;
PL_HashTableAdd(resourceHash, nid, existing);
setResourceType(existing, resourceTypeFromID(nid));
existing = specialUrlResource(id);
if (existing) return existing;
existing = (RDF_Resource)PL_HashTableLookup(resourceHash, id);
if (existing) return addDep(db, existing);
if (!createp) return NULL;
existing = NewRDFResource(id);
setResourceType(existing, resourceTypeFromID(id));
setContainerp(existing, iscontainerp(existing));
return addDep(db, existing);
if (nid) freeMem(nid);
return addDep(db, existing);
}
PR_PUBLIC_API (RDF_Error)
RDF_DeleteAllArcs (RDF rdf, RDF_Resource u)

View File

@ -69,6 +69,8 @@ RDF_BT resourceTypeFromID (char* id);
RDF_Cursor getSlotValues (RDF rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
void disposeResourceInt (RDF rdf, RDF_Resource u);
void possiblyGCResource (RDF_Resource u);
RDF_Resource NewRDFResource (char* id);
RDF_Resource QuickGetResource (char* id);
void assertNotify (RDF rdf, RDF_Notification not, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
void insertNotify (RDF rdf, RDF_Notification not, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
void unassertNotify (RDF_Notification not, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, char* ds);

View File

@ -243,11 +243,13 @@ addSlotValue (RDFFile f, RDF_Resource u, RDF_Resource s, void* v,
if (strstr(resourceID(u), ".rdf")) {
RDFL rl = f->db->rdf;
char* dburl = getBaseURL(resourceID(u));
while (rl) {
RDF_AddDataSource(rl->rdf, dburl);
rl = rl->next;
if (!startsWith(dburl, resourceID((RDF_Resource)v))) {
while (rl) {
RDF_AddDataSource(rl->rdf, dburl);
rl = rl->next;
}
freeMem(dburl);
}
freeMem(dburl);
}
}
(*f->assert)(f, f->db, u, s, v, type, tv);

View File

@ -418,7 +418,7 @@ nlocalStoreNextValue (RDFT rdf, RDF_Cursor c)
if ((c->tv == tvOfAs(nas)) && (c->type == valueTypeOfAs(nas))) {
if (c->type == RDF_RESOURCE_TYPE) {
RDF_Resource nu = RDF_GetResource(NULL, dataOfDBMAs(nas), 1);
if (nu && strstr(resourceID(nu), ".rdf")) {
if (nu && startsWith("http", resourceID(nu)) && strstr(resourceID(nu), ".rdf")) {
RDFL rl = rdf->rdf;
char* dburl = getBaseURL(resourceID(nu));
while (rl) {

View File

@ -52,12 +52,11 @@ char *
getHref(char** attlist)
{
char* ans = getAttributeValue(attlist, "rdf:href");
if (ans != NULL) {
return ans;
} else return getAttributeValue(attlist, "href");
if (!ans) ans = getAttributeValue(attlist, "RDF:href");
if (!ans) ans = getAttributeValue(attlist, "href");
return ans;
}
int
parseNextRDFXMLBlob (NET_StreamClass *stream, char* blob, int32 size)
@ -221,7 +220,8 @@ containerTagp (RDFFile f, char* elementName)
(tagEquals(f, elementName, "RelatedLinks")));
}
#define DC_TITLE "http://purl.org/metadata/dublin_core/title"
#define SM_CHILD "http://purl.org/metadata/sitemap/child"
RDF_Resource
ResourceFromElementName (RDFFile f, char* elementName)
@ -238,12 +238,17 @@ ResourceFromElementName (RDFFile f, char* elementName)
char* url = getMem(strlen(ns->url) + strlen(elementName)-asn);
memcpy(url, ns->url, urln);
strcat(url, &elementName[asn+1]);
ans = RDF_GetResource(NULL, url, 1);
if (strcmp(url, DC_TITLE) == 0) {
ans = gCoreVocab->RDF_name;
} else if (strcmp(url, SM_CHILD) == 0) {
ans = gCoreVocab->RDF_child;
} else
ans = RDF_GetResource(NULL, url, 1);
freeMem(url);
return ans;
}
ns = ns->next;
}
}
return RDF_GetResource(NULL, elementName, 1);
}
}

View File

@ -220,7 +220,7 @@ remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s,
nextAs = prevAs = u->rarg1;
while (nextAs != null) {
if (asEqual(mcf, nextAs, u, s, v, type)) {
if (prevAs == null) {
if (prevAs == nextAs) {
u->rarg1 = nextAs->next;
} else {
prevAs->next = nextAs->next;

View File

@ -736,7 +736,7 @@ MakeCookieStore (char* url)
ntr->nextValue = CookieGetNextValue;
ntr->disposeCursor = CookieDisposeCursor;
gCookieStore = ntr;
NET_InitRDFCookieResources ( ) ;
/* NET_InitRDFCookieResources ( ) ; */
return ntr;
} else return gCookieStore;
} else return NULL;