Beispiel #1
0
MojErr MojDbPutHandler::validateWildcard(const MojString& val, MojErr errToThrow)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);

    if (val.empty())
        MojErrThrow(errToThrow);
    MojSize wildcardPos = val.find(_T('*'));
    if (wildcardPos != MojInvalidSize) {
        if (wildcardPos != val.length() - 1 ||
                (wildcardPos != 0 && val.at(wildcardPos - 1) != _T('.'))) {
            MojErrThrowMsg(errToThrow, _T("db: invalid wildcard in - '%s'"), val.data());
        }
    }
    return MojErrNone;
}
MojErr DeleteActivitiesCommand::GetActivityListResponse(MojObject& response, MojErr err)
{
	CommandTraceFunction();

	try {
		ResponseToException(response, err);

		MojObject activities;
		err = response.getRequired("activities", activities);
		ErrorToException(err);

		MojString creatorIdSubstring;
		err = creatorIdSubstring.assign("com.palm.imap");
		ErrorToException(err);

		BOOST_FOREACH(const MojObject& activity, DatabaseAdapter::GetArrayIterators(activities)) {
			MojObject activityId;
			err = activity.getRequired("activityId", activityId);
			ErrorToException(err);

			MojString name;
			err = activity.getRequired("name", name);
			ErrorToException(err);

			MojString creator;
			err = activity.getRequired("creator", creator);
			ErrorToException(err);

			// Check that the accountId and creator (com.palm.imap) are in the activity fields
			if(creator.find(creatorIdSubstring.data(), 0) != MojInvalidIndex
			&& ShouldDeleteActivity(activity)) {
				fprintf(stderr, "preparing to delete activity id=%s name=%s, creator=%s\n",
					AsJsonString(activityId).c_str(), name.data(), creator.data());
				m_deleteIds.push(activityId);
			}
		}

		DeleteActivities();
	} CATCH_AS_FAILURE