List of usage examples for java.util UUID fromString
public static UUID fromString(String name)
From source file:org.openlmis.fulfillment.web.FtpTransferPropertiesControllerIntegrationTest.java
@Override FtpTransferProperties generateProperties() { FtpTransferProperties ftp = new FtpTransferProperties(); ftp.setId(UUID.randomUUID()); ftp.setFacilityId(UUID.fromString(FACILITY_ID)); ftp.setProtocol(FTP);/*from w w w.j a v a 2 s .c o m*/ ftp.setServerHost("host"); ftp.setServerPort(21); ftp.setRemoteDirectory("remote/dir"); ftp.setLocalDirectory("local/dir"); ftp.setUsername("username"); ftp.setPassword("password"); ftp.setPassiveMode(true); return ftp; }
From source file:org.brekka.stillingar.example.FieldTypesXmlBeansTest.java
/** * /* w w w .jav a2s . co m*/ */ private void verify() throws Exception { ConfiguredFieldTypes t = configuredFieldTypes; assertEquals(new URI(testing.getAnyURI()), t.getUri()); assertEquals(testing.getBoolean(), t.isBooleanPrimitive()); assertEquals(Byte.valueOf(testing.getByte()), t.getByteValue()); assertEquals(testing.getByte(), t.getBytePrimitive()); assertEquals(testing.getDate(), t.getDateAsCalendar()); assertEquals(testing.getDate().getTime(), t.getDateAsDate()); assertEquals(testing.getDateTime(), t.getDateTimeAsCalendar()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsDate()); assertEquals(testing.getDecimal(), t.getDecimal()); assertEquals(Double.valueOf(testing.getDouble()), t.getDoubleValue()); assertEquals(testing.getDouble(), t.getDoublePrimitive(), 1d); assertEquals(testing.getFloat(), t.getFloatPrimitive(), 1f); assertEquals(Float.valueOf(testing.getFloat()), t.getFloatValue()); assertEquals(testing.getInt(), t.getIntPrimitive()); assertEquals(Integer.valueOf(testing.getInt()), t.getIntValue()); assertEquals(testing.getLanguage(), t.getLanguage().toString()); assertEquals(testing.getLong(), t.getLongPrimitive()); assertEquals(Long.valueOf(testing.getLong()), t.getLongValue()); assertEquals(testing.getShort(), t.getShortPrimitive()); assertEquals(Short.valueOf(testing.getShort()), t.getShortValue()); assertEquals(testing.getString(), t.getString()); assertEquals(testing.getTime(), t.getTimeAsCalendar()); assertEquals(testing.getPeriod().toString(), t.getPeriod().toString()); assertEquals(new DateTime(testing.getDateTime(), ISOChronology.getInstance()), t.getDateTime()); assertEquals(new LocalDate(testing.getDate(), ISOChronology.getInstance()), t.getLocalDate()); assertEquals(new LocalTime(testing.getTime(), ISOChronology.getInstance()), t.getLocalTime()); assertTrue(Arrays.equals(t.getBinary(), testing.getBinary())); assertEquals(UUID.fromString(testing.getUUID()), t.getUuid()); assertTrue(t.getTestingObject() instanceof Testing); assertNotNull(t.getTestingElement()); assertNotNull(t.getRoot()); }
From source file:edu.purdue.cybercenter.dm.service.VocabularyService.java
private Map<String, List<Term>> getChangedTerms(Vocabulary vocabulary) { edu.purdue.cybercenter.dm.domain.Vocabulary latestDbVocabulary = findLatestByUuid( UUID.fromString(vocabulary.getUuid())); Vocabulary latestVocabulary;//from ww w . j a v a2 s . co m if (latestDbVocabulary != null) { latestVocabulary = dbVocabularyToVocabulary(latestDbVocabulary); } else { latestVocabulary = null; } List<Term> newTerms = new ArrayList<>(); List<Term> updatedTerms = new ArrayList<>(); List<Term> deletedTerms = new ArrayList<>(); if (latestVocabulary != null) { // existing vocabulary // figure out new and updated terms for (Term term : vocabulary.getTerms().getTerm()) { boolean isNew = true; boolean isUpdated = true; for (Term latestTerm : latestVocabulary.getTerms().getTerm()) { if (latestTerm.getUuid().equals(term.getUuid())) { isNew = false; if (VocabularyUtils.isSame(latestTerm, term)) { isUpdated = false; } } } if (isNew) { newTerms.add(term); } else if (isUpdated) { updatedTerms.add(term); } } // figure out deleted terms for (Term latestTerm : latestVocabulary.getTerms().getTerm()) { boolean exist = false; for (Term term : vocabulary.getTerms().getTerm()) { if (latestTerm.getUuid().equals(term.getUuid())) { exist = true; break; } } if (!exist) { deletedTerms.add(latestTerm); } } } else { // new vocabulary newTerms.addAll(vocabulary.getTerms().getTerm()); } Map<String, List<Term>> changedTerms = new HashMap<>(); changedTerms.put(KEY_TERMS_NEW, newTerms); changedTerms.put(KEY_TERMS_UPDATED, updatedTerms); changedTerms.put(KEY_TERMS_DELETED, deletedTerms); return changedTerms; }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmXMsgRqstHandler.CFCrmXMsgRqstSecUserDeleteByIdIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/* w ww. j av a 2 s. c om*/ // Common XML Attributes String attrId = null; String attrSecUserId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstSecUserDeleteByIdIdx"); CFCrmXMsgRqstHandler xmsgRqstHandler = (CFCrmXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFCrmSchemaObj 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("SecUserId")) { if (attrSecUserId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecUserId = 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 ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecUserId"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types UUID natSecUserId; natSecUserId = UUID.fromString(attrSecUserId); // Delete the objects schemaObj.getSecUserTableObj().deleteSecUserByIdIdx(natSecUserId); String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSecUserMessageFormatter.formatSecUserRspnDeleted() + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:org.trustedanalytics.user.orgs.OrgsController.java
@ApiOperation(value = "Deletes organization.", notes = "Privilege level: Consumer of this endpoint must have a valid token containing " + "cloud_controller.admin scope") @ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "Organization not found."), @ApiResponse(code = 500, message = "Internal server error, e.g. error connecting to CloudController") }) @RequestMapping(value = GENERAL_ORGS_URL + "/{org}", method = DELETE) public void deleteOrg(@PathVariable String org) { ccClient.deleteOrg(UUID.fromString(org)); }
From source file:org.trustedanalytics.user.orgs.SpacesController.java
@ApiOperation(value = "Deletes space.", notes = "Privilege level: Consumer of this endpoint must be a member of organization the specified" + " space is part of, with OrgManager role, based on valid access token") @ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "Space not found."), @ApiResponse(code = 500, message = "Internal server error, e.g. error connecting to CloudController") }) @RequestMapping(value = GET_ALL_SPACES_URL + "/{space}", method = DELETE) public void deleteSpace(@PathVariable String space) { ccClient.deleteSpace(UUID.fromString(space)); }
From source file:org.acoustid.server.util.ParameterMap.java
public String[] getUUIDStringArray(String name) throws MissingParameterException, ParameterFormatException { String[] values = getStringArray(name); try {//from ww w . j av a2 s.c o m for (int i = 0; i < values.length; i++) { UUID.fromString(values[i]); } } catch (IllegalArgumentException ex) { throw new ParameterFormatException("Parameter '" + name + "' is not a valid UUID", ex); } return values; }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmXMsgRqstHandler.CFCrmXMsgRqstSecDeviceDeleteByUserIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/* w ww . j a v a2 s. c o m*/ // Common XML Attributes String attrId = null; String attrSecUserId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstSecDeviceDeleteByUserIdx"); CFCrmXMsgRqstHandler xmsgRqstHandler = (CFCrmXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFCrmSchemaObj 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("SecUserId")) { if (attrSecUserId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecUserId = 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 ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecUserId"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types UUID natSecUserId; natSecUserId = UUID.fromString(attrSecUserId); // Delete the objects schemaObj.getSecDeviceTableObj().deleteSecDeviceByUserIdx(natSecUserId); String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSecDeviceMessageFormatter.formatSecDeviceRspnDeleted() + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:org.brekka.stillingar.example.FieldTypesDOMTest.java
/** * /*from www . j a v a 2 s. c om*/ */ private void verify() throws Exception { ConfiguredFieldTypes t = configuredFieldTypes; assertEquals(new URI(testing.getAnyURI()), t.getUri()); assertEquals(testing.getBoolean(), t.isBooleanPrimitive()); assertEquals(Byte.valueOf(testing.getByte()), t.getByteValue()); assertEquals(testing.getByte(), t.getBytePrimitive()); assertEquals(testing.getDate().getTime(), t.getDateAsCalendar().getTime()); assertEquals(testing.getDate().getTime(), t.getDateAsDate()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsCalendar().getTime()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsDate()); assertEquals(testing.getDecimal(), t.getDecimal()); assertEquals(Double.valueOf(testing.getDouble()), t.getDoubleValue()); assertEquals(testing.getDouble(), t.getDoublePrimitive(), 1d); assertEquals(testing.getFloat(), t.getFloatPrimitive(), 1f); assertEquals(Float.valueOf(testing.getFloat()), t.getFloatValue()); assertEquals(testing.getInt(), t.getIntPrimitive()); assertEquals(Integer.valueOf(testing.getInt()), t.getIntValue()); assertEquals(testing.getLanguage(), t.getLanguage().toString()); assertEquals(testing.getLong(), t.getLongPrimitive()); assertEquals(Long.valueOf(testing.getLong()), t.getLongValue()); assertEquals(testing.getShort(), t.getShortPrimitive()); assertEquals(Short.valueOf(testing.getShort()), t.getShortValue()); assertEquals(testing.getString(), t.getString()); assertEquals(testing.getPeriod().toString(), t.getPeriod().toString()); assertEquals(new DateTime(testing.getDateTime()).toString(), t.getDateTime().toString()); assertEquals(new LocalDate(testing.getDate()).toString(), t.getLocalDate().toString()); assertEquals(new LocalTime(testing.getTime()).toString(), t.getLocalTime().toString()); assertEquals(String.format("%tT", testing.getTime()), String.format("%tT", t.getTimeAsCalendar().getTime())); assertTrue(Arrays.equals(t.getBinary(), testing.getBinary())); assertEquals(UUID.fromString(testing.getUUID()), t.getUuid()); assertNotNull(t.getTestingElement()); assertNotNull(t.getRoot()); }
From source file:org.brekka.stillingar.example.FieldTypesJAXBTest.java
/** * /*from w w w .ja va 2 s . c om*/ */ private void verify() throws Exception { ConfiguredFieldTypes t = configuredFieldTypes; assertEquals(new URI(testing.getAnyURI()), t.getUri()); assertEquals(testing.getBoolean(), t.isBooleanPrimitive()); assertEquals(Byte.valueOf(testing.getByte()), t.getByteValue()); assertEquals(testing.getByte(), t.getBytePrimitive()); assertEquals(testing.getDate().getTime(), t.getDateAsCalendar().getTime()); assertEquals(testing.getDate().getTime(), t.getDateAsDate()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsCalendar().getTime()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsDate()); assertEquals(testing.getDecimal(), t.getDecimal()); assertEquals(Double.valueOf(testing.getDouble()), t.getDoubleValue()); assertEquals(testing.getDouble(), t.getDoublePrimitive(), 1d); assertEquals(testing.getFloat(), t.getFloatPrimitive(), 1f); assertEquals(Float.valueOf(testing.getFloat()), t.getFloatValue()); assertEquals(testing.getInt(), t.getIntPrimitive()); assertEquals(Integer.valueOf(testing.getInt()), t.getIntValue()); assertEquals(testing.getLanguage(), t.getLanguage().toString()); assertEquals(testing.getLong(), t.getLongPrimitive()); assertEquals(Long.valueOf(testing.getLong()), t.getLongValue()); assertEquals(testing.getShort(), t.getShortPrimitive()); assertEquals(Short.valueOf(testing.getShort()), t.getShortValue()); assertEquals(testing.getString(), t.getString()); assertEquals(testing.getPeriod().toString(), t.getPeriod().toString()); assertEquals(new DateTime(testing.getDateTime()).toString(), t.getDateTime().toString()); assertEquals(new LocalDate(testing.getDate()).toString(), t.getLocalDate().toString()); assertEquals(new LocalTime(testing.getTime()).toString(), t.getLocalTime().toString()); assertEquals(String.format("%tT", testing.getTime()), String.format("%tT", t.getTimeAsCalendar().getTime())); assertTrue(Arrays.equals(t.getBinary(), testing.getBinary())); assertEquals(UUID.fromString(testing.getUUID()), t.getUuid()); assertNotNull(t.getTestingObject() instanceof org.brekka.stillingar.example.Configuration.Testing); assertNotNull(t.getTestingElement()); assertNotNull(t.getRoot()); }