当前位置: 首页>>代码示例>>Java>>正文


Java SchemaViolationException类代码示例

本文整理汇总了Java中javax.naming.directory.SchemaViolationException的典型用法代码示例。如果您正苦于以下问题:Java SchemaViolationException类的具体用法?Java SchemaViolationException怎么用?Java SchemaViolationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SchemaViolationException类属于javax.naming.directory包,在下文中一共展示了SchemaViolationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeUserSchema

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Mock a managed LDAP schema violation
 */
@Test
public void removeUserSchema() {
	thrown.expect(ValidationJsonException.class);
	thrown.expect(MatcherUtil.validationMatcher("groups", "last-member-of-group"));
	final GroupLdapRepository groupRepository = new GroupLdapRepository() {
		@Override
		public GroupOrg findById(final String name) {
			// The group has only the user user we want to remove
			return new GroupOrg("dc=" + name, name, Collections.singleton("flast1"));
		}

	};
	groupRepository.setLdapCacheRepository(Mockito.mock(LdapCacheRepository.class));

	final LdapTemplate ldapTemplate = Mockito.mock(LdapTemplate.class);
	groupRepository.setTemplate(ldapTemplate);
	Mockito.doThrow(new org.springframework.ldap.SchemaViolationException(new SchemaViolationException("any"))).when(ldapTemplate)
			.modifyAttributes(ArgumentMatchers.any(LdapName.class), ArgumentMatchers.any());
	removeUser(groupRepository);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:24,代码来源:GroupLdapRepositoryTest.java

示例2: rename

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void rename(Name nOld, Name nNew) throws NamingException {
    if (nOld == null || nNew == null) {
        throw new NullPointerException();
    }

    if (nOld.size() == 0 || nNew.size() == 0) {
        // ldap.3A=Can't rename empty name
        throw new InvalidNameException(Messages.getString("ldap.3A")); //$NON-NLS-1$
    }

    if (nOld.size() > 1 || nNew.size() > 1) {
        // ldap.3B=Can't rename across contexts
        throw new InvalidNameException(Messages.getString("ldap.3B")); //$NON-NLS-1$
    }
    // ldap.39=Can't rename schema
    throw new SchemaViolationException(Messages.getString("ldap.39")); //$NON-NLS-1$
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:LdapSchemaContextImpl.java

示例3: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcShortQuery4MessageContent operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
    long mid = operation.messageId();
    TitanFTMDb.BasicClient client = dbConnectionState.client();
    Vertex m;
    try {
        logger.debug("Short Query 4 called on message id: {}", mid);
        m = client.getVertex(mid, "Comment");
        if (m==null)
            m = client.getVertex(mid, "Post");

        String content = m.getProperty("content");
        if (content.length() == 0)
            content = m.getProperty("imageFile");
        LdbcShortQuery4MessageContentResult res = new LdbcShortQuery4MessageContentResult(
                content,(Long)m.getProperty("creationDate"));

        resultReporter.report(1, res, operation);
    } catch (SchemaViolationException e) {
    e.printStackTrace();
    resultReporter.report(-1, null, operation);
}

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:25,代码来源:LdbcShortQuery4Handler.java

示例4: getVertices

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Gets the specified vertices or null if no such vertex is found
 *
 * @param label     vertex type label
 * @param limit     int value limiting the result. use Integer.MAX_VALUE for unlimited
 * @param pValueMap PropertyKey->Value map
 * @return the specified vertices or null if no such vertex is found
 */
public Iterable<Vertex> getVertices(String label, Map<String, String> pValueMap, int limit) throws SchemaViolationException {
    Integer suffix = s.getVertexTypes().get(label);
    Set<Vertex> res = new HashSet<>();
    if (suffix == null)
        throw new SchemaViolationException(label + " vertex type is not defined in the schema for " + s.getClass().getSimpleName());
    GraphQuery gq = g.query();
    for (String property : pValueMap.keySet())
        gq = gq.has(property, pValueMap.get(property));
    if (limit != Integer.MAX_VALUE)
        gq = gq.limit(limit);

    for (Vertex v : gq.vertices())
        if ((((Long) v.getId()) % mult) == suffix)
            res.add(v);

    return res;
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:26,代码来源:TitanFTMDb.java

示例5: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate5AddForumMembership operation, TitanFTMDb.BasicDbConnectionState dbConnectionState, ResultReporter reporter) throws DbException {

    TitanFTMDb.BasicClient client = dbConnectionState.client();

    try {
        Vertex forum = client.getVertex(operation.forumId(), "Forum");
        Vertex person = client.getVertex(operation.personId(), "Person");
        if (forum==null)
            logger.error("Forum membership requested for nonexistent forum id {}", operation.forumId());
        if (person==null)
            logger.error("Forum membership requested for nonexistent person {}", operation.personId());

        Map<String, Object> props = new HashMap<>(1);
        props.put("joinDate", operation.joinDate().getTime());
        client.addEdge(forum, person, "hasMember", props);

    } catch (SchemaViolationException e) {
        logger.error("invalid vertex label requested by query update");
        e.printStackTrace();
    }

    reporter.report(0, LdbcNoResult.INSTANCE,operation);
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:25,代码来源:LdbcQueryU5Handler.java

示例6: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate8AddFriendship operation, TitanFTMDb.BasicDbConnectionState dbConnectionState, ResultReporter reporter) throws DbException {

    TitanFTMDb.BasicClient client = dbConnectionState.client();
    try {

        Map<String, Object> props = new HashMap<>(1);
        props.put("creationDate", operation.creationDate().getTime());
        Vertex person = client.getVertex(operation.person1Id(), "Person");
        Vertex friend = client.getVertex(operation.person2Id(), "Person");
        client.addEdge(person, friend, "knows", props);

    } catch (SchemaViolationException e) {
        logger.error("invalid vertex label requested by query update");
        e.printStackTrace();
    }

    reporter.report(0, LdbcNoResult.INSTANCE, operation);
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:20,代码来源:LdbcQueryU8Handler.java

示例7: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate2AddPostLike operation, TitanFTMDb.BasicDbConnectionState dbConnectionState, ResultReporter reporter) throws DbException {

    TitanFTMDb.BasicClient client = dbConnectionState.client();

    try {
        Vertex person = client.getVertex(operation.personId(), "Person");
        Vertex post = client.getVertex(operation.postId(), "Post");
        Map<String, Object> props = new HashMap<>(1);
        props.put("creationDate", operation.creationDate().getTime());
        client.addEdge(person, post, "likes", props);

    } catch (SchemaViolationException e) {
        logger.error("invalid vertex label requested by query update");
        e.printStackTrace();
    }

    reporter.report(0, LdbcNoResult.INSTANCE,operation);
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:20,代码来源:LdbcQueryU2Handler.java

示例8: getFoF

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Given a person, returns the set of friends and friends of friends
 * , excluding that person
 *
 * @param rootId personID to start from
 * @param client TitanFTMDb.BasicClient to use for root retrieval
 * @return Set<Vertex> of the persons friends and their friends
 */
public Set<Vertex> getFoF(long rootId, TitanFTMDb.BasicClient client) {
    Set<Vertex> res = new HashSet<>();
    Vertex root = null;
    try {
        root = client.getVertex(rootId, "Person");
    } catch (SchemaViolationException e) {
        e.printStackTrace();
    }

    GremlinPipeline<Vertex, Vertex> gp = (new GremlinPipeline<Vertex, Vertex>(root));
    gp.out("knows").aggregate(res)
            .out("knows").aggregate(res).iterate();
    res.remove(root);
    return res;
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:24,代码来源:QueryUtils.java

示例9: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcShortQuery1PersonProfile operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
    List<LdbcQuery1Result> result = new ArrayList<>();
    long person_id = operation.personId();
    TitanFTMDb.BasicClient client = dbConnectionState.client();
    final Vertex root;
    try {
        root = client.getVertex(person_id, "Person");
        logger.debug("Short Query 1 called on person id: {}", person_id);

        Vertex cityV = QueryUtils.getPersonCity(root);
        LdbcShortQuery1PersonProfileResult res = new LdbcShortQuery1PersonProfileResult(
                (String) root.getProperty("firstName"),(String) root.getProperty("lastName"),
                (Long) root.getProperty("birthday"), (String) root.getProperty("locationIP"),
                (String) root.getProperty("browserUsed"),client.getVLocalId((Long)cityV.getId()), (String) root.getProperty("gender"),
                (Long) root.getProperty("creationDate"));

        resultReporter.report(result.size(), res, operation);
    } catch (SchemaViolationException e) {
    e.printStackTrace();
    resultReporter.report(-1, null, operation);
}

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:25,代码来源:LdbcShortQuery1Handler.java

示例10: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate3AddCommentLike operation, TitanFTMDb.BasicDbConnectionState dbConnectionState, ResultReporter reporter) throws DbException {

    TitanFTMDb.BasicClient client = dbConnectionState.client();

    try {
        Vertex person = client.getVertex(operation.personId(), "Person");
        Vertex post = client.getVertex(operation.commentId(), "Comment");
        Map<String, Object> props = new HashMap<>(1);
        props.put("creationDate", operation.creationDate().getTime());
        client.addEdge(person, post, "likes", props);

    } catch (SchemaViolationException e) {
        logger.error("invalid vertex label requested by query update");
        e.printStackTrace();
    }


    reporter.report(0, LdbcNoResult.INSTANCE,operation);
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:21,代码来源:LdbcQueryU3Handler.java

示例11: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcShortQuery5MessageCreator operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
    long mid = operation.messageId();
    TitanFTMDb.BasicClient client = dbConnectionState.client();
    Vertex m;
    try {
        logger.debug("Short Query 5 called on message id: {}", mid);
        m = client.getVertex(mid, "Comment");
        if (m==null)
            m = client.getVertex(mid, "Post");

        GremlinPipeline<Vertex,Vertex> gp = new GremlinPipeline<>(m);
        Vertex person = gp.out("hasCreator").next();
        LdbcShortQuery5MessageCreatorResult res = new LdbcShortQuery5MessageCreatorResult(
                    client.getVLocalId((Long)person.getId()),
                    (String) person.getProperty("firstName"),(String) person.getProperty("lastName"));
        resultReporter.report(1, res, operation);

    } catch (SchemaViolationException e) {
    e.printStackTrace();
    resultReporter.report(-1, null, operation);
}

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:25,代码来源:LdbcShortQuery5Handler.java

示例12: importData

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public boolean importData(File dir) throws IOException, SchemaViolationException {
    //Based upon http://s3.thinkaurelius.com/docs/titan/current/bulk-loading.html
    //Enabled the storage.batch-loading configuration option in bdb.conf
    //Disabled automatic type creation by setting schema.default=none in bdb.conf
    //Using a local variation of BatchLoad https://github.com/tinkerpop/blueprints/wiki/Batch-Implementation

    logger.debug("entered import data, dir is: {}", dir.getAbsolutePath() );
    if (!dir.isDirectory())
        return false;

    WorkLoadSchema s = this.workload.getSchema();
    Map<String, String> vpMap = s.getVPFileMap();
    Map<String, String> eMap = s.getEFileMap();

    TypedBatchGraph bgraph = new TypedBatchGraph(g, VertexIDType.NUMBER, 10000);
    bgraph.setVertexIdKey(IdGraph.ID);

    loadVertices(bgraph, dir, s.getVertexTypes().keySet());
    loadVertexProperties(bgraph, dir, vpMap);
    loadEdges(bgraph, dir, eMap);
    logger.debug("completed import data");
    return true;


}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:27,代码来源:TitanImporter.java

示例13: removeUserNotMember

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Mock a managed LDAP schema violation
 */
@Test
public void removeUserNotMember() {
	final GroupLdapRepository groupRepository = newGroupLdapRepository();
	final LdapTemplate ldapTemplate = Mockito.mock(LdapTemplate.class);
	groupRepository.setTemplate(ldapTemplate);
	Mockito.doThrow(new org.springframework.ldap.SchemaViolationException(new SchemaViolationException("any"))).when(ldapTemplate)
			.modifyAttributes(ArgumentMatchers.any(LdapName.class), ArgumentMatchers.any());
	removeUser(groupRepository);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:13,代码来源:GroupLdapRepositoryTest.java

示例14: createSubcontext

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public DirContext createSubcontext(Name name, Attributes attributes)
        throws NamingException {
    int size = name.size();
    Hashtable<String, Object> subSchemaTree = doLookup(name
            .getPrefix(size - 1), size - 1);

    if (null == attributes || attributes.size() == 0) {
        // jndi.8D=Must supply attributes describing schema
        throw new SchemaViolationException(Messages.getString("jndi.8D")); //$NON-NLS-1$
    }

    if (level - size == 2) {
        // jndi.8E=Cannot create new entry under schema root
        throw new SchemaViolationException(Messages.getString("jndi.8E")); //$NON-NLS-1$
    }

    String subSchemaType = name.getSuffix(size - 1).toString();

    if (subSchemaTree.get(subSchemaType.toLowerCase()) != null) {
        throw new NameAlreadyBoundException(subSchemaType);
    }

    String schemaLine = SchemaParser.format(attributes);

    ModifyOp op = new ModifyOp(ldapContext.subschemasubentry);
    Name modifySchemaName = name.getPrefix(size - 1).addAll(rdn);
    BasicAttribute schemaEntry = new LdapAttribute(new BasicAttribute(
            jndi2ldap(modifySchemaName.toString()), schemaLine), ldapContext);
    op.addModification(OperationJndi2Ldap[DirContext.ADD_ATTRIBUTE],
            new LdapAttribute(schemaEntry, ldapContext));
    try {
        doBasicOperation(op);
        subSchemaTree.put(subSchemaType.toLowerCase(), schemaLine);
    } catch (ReferralException e) {
        // TODO
    }

    return (DirContext) lookup(name);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:41,代码来源:LdapSchemaContextImpl.java

示例15: validateVHeader

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Validates the file header against the schema used by the importer
 *
 * @param s      schema to validate against
 * @param vLabel vertex type to validate against
 * @param header header of csv file
 * @return suffix of this vertex
 */
private short validateVHeader(WorkLoadSchema s, String vLabel, String[] header) throws SchemaViolationException {
    Set<String> props = s.getVertexProperties().get(vLabel);
    if (props == null)
        throw new SchemaViolationException("No properties found for the vertex label " + vLabel);

    if (!header[0].equals("id") && !header[0].endsWith(".id"))
        throw new SchemaViolationException("First column of " + vLabel
                + " is not labeled 'id', but:" + header[0]);

    for (String col : header) {
        if (col.equals("id") || col.endsWith(".id"))
            continue;

        if (!props.contains(col)) {
            /*
            This is a due to the fact that Titan has
            global property keys and language has SINGLE
            cardinality for Post.language and LIST cardinality
            in Person.language.
            */
            if (col.equals("language") && props.contains("lang"))
                continue;
            else
                throw new SchemaViolationException("Unknown property for vertex Type" + vLabel
                        + ", found " + col + " expected " + props);
        }


        if (s.getVPropertyClass(vLabel, col) == null)
            throw new SchemaViolationException("Class definition missing for " + vLabel + "." + col);
    }

    return typeMultMap.get(vLabel).shortValue();

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:44,代码来源:TitanImporter.java


注:本文中的javax.naming.directory.SchemaViolationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。