HaikuDepot: Url -> Identifier
This change will rename the confusing "url" within HaikuDepot to be "identifier" in line with corresponding changes in pkg kit and HDS. Also at the same time support is introduced for HDS repos' meta-data to artificially match against multiple repos; as requested for the future R1B3 release process. Some tidy-ups and extensions have been made to the JSON schema-to-model and the schema-to-parser scripts. Change-Id: I402e7d610986039f58d72028bda7de977e9115e2 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2986 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
@@ -171,7 +171,7 @@
|
|||||||
the key that you are looking for.
|
the key that you are looking for.
|
||||||
\param[in] secondaryIdentifierOptional Use this query parameter to indicate
|
\param[in] secondaryIdentifierOptional Use this query parameter to indicate
|
||||||
if the secondary identifier has to match. When set to \a false, a
|
if the secondary identifier has to match. When set to \a false, a
|
||||||
result will be returned, even if the \a secondaryIdentifer does not
|
result will be returned, even if the \a secondaryIdentifier does not
|
||||||
match.
|
match.
|
||||||
\param[out] key A BKey object to copy the found data to. Any existing data
|
\param[out] key A BKey object to copy the found data to. Any existing data
|
||||||
in the key will be overwritten in case there is a match.
|
in the key will be overwritten in case there is a match.
|
||||||
|
|||||||
@@ -207,7 +207,7 @@
|
|||||||
why in the \ref BApplication::ReadyToRun() hook we check for the
|
why in the \ref BApplication::ReadyToRun() hook we check for the
|
||||||
availability of the key. If it is not available, or it does not work, the
|
availability of the key. If it is not available, or it does not work, the
|
||||||
user will be redirected to the authentication tool. The key will be stored
|
user will be redirected to the authentication tool. The key will be stored
|
||||||
as a password. It will be identified by the identifer "CoolWebService".
|
as a password. It will be identified by the identifier "CoolWebService".
|
||||||
|
|
||||||
\code{.cpp}
|
\code{.cpp}
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ resource app_flags B_SINGLE_LAUNCH;
|
|||||||
resource app_version {
|
resource app_version {
|
||||||
major = 0,
|
major = 0,
|
||||||
middle = 0,
|
middle = 0,
|
||||||
minor = 3,
|
minor = 4,
|
||||||
|
|
||||||
variety = B_APPV_ALPHA,
|
variety = B_APPV_ALPHA,
|
||||||
internal = 1,
|
internal = 1,
|
||||||
|
|
||||||
short_info = "HaikuDepot",
|
short_info = "HaikuDepot",
|
||||||
long_info = "HaikuDepot ©2013-2018 Haiku"
|
long_info = "HaikuDepot ©2013-2020 Haiku"
|
||||||
};
|
};
|
||||||
|
|
||||||
resource file_types message {
|
resource file_types message {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
# =====================================
|
# =====================================
|
||||||
# Copyright 2017-2019, Andrew Lindesay
|
# Copyright 2017-2020, Andrew Lindesay
|
||||||
# Distributed under the terms of the MIT License.
|
# Distributed under the terms of the MIT License.
|
||||||
# =====================================
|
# =====================================
|
||||||
|
|
||||||
@@ -70,12 +70,21 @@ def propmetadatatocpptypename(propmetadata):
|
|||||||
|
|
||||||
if type == JSON_TYPE_ARRAY:
|
if type == JSON_TYPE_ARRAY:
|
||||||
itemsmetadata = propmetadata['items']
|
itemsmetadata = propmetadata['items']
|
||||||
itemsjavatype = itemsmetadata['javaType']
|
itemstype = itemsmetadata['type']
|
||||||
|
|
||||||
if not itemsjavatype or 0 == len(itemsjavatype):
|
if not itemstype or 0 == len(itemstype):
|
||||||
raise Exception('missing "javaType" field')
|
raise Exception('missing "type" field')
|
||||||
|
|
||||||
return "%s <%s>" % (CPP_TYPE_ARRAY, javatypetocppname(itemsjavatype))
|
if itemstype == JSON_TYPE_OBJECT:
|
||||||
|
itemsjavatype = itemsmetadata['javaType']
|
||||||
|
if not itemsjavatype or 0 == len(itemsjavatype):
|
||||||
|
raise Exception('missing "javaType" field')
|
||||||
|
return "%s<%s>" % (CPP_TYPE_ARRAY, javatypetocppname(itemsjavatype))
|
||||||
|
|
||||||
|
if itemstype == JSON_TYPE_STRING:
|
||||||
|
return "%s<%s>" % (CPP_TYPE_ARRAY, CPP_TYPE_STRING)
|
||||||
|
|
||||||
|
raise Exception('unsupported type [%s]' % itemstype)
|
||||||
|
|
||||||
raise Exception('unknown json-schema type [' + type + ']')
|
raise Exception('unknown json-schema type [' + type + ']')
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# =====================================
|
# =====================================
|
||||||
# Copyright 2017-2019, Andrew Lindesay
|
# Copyright 2017-2020, Andrew Lindesay
|
||||||
# Distributed under the terms of the MIT License.
|
# Distributed under the terms of the MIT License.
|
||||||
# =====================================
|
# =====================================
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ import string
|
|||||||
|
|
||||||
def hasanylistproperties(schema):
|
def hasanylistproperties(schema):
|
||||||
for propname, propmetadata in schema['properties'].items():
|
for propname, propmetadata in schema['properties'].items():
|
||||||
if propmetadata['type'] == 'array':
|
if propmetadata['type'] == jscom.JSON_TYPE_ARRAY:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -217,12 +217,12 @@ def writescalaraccessorsheader(outputfile, cppname, cpptype):
|
|||||||
def writeaccessors(outputfile, cppclassname, propname, propmetadata):
|
def writeaccessors(outputfile, cppclassname, propname, propmetadata):
|
||||||
type = propmetadata['type']
|
type = propmetadata['type']
|
||||||
|
|
||||||
if type == 'array':
|
if type == jscom.JSON_TYPE_ARRAY:
|
||||||
writelistaccessors(outputfile,
|
writelistaccessors(outputfile,
|
||||||
cppclassname,
|
cppclassname,
|
||||||
jscom.propnametocppname(propname),
|
jscom.propnametocppname(propname),
|
||||||
jscom.propnametocppmembername(propname),
|
jscom.propnametocppmembername(propname),
|
||||||
jscom.javatypetocppname(propmetadata['items']['javaType']))
|
jscom.propmetadatatocpptypename(propmetadata['items']))
|
||||||
elif jscom.propmetadatatypeisscalar(propmetadata):
|
elif jscom.propmetadatatypeisscalar(propmetadata):
|
||||||
writescalaraccessors(outputfile,
|
writescalaraccessors(outputfile,
|
||||||
cppclassname,
|
cppclassname,
|
||||||
@@ -240,10 +240,10 @@ def writeaccessors(outputfile, cppclassname, propname, propmetadata):
|
|||||||
def writeaccessorsheader(outputfile, propname, propmetadata):
|
def writeaccessorsheader(outputfile, propname, propmetadata):
|
||||||
type = propmetadata['type']
|
type = propmetadata['type']
|
||||||
|
|
||||||
if type == 'array':
|
if type == jscom.JSON_TYPE_ARRAY:
|
||||||
writelistaccessorsheader(outputfile,
|
writelistaccessorsheader(outputfile,
|
||||||
jscom.propnametocppname(propname),
|
jscom.propnametocppname(propname),
|
||||||
jscom.javatypetocppname(propmetadata['items']['javaType']))
|
jscom.propmetadatatocpptypename(propmetadata['items']))
|
||||||
elif jscom.propmetadatatypeisscalar(propmetadata):
|
elif jscom.propmetadatatypeisscalar(propmetadata):
|
||||||
writescalaraccessorsheader(outputfile,
|
writescalaraccessorsheader(outputfile,
|
||||||
jscom.propnametocppname(propname),
|
jscom.propnametocppname(propname),
|
||||||
@@ -278,7 +278,7 @@ def writedestructor(outputfile, cppname, schema):
|
|||||||
|
|
||||||
outputfile.write(' if (%s != NULL) {\n' % propmembername)
|
outputfile.write(' if (%s != NULL) {\n' % propmembername)
|
||||||
|
|
||||||
if propmetadata['type'] == 'array':
|
if propmetadata['type'] == jscom.JSON_TYPE_ARRAY:
|
||||||
writedestructorlogicforlist(outputfile, propname, propmetadata)
|
writedestructorlogicforlist(outputfile, propname, propmetadata)
|
||||||
|
|
||||||
outputfile.write((
|
outputfile.write((
|
||||||
@@ -304,10 +304,10 @@ def writeheaderincludes(outputfile, properties):
|
|||||||
jsontype = propmetadata['type']
|
jsontype = propmetadata['type']
|
||||||
javatype = None
|
javatype = None
|
||||||
|
|
||||||
if jsontype == 'object':
|
if jsontype == jscom.JSON_TYPE_OBJECT:
|
||||||
javatype = propmetadata['javaType']
|
javatype = propmetadata['javaType']
|
||||||
|
|
||||||
if jsontype == 'array':
|
if jsontype == jscom.JSON_TYPE_ARRAY:
|
||||||
javatype = propmetadata['items']['javaType']
|
javatype = propmetadata['items']['javaType']
|
||||||
|
|
||||||
if javatype is not None:
|
if javatype is not None:
|
||||||
@@ -315,8 +315,9 @@ def writeheaderincludes(outputfile, properties):
|
|||||||
|
|
||||||
|
|
||||||
def schematocppmodels(inputfile, schema, outputdirectory):
|
def schematocppmodels(inputfile, schema, outputdirectory):
|
||||||
if schema['type'] != 'object':
|
type = schema['type']
|
||||||
raise Exception('expecting object')
|
if type != jscom.JSON_TYPE_OBJECT:
|
||||||
|
raise Exception('expecting object, but was [' + type + ']')
|
||||||
|
|
||||||
javatype = schema['javaType']
|
javatype = schema['javaType']
|
||||||
|
|
||||||
@@ -337,7 +338,7 @@ def schematocppmodels(inputfile, schema, outputdirectory):
|
|||||||
#define ${guarddefname}
|
#define ${guarddefname}
|
||||||
|
|
||||||
#include <ObjectList.h>
|
#include <ObjectList.h>
|
||||||
#include "String.h"
|
#include <String.h>
|
||||||
|
|
||||||
""").substitute({'guarddefname': guarddefname}))
|
""").substitute({'guarddefname': guarddefname}))
|
||||||
|
|
||||||
@@ -388,10 +389,12 @@ public:
|
|||||||
for propname, propmetadata in schema['properties'].items():
|
for propname, propmetadata in schema['properties'].items():
|
||||||
jsontype = propmetadata['type']
|
jsontype = propmetadata['type']
|
||||||
|
|
||||||
if jsontype == 'array':
|
if jsontype == jscom.JSON_TYPE_ARRAY:
|
||||||
schematocppmodels(inputfile, propmetadata['items'], outputdirectory)
|
arraySchema = propmetadata['items']
|
||||||
|
if arraySchema['type'] == jscom.JSON_TYPE_OBJECT:
|
||||||
|
schematocppmodels(inputfile, arraySchema, outputdirectory)
|
||||||
|
|
||||||
if jsontype == 'object':
|
if jsontype == jscom.JSON_TYPE_OBJECT:
|
||||||
schematocppmodels(inputfile, propmetadata, outputdirectory)
|
schematocppmodels(inputfile, propmetadata, outputdirectory)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# =====================================
|
# =====================================
|
||||||
# Copyright 2017-2019, Andrew Lindesay
|
# Copyright 2017-2020, Andrew Lindesay
|
||||||
# Distributed under the terms of the MIT License.
|
# Distributed under the terms of the MIT License.
|
||||||
# =====================================
|
# =====================================
|
||||||
|
|
||||||
@@ -23,12 +23,22 @@ class CppParserSubTypeNaming:
|
|||||||
_naming = None
|
_naming = None
|
||||||
|
|
||||||
def __init__(self, schema, naming):
|
def __init__(self, schema, naming):
|
||||||
javatype = schema['javaType']
|
type = schema['type']
|
||||||
|
|
||||||
if not javatype or 0 == len(javatype):
|
if not type or 0 == len(type):
|
||||||
raise Exception('missing "javaType" field')
|
raise Exception('missing "type" field')
|
||||||
|
|
||||||
self._cppmodelclassname = jscom.javatypetocppname(javatype)
|
def derivecppmodelclassname():
|
||||||
|
if type == jscom.JSON_TYPE_OBJECT:
|
||||||
|
javatype = schema['javaType']
|
||||||
|
if not javatype or 0 == len(javatype):
|
||||||
|
raise Exception('missing "javaType" field')
|
||||||
|
return jscom.javatypetocppname(javatype)
|
||||||
|
if type == jscom.JSON_TYPE_STRING:
|
||||||
|
return jscom.CPP_TYPE_STRING
|
||||||
|
raise Exception('unsupported "type" of "%s"' % type)
|
||||||
|
|
||||||
|
self._cppmodelclassname = derivecppmodelclassname()
|
||||||
self._naming = naming
|
self._naming = naming
|
||||||
|
|
||||||
def cppmodelclassname(self):
|
def cppmodelclassname(self):
|
||||||
@@ -38,6 +48,8 @@ class CppParserSubTypeNaming:
|
|||||||
return self._cppmodelclassname + '_' + self._naming.generatejsonlistenername('Stacked')
|
return self._cppmodelclassname + '_' + self._naming.generatejsonlistenername('Stacked')
|
||||||
|
|
||||||
def cppstackedlistlistenerclassname(self):
|
def cppstackedlistlistenerclassname(self):
|
||||||
|
if self._cppmodelclassname == jscom.CPP_TYPE_STRING:
|
||||||
|
return self._naming.cppstringliststackedlistenerclassname()
|
||||||
return self._cppmodelclassname + '_List_' + self._naming.generatejsonlistenername('Stacked')
|
return self._cppmodelclassname + '_List_' + self._naming.generatejsonlistenername('Stacked')
|
||||||
|
|
||||||
def todict(self):
|
def todict(self):
|
||||||
@@ -48,7 +60,8 @@ class CppParserSubTypeNaming:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# This naming relates to the whole schema. It's point of reference is the top level.
|
# This naming relates to the whole schema. It's point of
|
||||||
|
# reference is the top level.
|
||||||
|
|
||||||
class CppParserNaming:
|
class CppParserNaming:
|
||||||
_schemaroot = None
|
_schemaroot = None
|
||||||
@@ -57,8 +70,9 @@ class CppParserNaming:
|
|||||||
self._schemaroot = schemaroot
|
self._schemaroot = schemaroot
|
||||||
|
|
||||||
def cpprootmodelclassname(self):
|
def cpprootmodelclassname(self):
|
||||||
if self._schemaroot['type'] != 'object':
|
type = self._schemaroot['type']
|
||||||
raise Exception('expecting object')
|
if type != 'object':
|
||||||
|
raise Exception('expecting object, but was [' + type + "]")
|
||||||
|
|
||||||
javatype = self._schemaroot['javaType']
|
javatype = self._schemaroot['javaType']
|
||||||
|
|
||||||
@@ -82,6 +96,9 @@ class CppParserNaming:
|
|||||||
def cppsuperstackedlistenerclassname(self):
|
def cppsuperstackedlistenerclassname(self):
|
||||||
return self.generatejsonlistenername('AbstractStacked')
|
return self.generatejsonlistenername('AbstractStacked')
|
||||||
|
|
||||||
|
def cppstringliststackedlistenerclassname(self):
|
||||||
|
return self.generatejsonlistenername('StringList')
|
||||||
|
|
||||||
def cppbulkcontainerstackedlistenerclassname(self):
|
def cppbulkcontainerstackedlistenerclassname(self):
|
||||||
return self.generatejsonlistenername('BulkContainerStacked')
|
return self.generatejsonlistenername('BulkContainerStacked')
|
||||||
|
|
||||||
@@ -113,6 +130,7 @@ class CppParserNaming:
|
|||||||
'cppbulkcontaineritemliststackedlistenerclassname': self.cppbulkcontaineritemliststackedlistenerclassname(),
|
'cppbulkcontaineritemliststackedlistenerclassname': self.cppbulkcontaineritemliststackedlistenerclassname(),
|
||||||
'cppsuperstackedlistenerclassname': self.cppsuperstackedlistenerclassname(),
|
'cppsuperstackedlistenerclassname': self.cppsuperstackedlistenerclassname(),
|
||||||
'cppitemlistenerstackedlistenerclassname': self.cppitemlistenerstackedlistenerclassname(),
|
'cppitemlistenerstackedlistenerclassname': self.cppitemlistenerstackedlistenerclassname(),
|
||||||
|
'cppstringliststackedlistenerclassname': self.cppstringliststackedlistenerclassname(),
|
||||||
'cppgeneralobjectstackedlistenerclassname': self.cppgeneralobjectstackedlistenerclassname(),
|
'cppgeneralobjectstackedlistenerclassname': self.cppgeneralobjectstackedlistenerclassname(),
|
||||||
'cppgeneralarraystackedlistenerclassname': self.cppgeneralarraystackedlistenerclassname(),
|
'cppgeneralarraystackedlistenerclassname': self.cppgeneralarraystackedlistenerclassname(),
|
||||||
'cppitemlistenerclassname': self.cppitemlistenerclassname()
|
'cppitemlistenerclassname': self.cppitemlistenerclassname()
|
||||||
@@ -246,6 +264,81 @@ ${cppsuperstackedlistenerclassname}::Pop()
|
|||||||
""").substitute(istate.naming().todict()))
|
""").substitute(istate.naming().todict()))
|
||||||
|
|
||||||
|
|
||||||
|
def writestringliststackedlistenerinterface(istate):
|
||||||
|
istate.outputfile().write(
|
||||||
|
string.Template("""
|
||||||
|
|
||||||
|
/*! Sometimes attributes of objects are able to be arrays of strings. This
|
||||||
|
listener will parse and return the array of strings.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ${cppstringliststackedlistenerclassname} : public ${cppsuperstackedlistenerclassname} {
|
||||||
|
public:
|
||||||
|
${cppstringliststackedlistenerclassname}(
|
||||||
|
${cppsupermainlistenerclassname}* mainListener,
|
||||||
|
${cppsuperstackedlistenerclassname}* parent);
|
||||||
|
~${cppstringliststackedlistenerclassname}();
|
||||||
|
|
||||||
|
bool Handle(const BJsonEvent& event);
|
||||||
|
BObjectList<BString>* Target();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BObjectList<BString>* fTarget;
|
||||||
|
};
|
||||||
|
""").substitute(istate.naming().todict()))
|
||||||
|
|
||||||
|
|
||||||
|
def writestringliststackedlistenerimplementation(istate):
|
||||||
|
istate.outputfile().write(
|
||||||
|
string.Template("""
|
||||||
|
${cppstringliststackedlistenerclassname}::${cppstringliststackedlistenerclassname}(
|
||||||
|
${cppsupermainlistenerclassname}* mainListener,
|
||||||
|
${cppsuperstackedlistenerclassname}* parent)
|
||||||
|
:
|
||||||
|
${cppsuperstackedlistenerclassname}(mainListener, parent)
|
||||||
|
{
|
||||||
|
fTarget = new BObjectList<BString>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
${cppstringliststackedlistenerclassname}::~${cppstringliststackedlistenerclassname}()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BObjectList<BString>*
|
||||||
|
${cppstringliststackedlistenerclassname}::Target()
|
||||||
|
{
|
||||||
|
return fTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
${cppstringliststackedlistenerclassname}::Handle(const BJsonEvent& event)
|
||||||
|
{
|
||||||
|
switch (event.EventType()) {
|
||||||
|
case B_JSON_ARRAY_END:
|
||||||
|
{
|
||||||
|
bool status = Pop() && (ErrorStatus() == B_OK);
|
||||||
|
delete this;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
case B_JSON_STRING:
|
||||||
|
{
|
||||||
|
fTarget->AddItem(new BString(event.Content()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE,
|
||||||
|
"illegal state - unexpected json event parsing a string array");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrorStatus() == B_OK;
|
||||||
|
}
|
||||||
|
""").substitute(istate.naming().todict()))
|
||||||
|
|
||||||
|
|
||||||
def writeageneralstackedlistenerinterface(istate, alistenerclassname):
|
def writeageneralstackedlistenerinterface(istate, alistenerclassname):
|
||||||
istate.outputfile().write(
|
istate.outputfile().write(
|
||||||
string.Template("""
|
string.Template("""
|
||||||
@@ -310,7 +403,6 @@ bool
|
|||||||
${generalobjectclassname}::Handle(const BJsonEvent& event)
|
${generalobjectclassname}::Handle(const BJsonEvent& event)
|
||||||
{
|
{
|
||||||
switch (event.EventType()) {
|
switch (event.EventType()) {
|
||||||
|
|
||||||
case B_JSON_OBJECT_NAME:
|
case B_JSON_OBJECT_NAME:
|
||||||
case B_JSON_NUMBER:
|
case B_JSON_NUMBER:
|
||||||
case B_JSON_STRING:
|
case B_JSON_STRING:
|
||||||
@@ -319,34 +411,23 @@ ${generalobjectclassname}::Handle(const BJsonEvent& event)
|
|||||||
case B_JSON_NULL:
|
case B_JSON_NULL:
|
||||||
// ignore
|
// ignore
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_START:
|
case B_JSON_OBJECT_START:
|
||||||
Push(new ${generalobjectclassname}(fMainListener, this));
|
Push(new ${generalobjectclassname}(fMainListener, this));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_ARRAY_START:
|
case B_JSON_ARRAY_START:
|
||||||
Push(new ${generalarrayclassname}(fMainListener, this));
|
Push(new ${generalarrayclassname}(fMainListener, this));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_ARRAY_END:
|
case B_JSON_ARRAY_END:
|
||||||
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of array");
|
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of array");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_END:
|
case B_JSON_OBJECT_END:
|
||||||
{
|
{
|
||||||
bool status = Pop() && (ErrorStatus() == B_OK);
|
bool status = Pop() && (ErrorStatus() == B_OK);
|
||||||
delete this;
|
delete this;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ErrorStatus() == B_OK;
|
return ErrorStatus() == B_OK;
|
||||||
}
|
}
|
||||||
""").substitute(substitutedict))
|
""").substitute(substitutedict))
|
||||||
@@ -361,7 +442,6 @@ bool
|
|||||||
${generalarrayclassname}::Handle(const BJsonEvent& event)
|
${generalarrayclassname}::Handle(const BJsonEvent& event)
|
||||||
{
|
{
|
||||||
switch (event.EventType()) {
|
switch (event.EventType()) {
|
||||||
|
|
||||||
case B_JSON_OBJECT_NAME:
|
case B_JSON_OBJECT_NAME:
|
||||||
case B_JSON_NUMBER:
|
case B_JSON_NUMBER:
|
||||||
case B_JSON_STRING:
|
case B_JSON_STRING:
|
||||||
@@ -370,31 +450,21 @@ ${generalarrayclassname}::Handle(const BJsonEvent& event)
|
|||||||
case B_JSON_NULL:
|
case B_JSON_NULL:
|
||||||
// ignore
|
// ignore
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_START:
|
case B_JSON_OBJECT_START:
|
||||||
Push(new ${generalobjectclassname}(fMainListener, this));
|
Push(new ${generalobjectclassname}(fMainListener, this));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_ARRAY_START:
|
case B_JSON_ARRAY_START:
|
||||||
Push(new ${generalarrayclassname}(fMainListener, this));
|
Push(new ${generalarrayclassname}(fMainListener, this));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_END:
|
case B_JSON_OBJECT_END:
|
||||||
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of object");
|
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of object");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_ARRAY_END:
|
case B_JSON_ARRAY_END:
|
||||||
{
|
{
|
||||||
bool status = Pop() && (ErrorStatus() == B_OK);
|
bool status = Pop() && (ErrorStatus() == B_OK);
|
||||||
delete this;
|
delete this;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -438,23 +508,24 @@ public:
|
|||||||
${cppsuperstackedlistenerclassname}* parent);
|
${cppsuperstackedlistenerclassname}* parent);
|
||||||
~${subtype_cppstackedlistlistenerclassname}();
|
~${subtype_cppstackedlistlistenerclassname}();
|
||||||
|
|
||||||
|
|
||||||
bool Handle(const BJsonEvent& event);
|
bool Handle(const BJsonEvent& event);
|
||||||
|
|
||||||
|
BObjectList<${subtype_cppmodelclassname}>* Target();
|
||||||
BObjectList<${subtype_cppmodelclassname}>* Target(); // list of %s pointers
|
// list of ${subtype_cppmodelclassname} pointers
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BObjectList<${subtype_cppmodelclassname}>* fTarget;
|
BObjectList<${subtype_cppmodelclassname}>* fTarget;
|
||||||
};
|
};
|
||||||
""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict())))
|
""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict())))
|
||||||
|
|
||||||
for propname, propmetadata in subschema['properties'].items():
|
if 'properties' in subschema:
|
||||||
if propmetadata['type'] == 'array':
|
|
||||||
writestackedlistenerinterface(istate, propmetadata['items'])
|
for propname, propmetadata in subschema['properties'].items():
|
||||||
elif propmetadata['type'] == 'object':
|
if propmetadata['type'] == jscom.JSON_TYPE_ARRAY:
|
||||||
writestackedlistenerinterface(istate, propmetadata)
|
if propmetadata['items']['type'] == jscom.JSON_TYPE_OBJECT:
|
||||||
|
writestackedlistenerinterface(istate, propmetadata['items'])
|
||||||
|
elif propmetadata['type'] == jscom.JSON_TYPE_OBJECT:
|
||||||
|
writestackedlistenerinterface(istate, propmetadata)
|
||||||
|
|
||||||
|
|
||||||
def writebulkcontainerstackedlistenerinterface(istate, schema):
|
def writebulkcontainerstackedlistenerinterface(istate, schema):
|
||||||
@@ -605,18 +676,12 @@ bool
|
|||||||
${subtype_cppstackedlistenerclassname}::Handle(const BJsonEvent& event)
|
${subtype_cppstackedlistenerclassname}::Handle(const BJsonEvent& event)
|
||||||
{
|
{
|
||||||
switch (event.EventType()) {
|
switch (event.EventType()) {
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_ARRAY_END:
|
case B_JSON_ARRAY_END:
|
||||||
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array");
|
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_NAME:
|
case B_JSON_OBJECT_NAME:
|
||||||
fNextItemName = event.Content();
|
fNextItemName = event.Content();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_END:
|
case B_JSON_OBJECT_END:
|
||||||
{
|
{
|
||||||
bool status = Pop() && (ErrorStatus() == B_OK);
|
bool status = Pop() && (ErrorStatus() == B_OK);
|
||||||
@@ -778,16 +843,12 @@ bool
|
|||||||
${subtype_cppstackedlistlistenerclassname}::Handle(const BJsonEvent& event)
|
${subtype_cppstackedlistlistenerclassname}::Handle(const BJsonEvent& event)
|
||||||
{
|
{
|
||||||
switch (event.EventType()) {
|
switch (event.EventType()) {
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_ARRAY_END:
|
case B_JSON_ARRAY_END:
|
||||||
{
|
{
|
||||||
bool status = Pop() && (ErrorStatus() == B_OK);
|
bool status = Pop() && (ErrorStatus() == B_OK);
|
||||||
delete this;
|
delete this;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_START:
|
case B_JSON_OBJECT_START:
|
||||||
{
|
{
|
||||||
${subtype_cppstackedlistenerclassname}* nextListener =
|
${subtype_cppstackedlistenerclassname}* nextListener =
|
||||||
@@ -796,15 +857,12 @@ ${subtype_cppstackedlistlistenerclassname}::Handle(const BJsonEvent& event)
|
|||||||
Push(nextListener);
|
Push(nextListener);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE,
|
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE,
|
||||||
"illegal state - unexpected json event parsing an array of ${subtype_cppmodelclassname}");
|
"illegal state - unexpected json event parsing an array of ${subtype_cppmodelclassname}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ErrorStatus() == B_OK;
|
return ErrorStatus() == B_OK;
|
||||||
}
|
}
|
||||||
""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict())))
|
""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict())))
|
||||||
@@ -861,45 +919,32 @@ bool
|
|||||||
${cppbulkcontainerstackedlistenerclassname}::Handle(const BJsonEvent& event)
|
${cppbulkcontainerstackedlistenerclassname}::Handle(const BJsonEvent& event)
|
||||||
{
|
{
|
||||||
switch (event.EventType()) {
|
switch (event.EventType()) {
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_ARRAY_END:
|
case B_JSON_ARRAY_END:
|
||||||
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array");
|
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_NAME:
|
case B_JSON_OBJECT_NAME:
|
||||||
fNextItemName = event.Content();
|
fNextItemName = event.Content();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_START:
|
case B_JSON_OBJECT_START:
|
||||||
Push(new ${cppgeneralobjectstackedlistenerclassname}(fMainListener, this));
|
Push(new ${cppgeneralobjectstackedlistenerclassname}(fMainListener, this));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_ARRAY_START:
|
case B_JSON_ARRAY_START:
|
||||||
if (fNextItemName == "items")
|
if (fNextItemName == "items")
|
||||||
Push(new ${cppbulkcontaineritemliststackedlistenerclassname}(fMainListener, this, fItemListener));
|
Push(new ${cppbulkcontaineritemliststackedlistenerclassname}(fMainListener, this, fItemListener));
|
||||||
else
|
else
|
||||||
Push(new ${cppgeneralarraystackedlistenerclassname}(fMainListener, this));
|
Push(new ${cppgeneralarraystackedlistenerclassname}(fMainListener, this));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_END:
|
case B_JSON_OBJECT_END:
|
||||||
{
|
{
|
||||||
bool status = Pop() && (ErrorStatus() == B_OK);
|
bool status = Pop() && (ErrorStatus() == B_OK);
|
||||||
delete this;
|
delete this;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// ignore
|
// ignore
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ErrorStatus() == B_OK;
|
return ErrorStatus() == B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,27 +968,20 @@ bool
|
|||||||
${cppbulkcontaineritemliststackedlistenerclassname}::Handle(const BJsonEvent& event)
|
${cppbulkcontaineritemliststackedlistenerclassname}::Handle(const BJsonEvent& event)
|
||||||
{
|
{
|
||||||
switch (event.EventType()) {
|
switch (event.EventType()) {
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_START:
|
case B_JSON_OBJECT_START:
|
||||||
Push(new ${cppitemlistenerstackedlistenerclassname}(fMainListener, this, fItemListener));
|
Push(new ${cppitemlistenerstackedlistenerclassname}(fMainListener, this, fItemListener));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_ARRAY_END:
|
case B_JSON_ARRAY_END:
|
||||||
{
|
{
|
||||||
bool status = Pop() && (ErrorStatus() == B_OK);
|
bool status = Pop() && (ErrorStatus() == B_OK);
|
||||||
delete this;
|
delete this;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected json event");
|
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected json event");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ErrorStatus() == B_OK;
|
return ErrorStatus() == B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -972,7 +1010,9 @@ def writestackedlistenerimplementation(istate, schema):
|
|||||||
|
|
||||||
for propname, propmetadata in schema['properties'].items():
|
for propname, propmetadata in schema['properties'].items():
|
||||||
if propmetadata['type'] == 'array':
|
if propmetadata['type'] == 'array':
|
||||||
writestackedlistenerimplementation(istate, propmetadata['items'])
|
items = propmetadata['items']
|
||||||
|
if items['type'] == jscom.JSON_TYPE_OBJECT:
|
||||||
|
writestackedlistenerimplementation(istate, items)
|
||||||
elif propmetadata['type'] == 'object':
|
elif propmetadata['type'] == 'object':
|
||||||
writestackedlistenerimplementation(istate, propmetadata)
|
writestackedlistenerimplementation(istate, propmetadata)
|
||||||
|
|
||||||
@@ -1054,14 +1094,10 @@ ${cppsinglemainlistenerclassname}::Handle(const BJsonEvent& event)
|
|||||||
if (fErrorStatus != B_OK)
|
if (fErrorStatus != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
if (fStackedListener != NULL)
|
if (fStackedListener != NULL)
|
||||||
return fStackedListener->Handle(event);
|
return fStackedListener->Handle(event);
|
||||||
|
|
||||||
|
|
||||||
switch (event.EventType()) {
|
switch (event.EventType()) {
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_START:
|
case B_JSON_OBJECT_START:
|
||||||
{
|
{
|
||||||
${subtype_cppstackedlistenerclassname}* nextListener = new ${subtype_cppstackedlistenerclassname}(
|
${subtype_cppstackedlistenerclassname}* nextListener = new ${subtype_cppstackedlistenerclassname}(
|
||||||
@@ -1070,8 +1106,6 @@ ${cppsinglemainlistenerclassname}::Handle(const BJsonEvent& event)
|
|||||||
SetStackedListener(nextListener);
|
SetStackedListener(nextListener);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE,
|
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE,
|
||||||
"illegal state - unexpected json event parsing top level for ${cpprootmodelclassname}");
|
"illegal state - unexpected json event parsing top level for ${cpprootmodelclassname}");
|
||||||
@@ -1115,14 +1149,10 @@ ${cppbulkcontainermainlistenerclassname}::Handle(const BJsonEvent& event)
|
|||||||
if (fErrorStatus != B_OK)
|
if (fErrorStatus != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
if (fStackedListener != NULL)
|
if (fStackedListener != NULL)
|
||||||
return fStackedListener->Handle(event);
|
return fStackedListener->Handle(event);
|
||||||
|
|
||||||
|
|
||||||
switch (event.EventType()) {
|
switch (event.EventType()) {
|
||||||
|
|
||||||
|
|
||||||
case B_JSON_OBJECT_START:
|
case B_JSON_OBJECT_START:
|
||||||
{
|
{
|
||||||
${cppbulkcontainerstackedlistenerclassname}* nextListener =
|
${cppbulkcontainerstackedlistenerclassname}* nextListener =
|
||||||
@@ -1132,8 +1162,6 @@ ${cppbulkcontainermainlistenerclassname}::Handle(const BJsonEvent& event)
|
|||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE,
|
HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE,
|
||||||
"illegal state - unexpected json event parsing top level for ${cppbulkcontainermainlistenerclassname}");
|
"illegal state - unexpected json event parsing top level for ${cppbulkcontainermainlistenerclassname}");
|
||||||
@@ -1178,12 +1206,10 @@ public:
|
|||||||
${cppsupermainlistenerclassname}();
|
${cppsupermainlistenerclassname}();
|
||||||
virtual ~${cppsupermainlistenerclassname}();
|
virtual ~${cppsupermainlistenerclassname}();
|
||||||
|
|
||||||
|
|
||||||
void HandleError(status_t status, int32 line, const char* message);
|
void HandleError(status_t status, int32 line, const char* message);
|
||||||
void Complete();
|
void Complete();
|
||||||
status_t ErrorStatus();
|
status_t ErrorStatus();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetStackedListener(
|
void SetStackedListener(
|
||||||
${cppsuperstackedlistenerclassname}* listener);
|
${cppsuperstackedlistenerclassname}* listener);
|
||||||
@@ -1202,11 +1228,9 @@ public:
|
|||||||
${cppsinglemainlistenerclassname}();
|
${cppsinglemainlistenerclassname}();
|
||||||
virtual ~${cppsinglemainlistenerclassname}();
|
virtual ~${cppsinglemainlistenerclassname}();
|
||||||
|
|
||||||
|
|
||||||
bool Handle(const BJsonEvent& event);
|
bool Handle(const BJsonEvent& event);
|
||||||
${cpprootmodelclassname}* Target();
|
${cpprootmodelclassname}* Target();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
${cpprootmodelclassname}* fTarget;
|
${cpprootmodelclassname}* fTarget;
|
||||||
};
|
};
|
||||||
@@ -1227,7 +1251,6 @@ private:
|
|||||||
it is parsed from the bulk container. When the stream is
|
it is parsed from the bulk container. When the stream is
|
||||||
finished, the Complete() method is invoked.
|
finished, the Complete() method is invoked.
|
||||||
|
|
||||||
|
|
||||||
Note that the item object will be deleted after the Handle method
|
Note that the item object will be deleted after the Handle method
|
||||||
is invoked. The Handle method need not take responsibility
|
is invoked. The Handle method need not take responsibility
|
||||||
for deleting the item itself.
|
for deleting the item itself.
|
||||||
@@ -1258,10 +1281,8 @@ public:
|
|||||||
${cppitemlistenerclassname}* itemListener);
|
${cppitemlistenerclassname}* itemListener);
|
||||||
~${cppbulkcontainermainlistenerclassname}();
|
~${cppbulkcontainermainlistenerclassname}();
|
||||||
|
|
||||||
|
|
||||||
bool Handle(const BJsonEvent& event);
|
bool Handle(const BJsonEvent& event);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
${cppitemlistenerclassname}* fItemListener;
|
${cppitemlistenerclassname}* fItemListener;
|
||||||
};
|
};
|
||||||
@@ -1280,6 +1301,7 @@ private:
|
|||||||
|
|
||||||
writerootstackedlistenerinterface(istate)
|
writerootstackedlistenerinterface(istate)
|
||||||
writegeneralstackedlistenerinterface(istate)
|
writegeneralstackedlistenerinterface(istate)
|
||||||
|
writestringliststackedlistenerinterface(istate)
|
||||||
writestackedlistenerinterface(istate, schema)
|
writestackedlistenerinterface(istate, schema)
|
||||||
|
|
||||||
if supportbulkcontainer:
|
if supportbulkcontainer:
|
||||||
@@ -1289,6 +1311,7 @@ private:
|
|||||||
|
|
||||||
writerootstackedlistenerimplementation(istate)
|
writerootstackedlistenerimplementation(istate)
|
||||||
writegeneralstackedlistenerimplementation(istate)
|
writegeneralstackedlistenerimplementation(istate)
|
||||||
|
writestringliststackedlistenerimplementation(istate)
|
||||||
writestackedlistenerimplementation(istate, schema)
|
writestackedlistenerimplementation(istate, schema)
|
||||||
|
|
||||||
if supportbulkcontainer:
|
if supportbulkcontainer:
|
||||||
|
|||||||
@@ -1041,19 +1041,19 @@ Model::_NotifyCategoryListChanged()
|
|||||||
|
|
||||||
|
|
||||||
/*! This method will find the stored 'DepotInfo' that correlates to the
|
/*! This method will find the stored 'DepotInfo' that correlates to the
|
||||||
supplied 'url' and will invoke the mapper function in order to get a
|
supplied 'identifier' and will invoke the mapper function in order
|
||||||
replacement for the 'DepotInfo'. The 'url' is a unique identifier
|
to get a replacement for the 'DepotInfo'. The 'identifier' holds
|
||||||
for the repository that holds across mirrors.
|
across mirrors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
Model::ReplaceDepotByUrl(const BString& URL, DepotMapper* depotMapper,
|
Model::ReplaceDepotByIdentifier(const BString& identifier,
|
||||||
void* context)
|
DepotMapper* depotMapper, void* context)
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < fDepots.CountItems(); i++) {
|
for (int32 i = 0; i < fDepots.CountItems(); i++) {
|
||||||
DepotInfo depotInfo = fDepots.ItemAtFast(i);
|
DepotInfo depotInfo = fDepots.ItemAtFast(i);
|
||||||
|
|
||||||
if (RepositoryUrlUtils::EqualsNormalized(URL, depotInfo.URL())) {
|
if (identifier == depotInfo.URL()) {
|
||||||
BAutolock locker(&fLock);
|
BAutolock locker(&fLock);
|
||||||
fDepots.Replace(i, depotMapper->MapDepot(depotInfo, context));
|
fDepots.Replace(i, depotMapper->MapDepot(depotInfo, context));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,8 +147,8 @@ public:
|
|||||||
GetWebAppInterface() const
|
GetWebAppInterface() const
|
||||||
{ return fWebAppInterface; }
|
{ return fWebAppInterface; }
|
||||||
|
|
||||||
void ReplaceDepotByUrl(
|
void ReplaceDepotByIdentifier(
|
||||||
const BString& URL,
|
const BString& identifier,
|
||||||
DepotMapper* depotMapper,
|
DepotMapper* depotMapper,
|
||||||
void* context);
|
void* context);
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,12 @@
|
|||||||
#define B_TRANSLATION_CONTEXT "ServerRepositoryDataUpdateProcess"
|
#define B_TRANSLATION_CONTEXT "ServerRepositoryDataUpdateProcess"
|
||||||
|
|
||||||
|
|
||||||
|
struct repository_and_repository_source {
|
||||||
|
DumpExportRepository* repository;
|
||||||
|
DumpExportRepositorySource* repositorySource;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*! This repository listener (not at the JSON level) is feeding in the
|
/*! This repository listener (not at the JSON level) is feeding in the
|
||||||
repositories as they are parsed and processing them. Processing
|
repositories as they are parsed and processing them. Processing
|
||||||
includes finding the matching depot record and coupling the data
|
includes finding the matching depot record and coupling the data
|
||||||
@@ -43,6 +49,9 @@ public:
|
|||||||
|
|
||||||
virtual DepotInfo MapDepot(const DepotInfo& depot, void *context);
|
virtual DepotInfo MapDepot(const DepotInfo& depot, void *context);
|
||||||
virtual bool Handle(DumpExportRepository* item);
|
virtual bool Handle(DumpExportRepository* item);
|
||||||
|
void Handle(repository_and_repository_source& pair);
|
||||||
|
void Handle(const BString& identifier,
|
||||||
|
repository_and_repository_source& pair);
|
||||||
virtual void Complete();
|
virtual void Complete();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -73,12 +82,6 @@ DepotMatchingRepositoryListener::~DepotMatchingRepositoryListener()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct repository_and_repository_source {
|
|
||||||
DumpExportRepository* repository;
|
|
||||||
DumpExportRepositorySource* repositorySource;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*! This is invoked as a result of logic in 'Handle(..)' that requests that the
|
/*! This is invoked as a result of logic in 'Handle(..)' that requests that the
|
||||||
model call this method with the requested DepotInfo instance.
|
model call this method with the requested DepotInfo instance.
|
||||||
*/
|
*/
|
||||||
@@ -104,7 +107,8 @@ DepotMatchingRepositoryListener::MapDepot(const DepotInfo& depot, void *context)
|
|||||||
modifiedDepotInfo.Name().String(),
|
modifiedDepotInfo.Name().String(),
|
||||||
modifiedDepotInfo.URL().String(),
|
modifiedDepotInfo.URL().String(),
|
||||||
repositorySourceCode->String(),
|
repositorySourceCode->String(),
|
||||||
repositoryAndRepositorySource->repositorySource->Url()->String());
|
repositoryAndRepositorySource
|
||||||
|
->repositorySource->Identifier()->String());
|
||||||
} else {
|
} else {
|
||||||
printf("[DepotMatchingRepositoryListener] associated depot [%s] with "
|
printf("[DepotMatchingRepositoryListener] associated depot [%s] with "
|
||||||
"server repository source [%s]\n",
|
"server repository source [%s]\n",
|
||||||
@@ -116,6 +120,33 @@ DepotMatchingRepositoryListener::MapDepot(const DepotInfo& depot, void *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DepotMatchingRepositoryListener::Handle(const BString& identifier,
|
||||||
|
repository_and_repository_source& pair)
|
||||||
|
{
|
||||||
|
if (!identifier.IsEmpty()) {
|
||||||
|
fModel->ReplaceDepotByIdentifier(identifier, this, &pair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DepotMatchingRepositoryListener::Handle(repository_and_repository_source& pair)
|
||||||
|
{
|
||||||
|
Handle(*(pair.repositorySource->Identifier()), pair);
|
||||||
|
|
||||||
|
// there may be additional identifiers for the remote repository and
|
||||||
|
// these should also be taken into consideration.
|
||||||
|
|
||||||
|
for(int32 i = 0;
|
||||||
|
i < pair.repositorySource->CountExtraIdentifiers();
|
||||||
|
i++)
|
||||||
|
{
|
||||||
|
Handle(*(pair.repositorySource->ExtraIdentifiersItemAt(i)), pair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DepotMatchingRepositoryListener::Handle(DumpExportRepository* repository)
|
DepotMatchingRepositoryListener::Handle(DumpExportRepository* repository)
|
||||||
{
|
{
|
||||||
@@ -126,14 +157,7 @@ DepotMatchingRepositoryListener::Handle(DumpExportRepository* repository)
|
|||||||
repositoryAndRepositorySource.repository = repository;
|
repositoryAndRepositorySource.repository = repository;
|
||||||
repositoryAndRepositorySource.repositorySource =
|
repositoryAndRepositorySource.repositorySource =
|
||||||
repository->RepositorySourcesItemAt(i);
|
repository->RepositorySourcesItemAt(i);
|
||||||
|
Handle(repositoryAndRepositorySource);
|
||||||
BString* repoInfoURL = repositoryAndRepositorySource
|
|
||||||
.repositorySource->RepoInfoUrl();
|
|
||||||
|
|
||||||
if (!repoInfoURL->IsEmpty()) {
|
|
||||||
fModel->ReplaceDepotByUrl(*repoInfoURL, this,
|
|
||||||
&repositoryAndRepositorySource);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return !fStoppable->WasStopped();
|
return !fStoppable->WasStopped();
|
||||||
|
|||||||
@@ -26,11 +26,16 @@
|
|||||||
"code": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"url": {
|
"identifier": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"javaType": "java.lang.String"
|
||||||
},
|
},
|
||||||
"repoInfoUrl": {
|
"extraIdentifiers": {
|
||||||
"type": "string"
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"javaType": "java.lang.String"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"repositorySourceMirrors": {
|
"repositorySourceMirrors": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -37,11 +37,12 @@
|
|||||||
" \"repositorySources\": [\n" \
|
" \"repositorySources\": [\n" \
|
||||||
" {\n" \
|
" {\n" \
|
||||||
" \"code\": \"haikuports_x86_64\",\n" \
|
" \"code\": \"haikuports_x86_64\",\n" \
|
||||||
" \"url\": \"http://example.com/0\"\n" \
|
" \"identifier\": \"haiku:hpkr:haikuports_x86_64\",\n" \
|
||||||
|
" \"extraIdentifiers\":[\"zing\"]\n" \
|
||||||
" },\n" \
|
" },\n" \
|
||||||
" {\n" \
|
" {\n" \
|
||||||
" \"code\": \"haikuports_x86_gcc2\",\n" \
|
" \"code\": \"haikuports_x86_gcc2\",\n" \
|
||||||
" \"url\": \"http://example.com/1\"\n" \
|
" \"identifier\": \"haiku:hpkr:haikuports_x86_gcc2\"\n" \
|
||||||
" }\n" \
|
" }\n" \
|
||||||
" ]\n" \
|
" ]\n" \
|
||||||
"}\n"
|
"}\n"
|
||||||
@@ -67,7 +68,8 @@
|
|||||||
" \"repositorySources\": [\n" \
|
" \"repositorySources\": [\n" \
|
||||||
" {\n" \
|
" {\n" \
|
||||||
" \"code\": \"fatelk_x86_gcc2\",\n" \
|
" \"code\": \"fatelk_x86_gcc2\",\n" \
|
||||||
" \"url\": \"http://coquillemartialarts.com/fatelk/repo\"\n" \
|
" \"identifier\": \"can-be-anything\",\n" \
|
||||||
|
" \"extraIdentifiers\":[\"zing\"]\n" \
|
||||||
" }\n" \
|
" }\n" \
|
||||||
" ]\n" \
|
" ]\n" \
|
||||||
" },\n" \
|
" },\n" \
|
||||||
@@ -78,7 +80,7 @@
|
|||||||
" \"repositorySources\": [\n" \
|
" \"repositorySources\": [\n" \
|
||||||
" {\n" \
|
" {\n" \
|
||||||
" \"code\": \"besly_x86_gcc2\",\n" \
|
" \"code\": \"besly_x86_gcc2\",\n" \
|
||||||
" \"url\": \"http://software.besly.de/repo\"\n" \
|
" \"identifier\": \"haiku:hpkr:wojfqdi23e\"\n" \
|
||||||
" }\n" \
|
" }\n" \
|
||||||
" ]\n" \
|
" ]\n" \
|
||||||
" },\n" \
|
" },\n" \
|
||||||
@@ -89,11 +91,11 @@
|
|||||||
" \"repositorySources\": [\n" \
|
" \"repositorySources\": [\n" \
|
||||||
" {\n" \
|
" {\n" \
|
||||||
" \"code\": \"clasqm_x86_64\",\n" \
|
" \"code\": \"clasqm_x86_64\",\n" \
|
||||||
" \"url\": \"http://8ABA\"\n" \
|
" \"identifier\": \"haiku:hpkr:23r829rro\"\n" \
|
||||||
" },\n" \
|
" },\n" \
|
||||||
" {\n" \
|
" {\n" \
|
||||||
" \"code\": \"clasqm_x86_gcc2\",\n" \
|
" \"code\": \"clasqm_x86_gcc2\",\n" \
|
||||||
" \"url\": \"http://8D0B\"\n" \
|
" \"identifier\": \"haiku:hpkr:joihir32r\"\n" \
|
||||||
" }\n" \
|
" }\n" \
|
||||||
" ]\n" \
|
" ]\n" \
|
||||||
" },\n" \
|
" },\n" \
|
||||||
@@ -105,11 +107,11 @@
|
|||||||
" \"repositorySources\": [\n" \
|
" \"repositorySources\": [\n" \
|
||||||
" {\n" \
|
" {\n" \
|
||||||
" \"code\": \"haikuports_x86_64\",\n" \
|
" \"code\": \"haikuports_x86_64\",\n" \
|
||||||
" \"url\": \"http://B362\"\n" \
|
" \"identifier\": \"haiku:hpkr:jqod2333r3r\"\n" \
|
||||||
" },\n" \
|
" },\n" \
|
||||||
" {\n" \
|
" {\n" \
|
||||||
" \"code\": \"haikuports_x86_gcc2\",\n" \
|
" \"code\": \"haikuports_x86_gcc2\",\n" \
|
||||||
" \"url\": \"http://8AF3\"\n" \
|
" \"identifier\": \"haiku:hpkr:wyeuhfwiewe\"\n" \
|
||||||
" }\n" \
|
" }\n" \
|
||||||
" ]\n" \
|
" ]\n" \
|
||||||
" }\n" \
|
" }\n" \
|
||||||
@@ -172,10 +174,12 @@ DumpExportRepositoryJsonListenerTest::TestBulkContainer()
|
|||||||
BString("fatelk besly clasqm haikuports"),
|
BString("fatelk besly clasqm haikuports"),
|
||||||
itemListener.ConcatenatedCodes());
|
itemListener.ConcatenatedCodes());
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("!ConcatenatedSourcesUrls",
|
CPPUNIT_ASSERT_EQUAL_MESSAGE("!ConcatenatedSourcesUrls",
|
||||||
BString("http://coquillemartialarts.com/fatelk/repo"
|
BString("can-be-anything"
|
||||||
" http://software.besly.de/repo"
|
" haiku:hpkr:wojfqdi23e"
|
||||||
" http://8ABA http://8D0B"
|
" haiku:hpkr:23r829rro"
|
||||||
" http://B362 http://8AF3"),
|
" haiku:hpkr:joihir32r"
|
||||||
|
" haiku:hpkr:jqod2333r3r"
|
||||||
|
" haiku:hpkr:wyeuhfwiewe"),
|
||||||
itemListener.ConcatenatedSourcesUrls());
|
itemListener.ConcatenatedSourcesUrls());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,10 +223,11 @@ DumpExportRepositoryJsonListenerTest::TestSingle()
|
|||||||
repository->RepositorySourcesItemAt(1);
|
repository->RepositorySourcesItemAt(1);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(BString("haikuports_x86_64"), *(source0->Code()));
|
CPPUNIT_ASSERT_EQUAL(BString("haikuports_x86_64"), *(source0->Code()));
|
||||||
CPPUNIT_ASSERT_EQUAL(BString("http://example.com/0"), *(source0->Url()));
|
CPPUNIT_ASSERT_EQUAL(BString("haiku:hpkr:haikuports_x86_64"), *(source0->Identifier()));
|
||||||
|
CPPUNIT_ASSERT_EQUAL(BString("zing"), *(source0->ExtraIdentifiersItemAt(0)));
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(BString("haikuports_x86_gcc2"), *(source1->Code()));
|
CPPUNIT_ASSERT_EQUAL(BString("haikuports_x86_gcc2"), *(source1->Code()));
|
||||||
CPPUNIT_ASSERT_EQUAL(BString("http://example.com/1"), *(source1->Url()));
|
CPPUNIT_ASSERT_EQUAL(BString("haiku:hpkr:haikuports_x86_gcc2"), *(source1->Identifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -276,7 +281,7 @@ TestBulkContainerItemListener::Handle(DumpExportRepository* item)
|
|||||||
fConcatenatedSourcesUrl.Append(" ");
|
fConcatenatedSourcesUrl.Append(" ");
|
||||||
|
|
||||||
fConcatenatedSourcesUrl.Append(
|
fConcatenatedSourcesUrl.Append(
|
||||||
item->RepositorySourcesItemAt(i)->Url()->String());
|
item->RepositorySourcesItemAt(i)->Identifier()->String());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -308,4 +313,4 @@ bool
|
|||||||
TestBulkContainerItemListener::WasCompleteInvoked()
|
TestBulkContainerItemListener::WasCompleteInvoked()
|
||||||
{
|
{
|
||||||
return fWasCompleteInvoked;
|
return fWasCompleteInvoked;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user