本文整理汇总了Java中org.javarosa.core.model.User.getUsername方法的典型用法代码示例。如果您正苦于以下问题:Java User.getUsername方法的具体用法?Java User.getUsername怎么用?Java User.getUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.User
的用法示例。
在下文中一共展示了User.getUsername方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildUserParser
import org.javarosa.core.model.User; //导入方法依赖的package包/类
private TransactionParser buildUserParser(KXmlParser parser) {
return new UserXmlParser(parser) {
@Override
protected void commit(User parsed) throws IOException, InvalidStructureException {
if (!parsed.getUserType().equals(User.TYPE_DEMO)) {
throw new InvalidStructureException(
"Demo user restore file must be for a user with user_type set to demo");
}
if ("".equals(parsed.getUsername()) || parsed.getUsername() == null) {
throw new InvalidStructureException(
"Demo user restore file must specify a username in the Registration block");
} else {
OfflineUserRestore.this.username = parsed.getUsername();
}
}
@Override
public User retrieve(String entityId) {
return null;
}
};
}
示例2: validateUser
import org.javarosa.core.model.User; //导入方法依赖的package包/类
/**
*
* After login button is clicked, activity asks form to validate user
*
* @return
*/
public boolean validateUser() {
boolean superUserLogin = false;
//#ifdef superuser-login.enable:defined
//#if superuser-login.enable
//# superUserLogin = true;
//#endif
//#endif
String usernameEntered = this.usernameField.getString().trim();
String passwordEntered = this.passwordField.getString().trim();
IStorageIterator ui = users.iterate();
while (ui.hasMore()) {
User u = (User)ui.nextRecord();
String xName = u.getUsername();
String xPass = u.getPasswordHash();
String xType = u.getUserType();
if ( (xName.equalsIgnoreCase(usernameEntered) ||
(superUserLogin && xType.equals(User.ADMINUSER)))
&& checkPassword(xPass, passwordEntered)) {
setLoggedInUser(u);
return true;
}
}
return false;
}
示例3: getCredential
import org.javarosa.core.model.User; //导入方法依赖的package包/类
private static String getCredential(User user, String domain) {
final String username;
if (domain != null) {
username = user.getUsername() + "@" + domain;
} else {
username = user.getUsername();
}
final String password = user.getCachedPwd();
return getCredential(username, password);
}
示例4: performCustomRestoreFromFile
import org.javarosa.core.model.User; //导入方法依赖的package包/类
public <I extends CommCareActivity & PullTaskResultReceiver> void performCustomRestoreFromFile(
I context,
File incomingRestoreFile) {
User u = CommCareApplication.instance().getSession().getLoggedInUser();
String username = u.getUsername();
LocalFilePullResponseFactory.setRequestPayloads(new File[]{incomingRestoreFile});
syncData(context, false, false, "fake-server-that-is-never-used", username, null, "unused",
LocalFilePullResponseFactory.INSTANCE, true);
}
示例5: ServerSyncState
import org.javarosa.core.model.User; //导入方法依赖的package包/类
public ServerSyncState (HttpCredentialProvider currentUserCredentials) {
send = new SendAllUnsentState () {
protected SendAllUnsentController getController () {
return new SendAllUnsentController(new CommCareHQResponder(PropertyManager._().getSingularProperty(JavaRosaPropertyRules.OPENROSA_API_LEVEL)), true, true, Localization.get("sync.unsent.cancel"));
}
public void done () {
throw new RuntimeException("method not applicable");
}
public void done(boolean errorsOccurred) {
if (errorsOccurred) {
System.out.println("debug: server sync: errors occurred during send-all-unsent");
onError(Localization.get("sync.send.fail"));
} else if(TransportService.getCachedMessagesSize() != 0) {
//cancelled
onError(Localization.get("sync.cancelled.sending"));
} else {
System.out.println("debug: server sync: send-all-unsent successful");
launchPull();
}
}
};
String syncToken = null;
User u = CommCareContext._().getUser();
if(u != null) {
syncToken = u.getLastSyncToken();
}
HttpAuthenticator auth = new HttpAuthenticator(CommCareUtil.wrapCredentialProvider(currentUserCredentials));
pull = new CommCareOTARestoreState (syncToken, auth, u.getUsername()) {
public void cancel() {
//when your credentials have changed, the ota restore credentials screen will pop up, so we
//do need to support canceling here.
ServerSyncState.this.onError(Localization.get("sync.cancelled"));
}
public void commitSyncToken(String token) {
if(token != null) {
User u = CommCareContext._().getUser();
u.setLastSyncToken(token);
try {
StorageManager.getStorage(User.STORAGE_KEY).write(u);
} catch (StorageFullException e) {
Logger.die("sync", e);
}
}
}
public void done(boolean errorsOccurred) {
if (errorsOccurred) {
System.out.println("debug: server sync: errors occurred during pull-down");
onError(Localization.get("sync.pull.fail"));
} else {
onSuccess(restoreDetailMsg(controller.getCaseTallies()));
}
}
};
}
示例6: loadEntity
import org.javarosa.core.model.User; //导入方法依赖的package包/类
public void loadEntity(User u) {
this.username = u.getUsername();
this.type = u.getUserType();
}
示例7: CommcareRequestGenerator
import org.javarosa.core.model.User; //导入方法依赖的package包/类
public CommcareRequestGenerator(User user) {
this(user.getUsername(), user.getCachedPwd(), user.getUserType(), user.getUniqueId());
}