Esempio n. 1
0
def main(q, i, p, params, tags):

    alkira = Alkira(p.api)

    params['result'] = alkira.updateUser(params['userguid'],
                                         name=params['name'],
                                         password=params['password'])
Esempio n. 2
0
def main(q, i, p, params, tags):
    q.logger.log('Creating user %s' % params['name'], 1)
    alkira = Alkira(p.api)
    user = alkira.createUser(login=params['login'],
                             password=params['password'],
                             name=params['name'])
    params['result'] = user
Esempio n. 3
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.updateBookmark(params['bookmarkguid'],
                          name=params['name'],
                          url=params['url'],
                          order=params['order'])

    params['result'] = True
Esempio n. 4
0
    def __init__(self, tasklets=list()):
        basedir = os.path.join(q.dirs.pyAppsDir, p.api.appname)
        self._authenticate = q.taskletengine.get(os.path.join(basedir, 'impl', 'authenticate'))
        self._authorize = q.taskletengine.get(os.path.join(basedir, 'impl', 'authorize'))

        self.tasklets = tasklets
        self.alkira = Alkira(p.api)
        self.connection = OsisDB().getConnection(p.api.appname)
Esempio n. 5
0
def main(q, i, p, params, tags):
    q.logger.log('Creating space %s' % params['name'], 1)
    alkira = Alkira(p.api)
    alkira.createProject(params['name'],
                         params['path'],
                         tagsList=params.get("tags", "").split(" "))

    params['result'] = True
Esempio n. 6
0
def main(q, i, p, params, tags):
    q.logger.log('Creating rule for %s with function %s and context %s' % \
        (params['groupguids'], params['function'], params['context']), 1)
    alkira = Alkira(p.api)
    alkira.assignRule(params['groupguids'], params['function'],
                      params['context'])

    params['result'] = True
Esempio n. 7
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    tags = params.get("tags")
    alkira.updateProject(params['projectguid'],
                         newname=params['name'],
                         path=params['path'],
                         tagsList=tags.split(" ") if tags else None)

    params['result'] = True
Esempio n. 8
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    result = alkira.findMacroConfig(space=params['space'],
                    page=params['page'],
                    macro=params['macro'],
                    configid=params['configid'],
                    username=params['username'],
                    exact_properties=params['exact_properties'])

    params['result'] = result
Esempio n. 9
0
def linkExists(link, client, currentSpace):
    linkparts = link.split("/")

    if isExternalLink(linkparts):
        return "EXTERNAL"

    lenLink = len(linkparts)

    if linkparts[0] in ("http:", "https:"):
        #['http:', '', '0.0.0.0', 'pyapp_name', '#', 'Admin', 'Home']
        if not (7 >= lenLink >= 6) or linkparts[4] != "#":
            return "INVALID"
        if lenLink == 7:
            appname, space, page = linkparts[3], linkparts[5], linkparts[6]
        else:
            appname, space, page = linkparts[3], linkparts[5], "Home"

    if linkparts[0] == '':
        #['', 'pyapp_name', '#', 'Admin', 'Home']
        if not (5 >= lenLink >= 4) or linkparts[2] != "#":
            return "INVALID"
        if lenLink == 5:
            appname, space, page = linkparts[1], linkparts[3], linkparts[4]
        else:
            appname, space, page = linkparts[1], linkparts[3], "Home"

    elif linkparts[0] == '#':
        #['#', 'Admin', 'Home']
        if not (3 >= lenLink >= 2):
            return "INVALID"
        appname = client.api.appname
        if lenLink == 3:
            space, page = linkparts[1:]
        else:
            space, page = linkparts[1], "Home"

    elif lenLink == 1:
        appname = client.api.appname
        space = currentSpace
        page = linkparts[0]

    elif isImageFile(linkparts[-1]):
        return "IMAGE"

    else:
        return "INVALID"

    if not q.manage.applicationserver.isRunning(appname):
        return "UNKNOWN"

    if appname != client.api.appname:
        client = Alkira(p.api)
    result = client.spaceExists(space) and client.pageExists(space, page)
    return "OK" if result else "MISSING"
Esempio n. 10
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    result = alkira.pageFind(name=params['name'],
                             space=params['space'],
                             category=params['category'],
                             parent=params['parent'],
                             tags=params['tags'],
                             order=params['order'],
                             title=params['title'],
                             exact_properties=params['exact_properties'])

    params['result'] = result
Esempio n. 11
0
def main(q, i, p, params, tags):
    q.logger.log('Creating space %s' % params['name'], 1)
    alkira = Alkira(p.api)
    space = alkira.createSpace(
        params['name'],
        params.get("tags", "").split(" "),
        params.get('repository'),
        params.get('repo_username'),
        params.get('repo_password'),
        order=params['order'] if params['order'] else 10000)

    params['result'] = space.guid
