当前位置: 首页>>代码示例>>Java>>正文


Java User.getUsername方法代码示例

本文整理汇总了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;
        }

    };
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:25,代码来源:OfflineUserRestore.java

示例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;

}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:37,代码来源:LoginForm.java

示例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);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:11,代码来源:HttpUtils.java

示例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);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:11,代码来源:FormAndDataSyncer.java

示例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()));
            }
        }
    };
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:62,代码来源:ServerSyncState.java

示例6: loadEntity

import org.javarosa.core.model.User; //导入方法依赖的package包/类
public void loadEntity(User u) {
    this.username = u.getUsername();
    this.type = u.getUserType();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:5,代码来源:UserEntity.java

示例7: CommcareRequestGenerator

import org.javarosa.core.model.User; //导入方法依赖的package包/类
public CommcareRequestGenerator(User user) {
    this(user.getUsername(), user.getCachedPwd(), user.getUserType(), user.getUniqueId());
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:4,代码来源:CommcareRequestGenerator.java


注:本文中的org.javarosa.core.model.User.getUsername方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。