Package arq.cmd

Examples of arq.cmd.CmdException


        }
       
        Lang lang = selectLang(filename, Lang.NQUADS)
        LangHandler handler = dispatch.get(lang) ;
        if ( handler == null )
            throw new CmdException("Undefined language: "+lang) ;
       
        // If multiple files, choose the overall labels.
        if ( langHandlerOverall == null )
            langHandlerOverall = handler ;
        else
View Full Code Here


    // Subclass for specialised commands making common updates more convenient
    @Override
    protected void execUpdate(GraphStore graphStore)
    {
        if ( requestFiles.size() == 0 && getPositional().size() == 0 )
            throw new CmdException("Nothing to do") ;
       
        for ( Iterator<String> iter = requestFiles.iterator() ; iter.hasNext() ; )
        {
            String filename = iter.next();
            execOneFile(filename, graphStore) ;
View Full Code Here

    }
       
    @Override
    protected void processModulesAndArgs()
    {
        if ( !super.contains(argLocation) ) throw new CmdException("Required: --loc DIR") ;
//        if ( !super.contains(argTriplesOut) ) throw new CmdException("Required: --triples FILE") ;
//        if ( !super.contains(argQuadsOut) ) throw new CmdException("Required: --quads FILE") ;
       
        locationString   = super.getValue(argLocation) ;
        location = new Location(locationString) ;
View Full Code Here

        NodeTupleTable nodeTupleTableTriples = dsg.getTripleTable().getNodeTupleTable() ;
        NodeTupleTable nodeTupleTableQuads = dsg.getQuadTable().getNodeTupleTable() ;

        if ( nodeTupleTableTriples.getNodeTable() != nodeTupleTableQuads.getNodeTable() )
            throw new CmdException("Different node tables for triples and quads") ;

        NodeTable nodeTable = nodeTupleTableTriples.getNodeTable() ;
        // V special.
        Set<NodeTable> dumpedNodeTables = new HashSet<NodeTable> () ;
View Full Code Here

        // Two forms : with and without arg.
        // Maximises similarity with other tools.
        String file ;
       
        if ( ! super.contains(assemblerDescDecl) && getNumPositional() == 0 )
            throw new CmdException("No assembler description given") ;
       
        if ( super.contains(assemblerDescDecl) ) {
            if ( getValues(assemblerDescDecl).size() != 1 )
                throw new CmdException("Multiple assembler descriptions given via --desc") ;
            if ( getPositional().size() != 0 )
                throw new CmdException("Additional assembler descriptions given") ;
            file = getValue(assemblerDescDecl) ;
        } else {
            if ( getNumPositional() != 1 )
                throw new CmdException("Multiple assembler descriptions given as positional arguments") ;
            file = getPositionalArg(0) ;
        }
       
        if (file == null)
            throw new CmdException("No dataset specified") ;
        // Assumes a single test dataset description in the assembler file.
        Dataset ds = TextDatasetFactory.create(file) ;
        if (ds == null)
            throw new CmdException("No dataset description found") ;
        // get index.
        dataset = (DatasetGraphText)(ds.asDatasetGraph()) ;
        textIndex = dataset.getTextIndex() ;
        if (textIndex == null)
            throw new CmdException("Dataset has no text index") ;
        entityDefinition = textIndex.getDocDef() ;
    }
View Full Code Here

        if ( contains(argMemTDB) ) x++ ;

        if ( fusekiConfigFile != null )
        {
            if ( x > 1 )
                throw new CmdException("Dataset specificed on the command line and also a configuration file specificed.") ;
        }
        else
        {
            if ( x == 0 )
                throw new CmdException("Required: either --config=FILE or one of --mem, --file, --loc or --desc") ;
        }
       
        if ( contains(argMem) )
        {
            log.info("Dataset: in-memory") ;
            dsg = DatasetGraphFactory.createMem() ;
        }
        if ( contains(argFile) )
        {
            dsg = DatasetGraphFactory.createMem() ;
            // replace by RiotLoader after ARQ refresh.
            String filename = getValue(argFile) ;
            log.info("Dataset: in-memory: load file: "+filename) ;
            if ( ! FileOps.exists(filename) )
                throw new CmdException("File not found: "+filename) ;

            Lang language = RDFLanguages.filenameToLang(filename) ;
            if ( language == null )
                throw new CmdException("Can't guess language for file: "+filename) ;
            InputStream input = IO.openFile(filename) ;
           
            if ( RDFLanguages.isQuads(language) )
                RDFDataMgr.read(dsg, filename) ;
            else
                RDFDataMgr.read(dsg.getDefaultGraph(), filename) ;
        }
       
        if ( contains(argMemTDB) )
        {
            log.info("TDB dataset: in-memory") ;
            dsg = TDBFactory.createDatasetGraph() ;
        }
       
        if ( contains(argTDB) )
        {
            String dir = getValue(argTDB) ;
           
            if ( Lib.equal(dir, Names.memName) ) {
                log.info("TDB dataset: in-memory") ;
            } else {
                if ( ! FileOps.exists(dir) )
                    throw new CmdException("Directory not found: "+dir) ;
                log.info("TDB dataset: directory="+dir) ;
            }
            dsg = TDBFactory.createDatasetGraph(dir) ;
        }
       
        // Otherwise
        if ( contains(assemblerDescDecl) )
        {
            log.info("Dataset from assembler") ;
            Dataset ds = modDataset.createDataset() ;
            if ( ds != null )
                dsg = ds.asDatasetGraph() ;
        }
       
        if ( contains(argFusekiConfig) )
        {
            if ( dsg != null )
                throw new CmdException("Dataset specificed on the command line and also a configuration file specificed.") ;
            fusekiConfigFile = getValue(argFusekiConfig) ;
        }
       
        if ( contains(argPort) )
        {
            String portStr = getValue(argPort) ;
            try {
                port = Integer.parseInt(portStr) ;
            } catch (NumberFormatException ex)
            {
                throw new CmdException(argPort.getKeyName()+" : bad port number: "+portStr) ;
            }
        }
       
        if ( contains(argMgtPort) )
        {
            String mgtPortStr = getValue(argMgtPort) ;
            try {
                mgtPort = Integer.parseInt(mgtPortStr) ;
            } catch (NumberFormatException ex)
            {
                throw new CmdException(argMgtPort.getKeyName()+" : bad port number: "+mgtPortStr) ;
            }
        }

        if ( contains(argLocalhost) )
            listenLocal = true ;
           
        if ( fusekiConfigFile == null && dsg == null )
            throw new CmdException("No dataset defined and no configuration file: "+argUsage) ;
       
        if ( dsg != null )
        {
            if ( getPositional().size() == 0 )
                throw new CmdException("No dataset path name given") ;
            if ( getPositional().size() > )
                throw new CmdException("Multiple dataset path names given") ;
            datasetPath = getPositionalArg(0) ;
            if ( datasetPath.length() > 0 && ! datasetPath.startsWith("/") )
                throw new CmdException("Dataset path name must begin with a /: "+datasetPath) ;
           
            allowUpdate = contains(argAllowUpdate) ;
        }
       
        if ( contains(argTimeout) )
        {
            String str = getValue(argTimeout) ;
            ARQ.getContext().set(ARQ.queryTimeout, str) ;
        }
       
        if ( contains(argJettyConfig) )
        {
            jettyConfigFile = getValue(argJettyConfig) ;
            if ( !FileOps.exists(jettyConfigFile) )
                throw new CmdException("No such file: "+jettyConfigFile) ;
        }
       
        if ( contains(argBasicAuth) )
        {
            authConfigFile = getValue(argBasicAuth) ;
            if ( !FileOps.exists(authConfigFile) )
                throw new CmdException("No such file: " + authConfigFile) ;
        }
       
        if ( contains(argHome) )
        {
           List<String> args = super.getValues(argHome) ;
           homeDir = args.get(args.size()-1) ;
        }
       
        if ( contains(argPages) )
        {
           List<String> args = super.getValues(argPages) ;
           pagesDir = args.get(args.size()-1) ;
        }

        if ( contains(argGZip) )
        {
            if ( ! hasValueOfTrue(argGZip) && ! hasValueOfFalse(argGZip) )
                throw new CmdException(argGZip.getNames().get(0)+": Not understood: "+getValue(argGZip)) ;
            enableCompression = super.hasValueOfTrue(argGZip) ;
        }
       
        if ( contains(argUber) )
            SPARQLServer.überServlet = true ;
View Full Code Here

                    // Should use assembler inheritance but how do we assert the subclass relationship in a program?
                    thing = (Dataset)AssemblerUtils.build( modAssembler.getAssemblerFile(), DatasetAssemblerVocab.tDataset) ;
            }
            catch (JenaException ex)    { throw ex ; }
            catch (Exception ex)
            { throw new CmdException("Error creating", ex) ; }
            return thing ;
        }
       
        if ( modAssembler.getLocation() == null )
            throw new CmdException("No assembler file nor location provided") ;
       
        // No assembler - use location to find a database.
        Dataset ds = TDBFactory.createDataset(modAssembler.getLocation()) ;
        return ds ;
    }
View Full Code Here

   
    protected void exec()
    {
        Exec exec = dispatch.get(subCmd) ;
        if ( exec == null )
            throw new CmdException("No subcommand: "+subCmd) ;
        exec.exec(args) ;
    }
View Full Code Here

    }

    protected static String subCommand(String ... argv)
    {
        if ( argv.length == 0 )
            throw new CmdException("Missing subcommand") ;

        String subCmd = argv[0] ;
        if ( subCmd.startsWith("-") )
            throw new CmdException("Argument found where subcommand expected") ;
        return subCmd ;
    }
View Full Code Here

        NodeTupleTable nodeTupleTableTriples = dsg.getTripleTable().getNodeTupleTable() ;
        NodeTupleTable nodeTupleTableQuads = dsg.getQuadTable().getNodeTupleTable() ;

        if ( nodeTupleTableTriples.getNodeTable() != nodeTupleTableQuads.getNodeTable() )
            throw new CmdException("Different node tables for triples and quads") ;

        NodeTable nodeTable = nodeTupleTableTriples.getNodeTable() ;
        // V special.
        Set<NodeTable> dumpedNodeTables = new HashSet<>() ;
View Full Code Here

TOP

Related Classes of arq.cmd.CmdException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.