Esempio n. 12
0
def main(q, i, p, params, tags):

    alkira = Alkira(p.api)

    alkira.updateMacroConfig(
        space=params['space'],
        page=params['page'],
        macro=params['macro'],
        config=params['config'],
        username=params['username'],
        configid=params['configid'] if params['configid'] else None)

    params['result'] = True
Esempio n. 13
0
def main(q, i, p, params, tags):
    q.logger.log('Creating config %s/%s/%s/%s for user %s' %
        (params['space'], params['name'], params['macro'], params['configid'] if params['configid'] else "",
            params['username']), 1)
    
    alkira = Alkira(p.api)
    alkira.updateMacroConfig(space=params['space'],
                      page=params['page'],
                      macro=params['macro'],
                      config=params['config'],
                      configid=params['configid'] if params['configid'] else None,
                      username=params['username'])

    params['result'] = True
Esempio n. 14
0
def getInvalidLinks(spaces=None, pages=None, showValid=True):
    result = list()
    client = Alkira(p.api)

    if not spaces:
        spaces = client.listSpaces()

    for space in spaces:
        for page in client.listPages(space):
            if pages and (page not in pages):
                continue
            result += getPageReport(client,
                                    space,
                                    page,
                                    False,
                                    showValid=showValid)
    return result
Esempio n. 15
0
def main(q, i, p, params, tags):
    q.logger.log('Creating page %s/%s' % (params['space'], params['name']), 1)
    alkira = Alkira(p.api)
    parent = alkira.getPageByGUID(params["parent"]).name if params['parent'] else None
    for key in params:
        if type(params[key]) == unicode:
            params[key] = params[key].encode('utf-8')
    page = alkira.createPage(space=params['space'],
                      name=params['name'],
                      content=params['content'],
                      order=params['order'] if params['order'] else 10000,
                      title=params['title'] if params['title'] else params['name'],
                      tagsList=params.get('tags', '').split(" ") if params['tags'] else [],
                      category=params['category'],
                      parent=parent,
                      description=params['description'])
    if page:
        params['result'] = page.guid
    else:
        params['result'] = None
Esempio n. 16
0
def main(q, i, p, params, tags):
    tags = params["tags"].tags
    appname = p.api.appname
    client = Alkira(p.api)
    #
    pages = spaces = None
    showValid = True
    if "pages" in tags:
        pages = list(item.strip() for item in tags["pages"].split(","))
    if "spaces" in tags:
        if tags["spaces"] == "*":
            spaces = client.listSpaces()
        else:
            spaces = list(item.strip() for item in tags["spaces"].split(","))
    if "showvalid" in tags:
        showValid = (tags["showvalid"].lower() == "true")
    #
    if pages or spaces:
        result = getInvalidLinks(spaces, pages, showValid)
    else:
        result = getPageReport(client,
                               tags["space"],
                               tags["page"],
                               True,
                               showValid=showValid)
    html = "<TABLE><TR><TD>Page</TD><TD>URL</TD><TD>Status</TD></TR>"
    row = "<TR><TD>%s</TD><TD>%s</TD><TD>%s</TD></TR>"
    for item in result:
        parenturl = "/%s/#/%s" % (appname, item[0])
        if item[1] == "link":
            html += row % ("[%s](%s)" % (parenturl, parenturl), "[%s](%s)" %
                           (item[2], item[2]), item[3])
        elif item[1] == "macro":
            html += row % ("[%s](%s)" % (parenturl, parenturl), "[[%s]]" %
                           (item[2]), item[3])
    html += "</TABLE>"
    html = html.replace('\n#', '\n\#')
    html = html.replace('\n', '')
    params['result'] = "%s" % html
Esempio n. 17
0
def main(q, i, p, params, tags):

    alkira = Alkira(p.api)
    page = alkira.getPageByGUID(params['pageguid'])
    parent = alkira.getPageByGUID(
        params["parent"]).name if params['parent'] else None
    for key in params:
        if type(params[key]) == unicode:
            params[key] = params[key].encode('utf-8')
    alkira.updatePage(
        space=page.space,
        old_name=page.name,
        name=params['name'],
        content=params['content'],
        order=params['order'] if params['order'] else 10000,
        title=params['title'] if params['title'] else params['name'],
        tagsList=params.get('tags', '').split(" ") if params['tags'] else None,
        category=params['category'],
        parent=parent,
        description=params['description'])

    params['result'] = True
Esempio n. 18
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.deleteGroup(params['groupguid'])
    params['result'] = True
Esempio n. 19
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.deleteUserFromGroup(userguid=params['userguid'],
                               groupguid=params['groupguid'])
    params['result'] = True
