use of java.text.ParseException in project Openfire by igniterealtime.
the class SimpleSession method contactSubscribed.
// private Request prepareNotifyRequest(Dialog dialog, SimplePresence simplePresence) throws ParseException {
// Request request = prepareNotifyRequest(dialog);
// request.setContent(simplePresence.toXML(), headerFactory.createContentTypeHeader("application", "pidf+xml"));
//
// return request;
// }
public void contactSubscribed(String targetSipAddress) {
try {
// Roster roster = getTransport().getRosterManager().getRoster(getJID().getNode());
JID contactJID = getTransport().convertIDToJID(targetSipAddress);
// RosterItem item = roster.getRosterItem(contactJID);
Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed: Preparing presence packet...");
Presence presence = new Presence();
presence.setFrom(contactJID);
presence.setTo(getJID());
presence.setType(Presence.Type.subscribed);
getTransport().sendPacket(presence);
Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed: Presence packet sent ==> \n" + presence.toXML());
// Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed: Synchronizing SIP user roster...");
// String rosteruserid = ((SimpleTransport) transport).convertJIDToID(item.getJid());
// if (myRoster.getEntry(rosteruserid) == null) {
// SimpleBuddy simpleRosterItem = new SimpleBuddy(rosteruserid, item.getNickname(), 1L);
// myRoster.addEntry(rosteruserid, simpleRosterItem);
// }
// Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed: Finished synchronizing SIP user roster.");
// syncContactGroups(contact, item.getGroups());
} catch (Exception e) {
Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed: Exception occured when adding pending contact " + targetSipAddress, e);
// JID contactJID = getTransport().convertIDToJID(targetSipAddress);
}
}
use of java.text.ParseException in project Smack by igniterealtime.
the class TranscriptsProvider method parseAgents.
private List<Transcripts.AgentDetail> parseAgents(XmlPullParser parser) throws IOException, XmlPullParserException {
List<Transcripts.AgentDetail> agents = new ArrayList<Transcripts.AgentDetail>();
String agentJID = null;
Date joinTime = null;
Date leftTime = null;
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("agentJID")) {
agentJID = parser.nextText();
} else if (parser.getName().equals("joinTime")) {
try {
synchronized (UTC_FORMAT) {
joinTime = UTC_FORMAT.parse(parser.nextText());
}
} catch (ParseException e) {
}
} else if (parser.getName().equals("leftTime")) {
try {
synchronized (UTC_FORMAT) {
leftTime = UTC_FORMAT.parse(parser.nextText());
}
} catch (ParseException e) {
}
} else if (parser.getName().equals("agent")) {
agentJID = null;
joinTime = null;
leftTime = null;
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("agents")) {
done = true;
} else if (parser.getName().equals("agent")) {
agents.add(new Transcripts.AgentDetail(agentJID, joinTime, leftTime));
}
}
}
return agents;
}
use of java.text.ParseException in project ZhihuDailyPurify by izzyleung.
the class DateHeaderAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(HeaderViewHolder viewHolder, int position) {
Calendar calendar = Calendar.getInstance();
try {
calendar.setTime(Constants.Dates.simpleDateFormat.parse(newsList.get(position).getDate()));
calendar.add(Calendar.DAY_OF_YEAR, -1);
} catch (ParseException ignored) {
}
viewHolder.title.setText(dateFormat.format(calendar.getTime()));
}
use of java.text.ParseException in project ZhihuDailyPurify by izzyleung.
the class SingleDayNewsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
Fragment newFragment = new NewsListFragment();
String dateString = bundle.getString(Constants.BundleKeys.DATE);
Calendar calendar = Calendar.getInstance();
try {
Date date = Constants.Dates.simpleDateFormat.parse(dateString);
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_YEAR, -1);
} catch (ParseException ignored) {
}
//noinspection ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(DateFormat.getDateInstance().format(calendar.getTime()));
bundle.putString(Constants.BundleKeys.DATE, dateString);
bundle.putBoolean(Constants.BundleKeys.IS_FIRST_PAGE, isSameDay(calendar, Calendar.getInstance()));
bundle.putBoolean(Constants.BundleKeys.IS_SINGLE, true);
newFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_frame, newFragment).commit();
}
use of java.text.ParseException in project Openfire by igniterealtime.
the class IQQueryHandler method retrieveMessages.
/**
* Retrieve messages matching query request from server archive
* @param queryRequest
* @return
*/
private Collection<ArchivedMessage> retrieveMessages(QueryRequest queryRequest) {
String withField = null;
String startField = null;
String endField = null;
DataForm dataForm = queryRequest.getDataForm();
if (dataForm != null) {
if (dataForm.getField("with") != null) {
withField = dataForm.getField("with").getFirstValue();
}
if (dataForm.getField("start") != null) {
startField = dataForm.getField("start").getFirstValue();
}
if (dataForm.getField("end") != null) {
endField = dataForm.getField("end").getFirstValue();
}
}
Date startDate = null;
Date endDate = null;
try {
if (startField != null) {
startDate = xmppDateTimeFormat.parseString(startField);
}
if (endField != null) {
endDate = xmppDateTimeFormat.parseString(endField);
}
} catch (ParseException e) {
Log.error("Error parsing query date filters.", e);
}
return getPersistenceManager(queryRequest.getArchive()).findMessages(startDate, endDate, queryRequest.getArchive().toBareJID(), withField, queryRequest.getResultSet());
}
Aggregations