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.synchro.openmsp.OpenMSPException;
00038 import org.openmobileis.synchro.openmsp.protocol.Command;
00039 import org.openmobileis.synchro.openmsp.protocol.ContainerMessage;
00040 import org.openmobileis.synchro.openmsp.protocol.DataItem;
00041 import org.openmobileis.synchro.openmsp.protocol.Element;
00042 import org.openmobileis.synchro.openmsp.protocol.Result;
00043 import org.openmobileis.synchro.openmsp.protocol.Status;
00044 import org.openmobileis.synchro.openmsp.server.synctarget.DefaultOpenMSPSynchroTargetListener;
00045 import org.openmobileis.synchro.security.auth.Credential;
00046
00047
00048
00058 public class ProfilManagerSyncTarget extends DefaultOpenMSPSynchroTargetListener {
00059
00060 public ProfilManagerSyncTarget() {
00061 }
00062
00063 public String getTargetName() {
00064 return OpenMSPProfileSyncListener.profilSynchroTargetName;
00065 }
00066
00067 protected ContainerMessage processMapCommand(Credential cred,ContainerMessage mapContainer) throws OpenMSPException {
00068 throw new OpenMSPException("MAP command not implemented.");
00069 }
00070
00071 protected void notifySyncAction(long sessionId,Credential cred, Command syncCommand) throws OpenMSPException {
00072
00073 }
00074
00075 protected void processResultCommand(Credential cred,Result resultCommande) throws OpenMSPException {
00076 throw new OpenMSPException("RESULT command not implemented.");
00077 }
00078
00079 protected void processStatusCommand(Credential cred,Status statusCommande) throws OpenMSPException {
00080 throw new OpenMSPException("STATUS not implemented.");
00081 }
00082
00083 protected Status processAddCommand(Credential cred, ContainerMessage addContainer) throws OpenMSPException {
00084 throw new OpenMSPException("ADD command not implemented.");
00085 }
00086
00087 protected Status processDeleteCommand(Credential cred, ContainerMessage deleteContainer) throws OpenMSPException {
00088 throw new OpenMSPException("DELETE command not implemented.");
00089 }
00090
00091 protected Status processReplaceCommand(Credential cred, ContainerMessage replaceContainer) throws OpenMSPException {
00092 throw new OpenMSPException("REPLACE command not implemented.");
00093 }
00094
00095 protected void beginProcessOpenMSpCommand(Credential cred) throws OpenMSPException {
00096 }
00097
00098 protected ContainerMessage[] endProcessOpenMSpCommand() throws OpenMSPException {
00099
00100 return null;
00101 }
00102
00103 protected ContainerMessage[] processGetCommand(Credential cred, ContainerMessage getContainer) throws OpenMSPException {
00104 try {
00105 Element getCommand = getContainer.getElement();
00106
00107 Result resultCommand = new Result(getCommand.getCmdId(), this.getTargetName(), OpenMSPProfileSyncListener.profilSynchroSourceName);
00108
00109 ContainerMessage resultContainer = new ContainerMessage(resultCommand);
00110 SessionContext context = SessionContextManager.getManager().getSessionContext();
00111 User user = UserManager.getManager().getUser(context.getUserGroup(), context.getUserId());
00112 Profile profil = ProfileDataManager.getManager().getProfil(context.getUserGroup(), user.getProfil());
00113 String encodedProfil = new String(GeneralCoder.encodeBase64(profil.toXML().getBytes()));
00114 DataItem newItem = new DataItem(Element.ITEM, "xmlprofil", encodedProfil, null, null);
00115 resultContainer.add(newItem);
00116 return new ContainerMessage[]{resultContainer};
00117 } catch (Throwable ex) {
00118 throw new OpenMSPException(ex);
00119 }
00120
00121 }
00122
00123 }