Esempio n. 20
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.deleteSpace(params['spaceguid'])
    params['result'] = True
Esempio n. 21
0
def main(q, i, p, params, tags):
    q.logger.log('Creating bookmark %s - %s' % (params['name'], params['url']),
                 1)
    alkira = Alkira(p.api)
    alkira.createBookmark(params['name'], params['url'], params['order'])
    params['result'] = True
Esempio n. 22
0
def main(q, i, p, params, tags):  #pylint: disable=W0613
    children_str = ""

    macro_tags = params['tags'].tags

    space = macro_tags['space']
    page = macro_tags['page']
    depth = int(macro_tags.get('depth', '1'))
    root_page = macro_tags.get('root', page)

    appname = p.api.appname
    alkira_client = Alkira(p.api)

    all_pages_info = alkira_client.listPageInfo(space)
    all_pages_info = filter(lambda x: x['name'] != 'pagetree', all_pages_info)  #pylint: disable=W0141

    page_guid_dict = dict([(x['name'], x['guid']) for x in all_pages_info])
    page_parent_dict = dict([(x['name'], x['parent']) for x in all_pages_info])
    page_title_dict = dict([(x['name'], x['title']) for x in all_pages_info])
    page_order_dict = dict([(x['name'], x['order']) for x in all_pages_info])

    all_pages = [x['name'] for x in all_pages_info]

    if root_page != 'all':
        root_pages = [root_page]
    else:
        root_pages = [x['name'] for x in all_pages_info if not x['parent']]

    if (root_page != 'all') and (root_page not in all_pages):
        children_str = 'Page "%s" does not exist.' % root_page

    def getGuid(page_name):
        return page_guid_dict.get(page_name)

    def getParent(page_name):
        return page_parent_dict.get(page_name)

    def getTitle(page_name):
        title = page_title_dict.get(page_name)
        return title if title else ""

    def childPages(root, pages, tree, tree_depth):
        tree_depth -= 1
        children = {}
        root_guid = getGuid(root)

        for page in pages:
            page_parent = getParent(page)
            if root_guid == page_parent:
                children[page] = {}
        tree[root] = children
        if tree_depth > 0:
            for child in tree[root].keys():
                childPages(child, all_pages, tree[root], tree_depth)
        return tree

    values = []
    for each_root_page in root_pages:
        values.append(
            childPages(each_root_page, all_pages, {each_root_page: {}}, depth))

    def pageSorter(page1, page2):
        result = cmp(page_order_dict[page1], page_order_dict[page2])
        if result == 0:
            result = cmp(page_title_dict[page1], page_title_dict[page2])
        if result == 0:
            result = cmp(page1, page2)
        return result

    def treePrint(indent, value_dict, hide, children_string):
        if value_dict:
            for item in sorted(value_dict, cmp=pageSorter):
                if hide == True:
                    children_string = treePrint(0, value_dict[item], False,
                                                children_string)
                else:
                    page_title = getTitle(item).replace("_", "\_") or item
                    children_string += indent * ' ' + "* <a href='/" + appname + '/#/' + space + '/' + item + "'>" + page_title + '</a>  \n'
                    children_string = treePrint(indent + 4, value_dict[item],
                                                False, children_string)
        return children_string

    for each_value in values:
        if root_page == 'all':
            children_str = treePrint(0, each_value, False, children_str)
        else:
            children_str = treePrint(0, each_value, True, children_str)

    result = """
%s
- - -
    """ % (children_str)
    params['result'] = result
Esempio n. 23
0
def main(q, i, p, params, tags):
    from alkira import Alkira
    api = p.application.getAPI(params["appname"],
                               context=q.enumerators.AppContext.APPSERVER)
    alk = Alkira(api)
    alk.createDefaultRules()
Esempio n. 24
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.revokeRule(params['groupguids'], params['function'],
                      params['context'])
    params['result'] = True
Esempio n. 25
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.deleteMacroConfigByGUID(params['pageguid'])
    params['result'] = True
Esempio n. 26
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    tags = params.get("tags")
    alkira.updateSpace(params['spaceguid'], params['name'], tags.split(" ") if tags else None,
        order=params['order'] if params['order'] else 10000)
    params['result'] = True
Esempio n. 27
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.addUserToGroup(userguid=params['userguid'],
                          groupguid=params['groupguid'])
    params['result'] = True
Esempio n. 28
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.deleteUser(params['userguid'])
    params['result'] = True
Esempio n. 29
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.deleteBookmark(params['bookmarkguid'])
    params['result'] = True
Esempio n. 30
0
def main(q, i, p, params, tags):
    alkira = Alkira(p.api)
    alkira.deleteProject(params['projectguid'])
    params['result'] = True