Ejemplo n.º 1
0
def Run(prefix, ns):
    try:
        try:
            commit = 0
            #Get the repository by logging in
            repo = SmartLogin()
            model = repo.getModel()
            user = repo.getCurrentUser().getAbsolutePath()
            user = RepoPathToUri(user)
            stmts = model.complete(user, DASHBOARD_NS+"ns-mappings", None)
            if stmts:
                nsm_res = repo.fetchResource(stmts[0].object)
                nsm_res.xUpdate(ADD_NS_MAP_XUPDATE%locals())
                commit = 1
            else:
                print "No namespace mapping defined for this user"
        finally:
            try:
                if commit:
                    repo.txCommit()
                else:
                    repo.txRollback()
            except:
                pass

    except FtServerClientException, e:
        print e
def Run(path):
    try:
        try:
            commit = 0
            #Get the repository by logging in
            repo = SmartLogin()
            model = repo.getModel()
            user = repo.getCurrentUser().getAbsolutePath()
            user = RepoPathToUri(user)
            stmts = model.complete(user, DASHBOARD_NS+"ns-mappings", None)
            if not stmts:
                new_doc = repo.createDocument(
                    path, NS_MAPPING_TEMPLATE, imt='text/xml',
                    forcedType=ResourceTypes.ResourceType.XML_DOCUMENT)
                #container = new_doc.getParent().getAbsolutePath()
                #print container
                stmt = Statement(user, DASHBOARD_NS + "ns-mappings", path,
                                 scope=path)
                model.add(stmt)
                commit = 1
            else:
                print "This user already has a namespace mapping file: ", stmts[0].object
                
        finally:
            try:
                if commit:
                    repo.txCommit()
                else:
                    repo.txRollback()
            except:
                pass

    except FtServerClientException, e:
        print e
Ejemplo n.º 3
0
def Run():
    #user_name = raw_input("4SS superuser name: ")
    #passwdHash = sha.new(getpass.getpass("Password for %s: " % user_name)).hexdigest()
    print "In the following prompts, just hit enter if the given defaults are OK."
    container_name = raw_input("Name for the container to create [web]: ")
    if not container_name: container_name = 'web'
    server_port = raw_input("Port on which to host the HTTP server [8080]: ")
    if not server_port: server_port = '8080'
    server_name = raw_input("Brief name to identify the server [4ss]: ")
    if not server_name: server_name = '4ss'
    contact = raw_input("Contact e-mail address to display in case of error [root@localhost]: ")
    if not contact: contact = 'root@localhost'
    server_doc = SERVER_FILE%locals()

    try:
        try:
            commit = 0
            #Get the repository by logging in
            repo = SmartLogin()
            #repo = Core.GetRepository(user_name, passwdHash, 'localhost', 8803)
            cont = repo.createContainer('/' + container_name)
            cont.setAcl(AclConstants.WRITE_ACCESS, AclConstants.USERS_GROUP_NAME, AclConstants.ALLOWED)
            cont.setAcl(AclConstants.READ_ACCESS, AclConstants.USERS_GROUP_NAME, AclConstants.ALLOWED)
            cont.setAcl(AclConstants.READ_ACCESS, AclConstants.WORLD_GROUP_NAME, AclConstants.ALLOWED)
            doc = repo.createDocument('/' + container_name + '/server.xml',
                                      server_doc,
                                      imt='text/xml',
                                      docDef=None,
                                      forcedType=ResourceTypes.ResourceType.SERVER)
            commit = 1
        finally:
            try:
                if commit:
                    repo.txCommit()
                else:
                    repo.txRollback()
            except:
                pass

    except FtServerClientException, e:
        print e