00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 package org.openmobileis.module.profiles.server;
00029
00030 import org.openmobileis.common.user.User;
00031 import org.openmobileis.common.user.UserManager;
00032 import org.openmobileis.common.user.profile.Profile;
00033 import org.openmobileis.common.user.profile.ProfileDataManager;
00034 import org.openmobileis.common.util.codec.GeneralCoder;
00035 import org.openmobileis.common.context.*;
00036 import org.openmobileis.module.profiles.terminal.OpenMSPProfileSyncListener;
00037 import org.openmobileis.module.profiles.terminal.TerminalProfile;
00038 import org.openmobileis.synchro.openmsp.OpenMSPException;
00039 import org.openmobileis.synchro.openmsp.protocol.Command;
00040 import org.openmobileis.synchro.openmsp.protocol.ContainerMessage;
00041 import org.openmobileis.synchro.openmsp.protocol.DataItem;
00042 import org.openmobileis.synchro.openmsp.protocol.Element;
00043 import org.openmobileis.synchro.openmsp.protocol.Result;
00044 import org.openmobileis.synchro.openmsp.protocol.Status;
00045 import org.openmobileis.synchro.openmsp.server.synctarget.DefaultOpenMSPSynchroTargetListener;
00046 import org.openmobileis.synchro.security.auth.Credential;
00047
00048
00049
00059 public class ProfilManagerSyncTarget extends DefaultOpenMSPSynchroTargetListener {
00060
00061 public ProfilManagerSyncTarget() {
00062 }
00063
00064 public String getTargetName() {
00065 return OpenMSPProfileSyncListener.profilSynchroTargetName;
00066 }
00067
00068 protected ContainerMessage processMapCommand(Credential cred,ContainerMessage mapContainer) throws OpenMSPException {
00069 throw new OpenMSPException("MAP command not implemented.");
00070 }
00071
00072 protected void notifySyncAction(long sessionId,Credential cred, Command syncCommand) throws OpenMSPException {
00073
00074 }
00075
00076 protected void processResultCommand(Credential cred,Result resultCommande) throws OpenMSPException {
00077 throw new OpenMSPException("RESULT command not implemented.");
00078 }
00079
00080 protected void processStatusCommand(Credential cred,Status statusCommande) throws OpenMSPException {
00081 throw new OpenMSPException("STATUS not implemented.");
00082 }
00083
00084 protected Status processAddCommand(Credential cred, ContainerMessage addContainer) throws OpenMSPException {
00085 throw new OpenMSPException("ADD command not implemented.");
00086 }
00087
00088 protected Status processDeleteCommand(Credential cred, ContainerMessage deleteContainer) throws OpenMSPException {
00089 throw new OpenMSPException("DELETE command not implemented.");
00090 }
00091
00092 protected Status processReplaceCommand(Credential cred, ContainerMessage replaceContainer) throws OpenMSPException {
00093 throw new OpenMSPException("REPLACE command not implemented.");
00094 }
00095
00096 protected void beginProcessOpenMSpCommand(Credential cred) throws OpenMSPException {
00097 }
00098
00099 protected ContainerMessage[] endProcessOpenMSpCommand() throws OpenMSPException {
00100
00101 return null;
00102 }
00103
00104 protected ContainerMessage[] processGetCommand(Credential cred, ContainerMessage getContainer) throws OpenMSPException {
00105 try {
00106 Element getCommand = getContainer.getElement();
00107
00108 Result resultCommand = new Result(getCommand.getCmdId(), this.getTargetName(), OpenMSPProfileSyncListener.profilSynchroSourceName);
00109
00110 ContainerMessage resultContainer = new ContainerMessage(resultCommand);
00111 SessionContext context = SessionContextManager.getManager().getSessionContext();
00112 User user = UserManager.getManager().getUser(context.getUserGroup(), context.getUserId());
00113 Profile profile = ProfileDataManager.getManager().getProfil(context.getUserGroup(), user.getProfil());
00114 String encodedProfil = new String(GeneralCoder.encodeBase64(TerminalProfile.convertProfileToTerminalProfile(profile).toXML().getBytes()));
00115 DataItem newItem = new DataItem(Element.ITEM, "xmlprofil", encodedProfil, null, null);
00116 resultContainer.add(newItem);
00117 return new ContainerMessage[]{resultContainer};
00118 } catch (Throwable ex) {
00119 throw new OpenMSPException(ex);
00120 }
00121
00122 }
00123
00124 }