From 566e491b355c8c03a3bed02da60b4846b9ddf328 Mon Sep 17 00:00:00 2001 From: Carlos Manias Date: Fri, 18 Apr 2014 14:33:00 +0100 Subject: [PATCH] Revert EntityList<> with generics to ConcreteList (ProfileList) Revert EntityList<> with generics to ConcreteList (ProfileList) --- .../test/connections/BaseProfilesTest.java | 4 - .../com/ibm/sbt/ConnectionsTestSuite.java | 23 ++- .../profiles/ProfileServiceTestSuite.java | 2 +- .../profiles/ColleagueConnectionList.java | 14 ++ .../client/connections/profiles/Profile.java | 3 +- .../profiles/ProfileAdminService.java | 29 ++-- .../connections/profiles/ProfileList.java | 14 ++ .../connections/profiles/ProfileService.java | 145 ++++++++---------- .../client/connections/profiles/TagList.java | 14 ++ 9 files changed, 143 insertions(+), 105 deletions(-) create mode 100644 sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ColleagueConnectionList.java create mode 100644 sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileList.java create mode 100644 sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/TagList.java diff --git a/samples/j2ee/snippets/com.ibm.sbt.automation.core/src/main/java/com/ibm/sbt/automation/core/test/connections/BaseProfilesTest.java b/samples/j2ee/snippets/com.ibm.sbt.automation.core/src/main/java/com/ibm/sbt/automation/core/test/connections/BaseProfilesTest.java index f09e06779b..7058059a12 100644 --- a/samples/j2ee/snippets/com.ibm.sbt.automation.core/src/main/java/com/ibm/sbt/automation/core/test/connections/BaseProfilesTest.java +++ b/samples/j2ee/snippets/com.ibm.sbt.automation.core/src/main/java/com/ibm/sbt/automation/core/test/connections/BaseProfilesTest.java @@ -20,7 +20,6 @@ import com.ibm.commons.util.StringUtil; import com.ibm.commons.util.io.json.JsonJavaObject; import com.ibm.sbt.automation.core.test.BaseApiTest; -import com.ibm.sbt.services.client.ClientServicesException; import com.ibm.sbt.services.client.connections.profiles.Profile; import com.ibm.sbt.services.client.connections.profiles.ProfileService; import com.ibm.sbt.services.client.connections.profiles.ProfileServiceException; @@ -49,9 +48,6 @@ public Profile getProfile(String userId) { } catch (ProfileServiceException pse) { Assert.fail("Error get profile: " + pse.getMessage()); pse.printStackTrace(); - } catch (ClientServicesException e) { - Assert.fail("Error get profile: " + e.getMessage()); - e.printStackTrace(); } return profile; } diff --git a/sdk/com.ibm.sbt.core.test/src/test/java/com/ibm/sbt/ConnectionsTestSuite.java b/sdk/com.ibm.sbt.core.test/src/test/java/com/ibm/sbt/ConnectionsTestSuite.java index e75fb6cb08..f36f19333b 100644 --- a/sdk/com.ibm.sbt.core.test/src/test/java/com/ibm/sbt/ConnectionsTestSuite.java +++ b/sdk/com.ibm.sbt.core.test/src/test/java/com/ibm/sbt/ConnectionsTestSuite.java @@ -1,3 +1,19 @@ +/* + * © Copyright IBM Corp. 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.ibm.sbt; import org.junit.runner.RunWith; @@ -11,12 +27,17 @@ import com.ibm.sbt.services.client.connections.bookmarks.BookmarkServiceTest; import com.ibm.sbt.services.client.connections.cmisfiles.CMISFileServiceTest; import com.ibm.sbt.services.client.connections.communities.CommunityServiceTestSuite; -import com.ibm.sbt.services.client.connections.files.FileServiceTest; import com.ibm.sbt.services.client.connections.files.FileServiceTestSuite; import com.ibm.sbt.services.client.connections.follow.FollowServiceTest; import com.ibm.sbt.services.client.connections.forums.ForumServiceTestSuite; import com.ibm.sbt.services.client.connections.profiles.ProfileServiceTestSuite; import com.ibm.sbt.services.client.connections.wikis.WikiServiceTestSuite; + +/** + * + * @author Carlos Manias + * + */ @RunWith(Suite.class) @SuiteClasses({ // Errors/Failures/Ignored diff --git a/sdk/com.ibm.sbt.core.test/src/test/java/com/ibm/sbt/services/client/connections/profiles/ProfileServiceTestSuite.java b/sdk/com.ibm.sbt.core.test/src/test/java/com/ibm/sbt/services/client/connections/profiles/ProfileServiceTestSuite.java index 75b047c2f2..0336d0272a 100644 --- a/sdk/com.ibm.sbt.core.test/src/test/java/com/ibm/sbt/services/client/connections/profiles/ProfileServiceTestSuite.java +++ b/sdk/com.ibm.sbt.core.test/src/test/java/com/ibm/sbt/services/client/connections/profiles/ProfileServiceTestSuite.java @@ -1,5 +1,5 @@ /* - * ?? Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ColleagueConnectionList.java b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ColleagueConnectionList.java new file mode 100644 index 0000000000..bb1adf772a --- /dev/null +++ b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ColleagueConnectionList.java @@ -0,0 +1,14 @@ +package com.ibm.sbt.services.client.connections.profiles; + +import com.ibm.sbt.services.client.Response; +import com.ibm.sbt.services.client.base.IFeedHandler; +import com.ibm.sbt.services.client.base.datahandlers.AtomEntityList; + + +public class ColleagueConnectionList extends AtomEntityList { + + public ColleagueConnectionList(Response requestData, IFeedHandler feedHandler) { + super(requestData, feedHandler); + } + +} diff --git a/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/Profile.java b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/Profile.java index 034e496b89..1be88c2e58 100644 --- a/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/Profile.java +++ b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/Profile.java @@ -28,7 +28,6 @@ import com.ibm.sbt.services.client.ClientServicesException; import com.ibm.sbt.services.client.base.AtomEntity; import com.ibm.sbt.services.client.base.BaseService; -import com.ibm.sbt.services.client.base.datahandlers.EntityList; import com.ibm.sbt.services.client.base.datahandlers.XmlDataHandler; import com.ibm.sbt.services.client.connections.profiles.model.ProfileXPath; @@ -99,7 +98,7 @@ public void update() throws ProfileServiceException { * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getColleagues() throws ProfileServiceException, ClientServicesException { + public ProfileList getColleagues() throws ProfileServiceException, ClientServicesException { return getService().getColleagues(getUserid()); } diff --git a/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileAdminService.java b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileAdminService.java index ca54341e5a..29ce78be1a 100644 --- a/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileAdminService.java +++ b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileAdminService.java @@ -1,5 +1,10 @@ package com.ibm.sbt.services.client.connections.profiles; +import static com.ibm.sbt.services.client.connections.profiles.utils.ProfilesConstants.FORMAT; +import static com.ibm.sbt.services.client.connections.profiles.utils.ProfilesConstants.FULL; +import static com.ibm.sbt.services.client.connections.profiles.utils.ProfilesConstants.OUTPUT; +import static com.ibm.sbt.services.client.connections.profiles.utils.ProfilesConstants.VCARD; + import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -7,10 +12,7 @@ import com.ibm.commons.util.StringUtil; import com.ibm.sbt.services.client.ClientService; import com.ibm.sbt.services.client.ClientServicesException; -import com.ibm.sbt.services.client.base.datahandlers.EntityList; -import com.ibm.sbt.services.client.base.transformers.TransformerException; import com.ibm.sbt.services.client.connections.profiles.utils.Messages; -import com.ibm.sbt.services.client.connections.profiles.utils.ProfilesConstants; import com.ibm.sbt.services.endpoints.Endpoint; /** @@ -96,7 +98,6 @@ public void deleteProfile(String id) throws ProfileServiceException } catch (IOException e) { throw new ProfileServiceException(e, Messages.DeleteProfileException, id); } - } /** @@ -107,8 +108,7 @@ public void deleteProfile(String id) throws ProfileServiceException * @param Profile * @throws ProfileServiceException */ - public void createProfile(Profile profile) throws ProfileServiceException - { + public void createProfile(Profile profile) throws ProfileServiceException { if (profile == null) { throw new ProfileServiceException(null, Messages.InvalidArgument_3); } @@ -123,8 +123,6 @@ public void createProfile(Profile profile) throws ProfileServiceException }catch(ClientServicesException e) { throw new ProfileServiceException(e, Messages.CreateProfileException, profile.getUserid()); - }catch (TransformerException e) { - throw new ProfileServiceException(e, Messages.CreateProfilePayloadException); } catch (IOException e) { throw new ProfileServiceException(e, Messages.CreateProfileException, profile.getUserid()); } @@ -143,7 +141,7 @@ public void createProfile(Profile profile) throws ProfileServiceException * @throws ClientServicesException */ @Override - public EntityList searchProfiles(Map parameters) throws ClientServicesException { + public ProfileList searchProfiles(Map parameters) throws ProfileServiceException { String url = ProfileUrls.ADMIN_PROFILES.format(this); @@ -157,23 +155,18 @@ public EntityList searchProfiles(Map parameters) throws * @throws ProfileServiceException */ @Override - public void updateProfile(Profile profile) throws ProfileServiceException{ + public void updateProfile(Profile profile) throws ProfileServiceException { if (profile == null) { throw new ProfileServiceException(null, Messages.InvalidArgument_3); } try { Map parameters = new HashMap(); - parameters.put(ProfilesConstants.OUTPUT, "vcard"); - parameters.put(ProfilesConstants.FORMAT, "full"); + parameters.put(OUTPUT, VCARD); + parameters.put(FORMAT, FULL); String id = profile.getUserid(); parameters.put(getIdParameter(id), id); - Object updateProfilePayload; - try { - updateProfilePayload = constructUpdateRequestBody(profile); - } catch (TransformerException e) { - throw new ProfileServiceException(e); - } + Object updateProfilePayload = constructUpdateRequestBody(profile); String updateUrl = ProfileUrls.ADMIN_PROFILE_ENTRY.format(this); super.updateData(updateUrl, parameters,updateProfilePayload, getIdParameter(profile.getAsString("uid"))); profile.clearFieldsMap(); diff --git a/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileList.java b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileList.java new file mode 100644 index 0000000000..d7de44973c --- /dev/null +++ b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileList.java @@ -0,0 +1,14 @@ +package com.ibm.sbt.services.client.connections.profiles; + +import com.ibm.sbt.services.client.Response; +import com.ibm.sbt.services.client.base.IFeedHandler; +import com.ibm.sbt.services.client.base.datahandlers.AtomEntityList; + + +public class ProfileList extends AtomEntityList { + + public ProfileList(Response requestData, IFeedHandler feedHandler) { + super(requestData, feedHandler); + } + +} diff --git a/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileService.java b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileService.java index ad5c8366d1..1745508dd2 100644 --- a/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileService.java +++ b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/ProfileService.java @@ -76,9 +76,7 @@ import com.ibm.sbt.services.client.base.CommonConstants.HTTPCode; import com.ibm.sbt.services.client.base.IFeedHandler; import com.ibm.sbt.services.client.base.NamedUrlPart; -import com.ibm.sbt.services.client.base.datahandlers.EntityList; import com.ibm.sbt.services.client.base.datahandlers.JsonDataHandler; -import com.ibm.sbt.services.client.base.transformers.TransformerException; import com.ibm.sbt.services.client.connections.profiles.model.ProfileXPath; import com.ibm.sbt.services.client.connections.profiles.serializers.ColleagueConnectionSerializer; import com.ibm.sbt.services.client.connections.profiles.serializers.ProfileSerializer; @@ -180,6 +178,11 @@ public IFeedHandler getProfileFeedHandler() { protected Profile entityInstance(BaseService service, Node node, XPathExpression xpath) { return new Profile(service, node, nameSpaceCtx, xpath); } + + @Override + public ProfileList createEntityList(Response requestData) { + return new ProfileList((Response)requestData, this); + } }; } @@ -193,6 +196,11 @@ public IFeedHandler getColleagueFeedHandler() { protected ColleagueConnection entityInstance(BaseService service, Node node, XPathExpression xpath) { return new ColleagueConnection(service, node, nameSpaceCtx, xpath); } + + @Override + public ColleagueConnectionList createEntityList(Response requestData) { + return new ColleagueConnectionList((Response)requestData, this); + } }; } @@ -206,6 +214,11 @@ public IFeedHandler getTagFeedHandler() { protected Tag entityInstance(BaseService service, Node node, XPathExpression xpath) { return new Tag(service, node, nameSpaceCtx, xpath); } + + @Override + public TagList createEntityList(Response requestData) { + return new TagList((Response)requestData, this); + } }; } @@ -218,7 +231,7 @@ protected Tag entityInstance(BaseService service, Node node, XPathExpression xpa * @throws ProfileServiceException * @throws ClientServicesException */ - public Profile getProfile(String id) throws ProfileServiceException, ClientServicesException{ + public Profile getProfile(String id) throws ProfileServiceException { return getProfile(id, null); } @@ -232,7 +245,7 @@ public Profile getProfile(String id) throws ProfileServiceException, ClientServi * @throws ProfileServiceException * @throws ClientServicesException */ - public Profile getProfile(String id, Map parameters) throws ProfileServiceException, ClientServicesException{ + public Profile getProfile(String id, Map parameters) throws ProfileServiceException { // TODO: Do a cache lookup first. If cache miss, make a network call to get profile if (StringUtil.isEmpty(id)){ @@ -255,7 +268,7 @@ public Profile getProfile(String id, Map parameters) throws Prof * @return list of searched Profiles * @throws ClientServicesException */ - public EntityList searchProfiles( Map parameters) throws ClientServicesException { + public ProfileList searchProfiles( Map parameters) throws ProfileServiceException { if (null == parameters) { parameters = new HashMap(); } @@ -272,7 +285,7 @@ public EntityList searchProfiles( Map parameters) throw * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getTags(String id) throws ProfileServiceException, ClientServicesException{ + public TagList getTags(String id) throws ProfileServiceException { return getTags(id,null); } @@ -287,8 +300,7 @@ public EntityList getTags(String id) throws ProfileServiceException, Client * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getTags(String id, Map parameters) - throws ProfileServiceException, ClientServicesException{ + public TagList getTags(String id, Map parameters) throws ProfileServiceException { if (StringUtil.isEmpty(id)){ throw new ProfileServiceException(null, Messages.InvalidArgument_1); @@ -355,7 +367,7 @@ public void addTags(String sourceId, String targetId, Profile profile) throws Pr * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getColleagues(String id) throws ProfileServiceException, ClientServicesException{ + public ProfileList getColleagues(String id) throws ProfileServiceException { return getColleagues(id,null); } @@ -370,7 +382,7 @@ public EntityList getColleagues(String id) throws ProfileServiceExcepti * @throws ClientServicesException * @throws ProfileServiceException */ - public EntityList getColleagues(String id, Map parameters) throws ClientServicesException, ProfileServiceException { + public ProfileList getColleagues(String id, Map parameters) throws ProfileServiceException { if (StringUtil.isEmpty(id)){ throw new ProfileServiceException(null, Messages.InvalidArgument_1); } @@ -394,7 +406,7 @@ public EntityList getColleagues(String id, Map paramete * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getColleagueConnections(String id) throws ProfileServiceException, ClientServicesException{ + public ColleagueConnectionList getColleagueConnections(String id) throws ProfileServiceException { return getColleagueConnections(id,null); } @@ -409,8 +421,7 @@ public EntityList getColleagueConnections(String id) throws * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getColleagueConnections(String id, Map parameters) - throws ProfileServiceException, ClientServicesException{ + public ColleagueConnectionList getColleagueConnections(String id, Map parameters) throws ProfileServiceException { if (StringUtil.isEmpty(id)){ throw new ProfileServiceException(null, Messages.InvalidArgument_1); } @@ -436,7 +447,7 @@ public EntityList getColleagueConnections(String id, Map parameters) throws ProfileServiceException, ClientServicesException{ + public ColleagueConnection checkColleague(String sourceId, String targetId, Map parameters) throws ProfileServiceException { if (StringUtil.isEmpty(sourceId)) { throw new ProfileServiceException(null, Messages.InvalidArgument_4); @@ -490,7 +501,7 @@ public ColleagueConnection checkColleague(String sourceId, String targetId, Map< * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getCommonColleagues(String sourceId, String targetId) throws ProfileServiceException, ClientServicesException{ + public ProfileList getCommonColleagues(String sourceId, String targetId) throws ProfileServiceException { return getCommonColleagues(sourceId, targetId, null); } @@ -505,7 +516,7 @@ public EntityList getCommonColleagues(String sourceId, String targetId) * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getCommonColleagues(String sourceId, String targetId, Map parameters) throws ProfileServiceException, ClientServicesException{ + public ProfileList getCommonColleagues(String sourceId, String targetId, Map parameters) throws ProfileServiceException { if (StringUtil.isEmpty(sourceId)) { throw new ProfileServiceException(null, Messages.InvalidArgument_4); @@ -544,7 +555,7 @@ public EntityList getCommonColleagues(String sourceId, String targetId, * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getCommonColleagueConnections(String sourceId, String targetId) throws ProfileServiceException, ClientServicesException{ + public ColleagueConnectionList getCommonColleagueConnections(String sourceId, String targetId) throws ProfileServiceException { return getCommonColleagueConnections(sourceId, targetId, null); } @@ -559,7 +570,7 @@ public EntityList getCommonColleagueConnections(String sour * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getCommonColleagueConnections(String sourceId, String targetId, Map parameters) throws ProfileServiceException, ClientServicesException{ + public ColleagueConnectionList getCommonColleagueConnections(String sourceId, String targetId, Map parameters) throws ProfileServiceException { if (StringUtil.isEmpty(sourceId)) { throw new ProfileServiceException(null, Messages.InvalidArgument_4); @@ -596,7 +607,7 @@ public EntityList getCommonColleagueConnections(String sour * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getReportingChain(String id) throws ProfileServiceException, ClientServicesException{ + public ProfileList getReportingChain(String id) throws ProfileServiceException { return getReportingChain(id,null); } @@ -611,7 +622,7 @@ public EntityList getReportingChain(String id) throws ProfileServiceExc * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getReportingChain (String id, Map parameters)throws ProfileServiceException, ClientServicesException{ + public ProfileList getReportingChain (String id, Map parameters)throws ProfileServiceException { if (StringUtil.isEmpty(id)) { throw new ProfileServiceException(null, Messages.InvalidArgument_1); @@ -632,7 +643,7 @@ public EntityList getReportingChain (String id, Map par * @throws ProfileServiceException * @throws ClientServicesException */ - public EntityList getPeopleManaged(String id) throws ProfileServiceException, ClientServicesException{ + public ProfileList getPeopleManaged(String id) throws ProfileServiceException { return getPeopleManaged(id,null); } @@ -648,7 +659,7 @@ public EntityList getPeopleManaged(String id) throws ProfileServiceExce * @throws ClientServicesException * */ - public EntityList getPeopleManaged(String id, Map parameters)throws ProfileServiceException, ClientServicesException{ + public ProfileList getPeopleManaged(String id, Map parameters)throws ProfileServiceException { if (StringUtil.isEmpty(id)) { throw new ProfileServiceException(null, Messages.InvalidArgument_1); @@ -686,7 +697,7 @@ public String sendInvite(String id)throws ProfileServiceException{ * @return Id of the Connection * @throws ProfileServiceException */ - public String sendInvite(String id, String inviteMsg)throws ProfileServiceException{ + public String sendInvite(String id, String inviteMsg)throws ProfileServiceException { if (StringUtil.isEmpty(id)) { throw new ProfileServiceException(null, Messages.InvalidArgument_1); } @@ -701,8 +712,6 @@ public String sendInvite(String id, String inviteMsg)throws ProfileServiceExcept return extractConnectionIdFromHeaders(response); } catch (ClientServicesException e) { throw new ProfileServiceException(e, Messages.SendInviteException, id); - } catch (TransformerException e) { - throw new ProfileServiceException(e, Messages.SendInvitePayloadException); } catch (IOException e) { throw new ProfileServiceException(e, Messages.SendInviteException, id); } @@ -730,8 +739,6 @@ public void acceptInvite(ColleagueConnection connection)throws ProfileServiceExc super.updateData(url, parameters,payload, connection.getConnectionId()); } catch (ClientServicesException e) { throw new ProfileServiceException(e, Messages.AcceptInviteException, connection.getConnectionId()); - } catch (TransformerException e) { - throw new ProfileServiceException(e, Messages.AcceptInvitePayloadException); } catch (IOException e) { throw new ProfileServiceException(e, Messages.AcceptInviteException, connection.getConnectionId()); } @@ -769,7 +776,6 @@ public void deleteInvite(String connectionId)throws ProfileServiceException{ * @throws ProfileServiceException */ public void updateProfile(Profile profile) throws ProfileServiceException{ - if (profile == null) { throw new ProfileServiceException(null, Messages.InvalidArgument_3); } @@ -779,12 +785,7 @@ public void updateProfile(Profile profile) throws ProfileServiceException{ parameters.put(FORMAT, FULL); String id = profile.getUserid(); parameters.put(getIdParameter(id), id); - Object updateProfilePayload; - try { - updateProfilePayload = constructUpdateRequestBody(profile); - } catch (TransformerException e) { - throw new ProfileServiceException(e); - } + Object updateProfilePayload = constructUpdateRequestBody(profile); String updateUrl = ProfileUrls.PROFILE_ENTRY.format(this); super.updateData(updateUrl, parameters,updateProfilePayload, getIdParameter(profile.getAsString("uid"))); profile.clearFieldsMap(); @@ -824,7 +825,7 @@ public String getMyUserId()throws ProfileServiceException{ * @throws ProfileServiceException * @throws ClientServicesException */ - public Profile getMyProfile() throws ProfileServiceException, ClientServicesException{ + public Profile getMyProfile() throws ProfileServiceException { return getProfile(getMyUserId(), null); } @@ -836,7 +837,7 @@ public Profile getMyProfile() throws ProfileServiceException, ClientServicesExce * @param userid * @throws ProfileServiceException */ - public void updateProfilePhoto(File file, String userId) throws ProfileServiceException{ + public void updateProfilePhoto(File file, String userId) throws ProfileServiceException { if (file == null || !file.canRead()) { throw new ProfileServiceException(null, Messages.MessageCannotReadFile, file.getAbsolutePath()); @@ -876,7 +877,7 @@ public void updateProfilePhoto(File file, String userId) throws ProfileServiceEx * the map can contain object of type InputStream, Node, String, according to the return content type * @throws ProfileServiceException */ - public Map getExtendedAttributes(Profile p) throws ProfileServiceException{ + public Map getExtendedAttributes(Profile p) throws ProfileServiceException { Map ret = new HashMap(); List attributes = (List) p.getDataHandler().getEntries(ProfileXPath.extendedAttributes); for (Node link :attributes) { @@ -908,11 +909,7 @@ public Map getExtendedAttributes(Profile p) throws ProfileService * This method is used by ProfileService wrapper methods to construct request body for Add operations * @return Object */ - protected Object constructCreateRequestBody(Profile profile) throws TransformerException { - /* - ProfileTransformer transformer = new ProfileTransformer(profile); - String xml2 = transformer.createTransform(profile.getFieldsMap()); - */ + protected Object constructCreateRequestBody(Profile profile) { ProfileSerializer serializer = new ProfileSerializer(profile); return serializer.createPayload(); } @@ -921,12 +918,7 @@ protected Object constructCreateRequestBody(Profile profile) throws TransformerE * This method is used by ProfileService wrapper methods to construct request body for Update operations * @return Object */ - protected Object constructUpdateRequestBody(Profile profile) throws TransformerException { - /* - ProfileTransformer transformer = new ProfileTransformer(profile); - String xml = transformer.updateTransform(profile.getFieldsMap()); - return xml; - */ + protected Object constructUpdateRequestBody(Profile profile) { ProfileSerializer serializer = new ProfileSerializer(profile); return serializer.updatePayload(); } @@ -935,15 +927,7 @@ protected Object constructUpdateRequestBody(Profile profile) throws TransformerE * This method is used by ProfileService wrapper methods to construct request body for Add operations * @return Object */ - protected Object constructAcceptInviteRequestBody(ColleagueConnection connectionEntry, String action) throws TransformerException { - /* - ColleagueConnectionTransformer transformer = new ColleagueConnectionTransformer(connectionEntry); - String xml = ""; - if(!StringUtil.isEmpty(action)){ - xml = transformer.updateTransform(action, connectionEntry.getFieldsMap()); - } - return xml; - */ + protected Object constructAcceptInviteRequestBody(ColleagueConnection connectionEntry, String action) { ColleagueConnectionSerializer serializer = new ColleagueConnectionSerializer(connectionEntry); return serializer.acceptInvitePayload(); } @@ -953,14 +937,7 @@ protected Object constructAcceptInviteRequestBody(ColleagueConnection connection * @return Object * @throws ProfileServiceException */ - protected Object constructSendInviteRequestBody(String inviteMsg) throws TransformerException, ProfileServiceException { - /* - ColleagueConnection colleagueConnection = new ColleagueConnection(this, null); - colleagueConnection.setContent(inviteMsg); - ColleagueConnectionTransformer transformer = new ColleagueConnectionTransformer(colleagueConnection); - String xml = transformer.createTransform(colleagueConnection.getFieldsMap()); - return xml; - */ + protected Object constructSendInviteRequestBody(String inviteMsg) throws ProfileServiceException { ColleagueConnection colleagueConnection = new ColleagueConnection(this, null); colleagueConnection.setContent(inviteMsg); ColleagueConnectionSerializer serializer = new ColleagueConnectionSerializer(colleagueConnection); @@ -977,43 +954,53 @@ protected String extractConnectionIdFromHeaders(Response requestData){ return urlLocation.substring(urlLocation.indexOf(CONNECTION_UNIQUE_IDENTIFIER+EQUALS) + (CONNECTION_UNIQUE_IDENTIFIER+EQUALS).length()); } - protected Profile getProfileEntity(String requestUrl, Map parameters) throws ClientServicesException { + protected Profile getProfileEntity(String requestUrl, Map parameters) throws ProfileServiceException { try { return (Profile)getEntity(requestUrl, parameters, getProfileFeedHandler()); } catch (IOException e) { - throw new ClientServicesException(e); + throw new ProfileServiceException(e); + } catch(ClientServicesException e){ + throw new ProfileServiceException(e); } } - protected ColleagueConnection getColleagueConnectionEntity(String requestUrl, Map parameters) throws ClientServicesException { + protected ColleagueConnection getColleagueConnectionEntity(String requestUrl, Map parameters) throws ProfileServiceException { try { return (ColleagueConnection)getEntity(requestUrl, parameters, getColleagueFeedHandler()); } catch (IOException e) { - throw new ClientServicesException(e); + throw new ProfileServiceException(e); + } catch(ClientServicesException e){ + throw new ProfileServiceException(e); } } - protected EntityList getProfileEntityList(String requestUrl, Map parameters) throws ClientServicesException { + protected ProfileList getProfileEntityList(String requestUrl, Map parameters) throws ProfileServiceException { try { - return (EntityList)getEntities(requestUrl, getParameters(parameters), getProfileFeedHandler()); + return (ProfileList)getEntities(requestUrl, getParameters(parameters), getProfileFeedHandler()); } catch (IOException e) { - throw new ClientServicesException(e); + throw new ProfileServiceException(e); + } catch(ClientServicesException e){ + throw new ProfileServiceException(e); } } - protected EntityList getColleagueConnectionEntityList(String requestUrl, Map parameters) throws ClientServicesException { + protected ColleagueConnectionList getColleagueConnectionEntityList(String requestUrl, Map parameters) throws ProfileServiceException { try { - return (EntityList)getEntities(requestUrl, getParameters(parameters), getColleagueFeedHandler()); + return (ColleagueConnectionList)getEntities(requestUrl, getParameters(parameters), getColleagueFeedHandler()); } catch (IOException e) { - throw new ClientServicesException(e); + throw new ProfileServiceException(e); + } catch(ClientServicesException e){ + throw new ProfileServiceException(e); } } - protected EntityList getTagEntityList(String requestUrl, Map parameters) throws ClientServicesException { + protected TagList getTagEntityList(String requestUrl, Map parameters) throws ProfileServiceException { try { - return (EntityList)getEntities(requestUrl, getParameters(parameters), getTagFeedHandler()); + return (TagList)getEntities(requestUrl, getParameters(parameters), getTagFeedHandler()); } catch (IOException e) { - throw new ClientServicesException(e); + throw new ProfileServiceException(e); + } catch(ClientServicesException e){ + throw new ProfileServiceException(e); } } diff --git a/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/TagList.java b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/TagList.java new file mode 100644 index 0000000000..bfba6711c8 --- /dev/null +++ b/sdk/com.ibm.sbt.core/src/main/java/com/ibm/sbt/services/client/connections/profiles/TagList.java @@ -0,0 +1,14 @@ +package com.ibm.sbt.services.client.connections.profiles; + +import com.ibm.sbt.services.client.Response; +import com.ibm.sbt.services.client.base.IFeedHandler; +import com.ibm.sbt.services.client.base.datahandlers.AtomEntityList; + + +public class TagList extends AtomEntityList { + + public TagList(Response requestData, IFeedHandler feedHandler) { + super(requestData, feedHandler); + } + +}