List of usage examples for java.util UUID equals
public boolean equals(Object obj)
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRqstHandler.CFGenKbXMsgRqstLogOutHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from ww w . j ava 2 s.c o m*/ // Common XML Attributes String attrId = null; // Request Attributes String attrSecSessionId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstLogOut"); CFGenKbXMsgRqstHandler xmsgRqstHandler = (CFGenKbXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SecSessionId")) { if (attrSecSessionId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecSessionId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrSecSessionId == null) || (attrSecSessionId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecSessionId"); } UUID secSessionId = UUID.fromString(attrSecSessionId); if (secSessionId == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "converted-secSessionId"); } if (schemaObj.getAuthorization() == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Already disconnected from the database"); } ICFGenKbSecSessionObj secSession = schemaObj.getSecSession(); if (secSession == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session does not exist for this schema"); } if (!secSessionId.equals(secSession.getRequiredSecSessionId())) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session id does not match the one established by this schema"); } if (secSession.getOptionalFinish() == null) { schemaObj.rollback(); schemaObj.beginTransaction(); ICFGenKbSecSessionEditObj editSecSession = secSession.beginEdit(); editSecSession.setOptionalFinish(Calendar.getInstance()); editSecSession.update(); editSecSession.endEdit(); schemaObj.commit(); } schemaObj.disconnect(false); schemaObj.setAuthorization(null); String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGenKbXMsgSchemaMessageFormatter.formatRspnLoggedOut("\n\t\t\t", secSessionId) + "\n" + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); ((CFGenKbXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRqstHandler.CFGCashXMsgRqstLogOutHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {//from ww w .j a v a2 s .c o m // Common XML Attributes String attrId = null; // Request Attributes String attrSecSessionId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstLogOut"); CFGCashXMsgRqstHandler xmsgRqstHandler = (CFGCashXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGCashSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SecSessionId")) { if (attrSecSessionId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecSessionId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrSecSessionId == null) || (attrSecSessionId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecSessionId"); } UUID secSessionId = UUID.fromString(attrSecSessionId); if (secSessionId == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "converted-secSessionId"); } if (schemaObj.getAuthorization() == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Already disconnected from the database"); } ICFGCashSecSessionObj secSession = schemaObj.getSecSession(); if (secSession == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session does not exist for this schema"); } if (!secSessionId.equals(secSession.getRequiredSecSessionId())) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session id does not match the one established by this schema"); } if (secSession.getOptionalFinish() == null) { schemaObj.rollback(); schemaObj.beginTransaction(); ICFGCashSecSessionEditObj editSecSession = secSession.beginEdit(); editSecSession.setOptionalFinish(Calendar.getInstance()); editSecSession.update(); editSecSession.endEdit(); schemaObj.commit(); } schemaObj.disconnect(false); schemaObj.setAuthorization(null); String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnLoggedOut("\n\t\t\t", secSessionId) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); ((CFGCashXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgRqstHandler.CFAsteriskXMsgRqstLogOutHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFAsteriskXMsgSchemaMessageFormatter schemaFormatter = null; try {// w w w .java 2s.c o m // Common XML Attributes String attrId = null; // Request Attributes String attrSecSessionId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstLogOut"); CFAsteriskXMsgRqstHandler xmsgRqstHandler = (CFAsteriskXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFAsteriskSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SecSessionId")) { if (attrSecSessionId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecSessionId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrSecSessionId == null) || (attrSecSessionId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecSessionId"); } UUID secSessionId = UUID.fromString(attrSecSessionId); if (secSessionId == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "converted-secSessionId"); } if (schemaObj.getAuthorization() == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Already disconnected from the database"); } ICFSecuritySecSessionObj secSession = schemaObj.getSecSession(); if (secSession == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session does not exist for this schema"); } if (!secSessionId.equals(secSession.getRequiredSecSessionId())) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session id does not match the one established by this schema"); } if (secSession.getOptionalFinish() == null) { schemaObj.rollback(); schemaObj.beginTransaction(); ICFSecuritySecSessionEditObj editSecSession = secSession.beginEdit(); editSecSession.setOptionalFinish(Calendar.getInstance()); editSecSession.update(); editSecSession.endEdit(); schemaObj.commit(); } schemaObj.disconnect(false); schemaObj.setAuthorization(null); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSchemaMessageFormatter.formatRspnLoggedOut("\n\t\t\t", secSessionId) + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFAsteriskXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { CFAsteriskXMsgRqstHandler xmsgRqstHandler = ((CFAsteriskXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFAsteriskXMsgRqstHandler xmsgRqstHandler = ((CFAsteriskXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxXMsgRqstHandler.CFEnSyntaxXMsgRqstLogOutHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from w w w . j a v a2 s . co m*/ // Common XML Attributes String attrId = null; // Request Attributes String attrSecSessionId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstLogOut"); CFEnSyntaxXMsgRqstHandler xmsgRqstHandler = (CFEnSyntaxXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFEnSyntaxSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SecSessionId")) { if (attrSecSessionId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecSessionId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrSecSessionId == null) || (attrSecSessionId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecSessionId"); } UUID secSessionId = UUID.fromString(attrSecSessionId); if (secSessionId == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "converted-secSessionId"); } if (schemaObj.getAuthorization() == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Already disconnected from the database"); } ICFEnSyntaxSecSessionObj secSession = schemaObj.getSecSession(); if (secSession == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session does not exist for this schema"); } if (!secSessionId.equals(secSession.getRequiredSecSessionId())) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session id does not match the one established by this schema"); } if (secSession.getOptionalFinish() == null) { schemaObj.rollback(); schemaObj.beginTransaction(); ICFEnSyntaxSecSessionEditObj editSecSession = secSession.beginEdit(); editSecSession.setOptionalFinish(Calendar.getInstance()); editSecSession.update(); editSecSession.endEdit(); schemaObj.commit(); } schemaObj.disconnect(false); schemaObj.setAuthorization(null); String response = CFEnSyntaxXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFEnSyntaxXMsgSchemaMessageFormatter.formatRspnLoggedOut("\n\t\t\t", secSessionId) + "\n" + CFEnSyntaxXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); ((CFEnSyntaxXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { String response = CFEnSyntaxXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFEnSyntaxXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFEnSyntaxXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFEnSyntaxXMsgRqstHandler xmsgRqstHandler = ((CFEnSyntaxXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFEnSyntaxXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFEnSyntaxXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFEnSyntaxXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFEnSyntaxXMsgRqstHandler xmsgRqstHandler = ((CFEnSyntaxXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_4.CFFreeSwitchXMsgRqstHandler.CFFreeSwitchXMsgRqstLogOutHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFFreeSwitchXMsgSchemaMessageFormatter schemaFormatter = null; try {// ww w .j a v a 2s.com // Common XML Attributes String attrId = null; // Request Attributes String attrSecSessionId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstLogOut"); CFFreeSwitchXMsgRqstHandler xmsgRqstHandler = (CFFreeSwitchXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFFreeSwitchSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SecSessionId")) { if (attrSecSessionId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecSessionId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrSecSessionId == null) || (attrSecSessionId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecSessionId"); } UUID secSessionId = UUID.fromString(attrSecSessionId); if (secSessionId == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "converted-secSessionId"); } if (schemaObj.getAuthorization() == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Already disconnected from the database"); } ICFSecuritySecSessionObj secSession = schemaObj.getSecSession(); if (secSession == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session does not exist for this schema"); } if (!secSessionId.equals(secSession.getRequiredSecSessionId())) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Security session id does not match the one established by this schema"); } if (secSession.getOptionalFinish() == null) { schemaObj.rollback(); schemaObj.beginTransaction(); ICFSecuritySecSessionEditObj editSecSession = secSession.beginEdit(); editSecSession.setOptionalFinish(Calendar.getInstance()); editSecSession.update(); editSecSession.endEdit(); schemaObj.commit(); } schemaObj.disconnect(false); schemaObj.setAuthorization(null); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFreeSwitchXMsgSchemaMessageFormatter.formatRspnLoggedOut("\n\t\t\t", secSessionId) + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFFreeSwitchXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { CFFreeSwitchXMsgRqstHandler xmsgRqstHandler = ((CFFreeSwitchXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFreeSwitchXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFFreeSwitchXMsgRqstHandler xmsgRqstHandler = ((CFFreeSwitchXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFreeSwitchXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:org.usergrid.tools.EntityIndexCleanup.java
private List<HColumn<ByteBuffer, ByteBuffer>> scanIndexForAllTypes(Keyspace ko, IndexBucketLocator indexBucketLocator, UUID applicationId, Object rowKey, UUID entityId, String prop) throws Exception { //TODO Determine the index bucket. Scan the entire index for properties with this entityId. DynamicComposite start = null;// www.j a v a2 s . co m List<HColumn<ByteBuffer, ByteBuffer>> cols; List<HColumn<ByteBuffer, ByteBuffer>> results = new ArrayList<HColumn<ByteBuffer, ByteBuffer>>(); do { cols = cass.getColumns(ko, ENTITY_INDEX, rowKey, start, null, 100, false); for (HColumn<ByteBuffer, ByteBuffer> col : cols) { DynamicComposite secondaryIndexValue = DynamicComposite.fromByteBuffer(col.getName().duplicate()); UUID storedId = (UUID) secondaryIndexValue.get(2); //add it to the set. We can't short circuit due to property ordering if (entityId.equals(storedId)) { results.add(col); } start = secondaryIndexValue; } } while (cols.size() == 100); return results; }
From source file:org.lealone.cluster.locator.TokenMetaData.java
/** * Store an end-point to host ID mapping. Each ID must be unique, and * cannot be changed after the fact.//from w ww. j a va 2s .co m * * @param hostId * @param endpoint */ public void updateHostId(UUID hostId, InetAddress endpoint) { assert hostId != null; assert endpoint != null; lock.writeLock().lock(); try { InetAddress storedEp = endpointToHostIdMap.inverse().get(hostId); if (storedEp != null) { if (!storedEp.equals(endpoint) && (FailureDetector.instance.isAlive(storedEp))) { throw new RuntimeException( String.format("Host ID collision between active endpoint %s and %s (id=%s)", storedEp, endpoint, hostId)); } } UUID storedId = endpointToHostIdMap.get(endpoint); if ((storedId != null) && (!storedId.equals(hostId))) logger.warn("Changing {}'s host ID from {} to {}", endpoint, storedId, hostId); endpointToHostIdMap.forcePut(endpoint, hostId); } finally { lock.writeLock().unlock(); } }
From source file:org.apache.usergrid.tools.UniqueIndexCleanup.java
private List<HColumn<ByteBuffer, ByteBuffer>> scanIndexForAllTypes(Keyspace ko, IndexBucketLocator indexBucketLocator, UUID applicationId, Object rowKey, UUID entityId, String prop) throws Exception { //TODO Determine the index bucket. Scan the entire index for properties with this entityId. DynamicComposite start = null;/*from w w w.ja v a2 s.c o m*/ List<HColumn<ByteBuffer, ByteBuffer>> cols; List<HColumn<ByteBuffer, ByteBuffer>> results = new ArrayList<HColumn<ByteBuffer, ByteBuffer>>(); do { cols = cass.getColumns(ko, ENTITY_INDEX, rowKey, start, null, 100, false); for (HColumn<ByteBuffer, ByteBuffer> col : cols) { DynamicComposite secondaryIndexValue = DynamicComposite.fromByteBuffer(col.getName().duplicate()); UUID storedId = (UUID) secondaryIndexValue.get(2); //add it to the set. We can't short circuit due to property ordering if (entityId.equals(storedId)) { results.add(col); } start = secondaryIndexValue; } } while (cols.size() == 100); return results; }
From source file:com.megster.cordova.ble.central.Peripheral.java
private BluetoothGattCharacteristic findWritableCharacteristic(BluetoothGattService service, UUID characteristicUUID, int writeType) { BluetoothGattCharacteristic characteristic = null; // get write property int writeProperty = BluetoothGattCharacteristic.PROPERTY_WRITE; if (writeType == BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE) { writeProperty = BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE; }/*from www . j a v a2 s.c o m*/ List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics(); for (BluetoothGattCharacteristic c : characteristics) { if ((c.getProperties() & writeProperty) != 0 && characteristicUUID.equals(c.getUuid())) { characteristic = c; break; } } // As a last resort, try and find ANY characteristic with this UUID, even if it doesn't have the correct properties if (characteristic == null) { characteristic = service.getCharacteristic(characteristicUUID); } return characteristic; }
From source file:org.apache.usergrid.tools.UniqueValueScanner.java
@Override public void runTool(CommandLine line) throws Exception { startSpring();/*from www . ja v a 2s .c o m*/ UUID appToFilter = null; if (!line.getOptionValue(APPLICATION_ARG).isEmpty()) { appToFilter = UUID.fromString(line.getOptionValue(APPLICATION_ARG)); } logger.info("Staring Tool: UniqueValueScanner"); logger.info("Using Cassandra consistency level: {}", System.getProperty("usergrid.read.cl", "CL_LOCAL_QUORUM")); keyspace = injector.getInstance(com.netflix.astyanax.Keyspace.class); mvccEntitySerializationStrategy = injector.getInstance(MvccEntitySerializationStrategy.class); uniqueValueSerializationStrategy = injector.getInstance(UniqueValueSerializationStrategy.class); String fieldType = line.getOptionValue(ENTITY_FIELD_TYPE_ARG) != null ? line.getOptionValue(ENTITY_FIELD_TYPE_ARG) : "name"; String entityType = line.getOptionValue(ENTITY_TYPE_ARG); String entityName = line.getOptionValue(ENTITY_NAME_ARG); AtomicInteger count = new AtomicInteger(0); if (entityName != null && !entityName.isEmpty()) { if (appToFilter == null) { throw new RuntimeException("Cannot execute UniqueValueScanner with specific entity without the " + "application UUID for which the entity should exist."); } if (entityType == null) { throw new RuntimeException("Cannot execute UniqueValueScanner without the entity type (singular " + "collection name)."); } logger.info("Running entity unique load only"); //do stuff w/o read repair UniqueValueSet uniqueValueSet = uniqueValueSerializationStrategy.load( new ApplicationScopeImpl(new SimpleId(appToFilter, "application")), ConsistencyLevel.valueOf(System.getProperty("usergrid.read.cl", "LOCAL_QUORUM")), entityType, Collections.singletonList(new StringField(fieldType, entityName)), false); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("["); uniqueValueSet.forEach(uniqueValue -> { String entry = "fieldName=" + uniqueValue.getField().getName() + ", fieldValue=" + uniqueValue.getField().getValue() + ", uuid=" + uniqueValue.getEntityId().getUuid() + ", type=" + uniqueValue.getEntityId().getType() + ", version=" + uniqueValue.getEntityVersion(); stringBuilder.append("{").append(entry).append("},"); }); stringBuilder.deleteCharAt(stringBuilder.length() - 1); stringBuilder.append("]"); logger.info("Returned unique value set from serialization load = {}", stringBuilder.toString()); } else { logger.info("Running entity unique scanner only"); // scan through all unique values and log some info Iterator<com.netflix.astyanax.model.Row<ScopedRowKey<TypeField>, EntityVersion>> rows = null; try { rows = keyspace.prepareQuery(CF_UNIQUE_VALUES) .setConsistencyLevel(com.netflix.astyanax.model.ConsistencyLevel .valueOf(System.getProperty("usergrid.read.cl", "CL_LOCAL_QUORUM"))) .getAllRows().withColumnRange(new RangeBuilder().setLimit(1000).build()).execute() .getResult().iterator(); } catch (ConnectionException e) { logger.error("Error connecting to cassandra", e); } UUID finalAppToFilter = appToFilter; if (rows != null) { rows.forEachRemaining(row -> { count.incrementAndGet(); if (count.get() % 1000 == 0) { logger.info("Scanned {} rows in {}", count.get(), CF_UNIQUE_VALUES.getName()); } final String fieldName = row.getKey().getKey().getField().getName(); final String fieldValue = row.getKey().getKey().getField().getValue().toString(); final String scopeType = row.getKey().getScope().getType(); final UUID scopeUUID = row.getKey().getScope().getUuid(); if (!fieldName.equalsIgnoreCase(fieldType) || (finalAppToFilter != null && !finalAppToFilter.equals(scopeUUID))) { // do nothing } else { // if we have more than 1 column, let's check for a duplicate if (row.getColumns() != null && row.getColumns().size() > 1) { final List<EntityVersion> values = new ArrayList<>(row.getColumns().size()); Iterator<Column<EntityVersion>> columns = row.getColumns().iterator(); columns.forEachRemaining(column -> { final EntityVersion entityVersion = column.getName(); logger.trace(scopeType + ": " + scopeUUID + ", " + fieldName + ": " + fieldValue + ", " + "entity type: " + entityVersion.getEntityId().getType() + ", " + "entity uuid: " + entityVersion.getEntityId().getUuid()); if (entityType != null && entityVersion.getEntityId().getType().equalsIgnoreCase(entityType)) { // add the first value into the list if (values.size() == 0) { values.add(entityVersion); } else { if (!values.get(0).getEntityId().getUuid() .equals(entityVersion.getEntityId().getUuid())) { values.add(entityVersion); logger.error( "Duplicate found for field [{}={}]. Entry 1: [{}], Entry 2: [{}]", fieldName, fieldValue, values.get(0).getEntityId(), entityVersion.getEntityId()); } } } }); } } }); } else { logger.warn("No rows returned from table: {}", CF_UNIQUE_VALUES.getName()); } } }