diff --git a/.gitignore b/.gitignore index b57e84f9a9..d2bd4fe589 100644 --- a/.gitignore +++ b/.gitignore @@ -39,5 +39,5 @@ Desktop.ini ## Mac OS ############ -# Mac crap +# Desktop Services Store for the Mac .DS_Store diff --git a/assembly/assembly.xml b/assembly/assembly.xml index de4fcedd23..870aee161a 100644 --- a/assembly/assembly.xml +++ b/assembly/assembly.xml @@ -209,7 +209,7 @@ ${project.build.directory}/tomcat sbtsdk/tomcat - **/apache-tomcat-7.0.54-sbt.zip + **/apache-tomcat-7.0.61-sbt.zip diff --git a/assembly/cdnjs/sbt-core-dojo-amd.js b/assembly/cdnjs/sbt-core-dojo-amd.js index 20c7b0cc75..47a31787cf 100644 --- a/assembly/cdnjs/sbt-core-dojo-amd.js +++ b/assembly/cdnjs/sbt-core-dojo-amd.js @@ -60,80 +60,80 @@ getFromCache:function(a){if(this._cache)return this._cache.get(a)},createBadRequ "%20"))||null},validateField:function(a,g){if(!g){var c;c=b.substitute("Invalid value {0} for field {1}, the field must not be empty or undefined.",[g||"'undefined'",a]);return this.createBadRequestPromise(c)}},validateFields:function(a){for(var b in a){var g=this.validateField(b,a[b]);if(g)return g}},validateHTML5FileSupport:function(){if(!window.File||!window.FormData)return this.createBadRequestPromise("HTML 5 File API is not supported by the Browser.");if(-1!=j.getJavaScriptLibrary().indexOf("Dojo 1.4"))return this.createBadRequestPromise("Dojo 1.4.* is not supported for Update Profile Photo")}, _validateEntityId:function(a){if(!a||!c.isString(a))return a=b.substitute("Invalid argument {0}, expected valid entity identifier.",[a||"'undefined'"]),this.createBadRequestPromise(a)},getFileControl:function(a){var b=null;"string"==typeof a?b=document.getElementById(a):"object"==typeof a&&(b=a);return b}})})},"sbt/base/VCardDataHandler":function(){define(["../declare","../lang","../config","../stringUtil","./XmlDataHandler"],function(i,h,c,d,b){return i(b,{lineDelim:"\n",itemDelim:":",_vcard:null, constructor:function(){this.parseVCard()},parseVCard:function(){var a=d.trim(this.getAsString("vcard")).split(this.lineDelim);this._vcard={};for(var b=1;b\n"+k+"\n<\/script>"));this.index++}return i}})})},"sbt/connections/ProfileConstants":function(){define(["../lang","./ConnectionsConstants"],function(i,h){return i.mixin({DefaultCacheSize:10,AddressFields:"streetAddress,extendedAddress,locality,region,postalCode,countryName".split(","),ProfileFeedXPath:h.ConnectionsFeedXPath,ProfileNamespaces:h.Namespaces,TypeColleague:"colleague",StatusPending:"pending", -ProfileXPath:i.mixin({},h.AtomEntryXPath,{uid:"a:contributor/snx:userid",entry:"/a:feed/a:entry",userid:"a:contributor/snx:userid",name:"a:contributor/a:name",email:"a:contributor/a:email",altEmail:"a:content/h:div/h:span/h:div[@class='x-groupwareMail']",photoUrl:"a:link[@rel='http://www.ibm.com/xmlns/prod/sn/image']/@href",fnUrl:"a:content/h:div/h:span/h:div/h:a[@class='fn url']/@href",soundUrl:"a:content/h:div/h:span/h:div/h:a[@class='sound url']/@href",jobTitle:"a:content/h:div/h:span/h:div[@class='title']", -organizationUnit:"a:content/h:div/h:span/h:div[@class='org']/h:span[@class='organization-unit']",telephoneNumber:"a:content/h:div/h:span/h:div[@class='tel']/h:span[@class='value']",building:"a:content/h:div/h:span/h:div/h:span[@class='x-building']",floor:"a:content/h:div/h:span/h:div/h:span[@class='x-floor']",officeNumber:"a:content/h:div/h:span/h:div/h:span[@class='x-office-number']",streetAddress:"a:content/h:div/h:span/h:div/h:div[@class='street-address']",extendedAddress:"a:content/h:div/h:span/h:div/h:div[@class='extended-address x-streetAddress2']", -locality:"a:content/h:div/h:span/h:div/h:span[@class='locality']",postalCode:"a:content/h:div/h:span/h:div/h:span[@class='postal-code']",region:"a:content/h:div/h:span/h:div/h:span[@class='region']",countryName:"a:content/h:div/h:span/h:div/h:div[@class='country-name']",groupwareMail:"a:content/h:div/h:span/h:div[@class='x-groupwareMail']",blogUrl:"a:content/h:div/h:span/h:div/h:a[@class='x-blog-url url']/@href",role:"a:content/h:div/h:span/h:div[@class='role']",managerUid:"a:content/h:div/h:span/h:div[@class='x-manager-uid']", -isManager:"a:content/h:div/h:span/h:div[@class='x-is-manager']"}),ColleagueConnectionXPath:i.mixin({},h.AtomEntryXPath,{entry:"/a:feed/a:entry"}),ProfileVCardXPath:i.mixin({},h.AtomEntryXPath,{entry:"/a:feed/a:entry",uid:"a:contributor/snx:userid",vcard:"a:content",userid:"a:contributor/snx:userid",name:"a:contributor/a:name",email:"a:contributor/a:email",altEmail:"EMAIL;X_GROUPWARE_MAIL",photoUrl:"a:link[@rel='http://www.ibm.com/xmlns/prod/sn/image']/@href",fnUrl:"URL",soundUrl:"SOUND;VALUE=URL", -jobTitle:"TITLE",organizationUnit:"a:content/h:div/h:span/h:div[@class='org']/h:span[@class='organization-unit']",telephoneNumber:"TEL;WORK",building:"X_BUILDING",floor:"X_FLOOR",officeNumber:"X_OFFICE_NUMBER",workLocation:"ADR;WORK",streetAddress:"a:content/h:div/h:span/h:div/h:div[@class='street-address']",extendedAddress:"a:content/h:div/h:span/h:div/h:div[@class='extended-address x-streetAddress2']",locality:"a:content/h:div/h:span/h:div/h:span[@class='locality']",postalCode:"a:content/h:div/h:span/h:div/h:span[@class='postal-code']", -region:"a:content/h:div/h:span/h:div/h:span[@class='region']",countryName:"a:content/h:div/h:span/h:div/h:div[@class='country-name']",groupwareMail:"EMAIL;X_GROUPWARE_MAIL"}),ProfileTagsXPath:{entries:"/app:categories/a:category",targetEmail:"app:categories/snx:targetEmail",numberOfContributors:"@snx:numberOfContributors",entry:"/app:categories/a:category",uid:"@term",id:"@term",term:"@term",frequency:"@snx:frequency",intensity:"@snx:intensityBin",visibility:"@snx:visibilityBin",contributorName:"a:name", -contributorUserid:"a:userid",contributorEmail:"a:email"},InviteXPath:i.mixin({},h.AtomEntryXPath,{connectionType:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/connection/type']/@term",status:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/status']/@term"}),profileCreateAttributes:{guid:"com.ibm.snx_profiles.base.guid",email:"com.ibm.snx_profiles.base.email",uid:"com.ibm.snx_profiles.base.uid",distinguishedName:"com.ibm.snx_profiles.base.distinguishedName",displayName:"com.ibm.snx_profiles.base.displayName", -givenNames:"com.ibm.snx_profiles.base.givenNames",surname:"com.ibm.snx_profiles.base.surname",userState:"com.ibm.snx_profiles.base.userState"},AtomProfileDo:"/${profiles}{authType}/atom/profile.do",AtomProfileEntryDo:"/${profiles}{authType}/atom/profileEntry.do",AtomConnectionsDo:"/${profiles}{authType}/atom/connections.do",AtomReportingChainDo:"/${profiles}{authType}/atom/reportingChain.do",AtomPeopleManagedDo:"/${profiles}{authType}/atom/peopleManaged.do",AtomConnectionsInCommonDo:"/${profiles}{authType}/atom/connectionsInCommon.do", -AtomSearchDo:"/${profiles}{authType}/atom/search.do",AtomPeopleManagedDo:"/${profiles}{authType}/atom/peopleManaged.do",AtomTagsDo:"/${profiles}{authType}/atom/profileTags.do",AdminAtomProfileDo:"/${profiles}/admin/atom/profiles.do",AdminAtomProfileEntryDo:"/${profiles}/admin/atom/profileEntry.do"},h)})},"sbt/connections/FollowConstants":function(){define(["../lang","./ConnectionsConstants"],function(i,h){return i.mixin(h,{ActivitiesSource:"activities",ActivityResourceType:"activity",BlogsSource:"blogs", -BlogResourceType:"blog",CommunitiesSource:"communities",CommunitiesResourceType:"community",FilesSource:"files",FileResourceType:"file",FileFolderResourceType:"file_folder",ForumsSource:"forums",ForumResourceType:"forum",ForumTopicResourceType:"forum_topic",ProfilesSource:"profiles",ProfilesResourceType:"profile",WikisSource:"wikis",WikiResourceType:"wiki",WikiPageResourceType:"wiki_page",TagsSource:"tags",TagResourceType:"tag",FollowedResourceFeedXPath:h.ConnectionsFeedXPath,FollowedResourceXPath:i.mixin({}, -h.AtomEntryXPath,{followedResourceUuid:"a:id",categoryType:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term",source:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/source']/@term",resourceType:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-type']/@term",resourceId:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-id']/@term",relatedUrl:"a:link[@rel='related']/@href"}),OneFollowedResourceXPath:i.mixin({},h.AtomEntryXPath,{entry:"/a:feed/a:entry", -followedResourceUuid:"a:id",categoryType:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term",source:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/source']/@term",resourceType:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-type']/@term",resourceId:"a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-id']/@term",relatedUrl:"a:link[@rel='related']/@href"}),AtomFollowAPI:"/{service}/follow/atom/resources",AtomStopFollowAPI:"/{service}/follow/atom/resources/{resourceId}"})})}, -"sbt/base/AtomEntity":function(){define("../declare,../lang,../stringUtil,./BaseConstants,./BaseEntity,./XmlDataHandler".split(","),function(i,h,c,d,b,a){return i(b,{contentType:"html",categoryScheme:null,constructor:function(a){a.data?this.dataHandler=this.createDataHandler(a.service,a.data||null,a.response||null,a.namespaces||this.namespaces||d.Namespaces,a.xpath||this.xpath||d.AtomEntryXPath):(this.service=a.service||this.service,this.namespaces=a.namespaces||this.namespaces||d.Namespaces,this.xpath= -a.xpath||this.xpath||d.AtomEntryXPath)},createDataHandler:function(b,c,d,h,i){return new a({service:b,data:c,namespaces:h,xpath:i})},setData:function(a,b){this.dataHandler=this.createDataHandler(this.service,a,b||null,this.namespaces||d.Namespaces,this.xpath||d.AtomEntryXPath);this.inherited(arguments)},getId:function(){return this.getAsString("id")},getTitle:function(){return this.getAsString("title")},setTitle:function(a){return this.setAsString("title",a)},getSummary:function(){return this.getAsString("summary")}, -setSummary:function(a){return this.setAsString("summary",a)},getContent:function(){return this.getAsString("content")},setContent:function(a){return this.setAsString("content",a)},getCategoryTerms:function(){return this.getAsArray("categoryTerm")},setCategoryTerms:function(a){return this.setAsArray("categoryTerm",a)},getAuthor:function(){return this.getAsObject(["authorUserid","authorName","authorEmail","authorUserState"],["userid","name","email","userState"])},getContributor:function(){return this.getAsObject(["contributorUserid", -"contributorName","contributorEmail","contributorUserState"],["userid","name","email","userState"])},setContributor:function(a){return this.setAsObject(a)},getPublished:function(){return this.getAsDate("published")},getUpdated:function(){return this.getAsDate("updated")},getAlternateUrl:function(){return this.getAsString("alternateUrl")},getSelfUrl:function(){return this.getAsString("selfUrl")},getEditUrl:function(){return this.getAsString("editUrl")},createPostData:function(){var a=c.transform('${categoryScheme}${createTitle}${createContent}${createSummary}${createContributor}${createTags}${createEntryData}', -this,function(a){return a},this);return c.trim(a)},createTitle:function(){var a=this.getTitle();return a?c.transform('${title}',{title:c.htmlEntity(a)}):""},createContent:function(){var a=this.getContent();return a?("html"==this.contentType&&(a=a&&h.isString(a)?c.htmlEntity(a):a),c.transform('${content}',{contentType:this.contentType,content:a})):""},createSummary:function(){var a=this.getSummary();return a?c.transform('${summary}', -{summary:a}):""},createContributor:function(){var a=this.getContributor();if(a){var b="",d=a.email||(this.getEmail?this.getEmail():null);d&&(b+=c.transform("${email}",{email:d}));(a=a.userid||(this.getUserid?this.getUserid():null))&&(b+=c.transform('${userid}',{userid:a}));0${contributor}",{contributor:b}));return b}return""},createTags:function(){if(this.getTags&& -this.getTags()){var a="",b=this.getTags(),d;for(d in b)a+=c.transform('',{tag:b[d]});return a}return""},createEntryData:function(){return""},createNamespaces:function(){var a="",b=this.dataHandler?this.dataHandler.namespaces:this.namespaces;for(prefix in b)"a"!=prefix&&(a+=0=d.length&&c.substring(0,d.length)==d},endsWith:function(c,d){return c.length>=d.length&&c.substring(c.length-d.length)==d},transform:function(c,d,b,a){return c.replace(/\$\{([^\s\:\}]+)(?:\:([^\s\:\}]+))?\}/g,function(g,c){var k=d[c]||"";if("function"==typeof k)try{k=k.apply(a,[d])}catch(h){k="ERROR:"+c+" "+h}b&&(k=b.call(a,k,c));return"undefined"==typeof k||null==k?"":k.toString()})},hashCode:function(c){if(0==c.length)return 0;var d=0,b,a;for(b=0, -l=c.length;b\&]/gim,function(c){return"&#"+c.charCodeAt(0)+";"})}}})},"sbt/base/XmlDataHandler":function(){define("../declare,../lang,../stringUtil,../xml,../xpath,./DataHandler".split(","),function(i,h,c,d,b,a){return i(a,{dataType:"xml",xpath:null,namespaces:null,_values:null,_summary:null,constructor:function(a){h.mixin(this,a);this._values={};this.data=this._fromNodeOrString(a.data)}, -setData:function(a){this._values={};this.data=this._fromNodeOrString(a)},getAsString:function(a){this._validateProperty(a,"getAsString");return this._values?(this._values.hasOwnProperty(a)||(this._values[a]=this._selectText(a)),this._values[a]):_selectText(a)},getAsNumber:function(a){this._validateProperty(a,"getAsNumber");return this._values?(this._values.hasOwnProperty(a)||(this._values[a]=this._selectNumber(a)),this._values[a]):this._selectNumber(a)},getAsDate:function(a){this._validateProperty(a, -"getAsDate");return this._values?(this._values.hasOwnProperty(a)||(this._values[a]=this._selectDate(a)),this._values[a]):this._selectDate(a)},getAsBoolean:function(a){this._validateProperty(a,"getAsBoolean");return this._values?(this._values.hasOwnProperty(a)||(this._values[a]=this._selectBoolean(a)),this._values[a]):this._selectBoolean(a)},getAsArray:function(a){this._validateProperty(a,"getAsArray");return this._values?(this._values.hasOwnProperty(a)||(this._values[a]=this._selectArray(a)),this._values[a]): -this._selectArray(a)},getAsNodesArray:function(a){this._validateProperty(a,"getNodesArray");return this._values?(this._values.hasOwnProperty(a)||(this._values[a]=this._selectNodesArray(a)),this._values[a]):this._selectNodesArray(a)},getEntityId:function(){return c.trim(this.getAsString("uid"))},getEntityData:function(a){var c=this.xpath.entry;if(!c)return a;this._values.entry||(this._values.entry=b.selectNodes(a,c,this.namespaces)[0]||null);return this._values.entry},getSummary:function(){if(!this._summary&& -this._getXPath("totalResults"))this._summary={totalResults:b.selectNumber(this.data,this._getXPath("totalResults"),this.namespaces),startIndex:b.selectNumber(this.data,this._getXPath("startIndex"),this.namespaces),itemsPerPage:b.selectNumber(this.data,this._getXPath("itemsPerPage"),this.namespaces)};return this._summary},getEntitiesDataArray:function(){var a=this.xpath.entries;if(!a)return this.data;this._values.entries||(this._values.entries=b.selectNodes(this.data,a,this.namespaces));return this._values.entries}, -toJson:function(){var a={},b;for(b in this.xpath)this.xpath.hasOwnProperty(b)&&(a[b]=this.getAsString(b));return a},_fromNodeOrString:function(a){return h.isString(a)?(a=c.trim(a),this.getEntityData(d.parse(a))):a},_getXPath:function(a){return this.xpath[a]||a},_validateProperty:function(a,b){if(!a){var d=c.substitute("Invalid argument for XmlDataHandler.{1} {0}",[a,b]);throw Error(d);}},_selectText:function(a){return!this.data?null:c.trim(b.selectText(this.data,this._getXPath(a),this.namespaces))}, -_selectNumber:function(a){return!this.data?null:b.selectNumber(this.data,this._getXPath(a),this.namespaces)},_selectDate:function(a){return!this.data?null:(a=this._selectText(a))?new Date(Date.parse(a)):null},_selectBoolean:function(a){if(!this.data)return!1;var a=b.selectNodes(this.data,this._getXPath(a),this.namespaces),j=!1;if(a){if(1==a.length&&(j=c.trim(a[0].text||a[0].textContent))){j=j.toLowerCase();if("false"==j)return!1;if("true"==j)return!0}j=0',constructor:function(){},createDataHandler:function(a,b,f,e,c){return new m({service:a,data:b,namespaces:e,xpath:c})},createEntryData:function(){var a,b=function(a){return a};a=""+d.transform("${getCommunityType}",this,b,this);a+=d.transform("${isExternal}", -this,b,this);this.getCommunityUuid()&&(a+=d.transform('${getCommunityUuid}instance?communityUuid=${getCommunityUuid} ',this,b,this));this.isSubCommunity()&&(a+=d.transform(' ',this,b,this));this.getCommunityTheme()&&(a+=d.transform('${getCommunityTheme}', -this,b,this));return d.trim(a)},getCommunityUuid:function(){var a=this.getAsString("communityUuid");return u(this.service,a)},setCommunityUuid:function(a){return this.setAsString("communityUuid",a)},getCommunityType:function(){var b=this.getAsString("communityType");if(!b)b=a.Restricted;return b},setCommunityType:function(a){return this.setAsString("communityType",a)},getCommunityTheme:function(){return this.getAsString("communityTheme")},setCommunityTheme:function(a){return this.setAsString("communityTheme", -a)},isExternal:function(){return this.getAsBoolean("isExternal")},setExternal:function(a){return this.setAsBoolean("isExternal",a)},isSubCommunity:function(){var a=this.getParentCommunityUrl();return null!=a&&""!=a?!0:!1},getParentCommunityUrl:function(){return this.getAsString("parentCommunityUrl")},getTags:function(){return this.getAsArray("tags")},setTags:function(a){return this.setAsArray("tags",a)},getCommunityUrl:function(){return this.getAlternateUrl()},getLogoUrl:function(){return this.getAsString("logoUrl")}, -getMemberCount:function(){return this.getAsNumber("memberCount")},getForumTopics:function(a){return this.service.getForumTopics(this.getCommunityUuid(),a)},createForumTopic:function(a,b,f){c.isString(a)||(f=b,b=a);return this.service.createForumTopic(b,f)},getSubCommunities:function(a){return this.service.getSubCommunities(this.getCommunityUuid(),a)},getMembers:function(a){return this.service.getMembers(this.getCommunityUuid(),a)},addMember:function(a,b){return this.service.addMember(this.getCommunityUuid(), -a,b)},removeMember:function(a,b){return this.service.removeMember(this.getCommunityUuid(),a,b)},getMember:function(a,b){return this.service.getMember(this.getCommunityUuid(),a,b)},getAllInvites:function(a){return this.service.getAllInvites(this.getCommunityUuid(),a)},getForums:function(a){var b=this.service.getForumService(),a=c.mixin(a||{},{communityUuid:this.getCommunityUuid()});return b.getForums(a)},load:function(b){var f=this.getCommunityUuid(),e=this.service._validateCommunityUuid(f);if(e)return e; -var g=this,b={handleAs:"text",query:c.mixin({communityUuid:f},b||{})};return this.service.getEntity(a.AtomCommunityInstance,b,f,{createEntity:function(a,b,f){g.setData(b,f);return g}})},remove:function(a){return this.service.deleteCommunity(this.getCommunityUuid(),a)},update:function(a){return this.service.updateCommunity(this,a)},save:function(a){return this.getCommunityUuid()?this.service.updateCommunity(this,a):this.service.createCommunity(this,a)}}),e=i(j,{xpath:a.MemberXPath,namespaces:a.CommunityNamespaces, -categoryScheme:'',communityUuid:null,constructor:function(){this.getRole()||this.setRole(a.Member)},createEntryData:function(){var a;a=""+d.transform('${getRole}',this,function(a){return a},this);return d.trim(a)},getCommunityUuid:function(){return this.communityUuid},getName:function(){return this.getAsString("contributorName")}, -setName:function(a){return this.setAsString("contributorName",a)},getUserid:function(){return this.getAsString("contributorUserid")},setUserid:function(a){return this.setAsString("contributorUserid",a)},getEmail:function(){return this.getAsString("contributorEmail")},setEmail:function(a){return this.setAsString("contributorEmail",a)},getRole:function(){return this.getAsString("role")},setRole:function(a){return this.setAsString("role",a)},load:function(b){var f=this.communityUuid,e=this.service._validateCommunityUuid(f); -if(e)return e;var g=this,f={communityUuid:f},e=null,e=this.getUserid()?f.userid=this.getUserid():f.email=this.getEmail(),f=c.mixin(f,b||{});return this.service.getEntity(a.AtomCommunityMembers,{handleAs:"text",query:f},e,{createEntity:function(a,b,f){g.setData(b,f);return g}})},remove:function(a){var b=this.getUserid()||this.getEmail();return this.service.removeMember(this.getCommunityUuid(),b,a)}}),r=i(j,{xpath:a.InviteXPath,namespaces:a.CommunityNamespaces,categoryScheme:'', -communityUuid:null,inviteeUuid:null,constructor:function(a){this.inherited(arguments,[a])},getInviteUuid:function(){var a=this.getAsString("inviteUuid");return a&&0==a.indexOf("urn:lsid:ibm.com:communities:invite-")?a.substring(36):a},setInviteUuid:function(a){return this.setAsString("inviteUuid",a)},setCommunityUuid:function(a){this.communityUuid=a;return this},getCommunityUuid:function(){if(!this.communityUuid)this.communityUuid=this.service.getUrlParameter(this.getAsString("communityUrl"),"communityUuid"); -return this.communityUuid},setInviteeUuid:function(a){this.inviteeUuid=a;return this},getInviteeUuid:function(){if(!this.inviteeUuid){var a=this.getInviteUuid(),b=this.getCommunityUuid();this.inviteeUuid=a&&0==a.indexOf(b)?a.substring(b.length+1):a}return this.inviteeUuid},setUserid:function(a){return this.setAsString("contributorUserid",a)},getUserid:function(){return this.getAsString("contributorUserid")},setEmail:function(a){return this.setAsString("contributorEmail",a)},getEmail:function(){return this.getAsString("contributorEmail")}, -load:function(b){var f=this.getCommunityUuid(),e=this.service._validateCommunityUuid(f);if(e)return e;var g=this.getInviteeUuid();if(e=this.service._validateUserid(g))return e;var q=this,b={handleAs:"text",query:c.mixin({communityUuid:f,userid:g},b||{})};return this.service.getEntity(a.AtomCommunityInvites,b,f+"-"+g,{createEntity:function(a,b,f){q.setData(b,f);return q}})},remove:function(a){return this.service.removeInvite(this,a)},update:function(a){return this.service.updateInvite(this,a)},save:function(a){return this.getInviteUuid()? -this.service.updateInvite(this,a):this.service.createInvite(this,a)}}),s=i(j,{constructor:function(){},getEventUuid:function(){return this.getAsString("eventUuid")},getLocation:function(){return this.getAsString("location")},getAllDay:function(){return 0!==this.getAsString("allDay")},getSelfLink:function(){return this.getAsString("selfLink")},getSource:function(){return this.getAsObject(["id","title","link"],["id","title","link"])},getRecurrence:function(){return this.getAsObject("frequency,interval,until,allDay,startDate,endDate,byDay".split(","), +"../base/BaseConstants"],function(i,h){return i.mixin(h,{SmartcloudFeedXPath:{entries:"/a:feed/a:entry",totalResults:"/a:feed/opensearch:totalResults",startIndex:"/a:feed/opensearch:startIndex",itemsPerPage:"/a:feed/opensearch:itemsPerPage"}})})},"sbt/_bridge/declare":function(){define(["dojo/_base/declare"],function(i){return i})},"sbt/i18n":function(){define(["./_bridge/i18n"],function(i){return i})},"sbt/DebugTransport":function(){define("./declare,./lang,./dom,./json,./stringUtil,sbt/_bridge/Transport".split(","), +function(i,h,c,d,b,a){return i(a,{responseMap:{},index:0,createResponse:function(a,j,k,h){var i=this.inherited(arguments,[a,j,k,h]),m=c.byId("mockData");if(m){"json"==j.handleAs&&(k=d.jsonBeanStringify(k));var n=document.createElement("pre");m.appendChild(n);var m=i.status||0,e=j.handleAs||"text",r=j.method||"GET",s=i.getHeader("Location")||"",t=k instanceof Error;t&&(k=i.data.responseText||i.data.response.text||k);var u=a,f=b.hashCode(u);this.responseMap[f]?(this.responseMap[f]+=1,u+="#"+this.responseMap[f]): +this.responseMap[f]=1;n.appendChild(c.createTextNode(" \r\n \r\n
\r\n \r\n \r\n
\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n\r\n \r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n
\r\n \r\n\r\n \r\n
\r\n
\r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n\r\n", +'url:sbt/connections/controls/forums/templates/TopicBreadCrumb.html':"
\r\n\r\nForums>Topics\r\n
", +'sbt/emailService':function(){ /* * © Copyright IBM Corp. 2012 * @@ -519,21 +464,115 @@ define(["../../../declare", */ /** - * Definition of some DOM utilities. + * Provides functionality to send emails. * - * @module sbt.dom + * @module sbt.emailService */ -define(['./_bridge/dom'],function(dom) { - // The actual implementation is library dependent - // NOTE: dom.byId returns either a DOM element or false (null/undefined) - return dom; +define(['./declare', './lang', './config', './_bridge/Transport', './json'], function(declare, lang, config, Transport, sbtJson) { + var transport = new Transport(); + return { + /** + * Sends an email. + * @method send + * @static + * @param {Object || Array} email The JSON object representing the email to send. + * @return {sbt.Promise} A promise to fulfill the send. + * + * @example + * var emails = + * [ + * { + * "from" : "sdary@renovations.com", + * "to" : ["fadams@renovations.com", "tamado@renovations.com"], + * "cc" : ["pclemmons@renovations.com"], + * "bcc" : [], + * "subject" : "This is a test email", + * "mimeParts" : + * [ + * { + * "mimeType" : "text/plain", + * "content" : "This is plain text", + * "headers" : + * { + * "header1":"value1", + * "header2":"value2" + * } + * }, + * { + * "mimeType" : "text/html", + * "content" : "This is html" + * }, + * { + * "mimeType" : "application/embed+json", + * "content" : { + * "gadget" : "http://renovations.com/gadget.xml", + * "context" : { + * "foo" : "bar" + * } + * } + * } + * ] + * }, + * { + * "from" : "sdaryn@renovations.com", + * "to" : ["fadams@renovations.com", "tamado@renovations.com"], + * "subject": "This is a test email", + * "mimeParts" : + * [ + * { + * "mimeType" : "text/plain", + * "content" : "This is plain text" + * }, + * { + * "mimeType" : "text/html", + * "content" : "This is html" + * } + * ] + * } + * ]; + * var successCallback = function(response) { + * //If you send multiple emails, for example emails is an array of email objects, + * //than it is possible that some emails succeeded being sent while others may have + * //failed. It is good practice to check for any emails that had errors being sent. + * if(response.error && response.error.length != 0) { + * //There was one of more errors with emails sent, handle them + * } + * + * if(response.successful && response.successful.length > 0) { + * //Some or all of your emails were successfully sent + * } + * }; + * + * var errorCallback = function(error) { + * //This callback will only be called if there was an error in the request + * //being made to the server. It will NOT be called if there are errors + * //with any of the emails being sent. + * if(error.message) { + * //The request failed handle it. + * } + * }; + * + * email.send(emails).then(successCallback, errorCallback); + */ + send : function(emails) { + var postUrl = config.Properties.serviceUrl + '/mailer'; + + var options = { + method: "POST", + data: sbtJson.stringify(emails), + headers: {"Content-Type" : "application/json"}, + handleAs: "json" + }; + + return transport.request(postUrl, options); + } + }; }); - }, -'url:sbt/connections/controls/sharebox/templates/InputFormContent.html':"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n", -'sbt/connections/controls/sharebox/_InputForm':function(){ +'url:sbt/connections/controls/bootstrap/templates/ProfileRow.html':"\r\n\t\r\n\t\t
\r\n\t\t\t\r\n\t\t
\r\n\t\r\n\t\r\n\t\t
\"${name}\"
\r\n\t\r\n\t\r\n\t\t
\r\n\t\t\t

\r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

\r\n\t\t\t
\r\n\t\t
\r\n\t\r\n\t\r\n\t\t
\r\n\t\t\t
${nls.telephone} ${telephone}
\r\n\t\t\t
${nls.email}: ${email}
\r\n\t\t\t
${nls.altEmail}: ${altEmail}
\r\n\t\t
\r\n\t\r\n\r\n", +'sbt/connections/SearchConstants':function(){ /* - * (C) Copyright IBM Corp. 2012 + * © 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. @@ -547,118 +586,137 @@ define(['./_bridge/dom'],function(dom) { * implied. See the License for the specific language governing * permissions and limitations under the License. */ -define(["sbt/declare", "sbt/json", "sbt/connections/controls/_ConnectionsWidget"],function(declare, json, _ConnectionsWidget){ - /** - * InputForm - */ - var _InputForm = declare([_ConnectionsWidget], - { +/** + * Social Business Toolkit SDK. + * Definition of constants for SearchService. + */ +define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { + + return lang.mixin(conn, { + /** - * The connections InputForm. - * - * @property inputForm - * @type Object + * Namespaces to be used when reading the Search ATOM feed */ - inputForm: null, + SearchNamespaces : { + a : "http://www.w3.org/2005/Atom", + ibmsc : "http://www.ibm.com/search/content/2010", + opensearch : "http://a9.com/-/spec/opensearch/1.1/", + relevance : "http://a9.com/-/opensearch/extensions/relevance/1.0/", + snx : "http://www.ibm.com/xmlns/prod/sn", + spelling : "http://a9.com/-/opensearch/extensions/spelling/1.0/" + }, /** - * Set up the connections InputForm. - * - * @method constructor - * @param {Object} args - * @param {String} args.shareBoxNode Should contain the id of the html element to add the InputForm to. + * XPath expressions used when parsing a Connections Search ATOM feed */ - constructor: function(args){ - var url = "/${connections}/opensocial/basic/rest/ublog/@config/settings"; - var self = this; - - var xhrArgs = { - serviceUrl: url, //TODO Change these when opensocial oauth and/or endpoints become available - handleAs: "json", - load: function(data) { - var settings = { - maxNumberChars: 1000, - boardId: args.boardId || "@me", - postType: lconn.news.microblogging.sharebox.Context.SU_CONTEXT - }; - var connectionsSettings = data && data.entry; - if(connectionsSettings){ - settings.maxNumberChars = connectionsSettings["com.ibm.connections.ublog.microblogEntryMaxChars"]; - self.inputForm = new lconn.news.microblogging.sharebox.InputForm({ - params : settings, - "xhrHandler" : self.xhrHandler, - "UBLOG_RELATIVE_PATH" : "/basic/rest/ublog/", - isASGadget : false - }, dojo.byId(args.shareBoxNode)); - if(self.inputForm.attachActionButtonNode){ - dojo.empty(self.inputForm.attachActionButtonNode); - } - - self.modifyPostFunction(); - } - }, - error: function() { - console.log("Failed to find InputForm settings at " + url); - } - }; - - this.xhrHandler.xhrGet(xhrArgs); + SearchFeedXPath : conn.ConnectionsFeedXPath, + + /** + * XPath expressions used when parsing a Connections Search facets feed + * that only contains a single facet + */ + SingleFacetXPath : { + // used by getEntitiesDataArray + entries : "/a:feed/ibmsc:facets/ibmsc:facet[@id='{facet.id}']/ibmsc:facetValue" + // used by getSummary + //totalResults : "", + //startIndex : "", + //itemsPerPage : "" }, - + /** - * A hack needed to overcome a hardcoded dojo.xhr request in the connections InputForm. Overwrites the offending function. - * - * @method modifyPostFunction + * XPath expressions used when parsing a Connections Search facet */ - modifyPostFunction: function(){ - this.inputForm.postMicroblog = function (microblogMessage, fileAttachment) { - this._setPostButtonLabel(this._resourceBundle.POSTING); - this._setSubmitState(true); - var requestObj = this._buildRequestObj(microblogMessage, fileAttachment); - var postUrl = this._getPostUrlForContext(); - postUrl = postUrl.slice(postUrl.lastIndexOf("/connections")); - this.xhrHandler.xhrPost({ - serviceUrl: postUrl, - postData: json.stringify(requestObj), - handleAs: "json", - load: dojo.hitch(this, function (data) { - if (this.isGlobalSharebox){ - dojo.publish(this.AS_UPDATE, [data.entry.id]); - } else { - dojo.publish(this.TOPIC_POST_MESSAGE, [data]); - } - this._setInitialState(); - this._setSubmitState(false); - this._displaySuccessMessage(); - if (this.isGlobalSharebox) { - this._closeSharebox(); - this.setShareMode(lconn.news.microblogging.sharebox.constants.SHAREWITHEVERYONE); - dojo.publish(lconn.news.microblogging.sharebox.events.STATUSSHAREBOX_CLOSING); - } else { - this.mbSuccessClose.focus(); - this.textBoxControl.collapseTextBox(); - } - - this._setPostButtonLabel(this._resourceBundle.POST); + FacetValueXPath : { + // used by getEntityData + entry : "/ibmsc:facetValue", + // used by getEntityId + uid : "@id", + // used by getters + id : "@id", + label : "@label", + weight : "@weight" + }, - }), - error: dojo.hitch(this, function (data) { - this._handlePostError(data); - }), - headers: { - "Content-Type": "application/json" - } - }); - }; - } + /** + * XPath expressions to be used when reading a scope + */ + ScopeXPath : lang.mixin({}, conn.AtomEntryXPath, { + link : "link" + }), + + /** + * XPath expressions to be used when reading a search result + */ + SearchXPath : lang.mixin({}, conn.AtomEntryXPath, { + rank : "snx:rank", + relevance : "relevance:score", + type : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", + application : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/component']/@term", + applicationCount : "count(a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/component']/@term)", + primaryComponent : "a:category[ibmsc:field[@id='primaryComponent']]/@term", + tags : "a:category[not(@scheme)]/@term", + commentCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/comment']", + resultLink : "a:link[not(@rel)]/@href", + bookmarkLink : "ibmsc:field[@id='dogearURL']", + eventStartDate : "ibmsc:field[@id='eventStartDate']", + authorJobTitle : "a:content/xhtml:div/xhtml:span/xhtml:div[@class='title']", + authorJobLocation : "a:content/xhtml:div/xhtml:span/xhtml:div[@class='location']", + authorCount : "count(a:contributor)", + contributorCount : "count(a:author)", + tagCount : "count(a:category[not(@scheme)])", + highlightField : "ibmsc:field[@id='highlight']", + fileExtension : "ibmsc:field[@id='fileExtension']", + memberCount : "snx:membercount", + communityUuid : "snx:communityUuid", + containerType : "ibmsc:field[@id='container_type']", + communityParentLink : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/container' and @type='text/html']/@href", + parentageMetaID : "ibmsc:field[contains(@id, 'ID')]/@id", + parentageMetaURL : "ibmsc:field[contains(@id, 'URL')]", + parentageMetaURLID : "ibmsc:field[contains(@id, 'URL')]/@id", + objectRefDisplayName : "ibmsc:field[@id='FIELD_OBJECT_REF_DISPLAY_NAME']", + objectRefUrl : "ibmsc:field[@id='FIELD_OBJECT_REF_URL']", + accessControl : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/accesscontrolled']/@term", + commentsSummary : "ibmsc:field[@id='commentsSummary']" + }), + + /** + * Returns the set of supported values that can be passed to the "scope" parameter of the Search API. + * Scopes relating to Connections applications that have not been installed will not be returned. + */ + AtomScopes : "/${search}/atom/scopes", + + /** + * API call for searching IBM Connections to find content that, for example, contains a specific text + * string in its title or content, or is tagged with a specific tag. + */ + AtomSearch : "/${search}/atom/search", + + /** + * API call for searching IBM Connections to find content that, for example, contains a specific text + * string in its title or content, or is tagged with a specific tag. + */ + AtomMySearch : "/${search}/atom/mysearch", + + /** + * These API's are all deprecated + */ + publicSearch : "/${search}/atom/search/results", + mySearch : "/${search}/atom/mysearch/results", + peopleSearch : "/${search}/atom/search/facets/people", + myPeopleSearch : "/${search}/atom/mysearch/facets/people", + tagsSearch : "/${search}/atom/search/facets/tags", + myTagsSearch : "/${search}/atom/mysearch/facets/tags", + dateSearch : "/${search}/atom/search/facets/date", + myDateSearch : "/${search}/atom/mysearch/facets/date", + sourceSearch : "/${search}/atom/search/facets/source", + mySourceSearch : "/${search}/atom/mysearch/facets/source" - }); - return _InputForm; + }); }); - }, -'sbt/smartcloud/controls/profiles/nls/ProfileGridRenderer':function(){ +'sbt/connections/WikiService':function(){ /* * © Copyright IBM Corp. 2013 * @@ -675,2047 +733,1263 @@ define(["sbt/declare", "sbt/json", "sbt/connections/controls/_ConnectionsWidget" * permissions and limitations under the License. */ -// NLS_CHARSET=UTF-8 -define({ - root: { - summary : "Profiles Grid", - updatedBy : "Updated by ", - displayName: "Display Name", - recent: "Recent", - telephone: "Telephone:", - email: "Email:", - altEmail: "Alternate Email", - clickToEmail: "Click here to email the user, using their alternate email address", - ariaVcard: "Press control and enter for the business card", - communityIdError: "Community Uuid must not be empty" - } -}); - - -}, -'sbt/nls/Endpoint':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ - /** - * Social Business Toolkit SDK - Default resource bundle for validate module. - */ - - -define({ - root: ({ - cannot_find_endpoint:"Unable to find endpoint named {0}, creating it now with an error transport." - }) - -}); -}, -'sbt/connections/controls/forums/nls/ForumGridRenderer':function(){ -/* - * © 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 + * The Wikis application of IBM© Connections enables teams to create a shared repository of information. + * The Wikis API allows application programs to create new wikis, and to read and modify existing wikis. * - * 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. + * @module sbt.connections.WikiService */ +define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./WikiConstants", "./ConnectionsService", + "../base/AtomEntity", "../base/XmlDataHandler" ], + function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler) { + + var CategoryWiki = ""; + var CategoryWikiPage = ""; + + var LabelTmpl = "${getLabel}"; + var PermissionsTmpl = "${getPermissions}"; + var CategoryTmpl = ""; + + /** + * Wiki class represents an entry for a Wiki or Wiki Page feed returned by the + * Connections REST API. + * + * @class BaseWikiEntity + * @namespace sbt.connections + */ + var BaseWikiEntity = declare(AtomEntity, { + + /** + * Set to true to include the label in the post data when + * performing an update or create operation. By default the + * label is not sent which will keep it in synch with the + * Wiki or WikiPage title. + */ + includeLabelInPost : false, + + /** + * Construct a BaseWikiEntity entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, + + /** + * Return extra entry data to be included in post data for this entity. + * + * @returns {String} + */ + createEntryData : function() { + var postData = ""; + var transformer = function(value,key) { + return value; + }; + if (this.getLabel() && this.includeLabelInPost) { + postData += stringUtil.transform(LabelTmpl, this, transformer, this); + } + if (this.getPermissions()) { + postData += stringUtil.transform(PermissionsTmpl, this, transformer, this); + } + return stringUtil.trim(postData); + }, + + /** + * Return an array containing the tags for this wiki. + * + * @method getTags + * @return {Array} + */ + getTags : function() { + var tags = this.getAsArray("tags"); + return this.getAsArray("tags"); + }, + + /** + * Return an array containing the tags for this wiki. + * + * @method setTags + * @param {Array} + */ + setTags : function(tags) { + return this.setAsArray("tags", tags); + }, + + /** + * Return the value of id from Wiki ATOM + * entry document. + * + * @method getWikiUuid + * @return {String} Id of the Wiki + */ + getUuid : function() { + var uid = this.getAsString("uuid"); + return extractWikiUuid(uid); + }, -// NLS_CHARSET=UTF-8 -define({ - root: { - forums: "Forums", - forum: "Forum", - threads: "Topics", - latestPost: "Latest Post", - goToForum: "Go To The Forum", - viewProfile: "View Profile", - replies: "Replies", - topics: "Topic", - topic: "Topic", - author: "Author", - date: "Date", - back:"Back", - noResults: "There are no results", - feed : "Feed for these Forums" - } -}); -}, -'url:sbt/connections/controls/forums/templates/MyTopicsBreadCrumb.html':"
\r\n\r\nTopics>Replies\r\n
", -'url:sbt/connections/controls/search/templates/ProfileBody.html':"
\r\n
    \r\n \r\n ${profileBodyJobTitle}\r\n ${tagsList}\r\n
\r\n
", -'url:sbt/connections/controls/search/templates/em.html':"\r\n ${content}\r\n", -'sbt/xml':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ + /** + * Sets id of IBM Connections Wiki ATOM + * entry document. + * + * @method setWikiUuid + * @param {String} Id of the Wiki + */ + setUuid : function(uuid) { + return this.setAsString("uuid", uuid); + }, -/** - * Social Business Toolkit SDK - XML utilities. - */ -define(['./lang'], function(lang) { - var xml_to_encoded = { - '&': '&', - '"': '"', - '<': '<', - '>': '>' - }; + /** + * Return short text label used to identify the Wiki Entry in API operation resource addresses. + * + * @method getLabel + * @return {String} short text label used to identify the Wiki Entry in API operation resource addresses. + */ + getLabel : function() { + return this.getAsString("label"); + }, - var encoded_to_xml = { - '&': '&', - '"': '"', - '<': '<', - '>': '>' - }; - - return { - /** - * XML Parser. - * This function parses an XML string and returns a DOM. - */ - parse: function(xml) { - var xmlDoc=null; - try { - if(!document.evaluate){ - xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); - xmlDoc.async="false"; - xmlDoc.loadXML(xml); - }else{ - if(window.DOMParser){ - parser=new DOMParser(); - xmlDoc=parser.parseFromString(xml,"text/xml"); - } - } - }catch(ex){ - console.log(ex.message); - } - return xmlDoc; - }, - asString: function(xmlDoc) { - if (xmlDoc==null) { - return ""; - } else if(window.ActiveXObject){ - return xmlDoc.xml; - } else { - return (new XMLSerializer()).serializeToString(xmlDoc); - } - }, - getText : function (xmlElement){ - if(!document.evaluate){ - return xmlElement.text; - }else{ - return xmlElement.textContent; - } - }, - encodeXmlEntry: function(string) { - if (lang.isArray(string)) { - string = string.join(); - } - if (!lang.isString(string)) { - string = string.toString(); - } - return string.replace(/([\&"<>])/g, function(str, item) { - return xml_to_encoded[item]; - }); - }, - decodeXmlEntry: function (string) { - return string.replace(/("|<|>|&)/g,function(str, item) { - return encoded_to_xml[item]; - }); - } - }; -}); -}, -'sbt/stringUtil':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ + /** + * Set the short text label used to identify the Wiki Entry in API operation resource addresses. + * + * @method setLabel + * @param label short text label used to identify the Wiki Entry in API operation resource addresses. + */ + setLabel : function(label) { + return this.setAsString("label", label); + }, -/** - * Defination of some string Utilities - * - * @module sbt.stringUtil - */ -define(['./xml'], function(xml) { + /** + * Return the set of permissions available for the Wiki Entry. + * + * @method getPermissions + * @return {String} Permissions available for the Wiki Entry + */ + getPermissions : function() { + return this.getAsString("permissions"); + }, + + /** + * Set the permissions available for the Wiki Entry. + * + * @method setPermissions + * @param permissions Permissions available for the Wiki Entry + */ + setPermissions : function(permissions) { + return this.setAsString("permissions", permissions); + }, + + /** + * Return modifier of the Wiki Entry. + * + * @method getModifier + * @return {Object} Modifier of the Wiki Entry + */ + getModifier : function() { + return this.getAsObject( + [ "modifierUserid", "modifierName", "modifierEmail", "modifierUserState" ], + [ "userid", "name", "email", "userState" ]); + }, - var _regex = new RegExp("{-?[0-9]+}", "g"); + /** + * Return the date the wiki was created. + * + * @method getCreated + * @return {Date} Date the wiki was created + */ + getCreated : function() { + return this.getAsDate("created"); + }, - return { - /** - * Substitutes the String with pattern {<>} with argument array provided. {-1} is for printing '{' and {-2} is for printing '}' in the text - * - * @param {String} [str] String to be formatted - * @param {Array} [args] arguments Array - * @param {Boolean} [useBlankForUndefined = false] optional flag to indicate to user blank String in case index is not found in args. - * @static - * @method substitute - */ - substitute : function(str, args, useBlankForUndefined) { - if (str && args) { - return str.replace(_regex, function(item) { - var intVal = parseInt(item.substring(1, item.length - 1)); - var replace; - if (intVal >= 0) { - replace = args[intVal] ? args[intVal] : useBlankForUndefined ? "" : "undefined"; - } else if (intVal == -1) { - replace = "{"; - } else if (intVal == -2) { - replace = "}"; - } else { - replace = ""; - } - return replace; - }); - } - return str; - }, - - /** - * Replaces the String with pattern {<>} with argument map provided. Replaces blank if key to be replaces is not found in argsMap. - * - * @param {String} [str] String to be formatted - * @param {Array} [argsMap] arguments Map - * @static - * @method replace - */ - replace : function(str, argsMap) { - if (str && argsMap) { - return str.replace(/{(\w*)}/g, function(m, key) { - var replace; - replace = argsMap.hasOwnProperty(key) ? xml.encodeXmlEntry(argsMap[key]) : ""; - return replace; - }); - } - return str; - }, - - trim: function x_trim(s) { - return s ? s.replace(/^\s+|\s+$/g,"") : s; - }, - - startsWith: function x_sw(s,prefix) { - return s.length>=prefix.length && s.substring(0,prefix.length)==prefix; - }, - - endsWith: function x_ew(s,suffix) { - return s.length>=suffix.length && s.substring(s.length-suffix.length)==suffix; - }, - - transform: function(template, map, transformer, thisObject) { - return template.replace(/\$\{([^\s\:\}]+)(?:\:([^\s\:\}]+))?\}/g, - function(match, key, format){ - var value = map[key] || ""; - if (typeof value == 'function') { - // invoke function to return the value - try { - value = value.apply(thisObject, [ map ]); - } catch (ex) { - value = "ERROR:" + key + " " + ex; - } - } - if (transformer) { - value = transformer.call(thisObject, value, key); - } - if (typeof value == "undefined" || value == null) { - return ""; - } - return value.toString(); - } - ); - }, - - hashCode: function(str) { - if (str.length == 0) { - return 0; - } - var hash = 0, i, charStr; - for (i = 0, l = str.length; i < l; i++) { - charStr = str.charCodeAt(i); - hash = ((hash<<5)-hash)+charStr; - hash |= 0; - } - return hash; - }, - - htmlEntity : function(htmlContent){ - return htmlContent.replace(/[\u00A0-\u9999<>\&]/gim, function(c) { - return '&#'+c.charCodeAt(0)+';'; - }); + /** + * Return the date the wiki was modified. + * + * @method getModified + * @return {Date} Date the wiki was modified + */ + getModified : function() { + return this.getAsDate("modified"); } - }; -}); - -}, -'sbt/connections/ForumConstants':function(){ -/* - * © 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. - */ -/** - * Social Business Toolkit SDK. - * Definition of constants for ForumService. - */ -define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - - return lang.mixin(conn, { - - /** - * Term value with a forum recommendation - */ - FlagAnswer : "recommendation", - - /** - * Term value when a forum reply is an accepted answer - */ - FlagAnswer : "answer", - - /** - * Term value when a forum topic is pinned - */ - FlagPinned : "pinned", - - /** - * Term value when a forum topic is locked - */ - FlagLocked : "locked", - - /** - * Term value when a forum topic is a question - */ - FlagQuestion : "question", - - /** - * Term value when a forum topic is an answered question - */ - FlagAnswered : "answered", - - /** - * Category term and scheme to lock a topic - */ - setLocked: "locked scheme=\"http://www.ibm.com/xmlns/prod/sn/flags\"", + }); + + /** + * Wiki class represents an entry for a Wiki feed returned by the + * Connections REST API. + * + * @class Wiki + * @namespace sbt.connections + */ + var Wiki = declare(BaseWikiEntity, { - /** - * Category term and scheme to pin a topic - */ - setPinned: "pinned scheme=\"http://www.ibm.com/xmlns/prod/sn/flags\"", + xpath : consts.WikiXPath, + contentType : "html", + categoryScheme : CategoryWiki, - /** - * Category term and scheme to mark a topic as a question - */ - markAsQuestion: "question scheme=\"http://www.ibm.com/xmlns/prod/sn/flags\"", - /** - * XPath expressions used when parsing a Connections Forums ATOM feed + * Construct a Wiki entity. + * + * @constructor + * @param args */ - ForumsFeedXPath : conn.ConnectionsFeedXPath, - + constructor : function(args) { + }, + /** - * XPath expressions to be used when reading an forum entry + * Return the community©s unique ID if this wiki belongs to a community. + * + * @method getCommunityUuid + * @return {String} Uuid of the Community */ - ForumXPath : lang.mixin({ - forumUuid : "a:id", - content : "a:content[@type='text']", - tags : "a:category[not(@scheme)]/@term", - moderation : "snx:moderation/@status", - threadCount: "a:link[@rel='replies']/@thr:count", - forumUrl : "a:link[@rel='alternate']/@href", - communityUuid : "snx:communityUuid" - }, conn.AtomEntryXPath), - + getCommunityUuid : function() { + return this.getAsString("communityUuid"); + }, + /** - * XPath expressions to be used when reading an forum topic entry + * Set the community©s unique ID if this wiki belongs to a community. + * + * @method setCommunityUuid + * @param {String} communityUuid Community Uuid of the forum + * @return {Wiki} */ - ForumTopicXPath : lang.mixin({ - topicUuid : "a:id", - topicTitle: "a:title", - forumUuid : "thr:in-reply-to/@ref", - tags : "a:category[not(@scheme)]/@term", - permissions : "snx:permissions", - communityUuid : "snx:communityUuid", - threadCount: "a:link[@rel='replies']/@thr:count", - locked: "a:category[@term='locked' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", - pinned: "a:category[@term='pinned' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", - question: "a:category[@term='question' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", - answered: "a:category[@term='answered' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", - notRecommendedByCurrentUser: "a:category[@term='NotRecommendedByCurrentUser']", - threadRecommendationCount: "a:category[@term='ThreadRecommendationCount']/@label", - recommendationsUrl : "a:link[@rel='recommendations']/@href" - }, conn.AtomEntryXPath), + setCommunityUuid : function(communityUuid) { + return this.setAsString("communityUuid", communityUuid); + }, /** - * XPath expressions to be used when reading an forum reply entry + * return the wiki theme name. + * + * @method getThemeName + * @return {String} Wiki theme name */ - ForumReplyXPath : lang.mixin({ - replyUuid : "a:id", - topicUuid : "thr:in-reply-to/@ref", - permissions : "snx:permissions", - communityUuid : "snx:communityUuid", - answer: "a:category[@term='answer' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", - replyTo: "thr:in-reply-to/@ref", - notRecommendedByCurrentUser: "a:category[@term='NotRecommendedByCurrentUser']", - recommendationsUrl : "a:link[@rel='recommendations']/@href" - }, conn.AtomEntryXPath), - + getThemeName : function() { + return this.getAsString("themeName"); + }, + /** - * XPath expressions to be used when reading an forum recommendation entry + * Return the library size. + * + * @method getLibrarySize + * @return {Number} the library size */ - ForumRecommendationXPath : lang.mixin({ - postUuid : "a:link[@rel='self']/@href" - }, conn.AtomEntryXPath), - + getLibrarySize : function() { + return this.getAsNumber("librarySize"); + }, + /** - * Edit link for a forum entry. + * Return the library quota. + * + * @method getLibraryQuota + * @return {Number} the library quota */ - AtomForum : "${forums}/atom/forum", - + getLibraryQuota : function() { + return this.getAsNumber("libraryQuota"); + }, + /** - * Edit link for a forum topic entry. + * Return the total removed size. + * + * @method getTotalRemovedSize + * @return {Number} the total removed size */ - AtomTopic : "/${forums}/atom/topic", + getTotalRemovedSize : function() { + return this.getAsNumber("totalRemovedSize"); + }, - /** - * Edit link for a forum reply entry. + /** + * Get a list for wiki pages from this wiki. + * + * @method getPages + * @param {Object} args */ - AtomReply : "/${forums}/atom/reply", - - /** - * Get a feed that includes all stand-alone and community forums created in the enterprise. + getPages : function(args) { + return this.service.getWikiPages(this.getLabel(), args); + }, + + /** + * Loads the wiki object with the atom entry associated with the + * wiki. By default, a network call is made to load the atom entry + * document in the wiki object. + * + * @method load + * @param {Object} [args] Argument object */ - AtomForums : "/${forums}/atom/forums", - - /** - * Get a feed that includes all of the forums hosted by the Forums application. + load : function(args) { + // detect a bad request by validating required arguments + var label = this.getLabel(); + var promise = this.service._validateWikiLabel(label); + if (promise) { + return promise; + } + + var self = this; + var callbacks = { + createEntity : function(service,data,response) { + self.setData(data); + return self; + } + }; + + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + var url = this.service.constructUrl(consts.WikiEntry, null, { "wikiLabel" : encodeURIComponent(label) }); + + return this.service.getEntity(url, options, label, callbacks); + }, + + /** + * Remove this wiki + * + * @method remove + * @param {Object} [args] Argument object */ - AtomForumsPublic : "/${forums}/atom/forums/public", - - /** - * Get a feed that includes forums created by the authenticated user or associated with communities to which the user belongs. + remove : function(args) { + return this.service.deleteWiki(this.getLabel(), args); + }, + + /** + * Update this wiki + * + * @method update + * @param {Object} [args] Argument object */ - AtomForumsMy : "/${forums}/atom/forums/my", + update : function(args) { + return this.service.updateWiki(this, args); + }, - /** - * Get a feed that includes the topics in a specific stand-alone forum. + /** + * Save this wiki + * + * @method save + * @param {Object} [args] Argument object */ + save : function(args) { + if (this.getWikiUuid()) { + return this.service.updateWiki(this, args); + } else { + return this.service.createWiki(this, args); + } + } - AtomTopics : "/${forums}/atom/topics", - + }); + + /** + * WikiPage class represents an entry for a Wiki Page feed returned by the + * Connections REST API. + * + * @class WikiPage + * @namespace sbt.connections + */ + var WikiPage = declare(BaseWikiEntity, { + + xpath : consts.WikiPageXPath, + contentType : "html", + categoryScheme : CategoryWikiPage, + wikiLabel : null, + /** - * Get a feed that includes the topics that the authenticated user created in stand-alone forums and in forums associated - * with communities to which the user belongs. + * Construct a Wiki entity. + * + * @constructor + * @param args */ - AtomTopicsMy : "/${forums}/atom/topics/my", + constructor : function(args) { + }, /** - * Get a feed that includes all of the replies for a specific forum topic. + * Return the wiki label associated with this Wiki Page. + * + * @method getWikiLabel + * @return {String} wiki label */ - AtomReplies : "/${forums}/atom/replies", - + getWikiLabel : function() { + if (this.wikiLabel) { + return this.wikiLabel; + } else { + return this.getAsString("label"); + } + }, + /** - * Get a category document that lists the tags that have been assigned to forums. + * Set the wiki label associated with this Wiki Page. + * + * @method setWikiLabel + * @param {String} wiki label + * @return {WikiPage} */ - AtomTagsForum : "/atom/tags/forums", + setWikiLabel : function(wikiLabel) { + this.wikiLabel = wikiLabel; + return this; + }, /** - * Get a category document that lists the tags that have been assigned to forum topics. + * Return the last accessed date/time. + * + * @method getLastAccessed + * @return {Date} the last accessed date/time */ - AtomTagsTopics : "/atom/tags/topics", - + getLastAccessed : function() { + return this.getAsDate("lastAccessed"); + }, + /** - * Get a feed that includes all of the recommendations for a specific forum post. + * Return the version uuid. + * + * @method getVersionUuid + * @return {String} the version uuid */ - AtomRecommendationEntries : "/${forums}/atom/recommendation/entries" + getVersionUuid : function() { + return this.getAsString("versionUuid"); + }, - }); -}); -}, -'sbt/connections/controls/astream/_SbtAsConfigUtil':function(){ -/* - * © 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. - */ -define(["../../../declare", "../../../config", "../../../url", "../../../Promise"], function(declare, config, Url, Promise){ - /* - * @class sbt.controls.astream._SbtAsConfigUtil A helper module for building ActivityStream config objects. - */ - var _SbtAsConfigUtil = declare(null, - { - /* - * The constructor. + /** + * Return the version label. * - * @method constructor - * @param {Object} xhrHandler The xhrHandler to use when making requests for user info. + * @method getVersionLabel + * @return {String} the version label */ - constructor: function(xhrHandler){ - this.xhrHandler = xhrHandler; + getVersionLabel : function() { + return this.getAsString("versionLabel"); }, - - /* - * Goes to /rest/people/@me/@self and retrieves the user info + + /** + * Return the propagation. * - * var ui = { - * id: connId, - * osId: user.id, - * displayName: user.displayName - * }; - * - * Retrieves user info from connections. - * @method getUserInfo - * @returns {Promise} A promise. Resolves with a user info object containing a user id, an os id and a displayName. + * @method getPropagation + * @return {Boolean} the propagation */ - getUserInfo: function() { - var promise = new Promise(); - var microbloggingUrl = lconn.core.config.services.microblogging.secureUrl; - microbloggingUrl = microbloggingUrl.replace(this.xhrHandler.getEndpoint().getProxyUrl(), ""); - relativeUrl = microbloggingUrl.indexOf("/") === 0 ? microbloggingUrl : new Url(microbloggingUrl).getPath(); - var serviceUrl = relativeUrl + "/" + this.xhrHandler.endpoint.authType + "/rest/people/@me/@self"; - serviceUrl = this.xhrHandler.correctUrlAuth(serviceUrl); // ensure correct url for given auth type. - - this.xhrHandler.xhrGet({ - serviceUrl: serviceUrl, - handleAs: "json", - load: function(resp) { - var user = resp && resp.entry; - if (user && user.id && user.displayName) { - - var connId = user.id; - if (connId && connId.indexOf('urn:lsid:lconn.ibm.com:') != -1) { - var endPrefix = connId.lastIndexOf(':'); - if (endPrefix != -1) { - connId = connId.substr(endPrefix+1); - } - } + getPropagation : function() { + return this.getAsBoolean("propagation"); + }, - var ui = { - id: connId, - osId: user.id, - displayName: user.displayName - }; - promise.fulfilled(ui); - } - }, - error: function() { - promise.rejected(); - } - }); - - return promise; - }, - - /* - * Require only the extensions that we need. + /** + * Return the total media size. * - * @method requireExtensions - * @param {Array} extensionsArray Array containing a list of the modules to require. + * @method getTotalMediaSize + * @return {Number} the total media size */ - requireExtensions: function(extensionsArray){ - var i; - for(i = 0; i < extensionsArray.length; i++){ - var ext = extensionsArray[i]; - dojo.require(ext); - } + getTotalMediaSize : function() { + return this.getAsNumber("totalMediaSize"); }, - - getBoardIdFromUrl: function(url){ - if(url.indexOf("urn:lsid:")===-1) // is it a community? - return "@me"; - var stream = "/activitystreams/"; - var index = url.indexOf(stream)+stream.length; - var idString = url.slice(index); - index = 0; - var result = idString.substring(index, idString.indexOf("/")); - - return result; + + /** + * Return the number of recommendations. + * + * @method getRecommendations + * @return {Number} the number of recommendations + */ + getRecommendations : function() { + return this.getAsNumber("recommendations"); }, - - getBoardIdFromAppId: function(appId){ - if(appId.indexOf("urn:lsid:" === -1)){//is it a community? - return "@me"; - } - return appId; + + /** + * Return the number of comments. + * + * @method getComments + * @return {Number} the number of comments + */ + getComments : function() { + return this.getAsNumber("comment"); }, - - /* - * Build the config from a full config object. Adds missing information if - * needed, such as user info. + + /** + * Return the number of hits. * - * @method buildSbtConfigFull - * @param {Object} cfg An ActivityStream config object. If this does not contain user info then user info will be added based on the currently authenticated user. - * @returns {Promise} A promise which, when fulfilled, will contain a completed ActivityStream config object. + * @method getHits + * @return {Number} the number of hits */ - buildSbtConfigFull: function(cfg){ - var cfgPromise = new Promise(); - - if (!cfg.userInfo || !cfg.userInfo.id || !cfg.userInfo.displayName) { - cfg.boardId = this.getBoardIdFromAppId(cfg.defaultUrlTemplateValues.appId); - this.getUserInfo().then( - function(ui) { - if (ui && ui.id && ui.displayName) - cfg.userInfo = ui; - cfgPromise.fulfilled(cfg); - }, - function(error) { - cfgPromise.rejected(error); - }); - } else { - cfgPromise.fulfilled(cfg); - } - return cfgPromise; + getHits : function() { + return this.getAsNumber("hit"); }, - - /* - * Builds a config object from a feedUrl and an optional extensions object. - * The extensions object contains simple true or false values as a shortcut for four common extensions, - * e.g. - * extensions: { - * commenting: true, - * saving: true, - * refreshButton: true, - * deleteButton: true - * } - * These will be required if needed. - * @method buildSbtConfigFromFeed - * @param {Object} args This should contain a feedUrl, and an optional extensions object. - * @param {String} args.feedUrl The url of the ActivityStream feed. + + /** + * Return the number of anonymous hits. * - * @returns {Promise} A promise which, when fulfilled, will contain a completed ActivityStream config object. + * @method getAnonymousHits + * @return {Number} the number of anonymous hits */ - buildSbtConfigFromFeed: function(args){ - var cfgPromise = new Promise(); - - var cfg = { - defaultUrlTemplate : args.feedUrl, - defaultUrlTemplateValues : {}, - views : { - main : {} - }, - extensions : args.extensions || [], - eeManager: "com.ibm.social.as.ee.EEManager", - boardId: this.getBoardIdFromUrl(args.feedUrl) - }; - // if public stream - if(args.feedUrl.indexOf("anonymous/") === -1){ - this.getUserInfo().then( - function(ui) { - if (ui && ui.id && ui.displayName){ - cfg.userInfo = ui; - } - cfgPromise.fulfilled(cfg); - }, - function(error) { - cfgPromise.rejected(error); - } - ); - } else{ - this.requireExtensions(cfg.extensions); - cfgPromise.fulfilled(cfg); - } - this.requireExtensions(cfg.extensions); - return cfgPromise; + getAnonymousHits : function() { + return this.getAsNumber("anonymous_hit"); }, - - /* - * If a feed is present build from feed, otherwise build from full config - * object, augmenting if needed. + + /** + * Return the number of shares. * - * @method buildSbtConfig - * @param args If this contains a feedUrl then builds a config from it. Otherwise it should have an args.config object. - * @returns {Promise} A promise which, when fulfilled, will contain a completed ActivityStream config object. + * @method getShare + * @return {Number} the number of shares */ - buildSbtConfig: function(args){ - if(args.feedUrl){ - return this.buildSbtConfigFromFeed(args); - } - else{ - return this.buildSbtConfigFull(args.config); - } - } - }); - - return _SbtAsConfigUtil; -}); + getShare : function() { + return this.getAsNumber("share"); + }, -}, -'url:sbt/connections/controls/profiles/templates/ColleagueItem.html':"
\r\n \r\n \r\n \"${title}\"\r\n \r\n ${uid}\r\n ${title}\r\n \r\n
", -'url:sbt/connections/controls/bookmarks/templates/BookmarkListItem.html':"
  • \r\n\t

    ${title}

    \r\n
  • ", -'url:sbt/connections/controls/profiles/templates/CommunityMemberRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${contributorName}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.role}: ${role}
    \r\n\t\t\t
    ${nls.email} ${contributorEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n", -'sbt/ErrorTransport':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ + /** + * Return the number of collections. + * + * @method getCollections + * @return {Number} the number of collections + */ + getCollections : function() { + return this.getAsNumber("collections"); + }, -/** - * Implementation of a transport that emits an error the first time it is invoked. - * @module sbt.ErrorTransport - */ -define(['./declare','./lang','./Promise','./stringUtil','./log','sbt/i18n!sbt/nls/ErrorTransport'], function(declare,lang,Promise,stringUtil,log,nls) { - return declare(null, { - _called: false, - _endpointName: null, - _message: null, - - constructor: function(endpointName, message) { - this._endpointName = endpointName; - if (message) { - this._message = message; - } else { - this._message = stringUtil.substitute(nls.endpoint_not_available, [endpointName]); - } + /** + * Return the number of attachments. + * + * @method getAttachments + * @return {Number} the number of attachments + */ + getAttachments : function() { + return this.getAsNumber("attachments"); }, - - request : function(url,options) { - if (!this._called) { - alert(this._message); - this._called = true; - } - var promise = new Promise(); - var error = new Error(this._message); - error.status = 400; - promise.rejected(error); - return promise; + + /** + * Return the number of versions. + * + * @method getVersions + * @return {Number} the number of versions + */ + getVersions : function() { + return this.getAsNumber("versions"); }, - - xhr: function(method, args, hasBody) { - if (!this._called) { - log.error(this._message); - this._called = true; + + /** + * Loads the Wiki Page object with the atom entry associated with the + * wiki. By default, a network call is made to load the atom entry + * document in the Wiki Page object. + * + * @method load + * @param {Object} [args] Argument object + */ + load : function(args) { + // detect a bad request by validating required arguments + var label = this.getLabel(); + var promise = this.service._validatePageLabel(label); + if (promise) { + return promise; } - var _handle = args.handle; - var _error = args.error; - if (lang.isFunction(_error) || lang.isFunction(_handle)) { - var error = new Error(this._message); - error.status = 400; - if(lang.isFunction(_error)){ - _error(error); - } - if(lang.isFunction(_handle)){ - _handle(error); - } + var wikiLabel = this.getWikiLabel(); + promise = this.service._validateWikiLabel(wikiLabel); + if (promise) { + return promise; } - } - }); -}); -}, -'sbt/connections/controls/vcard/CommunityVCard':function(){ -require({cache:{ -'url:sbt/connections/controls/vcard/templates/CommunityVCard.html':"\r\n ${name}\r\n ${uuid}\r\n ${selectedWidgetId}\r\n"}}); -/* - * © 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. - */ -/** - * - */ -define(["../../../declare", - "../../../dom", - "../../../widget/_TemplatedWidget", - "../../../lang", - "../../../connections/controls/vcard/SemanticTagService", - "../../../text!./templates/CommunityVCard.html"], - function(declare, dom, _TemplatedWidget, lang, SemanticTagService, template) { + var self = this; + var callbacks = { + createEntity : function(service,data,response) { + self.setData(data); + return self; + } + }; - /** - * @class sbt.controls.CommunityVCard - */ - var communityVCard = declare([ _TemplatedWidget ], { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + var urlParams = { "pageLabel" : encodeURIComponent(label), "wikiLabel" : encodeURIComponent(wikiLabel) }; + var url = this.service.constructUrl(consts.WikiPageEntry, null, urlParams); + + return this.service.getEntity(url, options, label, callbacks); + }, /** - * The html template of the vcard. + * Remove this Wiki Page * - * @property configUtil - * @type String + * @method remove + * @param {Object} [args] Argument object */ - templateString: template, - + remove : function(args) { + return this.service.deleteWikiPage(this.getLabel(), args); + }, + /** - * Whether or not to encode HTML. + * Update this Wiki Page * - * @property encodeHtml - * @type Boolean - * @default true + * @method update + * @param {Object} [args] Argument object */ - encodeHtml: true, + update : function(args) { + return this.service.updateWikiPage(this, args); + }, /** - * The uuid of the community. + * Save this Wiki Page * - * @property uuid - * @type String - * @default "" + * @method save + * @param {Object} [args] Argument object */ - uuid: "", + save : function(args) { + if (this.getWikiUuid()) { + return this.service.updateWikiPage(this, args); + } else { + return this.service.createWikiPage(this, args); + } + } - /** - * A text string that corresponds to the widgetDefId of the widget that has been added to the community. - * This text string is used to highlight the menu item in the navigation bar. - * This argument is optional, and must only be provided for iWidgets that are integrated into Communities. - * The widget ID is defined by the iWidget developer, and you need to request it from your administrator or the iWidget developer. - * - * @property selectedWidgetId - * @type String - * @default "" - */ - selectedWidgetId: "", + }); + + /* + * Method used to extract the wiki uuid for an id string. + */ + var extractWikiUuid = function(uid) { + if (uid && uid.indexOf("urn:lsid:ibm.com:td:") == 0) { + return uid.substring("urn:lsid:ibm.com:td:".length); + } else { + return uid; + } + }; + + /* + * Callbacks used when reading a feed that contains wiki entries. + */ + var WikiFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.WikiFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new Wiki({ + service : service, + data : data + }); + } + }; + + /* + * Callbacks used when reading a feed that contains wiki page entries. + */ + var WikiPageFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.WikiFeedXPath + }); + } + }; + + /* + * Callbacks used when reading an entry that contains wiki. + */ + var WikiCallbacks = { + createEntity : function(service,data,response) { + return new Wiki({ + service : service, + data : data + }); + } + }; + + /** + * WikisService class. + * + * @class WikisService + * @namespace sbt.connections + */ + var WikiService = declare(ConnectionsService, { + + contextRootMap: { + wikis: "wikis" + }, + serviceName : "wikis", /** - * The name of the community. + * Constructor for WikisService * - * @property name - * @type String - * @default "" + * @constructor + * @param args */ - name: "", + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } + }, /** - * The constructor + * Create a Wiki object with the specified data. * - * @method constructor - * @param {Object} args - * @param {String} [args.name] The name to display on the community vcard. - * @param {String} args.uuid The uuid of the community. - * @param {String} [args.selectedWidgetId] a text string that corresponds to the widgetDefId of the widget that has been added to the community. - * This text string is used to highlight the menu item in the navigation bar. The element is optional, and must only be provided for iWidgets that are integrated into Communities. - * The widget ID is defined by the iWidget developer, and you need to request it from your administrator or the iWidget developer. + * @method newWiki + * @param {Object} args Object containing the fields for the new Wiki */ - constructor: function(args) { - if(!args.selectedWidgetId) - args.selectedWidgetId=""; - lang.mixin(args); + newWiki : function(args) { + return this._toWiki(args); }, /** - * @method postCreate + * Create a Wiki Page object with the specified data. + * + * @method newWikiPage + * @param {Object} args Object containing the fields for the new Wiki Page */ - postCreate: function() { - this.inherited(arguments); - - SemanticTagService.loadSemanticTagService(); - } - - }); - - return communityVCard; -}); -}, -'sbt/connections/controls/profiles/ColleagueGridRenderer':function(){ -require({cache:{ -'url:sbt/connections/controls/profiles/templates/ColleagueItem.html':"
    \r\n \r\n \r\n \"${title}\"\r\n \r\n ${uid}\r\n ${title}\r\n \r\n
    ", -'url:sbt/connections/controls/profiles/templates/ViewAll.html':"\r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n ${viewAllTitle}\r\n \r\n
    ", -'url:sbt/connections/controls/profiles/templates/ColleagueItemFull.html':"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \"${name}\r\n \r\n ${uid}\r\n ${name}\r\n \r\n
    \r\n
    \r\n \r\n ${name}\r\n ${uid}\r\n ${name}\r\n \r\n
    \r\n"}}); -/* - * © 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. - */ - -/** - * - */ -define(["../../../declare", "../../../stringUtil", - "../../../dom","../../../lang", - "../ConnectionsGridRenderer", - "../../../i18n!./nls/ColleagueGridRenderer", - "../../../text!./templates/ColleagueItem.html", - "../../../text!./templates/ViewAll.html", - "../../../text!./templates/ColleagueItemFull.html"], - function(declare, stringUtil, dom, lang, ConnectionsGridRenderer, nls, colleagueItemTemplate, viewAllTemplate, colleagueItemFullTemplate) { - - /** - * @class ColleagueGridRenderer - * @namespace sbt.connections.controls.profiles - * @module sbt.connections.controls.profiles.ColleagueGridRenderer - */ - var ColleagueGridRenderer = declare(ConnectionsGridRenderer, { - - _nls: nls, - - containerClass: "lotusChunk", - - template: colleagueItemTemplate, - viewAllTemplate: viewAllTemplate, - fullTemplate: colleagueItemFullTemplate, - - countAlign: "left", - verticalAlign: "middle", - - render: function(grid, el, items, data) { - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - var size = items.length; - if (size === 0) { - this.renderEmpty(grid, el); - } - else { - var container = this.renderContainer(grid, el, items, data); - for (var i=0; i\r\n
      \r\n
    • \r\n ${bodyBookmarkLiContent}\r\n
    • \r\n
    • \r\n ${updatedLabel}\r\n
    • \r\n ${tagsList}\r\n
    \r\n\r\n
    \r\n
    \r\n ${resultLink}\r\n
    ", -'url:sbt/connections/controls/search/templates/CalendarBody.html':"
    \r\n
      \r\n
    • \r\n ${_nls.eventDateOn}\r\n \r\n ${eventStartDate}\r\n \r\n
    • \r\n ${bodyCalendarLis}\r\n ${personCard}\r\n
    \r\n
    ", -'url:sbt/connections/controls/search/templates/CommunityBody.html':"
    \r\n
      \r\n ${communityMembers}\r\n
    • \r\n ${updatedLabel}\r\n
    • \r\n ${tagsList}\r\n
    \r\n\r\n
    \r\n\r\n", -'url:sbt/connections/controls/search/templates/DefaultBody.html':"
    \r\n
      \r\n ${bodyPersonCardLi}\r\n ${bodyUpdatedLi}\r\n ${bodyCommentCountLi}\r\n ${objectReferenceLi}\r\n ${tagsList}\r\n ${bodyBookmarkLi}\r\n
    \r\n
    ", -'url:sbt/connections/controls/search/templates/DefaultHeader.html':"", -'url:sbt/connections/controls/search/templates/DefaultSummary.html':"
    \r\n \r\n ${summaryIcon}\r\n \r\n \r\n ${communityParent}\r\n ${parentageMeta}\r\n \r\n ${summaryTypeLabel}  \r\n \r\n ${resultSummary}  \r\n
    \r\n\r\n${resultComment}", -'url:sbt/connections/controls/search/templates/ProfileBody.html':"
    \r\n
      \r\n \r\n ${profileBodyJobTitle}\r\n ${tagsList}\r\n
    \r\n
    ", -'url:sbt/connections/controls/search/templates/ProfileHeader.html':"
    \r\n

    \r\n \r\n \r\n ${formattedTitle}\r\n \r\n \r\n ${authorUid}\r\n \r\n \r\n

    \r\n
    ", -'url:sbt/connections/controls/search/templates/PersonCard.html':"\r\n \r\n ${authorName}\r\n ${inactiveLabel}\r\n \r\n \r\n ${authorUid}\r\n \r\n\r\n", -'url:sbt/connections/controls/search/templates/StatusUpdateExtraHeader.html':"
    \r\n \r\n ${authorUid}\r\n \r\n
    \r\n", -'url:sbt/connections/controls/search/templates/StatusUpdateHeader.html':"", -'url:sbt/connections/controls/search/templates/a.html':"${content}", -'url:sbt/connections/controls/search/templates/td.html':"${content}", -'url:sbt/connections/controls/search/templates/tr.html':"${content}", -'url:sbt/connections/controls/search/templates/li.html':"
  • ${content}
  • ", -'url:sbt/connections/controls/search/templates/ul.html':"
      ${content}
    ", -'url:sbt/connections/controls/search/templates/span.html':"${content}", -'url:sbt/connections/controls/search/templates/img.html':"", -'url:sbt/connections/controls/search/templates/em.html':"\r\n ${content}\r\n", -'url:sbt/connections/controls/search/templates/div.html':"
    \r\n ${content}\r\n
    "}}); -/* - * © 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. - */ - -/** - * - */ -define(["../../../declare", - "../../../dom", - "../ConnectionsGridRenderer", - "../../../lang", "../../../stringUtil", "../../../i18n", - "../../../i18n!./nls/SearchGridRenderer", - "../../../text!./templates/BookmarkBody.html", - "../../../text!./templates/CalendarBody.html", - "../../../text!./templates/CommunityBody.html", - "../../../text!./templates/DefaultBody.html", - "../../../text!./templates/DefaultHeader.html", - "../../../text!./templates/DefaultSummary.html", - "../../../text!./templates/ProfileBody.html", - "../../../text!./templates/ProfileHeader.html", - "../../../text!./templates/PersonCard.html", - "../../../text!./templates/StatusUpdateExtraHeader.html", - "../../../text!./templates/StatusUpdateHeader.html", - "../../../text!./templates/a.html", - "../../../text!./templates/td.html", - "../../../text!./templates/tr.html", - "../../../text!./templates/li.html", - "../../../text!./templates/ul.html", - "../../../text!./templates/span.html", - "../../../text!./templates/img.html", - "../../../text!./templates/em.html", - "../../../text!./templates/div.html"], - function(declare, dom, ConnectionsGridRenderer, lang, stringUtil, i18n, nls, bookmarkBodyTemplate, calendarBodyTemplate, communityBodyTemplate, defaultBodyTemplate, defaultHeaderTemplate, defaultSummaryTemplate, profileBodyTemplate, profileHeaderTemplate, personCardTemplate, statusUpdateExtraHeaderTemplate, statusUpdateHeaderTemplate, aElement, tdElement, trElement, liElement, ulElement, spanElement, imgElement, emElement, divElement) { - - /** - * @class SearchGridRenderer - * @module sbt.controls.grid.connections.SearchGridRenderer - * @namespace sbt.controls.grid.connections - */ - var searchGridRenderer = declare(ConnectionsGridRenderer, { - - _nls: nls, - - resultType: null, - - application: null, + newWikiPage : function(args) { + return this._toWikiPage(args); + }, /** - * Takes a html template and a list of arguments. These arguments are substituted into the template and the template is returned with attributes set. + * This retrieves a list of wikis to which the authenticated user has access. * - * Used for creating html elements. + * @method getAllWikis + * @param requestArgs + */ + getAllWikis: function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.WikisAll, options, WikiFeedCallbacks); + }, + + /** + * This retrieves a list of wikis to which everyone who can log into the Wikis application has access. * - * e.g. - * buildElement("
  • ${content}
  • ", {classAttr: "lotusFirst", roleAttr: "listitem", content: "content"}); + * @method getPublicWikis + * @param requestArgs + */ + getPublicWikis: function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.WikisPublic, options, WikiFeedCallbacks); + }, + + /** + * This retrieves a list of wikis of which the authenticated user is a member. * - * returns + * @method getMyWikis + * @param requestArgs + */ + getMyWikis: function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.WikisMy, options, WikiFeedCallbacks); + }, + + /** + * This retrieves a list all wikis sorted by wikis with the most comments first. + * This returns a list of wikis to which everyone who can log into the Wikis application has access. * - * "
  • content
  • " + * @method getMostCommentedWikis + * @param requestArgs + */ + getMostCommentedWikis: function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.WikisMostCommented, options, WikiFeedCallbacks); + }, + + /** + * This retrieves a list all wikis sorted by wikis with the most recommendations first. + * This returns a list of wikis to which everyone who can log into the Wikis application has access. * - * @param html - * @param args - * @returns The html template with the substituted values. + * @method getMostRecommendedWikis + * @param requestArgs */ - buildElement: function(html, args){ - args.classAttr = args.classAttr ? 'class="' + args.classAttr + '"' : ""; - args.styleAttr = args.styleAttr ? 'style="' + args.styleAttr + '"' : ""; - args.roleAttr = args.roleAttr ? 'role="' + args.roleAttr + '"' : ""; - args.hrefAttr = args.hrefAttr ? 'href="' + args.hrefAttr + '"' : ""; - args.onclickAttr = args.onclickAttr ? 'onclick="' + args.onclickAttr + '"' : ""; - args.colspanAttr = args.colspanAttr ? 'colspan="' + args.colspanAttr + '"' : ""; - args.altAttr = args.altAttr ? 'alt="' + args.altAttr + '"' : ""; - args.srcAttr = args.srcAttr ? 'src="' + args.srcAttr + '"' : ""; - args.titleAttr = args.titleAttr ? 'title="' + args.titleAttr + '"' : ""; - args.widthAttr = args.widthAttr ? 'width="' + args.widthAttr + '"' : ""; - args.heightAttr = args.heightAttr ? 'height="' + args.heightAttr + '"' : ""; + getMostRecommendedWikis: function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; - return stringUtil.transform(html, args); + return this.getEntities(consts.WikisMostRecommended, options, WikiFeedCallbacks); }, - - resultTypes: { - activities : "activities", - blogs : "blogs", - bookmark: "bookmark", - calendar : "calendar", - communities : "communities", - files : "files", - forums : "forums", - inactiveProfiles : "inactiveProfiles", - profiles : "profiles", - statusUpdates : "status_updates", - wiki : "wiki" + + /** + * This retrieves a list all wikis sorted by wikis with the most visits first. + * This returns a list of wikis to which everyone who can log into the Wikis application has access. + * + * @method getMostVisitedWikis + * @param requestArgs + */ + getMostVisitedWikis: function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.WikisMostVisited, options, WikiFeedCallbacks); }, - + /** - * Creates an li containing a list of tags. + * This retrieves a list all of the pages in a specific wiki. * - * @param grid - * @param item - * @param i - * @param items - * @returns An li containing a list of tags. + * @method getWikiPages + * @param wikiLabel Value of the element of the wiki. + * @param requestArgs */ - tagsList: function(grid, item, i, items){ - var tagCount = item.getValue("tagCount"); - tagCount = parseInt(tagCount); - if(tagCount === 0){ - return ""; + getWikiPages: function(wikiLabel, requestArgs) { + var promise = this._validateWikiLabel(wikiLabel); + if (promise) { + return promise; } - var resultLiRole = "listitem"; + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; - var ulClass = "lotusInlinelist"; - var ulStyle = "display:inline"; - var ulContent = ""; + var callbacks = lang.mixin(WikiPageFeedCallbacks, { + createEntity : function(service,data,response) { + return new WikiPage({ + service : service, + wikiLabel : wikiLabel, + data : data + }); + } + }); - var tags = item.getValue("tags"); + var url = this.constructUrl(consts.WikiPages, null, { "wikiLabel" : encodeURIComponent(wikiLabel) }); - var i; - for(i = 0; i < tagCount && i < 3; i++){ - var currentTag = typeof tags === 'string' ? tags : tags[i]; - var liStyle = "padding:0px"; - var liClass = "lotusFirst"; - if(i === 2 || i === tagCount - 1){ - liClass = "lotusLast"; - } - var aHref = "javascript:void(0);"; - var aOnClick = "onclick=\"searchObject.performTagFilter('" + tags[i] + "');\""; - var aAlt = currentTag; + return this.getEntities(url, options, callbacks); + }, - if(item.getValue("highlightField")){ - var aClass = currentTag; - }else{ - aClass = undefined; + /** + * This retrieves a list all of the pages in a specific wiki that have been added or edited by the authenticated user. + * + * @method geMyWikiPages + * @param wikiLabel Value of the element of the wiki. + * @param requestArgs + */ + getMyWikiPages: function(wikiLabel, requestArgs) { + var promise = this._validateWikiLabel(wikiLabel); + if (promise) { + return promise; + } + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + var callbacks = lang.mixin(WikiPageFeedCallbacks, { + createEntity : function(service,data,response) { + return new WikiPage({ + service : service, + wikiLabel : wikiLabel, + data : data + }); } - var aContent = currentTag; + }); - var a = this.buildElement(aElement, { - hrefAttr: aHref, - onclickAttr: aOnClick, - altAttr: aAlt, - classAttr: aClass, - content: aContent - }); - var liContent = a; - if(i != tagCount - 1 && i != 2){ - liContent += ", "; - } - var li = this.buildElement(liElement, { - content: liContent, - classAttr: liClass, - styleAttr: liStyle - }); - ulContent += li + "\n"; + var url = this.constructUrl(consts.WikiMyPages, null, { "wikiLabel" : encodeURIComponent(wikiLabel) }); + + return this.getEntities(url, options, callbacks); + }, + + /** + * This retrieves a list of the pages that have been deleted from wikis and are currently stored in the trash. + * + * @method getRecycledPages + * @param wikiLabel Value of the element or the element of the wiki. + * @param requestArgs + */ + getRecycledWikiPages: function(wikiLabelOrId, requestArgs) { + var promise = this._validateWikiLabel(wikiLabelOrId); + if (promise) { + return promise; } + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; - var more = tagCount > 3 ? this._nls.tagsMore.replace("{0}", tagCount-3) : ""; - var ul = this.buildElement(ulElement, { - content: ulContent, - classAttr: ulClass, - styleAttr: ulStyle - }); - var span = this.buildElement(spanElement, { - content: this._nls.tags + "  " + ul + " " + more + var callbacks = lang.mixin(WikiPageFeedCallbacks, { + createEntity : function(service,data,response) { + return new WikiPage({ + service : service, + wikiLabelOrId : wikiLabelOrId, + data : data + }); + } }); + + var url = this.constructUrl(consts.WikiRecycleBin, null, { "wikiLabelOrId" : encodeURIComponent(wikiLabelOrId) }); - return this.buildElement(liElement, { - roleAttr: resultLiRole, - content: span + return this.getEntities(url, options, callbacks); + }, + + /** + * Retrieve a wiki. + * + * @method getWiki + * @param wikiLabel Value of the element or the element of the wiki. + * @param requestArgs + */ + getWiki: function(wikiLabel, requestArgs) { + var wiki = new Wiki({ + service : this, + _fields : { label : wikiLabel } }); + return wiki.load(requestArgs); }, /** - * Returns the img tag defining the image to use as the application icon. + * Create a wiki. * - * @param grid - * @param item - * @param i - * @param items - * @returns {String} + * @method createWiki + * @param wikiOrJson + * @param requestArgs */ - summaryIcon: function(grid, item, i, items){ - var fileExtension = item.getValue("fileExtension"); - var summaryImageClass = "lconn-ftype16 lconn-ftype16-" + fileExtension, summaryImageSrc = "", summaryImageAlt = "", summaryImageTitle = "", summaryImageRole = ""; - switch(this.resultType){ - case this.resultTypes.activities: - summaryImageClass = "lconnSprite lconnSprite-iconActivities16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.activities; - summaryImageTitle = this._nls.activities; - summaryImageRole = "presentation"; - break; - case this.resultTypes.blogs: - summaryImageClass = "lconnSprite lconnSprite-iconBlogs16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.blogs; - summaryImageTitle = this._nls.blogs; - summaryImageRole = "presentation"; - break; - case this.resultTypes.bookmark: - summaryImageClass = "lconnSprite lconnSprite-iconBookmarks16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.bookmarks; - summaryImageTitle = this._nls.bookmarks; - summaryImageRole = "presentation"; - break; - case this.resultTypes.calendar: - summaryImageClass = "lconnSprite lconnSprite-iconCalendar16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.calendar; - summaryImageTitle = this._nls.calendar; - summaryImageRole = "presentation"; - break; - case this.resultTypes.communities: - summaryImageClass = this.componentContains(item, "communities:feed") ? "lconnSprite lconnSprite-iconFeed16" : "lconnSprite lconnSprite-iconCommunities16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.communities; - summaryImageTitle = this._nls.communities; - summaryImageRole = "presentation"; - break; - case this.resultTypes.files: - summaryImageClass = fileExtension ? summaryImageClass : "lconnSprite lconnSprite-iconFiles16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.files; - summaryImageTitle = this._nls.files; - summaryImageRole = "presentation"; - break; - case this.resultTypes.forums: - summaryImageClass = "lconnSprite lconnSprite-iconForums16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.forums; - summaryImageTitle = this._nls.forums; - summaryImageRole = "presentation"; - break; - case this.resultTypes.profiles: - summaryImageClass = "lconnSprite lconnSprite-iconProfiles16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.profiles; - summaryImageTitle = this._nls.profiles; - summaryImageRole = "presentation"; - break; - case this.resultTypes.statusUpdates: - summaryImageClass = "lconnSprite lconnSprite-iconStatusUpdate16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.statusUpdates; - summaryImageTitle = this._nls.statusUpdates; - summaryImageRole = "presentation"; - break; - case this.resultTypes.wikis: - summaryImageClass = fileExtension.length !== 0 ? summaryImageClass : "lconnSprite lconnSprite-iconWikis16"; - summaryImageSrc = "images/blank.gif"; - summaryImageAlt = this._nls.wikis; - summaryImageTitle = this._nls.wikis; - summaryImageRole = "presentation"; - break; - } - return this.buildElement(imgElement, { - classAttr: summaryImageClass, - srcAttr: summaryImageSrc, - altAttr: summaryImageAlt, - titleAttr: summaryImageTitle, - roleAttr: summaryImageRole - }); - }, - - /** - * Returns a result Summary, which is a span element containing a summary but includes an extra ul if the result type is statusUpdate. - * @param grid - * @param item - * @param i - * @param items - * @returns - */ - resultSummary: function(grid, item, i, items){ - var summary = item.getValue("summary"); - if(summary.length!==0){ - var statusUpdateUl = ""; - if(this.resultType === this.resultTypes.statusUpdates){ - var statusUpdateLi = this.buildElement(liElement, { - classAttr: "lotusMeta lconnSearchHighlight", - content: this._nls.comment - }); - statusUpdateUl = this.buildElement(ulElement, { - styleAttr: "display: inline", - classAttr: "lotusInlinelist", - roleAttr: "presentation", - content: statusUpdateLi - }); - } - summary = summary.replace(/<b>/g, ""); // replace the encoded tags... - summary = summary.replace(/<\/b>/g, ""); - - var summarySpan = this.buildElement(spanElement, { - classAttr: "lotusMeta lconnSearchHighlight", - content: summary - }); - - return statusUpdateUl + "\n" + summarySpan + "\n"; - }else if(this.resultType != this.resultTypes.statusUpdates){ - return this.buildElement(emElement, { - content: this._nls.noDescription, - classAttr: "lotusMeta" - }); - } - - }, - - resultComment: function(grid, item, i, items){ - if(item.getValue("commentsSummary").length > 0 && this.resultType != this.resultTypes.statusUpdates){ - var divSpan = this.buildElement(spanElement, { - classAttr: "lotusMeta lconnSearchHighlight", - content: this._nls.comment + item.getValue("commentsSummary") - }); - return this.buildElement(divElement, { - styleAttr: "clear:both;", - content: divSpan - }); - } - }, - - formattedTitle: function(grid, item, i, items){ - var title = item.getValue("title"); - if(title.length !== 0){ - title = title.replace(/<b>/g, ""); // replace the encoded tags... - title = title.replace(/<\/b>/g, ""); + createWiki: function(wikiOrJson, requestArgs) { + var wiki = this._toWiki(wikiOrJson); + var promise = this._validateWiki(wiki, false, requestArgs); + if (promise) { + return promise; } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + wiki.setData(data); + return wiki; + }; + + var options = { + method : "POST", + query : requestArgs || {}, + headers : consts.AtomXmlHeaders, + data : wiki.createPostData() + }; - return title; + return this.updateEntity(consts.WikisAll, options, callbacks, requestArgs); }, - - parentageMeta: function(grid, item, i, items){ - switch(item.getValue("parentageMetaURLID")){ - case 'blogURL': - var aHref = item.getValue("parentageMetaURL"); - var aContent = ""; - if(this.componentcontains(item, "blogs:ideationblogs:idea")){ - aContent = this._nls.fromAnIdeationBlog; - }else{ - aContent = this._nls.fromABlog; - } - return this.buildElement(aElement, { - hrefAttr: aHref, - content: aContent - }) + " > "; - case 'forumURL': - return this.buildElement(aElement, { - hrefAttr: item.getValue("parentageMetaURL"), - content: this._nls.fromAForum - }) + " > "; - case 'wikiURL': - return this.buildElement(aElement, { - hrefAttr: item.getValue("parentageMetaURL"), - content: this._nls.fromAWiki - }) + " > "; - case 'activityURL': - if(item.getValue("primaryComponent").indexOf("activities") === 0 || item.getValue("primaryComponent").indexOf("communities:activities") === 0){ - if(item.getValue("primaryComponent") === "activities:bookmark" || item.getValue("primaryComponent") === "communities:activities:bookmark" || this.componentContains("activities:section") || this.componentContains("activities:task") || this.componentContains("activities:entry")){ - return this.buildElement(aElement, { - hrefAttr: item.getValue("parentageMetaURL"), - content: this._nls.fromAnActivity - }) + " > "; - } - if(item.getValue("parentageMetaID") === "activityEntryURL" || item.getValue("primaryComponent") === "activities:bookmark"){ - return this.buildElement(aElement, { - hrefAttr: item.getValue("parentageMetaURL"), - content: this._nls.entry - }) + " > "; - } - } - } - return ""; - }, - - communityParent: function(grid, item, i, items){ - if(item.getValue("communityUuid").length!=0 && item.getValue("containerType") != "stand-alone" && item.getValue("primaryComponent") != "communities:entry" && item.getValue("primaryComponent").indexOf("communities") === 0){ - return this.buildElement(aElement, { - hrefAttr: item.getValue("communityParentLink"), - content: this._nls.fromACommunity - }) + " > "; - }else{ - return ""; - } - }, - /** - * @param grid - * @param item - * @param i - * @param items - * @returns - */ - summaryTypeLabel: function(grid, item, i, items){ - var spanContent = ""; - var resultTypes = this.resultTypes; - switch(this.resultType){ - case resultTypes.activities: - if(this.componentContains(item, "activities:task")){ - spanContent = this._nls.activityToDo; - }else if(this.componentContains(item, "activities:activity") || this.componentContains(item, "activities:community_activity") || this.componentContains(item, "activities:community_activity+members") || this.componentContains(item, "activities:explicit_membership_community_activity")){ - spanContent = this._nls.activity; - }else if(this.componentContains(item, "activities:bookmark")){ - spanContent = this._nls.activityBookmark; - }else if(this.componentContains(item, "activities:section")){ - spanContent = this._nls.activitySection; - }else if(this.componentContains(item, "activities:reply")){ - spanContent = this._nls.activityComment; - }else{ - spanContent = this._nls.activityEntry; - } - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: spanContent - }); - case resultTypes.blogs: - if(this.componentContains(item, "blogs:ideationblogs:ideationblog")){ - spanContent = this._nls.ideationBlog; - }else if(this.componentContains(item, "blogs:ideationblogs:idea")){ - spanContent = this._nls.idea; - }else if(this.componentContains(item, "blogs:ideationblogs:comment")){ - spanContent = this._nls.ideaComment; - }else if(this.componentContains(item, "blogs:entry")){ - spanContent = this._nls.blogEntry; - }else if(this.componentContains(item, "blogs:comment")){ - spanContent = this._nls.blogComment; - }else{ - spanContent = this._nls.blog; - } - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: spanContent - }); - case resultTypes.bookmark: - spanContent = this._nls.bookmark; - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: spanContent - }); - case resultTypes.calendar: - spanContent = this._nls.calendar; - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: spanContent - }); - case resultTypes.communities: - if(this.componentContains(item, "communities:entry")){ - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: this._nls.community - }); - }else if(this.componentContains(item, "communities:feed")){ - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: this._nls.feed - }); - }else if(this.componentContains(item, "communities:bookmark")){ - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: this._nls.bookmark - }); - } - case resultTypes.files: - spanContent = this._nls.file; - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: spanContent - }); - case resultTypes.forums: - if(this.componentContains(item, "communities:forums:forum")){ - spanContent = this._nls.forum; - }else if(this.componentContains(item, "communities:forums:category")){ - spanContent = this._nls.forumCategory; - }else{ - spanContent = this._nls.forumTopic; - } - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: spanContent - }); - case resultTypes.profiles: - spanContent = this._nls.profile; - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: spanContent - }); - case resultTypes.statusUpdates: - spanContent = this._nls.fromAStatusUpdate; - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: spanContent - }); - case resultTypes.wikis: - if(this.componentContains(item, "wikis:wiki")){ - spanContent = this._nls.wikiType; - }else if(this.componentContains(item, "wikis:file")){ - spanContent = this._nls.wikiFile; - }else{ - spanContent = this._nls.wikiPage; - } - return this.buildElement(spanElement, { - classAttr: "lotusMeta", - content: spanContent - }); - } - }, - /** - * UtilityFunction, used to test if the item application array contains a certain string. Or if it is in the primaryComponent. + * Update a wiki. + * All existing wiki information will be replaced with the new data. To avoid deleting all existing data, + * retrieve any data you want to retain first, and send it back with this request. For example, if you want + * to add a new tag to a wiki definition entry, retrieve the existing tags, and send them all back with the + * new tag in the update request. * - * @param item - * @param appString + * @method updateWiki + * @param wikiOrJson + * @param requestArgs */ - componentContains: function(item, appString){ - if(item.getValue("primaryComponent") === appString){ - return true; - } - for(var key in item.getValue("application")){ - var app = item.getValue("application")[key]; - if(app === appString){ - return true; - } - } - return false; - }, - - communityMembers: function(grid, item, i, items){ - var isCommunitiesEntry = this.componentContains(item, "communities:entry"); - if(!isCommunitiesEntry){ - return this.buildElement(liElement, { - content: this._substituteItem(personCardTemplate, grid, item, i, items), - classAttr: "lotusFirst", - roleAttr: "listitem" - }); + updateWiki: function(wikiOrJson, requestArgs) { + var wiki = this._toWiki(wikiOrJson); + var promise = this._validateWiki(wiki, true, requestArgs); + if (promise) { + return promise; } - var liMembersContent = item.getValue("memberCount") + " " + this._nls.members; - var liMembers = this.buildElement(liElement, { - content: liMembersContent, - classAttr: "lotusFirst members", - roleAttr: "listitem" - }); + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + wiki.setData(data); + return wiki; + }; + + var options = { + method : "PUT", + query : requestArgs || {}, + headers : consts.AtomXmlHeaders, + data : wiki.createPostData() + }; - var liPersonCard = this.buildElement(liElement, { - content: this._substituteItem(personCardTemplate, grid, item, i, items), - roleAttr: "listitem" - }); + var url = this.constructUrl(consts.WikiEntry, null, { "wikiLabel" : encodeURIComponent(wiki.getLabel()) }); - return liMembers + "\n" + liPersonCard; + return this.updateEntity(url, options, callbacks, requestArgs); }, - - bodyCalendarLis: function(grid, item, i, items){ - var allDayEventLi = "", repeatingEventLi = "", locationLi = ""; + + /** + * Delete a wiki. + * + * @method deleteWiki + * @param wikiLabel + * @param requestArgs + */ + deleteWiki: function(wikiLabel, requestArgs) { + var promise = this._validateWikiLabel(wikiLabel); + if (promise) { + return promise; + } + + var options = { + method : "DELETE", + query : requestArgs || {}, + handleAs : "text" + }; - if(item.getValue("allDayEvent") ==="true"){ - allDayEventLi = this.buildElement(liElement,{ - roleAttr: "listitem", - content: this._nls.eventIsAllDay - }); - } - if(item.getValue("repeatingEvent") ==="true"){ - allDayEventLi = this.buildElement(liElement,{ - roleAttr: "listitem", - content: this._nls.eventRepeats - }); - } - if(item.getValue("location.length") > 1){ - allDayEventLi = this.buildElement(liElement,{ - roleAttr: "listitem", - content: item.getValue("location") - }); - } - return allDayEventLi + "\n" + repeatingEventLi + "\n" + locationLi + "\n"; - }, - - bodyBookmarkLiContent : function(grid, item, i, items){ - var contributorCount = parseInt(item.getValue("contributorCount")); - var authorCount = parseInt(item.getValue("authorcount")); + var url = this.constructUrl(consts.WikiEntry, null, { "wikiLabel" : encodeURIComponent(wikiLabel) }); - if(item.getValue("bookmarkLink").length > 0 && (contributorCount + authorCount) > 1){ - var spanA = this.buildElement(aElement, { - hrefAttr: item.getValue("bookmarkLink"), - content: contributorCount + authorCount + this._nls.people - }); - return this.buildElement(spanElement, { - content: spanA - }); - }else{ - return this._substituteItem(personCardTemplate, grid, item, i, items); - } + return this.deleteEntity(url, options, wikiLabel); }, - + /** - * Returns the class to be used for a vcard. + * Retrieve a wiki page. * - * @param grid - * @param item - * @param i - * @param items - * @returns {String} + * @method getWikiPage + * @param wikiLabel Value of the element or the element of the wiki. + * @param requestArgs */ - cardClass: function(grid, item, i, items){ - if(item.getValue("authorState") != 'active'){ - return "lotusPersonInactive"; - }else{ - return "vcard"; - } + getWikiPage: function(wikiLabel, pageLabel, requestArgs) { + var wikiPage = new WikiPage({ + service : this, + wikiLabel : wikiLabel, + _fields : { label : pageLabel } + }); + return wikiPage.load(requestArgs); }, /** - * Returns an li with the author's job title if it exists, otherwise an empty string. + * Create a wiki page. * - * @param grid - * @param item - * @param i - * @param items - * @returns + * @method createWikiPage + * @param pageOrJson + * @param requestArgs */ - profileBodyJobTitle: function(grid, item, i, items){ - if(item.getValue("authorJobTitle") && item.getValue("authorJobTitle").length != 0){ - return this.buildElement(liElement, { - content: item.getValue("authorJobTitle")+" ", - classAttr: "lotusFirst", - roleAttr: "listitem" - }); - }else{ - return this._nls.emptyString; + createWikiPage: function(pageOrJson, requestArgs) { + var wikiPage = this._toWikiPage(pageOrJson); + var promise = this._validateWikiPage(wikiPage, false, requestArgs); + if (promise) { + return promise; } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + wiki.setData(data); + return wiki; + }; + + var options = { + method : "POST", + query : requestArgs || {}, + headers : consts.AtomXmlHeaders, + data : wikiPage.createPostData() + }; + + var url = this.constructUrl(consts.WikiFeed, null, { "wikiLabel" : encodeURIComponent(wikiPage.getWikiLabel()) }); + + return this.updateEntity(url, options, callbacks, requestArgs); }, - + /** + * Update a wiki page. * - * - * @returns {String} + * @method updateWikiPage + * @param pageOrJson + * @param requestArgs */ - bodyPersonCardLi: function(grid, item, i, items){ - if(item.getValue("authorName").length != 0){ - return this.buildElement(liElement, { - content: this._substituteItem(personCardTemplate, grid, item, i, items), - roleAttr: "listitem", - classAttr: "lotusFirst" - }); - }else{ - return ""; - } - }, - - bodyUpdatedLi: function(grid, item, i, items){ - var liClass = "searchDateClass"; - if(item.getValue("authorName").length==0){ - liClass+= " lotusFirst"; - } - return this.buildElement(liElement, { - classAttr: liClass, - content: this.updatedLabel(grid, item, i, items) - }); - }, - - bodyCommentCountLi: function(grid, item, i, items){ - var commentcount = parseInt(item.getValue("commentCount")); - if(commentcount >= 1){ - var liContent = commentcount === 1 ? this._nls.oneComment : commentcount + " " + this._nls.comments; - return this.buildElement(liElement, { - classAttr: "comments", - roleAttr: "listitem", - content: liContent - }); - } - }, - - objectReferenceLi: function(grid, item, i, items){ - if(item.getValue("objectRefDisplayName").length != 0 && item.getValue("objectRefUrl").length != 0){ - var liContent = this.buildElement(aElement, { - hrefAttr: item.getValue("objectRefUrl"), - content: item.getValue("objectRefDisplayName") - }); - - return this.buildElement(liElement, { - roleAttr: "listitem", - content: liContent - }); + updateWikiPage: function(pageOrJson, requestArgs) { + var wikiPage = this._toWikiPage(pageOrJson); + var promise = this._validateWikiPage(wikiPage, true, requestArgs); + if (promise) { + return promise; } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + wikiPage.setData(data); + return wikiPage; + }; + + var options = { + method : "PUT", + query : requestArgs || {}, + headers : consts.AtomXmlHeaders, + data : wikiPage.createPostData() + }; + + var urlParams = { "pageLabel" : encodeURIComponent(wikiPage.getLabel()), "wikiLabel" : encodeURIComponent(wikiPage.getWikiLabel()) }; + var url = this.constructUrl(consts.WikiPageEntry, null, urlParams); + + return this.updateEntity(url, options, callbacks, requestArgs); }, - - bodyBookmarkLi: function(grid, item, i, items){ - var applicationCount = parseInt(item.getValue("applicationCount")); - if(((this.application=='dogear' && applicationCount > 1) || (this.application=='activities:bookmark' && applicationCount > 2) || (this.application=='communities:bookmark' && applicationCount > 2) ) && item.getValue("accessControl")=='public'){ - var aImg = this.buildElement(imgElement, { - classAttr: "lconnSprite lconnSprite-iconHelp16", - srcAttr: "images/blank.gif", - titleAttr: this._nls.help, - altAttr: this._nls.help - }); - var aSpan = this.buildElement(spanElement, { - classAttr: "lotusAltText", - content: "?" - }); - var aResult = this.buildElement(aElement, { - classAttr: "lconnSearchBookmarkHelpButton", - hrefAttr: "javascript:;", - content: aImg + "\n" + aSpan - }); - - var ulContent = ""; - - if(this.application ==="dogear"){ - ulContent += this.buildElement(liElement, { - content: this._nls.bookmarksTitle - }) + "\n"; - } - if(this.application ==="activities:bookmark"){ - ulContent += this.buildElement(liElement, { - content: this._nls.activitiesTitle - }) + "\n"; - } - if(this.application ==="communities:bookmark"){ - ulContent += this.buildElement(liElement, { - content: this._nls.communitiesTitle - }) + "\n"; - } - var spanUl = this.buildElement(ulElement, { - content: ulContent - }); - - var divSpan = this.buildelement(spanElement, { - classAttr: "lotusLeft lconnSearchBookmarkHelpText", - content: spanUl - }); - var divResult = this.buildElement(divElement, { - styleAttr: "display:none", - content: divSpan - }); - return aResult + "\n" + divResult + "\n"; - } - }, - - /** - * Returns the commentOn nls string if it is an activities:reply - * @param grid - * @param item - * @param i - * @param items - * @returns - */ - commentOn: function(grid, item, i, items){ - if(this.componentContains(item, "activities:reply")){ - return this._nls.commentOn; - }else{ - return this._nls.emptyString; - } - }, - /** + * Delete a wiki page. * - * - * @param grid - * @param item - * @param i - * @param items - * @returns + * @method deleteWikiPage + * @param wikiLabel + * @param pageLabel + * @param requestArgs */ - ltr: function(grid, item, i, items){ - if(this.componentContains(item, "wikis:file")){ - return 'dir="' + this._nls.ltr + '"'; - }else{ - return this._nls.emptyString; - } - }, - - inactiveLabel: function(grid, item, i, items){ - if(this.componentContains(item, "profiles")){ - return this._nls.inactiveLabel; - }else{ - return this._nls.emptyString; - } - }, - - colspan: function(grid, item, i, items){ - if(!this.componentContains(item, "status_update")){ - return 'colspan="2"'; - }else{ - return ''; - } + deleteWikiPage: function(wikiLabel, pageLabel, requestArgs) { + var promise = this._validateWikiLabel(wikiLabel); + if (promise) { + return promise; + } + promise = this._validatePageLabel(pageLabel); + if (promise) { + return promise; + } + + var options = { + method : "DELETE", + query : requestArgs || {}, + handleAs : "text" + }; + + var urlParams = { "pageLabel" : encodeURIComponent(label), "wikiLabel" : encodeURIComponent(wikiLabel) }; + var url = this.constructUrl(consts.WikiPageEntry, null, urlParams); + + return this.deleteEntity(url, options, wikiLabel); }, - + + // + // Internals + // + /** - * Returns the app label (e.g. profile) but capitalised (e.g. Profile). - * - * @param grid - * @param item - * @param i - * @param items - * @returns + * Move this to BaseService */ - applicationLabel: function(grid, item, i, items){ - var application = this.application; - return application.charAt(0).toUpperCase() + application.slice(1); - }, - - summaryClass: function(grid, item, i, items){ - if(item.getValue("authorState") === "inactive"){ - return "lotusDim"; - }else{ - return "lconnSearchComponentCategory"; + constructUrl : function(url,params,urlParams) { + if (!url) { + throw new Error("BaseService.constructUrl: Invalid argument, url is undefined or null."); } - }, - + + var _urlParams = lang.mixin( + { authType: this.endpoint.authType }, + this.contextRootMap, + this.endpoint.serviceMappings, + urlParams || {}); + url = stringUtil.replace(url, _urlParams); - summaryStyle: function(grid, item, i, items){ - if(item.getValue("authorState") === "inactive"){ - return "filter: alpha(opacity = 50)"; - }else{ - return ""; - } - }, - - getApplication: function(item){ - if(typeof item.getValue("application") === "string"){ - return item.getValue("application"); - }else{ - for(var key in item.getValue("application")){ - var app = item.getValue("application")[key]; - if(app.indexOf(":") ===-1){ - return app; + if (params) { + for (param in params) { + if (url.indexOf("?") == -1) { + url += "?"; + } else if (url.indexOf("&") != (url.length - 1)) { + url += "&"; + } + var value = encodeURIComponent(params[param]); + if (value) { + url += param + "=" + value; } } } + return url; }, - getResultType: function(item){ - var primaryComponent = item.getValue("primaryComponent"); - var resultTypes = this.resultTypes; - - this.application = this.getApplication(item); - - switch(this.application){ - case "blogs": - return resultTypes.blogs; - case "calendar": - return resultTypes.calendar; - case "dogear": - return resultTypes.bookmark; - case "files": - return resultTypes.files; - case "forums": - return resultTypes.forums; - case "profiles": - return resultTypes.profiles; - case "status_updates": - return resultTypes.statusUpdates; - case "wikis": - return resultTypes.wikis; - - } - - if(primaryComponent.indexOf("activities") === 0 || primaryComponent.indexOf("communities:activities") === 0){ - if(primaryComponent === "activities:bookmark" || primaryComponent === "communities:activities:bookmark"){ - return resultTypes.bookmarks; - }else{ - return resultTypes.activities; - } - }else if (primaryComponent.indexOf("communities") === 0){ - if(primaryComponent === "communities:bookmark"){ - return resultTypes.bookmark; - }else{ - return resultTypes.communities; - } + /* + * Validate a Wiki and return a Promise if invalid. + */ + _validateWiki : function(wiki,checkLabel) { + if (!wiki || !wiki.getTitle()) { + return this.createBadRequestPromise("Invalid argument, wiki with title must be specified."); } - - }, - - getRowContent: function(resultType){ - var resultTypes = this.resultTypes; - switch(resultType){ - case resultTypes.activities: - return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; - case resultTypes.blogs: - return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; - case resultTypes.bookmark: - return defaultHeaderTemplate + bookmarkBodyTemplate + defaultSummaryTemplate; - case resultTypes.calendar: - return defaultHeaderTemplate + calendarBodyTemplate + defaultSummaryTemplate; - case resultTypes.communities: - return defaultHeaderTemplate + communityBodyTemplate + defaultSummaryTemplate; - case resultTypes.files: - return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; - case resultTypes.forums: - return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; - case resultTypes.profiles: - return profileHeaderTemplate + profileBodyTemplate + defaultSummaryTemplate; - case resultTypes.statusUpdates: - return statusUpdateHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; - case resultTypes.wikis: - return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; - default: return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; + if (checkLabel && !wiki.getLabel()) { + return this.createBadRequestPromise("Invalid argument, wiki with label must be specified."); } }, - /** - * Returns a tr with the correct content templates for a particular search result. - * @param item - * @param i - * @returns + /* + * Validate a WikiPage and return a Promise if invalid. */ - getTemplate: function(item, i){ - this.resultType = this.getResultType(item); - var tdContent = this.getRowContent(this.resultType); - - // Build tr, adding attributes and content. - var trClass = undefined; - if(i===0){ - trClass = "lotusFirst"; + _validateWikiPage : function(wikiPage,checkLabels) { + if (!wikiPage || !wikiPage.getTitle()) { + return this.createBadRequestPromise("Invalid argument, wiki page with title must be specified."); } - var tdColspan = undefined; - if(true){ - tdColspan = "2"; + if (checkLabels && !wikiPage.getLabel()) { + return this.createBadRequestPromise("Invalid argument, wiki page with label must be specified."); } - var trContent = this.buildElement(tdElement, { - content: tdContent, - colspanAttr: tdColspan - }); - - if(this.resultType === this.resultTypes.statusUpdates){ - var statusUpdateExtraHeader = this.buildElement(tdElement, { - content: statusUpdateExtraHeaderTemplate, - widthAttr: "65", - heightAttr: "55", - classAttr: "lotusFirstCell" - }); - - trContent = statusUpdateExtraHeader + trContent; + if (checkLabels && !wikiPage.getWikiLabel()) { + return this.createBadRequestPromise("Invalid argument, wiki page with wiki label must be specified."); } - - return this.buildElement(trElement, { - content: trContent, - classAttr: trClass - }); }, - createdLabel: function(grid, item, i, items){ - var result = i18n.getSearchUpdatedLabel(item.getValue('created')); - return result; + /* + * Validate a wiki label, and return a Promise if invalid. + */ + _validateWikiLabel : function(wikiLabel) { + if (!wikiLabel || wikiLabel.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected wiki label."); + } }, - updatedLabel: function(grid, item, i, items){ - var result = i18n.getSearchUpdatedLabel(item.getValue('updated')); - return result; + /* + * Validate a wiki page label, and return a Promise if invalid. + */ + _validatePageLabel : function(pageLabel) { + if (!pageLabel || pageLabel.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected wiki page label."); + } }, - /** - * - * @param args + /* + * Validate a wiki UUID, and return a Promise if invalid. */ - constructor: function(args) { - + _validateWikiUuid : function(wikiUuid) { + if (!wikiUuid || wikiUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected wikiUuid."); + } }, - emptyClass: "lconnEmpty lotusui", - - //TODO Handle empty grid. Should override renderEmpty? - - renderItem : function(grid, el, data, item, i, items){ - this.template = this.getTemplate(item, i); - - this.inherited(arguments); + /* + * Return a Wiki instance from Wiki or JSON or String. Throws + * an error if the argument was neither. + */ + _toWiki : function(wikiOrJsonOrString) { + if (wikiOrJsonOrString instanceof Wiki) { + return wikiOrJsonOrString; + } else { + if (lang.isString(wikiOrJsonOrString)) { + wikiOrJsonOrString = { + handle : wikiOrJsonOrString + }; + } + return new Wiki({ + service : this, + _fields : lang.mixin({}, wikiOrJsonOrString) + }); + } }, - /** - * Creates a Div, with a different CSS class, to display a grid that has no results - * @method - renderEmpty - * @param - grid - The Grid - * @param - el - The Current Element + /* + * Return a WikiPage instance from WikiPage or JSON or String. Throws + * an error if the argument was neither. */ - renderEmpty: function(grid, el) { - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - var lotusUiDiv = dom.create("div", { // here purely so a parent of the empty div has the lotusui class... - "class": "lotusui lconnSearchResults", - innerHTML: "" - }, el); - var lotusEmptyDiv = dom.create("div", { - "class": this.emptyClass, - innerHTML: "", - "aria-relevant": "all", - "aria-live": "assertive" - }, lotusUiDiv); - dom.create("span", { - innerHTML: this._nls.empty - }, lotusEmptyDiv); - }, + _toWikiPage : function(pageOrJsonOrString) { + if (pageOrJsonOrString instanceof WikiPage) { + return pageOrJsonOrString; + } else { + if (lang.isString(pageOrJsonOrString)) { + pageOrJsonOrString = { + handle : pageOrJsonOrString + }; + } + return new WikiPage({ + service : this, + _fields : lang.mixin({}, pageOrJsonOrString) + }); + } + } - tableClass: "lotusTable lconnSearchResults" - }); - return searchGridRenderer; + }); + return WikiService; }); + }, -'sbt/log':function(){ +'sbt/connections/ConnectionsService':function(){ /* - * © Copyright IBM Corp. 2012 + * © 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. @@ -2731,160 +2005,302 @@ define(["../../../declare", */ /** - * Social Business Toolkit SDK - Logging Utilities - * @module sbt.log + * Connections common APIs allow application programs to discover information about IBM© Connections as a whole. + * + * @module sbt.connections.ConnectionsService */ -define(['./stringUtil'], function(stringUtil) { - - var loggingEnabled = function isLoggingEnabled(){ - return sbt.Properties["js.logging.enabled"] ? sbt.Properties["js.logging.enabled"].toLowerCase() == "true" : true; - }; - - var Level = { - DEBUG : 1, - INFO : 2, - WARN : 3, - ERROR : 4 - }; +define([ "../declare", "../config", "../Promise", "./ConnectionsConstants", "../base/BaseService", + "../base/AtomEntity", "../base/XmlDataHandler", "../xpath" ], + function(declare,config,Promise,consts,BaseService,AtomEntity,XmlDataHandler,xpath) { - var loggingLevel = function getLoggingLevel(){ - return Level[sbt.Properties["js.logging.level"] ? sbt.Properties["js.logging.level"] : "DEBUG"]; - }; - - return { - /** - * Sets the logging level. - * @param {String} [l ]logging level. Possible values are DEBUG, INFO, WARN, ERROR - * @static - * @method setLevel - */ - setLevel : function(l) { - loggingLevel = Level[l]; - }, - /** - * Enables/disables logging. - * @param {Boolean} [enabled] logging enabled true or false - * @static - * @method setEnabled - */ - setEnabled : function(enabled) { - loggingEnabled = enabled; - }, - /** - * log a debug statement. - * @static - * @method debug - */ - debug : function() { - if (!loggingEnabled) { - return; - } - if (loggingLevel > 1) { - return; - } - if (console && arguments.length > 0) { - var args = Array.prototype.slice.call(arguments); - var text = args[0]; - args = args.slice(1); - var formattedText = stringUtil.substitute(text, args); - if (console.debug) { - console.debug(formattedText); - } else { - console.log("DEBUG : " + formattedText); - } - } - }, - /** - * log an info statement. - * @static - * @method info - */ - info : function() { - if (!loggingEnabled) { - return; - } - if (loggingLevel > 2) { - return; - } - if (console && arguments.length > 0) { - var args = Array.prototype.slice.call(arguments); - var text = args[0]; - args = args.slice(1); - var formattedText = stringUtil.substitute(text, args); - if (console.info) { - console.info(formattedText); - } else { - console.log("INFO : " + formattedText); - } - } - }, - /** - * log a warning statement. - * @static - * @method warn - */ - warn : function() { - if (!loggingEnabled) { - return; - } - if (loggingLevel > 3) { - return; - } - if (console && arguments.length > 0) { - var args = Array.prototype.slice.call(arguments); - var text = args[0]; - args = args.slice(1); - var formattedText = stringUtil.substitute(text, args); - if (console.warn) { - console.warn(formattedText); - } else { - console.log("WARN : " + formattedText); - } - } - }, - /** - * log an error statement. - * @static - * @method error - */ - error : function() { - if (!loggingEnabled) { - return; - } - if (console && arguments.length > 0) { - var args = Array.prototype.slice.call(arguments); - var text = args[0]; - args = args.slice(1); - var formattedText = stringUtil.substitute(text, args); - if (console.error) { - console.error(formattedText); - } else { - console.log("ERROR : " + formattedText); - } - } - }, - /** - * log an exception - * @static - * @method error - */ - exception : function() { - if (!loggingEnabled) { - return; - } - if (console && arguments.length > 0) { - var args = Array.prototype.slice.call(arguments); - var text = args[0]; - args = args.slice(1); - var formattedText = stringUtil.substitute(text, args); - if (console.error) { - console.error("EXCEPTION : " + formattedText); - } else { - console.log("EXCEPTION : " + formattedText); - } - } - } - }; + var CategoryConnectionsBookmark = ""; + var CategoryMember = ""; + var CategoryServiceConfig = "" + + var ServiceConfigsDataHandler = declare(XmlDataHandler, { + /** + * @method getSummary + * @returns + */ + getSummary : function() { + var languageTermsArray = this._selectArray("language"); + var languageLabelsArray = this._selectArray("languageLabels"); + var displayLanguagesMap = []; + for(var i=0;i\r\n
    \r\n \r\n

    \r\n \r\n ${title}\r\n \r\n ${title}\r\n

    \r\n \r\n ${threadCount}\r\n \r\n ${getDateLabel}
    ${authorName}\r\n\r\n\r\n", -'url:sbt/connections/controls/forums/templates/TableHeader.html':" \r\n \r\n ${nls.forums}\r\n \r\n ${nls.threads}\r\n \r\n ${nls.latestPost}\r\n ", -'url:sbt/connections/controls/forums/templates/TopicRow.html':"\r\n\t\r\n\t\t
    \r\n \r\n\t\r\n\t\t

    \r\n\t\t\t${title}\r\n\t\t

    \r\n\t\r\n\t\r\n\t\t\r\n\t${threadCount}\r\n\t\r\n\t${getDateLabel}\r\n", -'url:sbt/connections/controls/forums/templates/ForumTopicRow.html':"\r\n\t\r\n\t\t\r\n \r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t${title}\r\n\t\t\t${isTopicLocked}\r\n\t\t

    \r\n\t\t\r\n\t\r\n\t\r\n\t\r\n\t${threadCount}\r\n\t\r\n\t${getDateLabel}\r\n", -'url:sbt/connections/controls/forums/templates/TopicHeader.html':"\r\n\t\r\n\t${nls.topics}\r\n\t${nls.replies}\r\n\t\r\n\t${nls.latestPost}\r\n", -'url:sbt/connections/controls/forums/templates/ReplyRow.html':"\r\n\t\r\n\t\t
    \r\n \r\n\t\r\n\t\t

    \r\n\t\t\t${content}\r\n\t\t

    \r\n\t\r\n\t\r\n\t${title}\r\n\t\r\n\t\r\n\t${authorName}\r\n\t\r\n\t${getDateLabel}\r\n", -'url:sbt/connections/controls/forums/templates/ReplyHeader.html':"\r\n\t${nls.replies}\r\n\t${nls.topic}\r\n\t\r\n\t${nls.author}\r\n\t${nls.date}\r\n", -'url:sbt/connections/controls/forums/templates/ReplyBreadCrumb.html':"
    \r\n\r\nForums>Topics>Replies\r\n
    ", -'url:sbt/connections/controls/forums/templates/TopicBreadCrumb.html':"
    \r\n\r\nForums>Topics\r\n
    ", -'url:sbt/connections/controls/forums/templates/MyTopicsBreadCrumb.html':"
    \r\n\r\nTopics>Replies\r\n
    ", -'url:sbt/connections/controls/forums/templates/BootstrapForumRow.html':"\r\n\t\r\n \r\n \r\n \r\n ${title}\r\n \r\n \r\n \r\n\r\n\r\n", -'url:sbt/connections/controls/forums/templates/BootstrapTopicRow.html':"\r\n\t\r\n\t\t\r\n\r\n\t\t\r\n\t\t\t${title}\r\n\t\t\r\n\t\r\n"}}); +'url:sbt/connections/controls/files/templates/FileRow.html':"\r\n \r\n \r\n \r\n \r\n \r\n \"\"${_nls.download}\r\n \r\n \r\n \r\n

    \r\n ${title} \r\n

    \r\n
    \r\n
      \r\n
    • \r\n \r\n \t\t\t\t\t\t${authorName}\r\n \t\t\t\t\t\t${authorUserId}\r\n\t\t\t\t\t\r\n ${_nls.created} ${createdLabel}\r\n
    • \r\n
    • \r\n ${hitCount} ${_nls.downloads}\r\n
    • \r\n
    • \r\n ${commentsCount} ${_nls.comments}\r\n
    • \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \"${nls.pin}\"\r\n \r\n \r\n \r\n \r\n \"\"\r\n ${shareLabel}\r\n \r\n \r\n \r\n\r\n\r\n\r\n", +'sbt/config':function(){ /* * © Copyright IBM Corp. 2013 * @@ -3128,283 +2532,122 @@ require({cache:{ * permissions and limitations under the License. */ -define(["../../../declare", - "../ConnectionsGridRenderer", - "../../../i18n", - "../../../dom", - "../../../lang", - "../../../connections/ForumConstants", - "../../../text!./templates/ForumRow.html", - "../../../text!./templates/TableHeader.html", - "../../../text!./templates/TopicRow.html", - "../../../text!./templates/ForumTopicRow.html", - "../../../text!./templates/TopicHeader.html", - "../../../text!./templates/ReplyRow.html", - "../../../text!./templates/ReplyHeader.html", - "../../../text!./templates/ReplyBreadCrumb.html", - "../../../text!./templates/TopicBreadCrumb.html", - "../../../text!./templates/MyTopicsBreadCrumb.html", - "../../../text!./templates/BootstrapForumRow.html", - "../../../text!./templates/BootstrapTopicRow.html", - "../../../i18n!./nls/ForumGridRenderer"], +/** + * Definition of config module. + * This module needs a _config module to be defined at runtime. + * + * @module sbt.config + */ +define(['./defer!./_config'],function(cfg){ + return cfg; +}); +}, +'sbt/connections/ProfileAdminService':function(){ +/* + * © 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. + */ - function(declare, ConnectionsGridRenderer, i18n, dom, lang, consts, ForumRow, tableHeader, TopicRow, ForumTopicRow, - TopicHeader, ReplyTemplate, ReplyHeader,ReplyBreadCrumb,TopicBreadCrumb, - MyTopicsBreadCrumb, BootstrapForumRow,BootstrapTopicRow, nls){ - - /** - * @class ForumGridRenderer - * @namespace sbt.connections.controls.forum - * @module sbt.connections.controls.forum.ForumGridRenderer - */ - var ForumGridRenderer = declare(ConnectionsGridRenderer,{ - - /**Strings used by the forum grid */ - _nls:nls, - - topicTemplate: TopicRow, - - forumTopicTemplate: ForumTopicRow, - - topicHeader: TopicHeader, - - replyTemplate: ReplyTemplate, - - replyHeader: ReplyHeader, - - forumTemplate: ForumRow, - - forumHeader: tableHeader, - - headerTemplate: tableHeader, - - replyBreadCrumb: ReplyBreadCrumb, - - topicBreadCrumb: TopicBreadCrumb, - - myTopicsBreadCrumb:MyTopicsBreadCrumb, - - breadCrumb: ReplyBreadCrumb, - - bootstrapForumRow: BootstrapForumRow, - - bootstrapTopicRow: BootstrapTopicRow, - - /** - * The constructor function - * @method constructor - * @param args - */ - constructor: function(args,grid){ - - if(grid.theme == "bootstrap"){ - if(args.type=="myTopics" || grid.type == "forumTopics"){ - this.template = this.bootstrapTopicRow; - this.headerTemplate = null; - }else{ - this.template = this.bootstrapForumRow; - this.headerTemplate = null; - } - }else{ - if(args.type=="myTopics"){ - this.template = this.topicTemplate; - this.headerTemplate = this.topicHeader; - }else if(args.type=="forumTopics"){ - this.template = this.forumTopicTemplate; - this.headerTemplate = this.topicHeader; - }else{ - this.template = this.forumTemplate; - } - } - - }, - - /** - * Function to render the Paging, the table and the table header. - * @method - render - * @param grid - the grid - * @param el - the grid DOM node - * @param items - the items in the grid row, for example icon, displayName,email etc. - * @param data - the data associated with the grid row - */ - render: function(grid, el, items, data) { - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - var size = items.length; - if (size === 0) { - this.renderEmpty(grid, el); - } - else { - this.renderPager(grid, el, items, data); - - this.renderBreadCrumb(grid, el, items, data); - - var tbody = this.renderTable(grid, el, items, data); - - this.renderHeader(grid, el, items, data, tbody); - - for (var i=0; i" + this.nls.noResults +"", - role: "document", - tabIndex: 0 - }, el, "only"); - - grid._doAttachEvents(el, data); - }, - - - getDateLabel: function(grid, item, i, items){ - var result = i18n.getUpdatedLabel(item.getValue('updated')); - return result; - }, - - getParentLink: function(grid, item, i, items){ - - if(grid.params.type == "myTopics"){ - return item.getValue("topicForumTitle"); - }else{ - return ""; - } - - - }, - - /** - * Displays a tooltip by calling the getTooltip function in the ForumAction class - * @method tooltip - * @param grid The Grid element - * @param item the element to display the tooltip - * @param i the number of the current row - * @param items all of the items in the grid row - * @returns A String used as a tooltip - */ - tooltip: function(grid, item, i, items) { - if (grid.forumAction) { - return grid.forumAction.getTooltip(item); - } - }, - - getUserProfileHref: function(grid,item,i,items){ - return this.getProfileUrl(grid,item.getValue("authorUserid")); - }, - - rendererPinnedLogo: function(grid,item,i,items){ - var terms = item.getValue("categoryTerm"); - for(var i=0;i\r\n\t\r\n\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t${title} \r\n\t\t\t \r\n\t\t

    \r\n\t\t\r\n\t\t
    \r\n\t\t\t${nls.updatedBy}\r\n\t\t\t\t ${authorName} \r\n\t\t\t\t\r\n\t\t\t\t| \r\n\t\t\t\t${updatedDate}\r\n\t\t\t\t\r\n\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t| \r\n\t\t\t\t${nls.dueDate}\t\t\t\t\r\n\t\t\t\t${getDueDate}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t| \r\n\t\t\t\t${nls.tags}\t\t\t\t\r\n\t\t\t\t${tags}\r\n\t\t\t\r\n\t\t
    \r\n\t\r\n", +'url:sbt/connections/controls/activities/templates/BootstrapActivityRow.html':"\r\n\r\n\t\r\n\t\t

    ${title}

    \r\n\t\r\n"}}); /* * © Copyright IBM Corp. 2013 * @@ -3421,35 +2664,103 @@ define(["../../../declare", * permissions and limitations under the License. */ -// NLS_CHARSET=UTF-8 -define({ - root: { - summary : "Profiles Grid", - updatedBy : "Updated by ", - displayName: "Display Name", - recent: "Recent", - telephone: "Telephone:", - email: "Email:", - altEmail: "Alternate Email", - clickToEmail: "Click here to email the user, using their alternate email address", - ariaVcard: "Press control and enter for the business card", - role: "Role", - created: "Created", - edit: "Edit", - remove: "Remove", - save: "Save", - cancel: "Close", - member: "Member", - owner: "Owner", - feed : "Feed for these Community Members" - } -}); +define(["../../../declare", + "../ConnectionsGridRenderer", + "../../../localeUtil", + "../../../text!./templates/ActivityRow.html", + "../../../text!./templates/BootstrapActivityRow.html", + "../../../i18n!./nls/ActivityGridRenderer"], - + function(declare, ConnectionsGridRenderer, localeUtil, ActivityRow, BootstrapActivityRow, nls){ + + /** + * @class ActivityGridRenderer + * @namespace sbt.connections.controls.activities + * @module sbt.connections.controls.forum.ActivityGridRenderer + */ + var ActivityGridRenderer = declare(ConnectionsGridRenderer,{ + + /**Strings used by the forum grid */ + _nls:nls, + + /** + * The constructor function + * @method constructor + * @param args + */ + constructor: function(args,grid){ + + if(grid.theme == "bootstrap"){ + this.template = BootstrapActivityRow; + }else{ + this.template = ActivityRow; + } + }, + + /** + * Displays a tooltip by calling the getTooltip function in the ForumAction class + * @method tooltip + * @param grid The Grid element + * @param item the element to display the tooltip + * @param i the number of the current row + * @param items all of the items in the grid row + * @returns A String used as a tooltip + */ + tooltip: function(grid, item, i, items) { + if (grid.activitiesAction) { + return grid.activitiesAction.getTooltip(item); + } + }, + + getUserProfileHref: function(grid,item,i,items){ + return this.getProfileUrl(grid,item.getValue("authorUserId")); + }, + + /** + * Gets the last updated date for an activity + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i the number of the current grid row + * @param items an object array containing the data for all of the grid rows + * @returns The date when the community was last updates + */ + updatedDate: function(grid, item, i, items) { + var updatedLabel = item.getValue("updated"); + if(updatedLabel.length > 0){ + return localeUtil.getUpdatedLabel(updatedLabel); + }else{ + return ""; + } + }, + + /** + * Gets the due date for an activity + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i the number of the current grid row + * @param items an object array containing the data for all of the grid rows + * @returns The date when the community was last updates + */ + getDueDate: function(grid, item, i, items) { + var dueDate = item.getValue("dueDate"); + if(dueDate.length > 0){ + return localeUtil.getUpdatedLabel(dueDate); + }else{ + return ""; + } + } + + }); + + return ActivityGridRenderer; +}); }, -'sbt/Portlet':function(){ +'url:sbt/connections/controls/search/templates/img.html':"", +'url:sbt/smartcloud/controls/profiles/templates/CommunityMember.html':"\r\n\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t${title}\r\n\r\n\t\t

    \r\n\t\t\r\n\t\r\n\t\r\n\t\t\r\n\t\t\tRole: ${role}\r\n\t\t\r\n\t\r\n\r\n", +'url:sbt/smartcloud/controls/profiles/templates/ColleagueItem.html':"
    \r\n \r\n \"${name}\"\r\n \r\n
    \r\n", +'sbt/connections/controls/profiles/nls/ProfileTagsGridRenderer':function(){ /* - * © Copyright IBM Corp. 2012 + * © 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. @@ -3464,20 +2775,22 @@ define({ * permissions and limitations under the License. */ -/** - * Social Business Toolkit SDK - Portlet specific helpers. - */ -define([],function() { - -sbt.getUserPref = function(ns,name) { - -} - +// NLS_CHARSET=UTF-8 +define({ + root: { + taggedByPerson : "Tagged by 1 person:", + taggedByPeople : "Tagged by {numberOfContributors} people:", + taggedByMe : "My tags for this profile:", + taggedBy : "Tagged by {tagSource}:" + } }); + + }, -'sbt/Endpoint':function(){ +'url:sbt/connections/controls/forums/templates/MyTopicsBreadCrumb.html':"
    \r\n\r\nTopics>Replies\r\n
    ", +'sbt/connections/controls/profiles/ProfileGrid':function(){ /* - * (C) Copyright IBM Corp. 2012 + * © 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. @@ -3493,668 +2806,452 @@ sbt.getUserPref = function(ns,name) { */ /** - * Definition of the endpoint module - * @module sbt.Endpoint - */ - -/** - * Endpoint which defines a connection to a back-end server. - * - * @module sbt.Endpoint + * @module sbt.connections.controls.profiles.ProfileGrid */ -define(['./declare','./lang','./ErrorTransport','./Promise','./pathUtil','./compat','./log', './stringUtil', 'sbt/i18n!sbt/nls/Endpoint', './xml'], -function(declare,lang,ErrorTransport,Promise,pathUtil,compat,log,stringUtil,nls,xml) { +define([ "../../../declare", + "../../../config", + "../../../lang", + "../../../controls/grid/Grid", + "./ProfileGridRenderer", + "./ProfileAction", + "../../../connections/controls/vcard/SemanticTagService", + "../../../store/parameter", + "../../../connections/ProfileConstants", + "../../../connections/CommunityConstants"], + function(declare, sbt, lang, Grid, ProfileGridRenderer, ProfileAction, SemanticTagService, parameter, consts, communities) { -/** - * This class encapsulates an actual endpoint, with its URL, proxy and its authentication mechanism. - * - * @class sbt.Endpoint - */ -var Endpoint = declare(null, { - - /** - * URL of the server used to connect to the endpoint - * @property baseUrl - * @type String - */ - baseUrl: null, - - /** - * Proxy to be used - * @property proxy - * @type String - */ - proxy: null, - - /** - * Path to be added to the proxy url, if any - * @property proxyPath - * @type String - */ - proxyPath: null, + var sortVals = { + displayName: "displayName", + recent: "3" + }; - /** - * Transport to be used - * @property transport - * @type String - */ - transport: null, + var communityMembersSortVals = { + displayName: "displayName", + created: "created" + }; - /** - * Authenticator to be used - * @property authenticator - * @type String - */ - authenticator: null, + var ParamSchema = { + pageNumber: parameter.oneBasedInteger("page"), + pageSize: parameter.oneBasedInteger("ps"), + sortBy: parameter.sortField("sortBy",sortVals), + sortOrder: parameter.sortOrder("sortOrder") + }; - /** - * Auth Type to be used - * @property authType - * @type String - */ - authType: null, - - /** - * UI Login mode: mainWindow, dialog or popup - * @property loginUi - * @type String - */ - loginUi: "", - - /** - * Page for login form for mainWindow and popup - * @property loginPage - * @type String - */ - loginPage: null, - - /** - * Page for login form for dialog - * @property dialogLoginPage - * @type String - */ - dialogLoginPage: null, - - /** - * Whether auth dialog should come up automatically or not. In case of not 401 would be propagated to user. - * @property autoAuthenticate - * @type String - */ - autoAuthenticate: null, - - /** - * Whether user is authenticated to endpoint or not. - * @property isAuthenticated - * @type String - */ - isAuthenticated: false, - - /** - * The error code that is returned from the endpoint on authentication failure. - * @property authenticationErrorCode - * @type String - */ - authenticationErrorCode: null, - - /** - * Simple constructor that mixes in its parameters as object properties - * @constructor - * @param {Array} args - */ - constructor: function(args) { - lang.mixin(this, args || {}); - }, + var CommunityMembersParamSchema = { + pageNumber: parameter.oneBasedInteger("page"), + pageSize: parameter.oneBasedInteger("ps"), + sortBy: parameter.sortField("sortBy", communityMembersSortVals), + sortOrder: parameter.sortOrder("sortOrder") + }; /** - * Provides an asynchronous request using the associated Transport. - * - * @method request - * @param {String) - * url The URL the request should be made to. - * @param {String) - * loginUi The type of UI to use when authenticating, - * valid values are: mainWindow, popup, dialog. - * @param {Boolean) - * authAuthenticate if true the Endpoint with authenticate - * when a 401 (or associated authenication code) is received. - * @param {Object} - * [options] Optional A hash of any options for the provider. - * @param {String|Object} - * [options.data=null] Data, if any, that should be sent with - * the request. - * @param {String|Object} - * [options.query=null] The query string, if any, that should - * be sent with the request. - * @param {Object} - * [options.headers=null] The headers, if any, that should - * be sent with the request. - * @param {Boolean} - * [options.preventCache=false] If true will send an extra - * query parameter to ensure the the server won't supply - * cached values. - * @param {String} - * [options.method=GET] The HTTP method that should be used - * to send the request. - * @param {Integer} - * [options.timeout=null] The number of milliseconds to wait - * for the response. If this time passes the request is - * canceled and the promise rejected. - * @param {String} - * [options.handleAs=text] The content handler to process the - * response payload with. - * @return {sbt.Promise} + * @class ProfileGrid + * @namespace sbt.connections.controls.profiles + * @module sbt.connections.controls.profiles.ProfileGrid */ - request : function(url, options) { - // rewrite the url if needed - var qurl = url; - if (qurl.indexOf("http") != 0) { - if (this.proxy) { - qurl = this.proxy.rewriteUrl(this.baseUrl, url, this.proxyPath); + var ProfileGrid = declare(Grid, { + + /** + * @param options, This is a list of all + * the different types of profile grids available. + * Depending on which one is selected specific arguments will be given to + * the atom store and grid renderer. + */ + options : { + "profile" : { + storeArgs : { + url : consts.AtomProfileDo, + attributes : consts.ProfileXPath, + feedXPath : consts.ProfileFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "profile" + } + }, + "colleagues" : { + storeArgs : { + url : consts.AtomConnectionsDo, + attributes : consts.ProfileXPath, + feedXPath : consts.ProfileFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "profile" + } + }, + "connectionsInCommon" : { + storeArgs : { + url : consts.AtomConnectionsInCommonDo, + attributes : consts.ProfileXPath, + feedXPath : consts.ProfileFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "profile" + } + }, + "peopleManaged" : { + storeArgs : { + url : consts.AtomPeopleManagedDo, + attributes : consts.ProfileXPath, + feedXPath : consts.ProfileFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "profile" + } + }, + "reportingChain" : { + storeArgs : { + url : consts.AtomReportingChainDo, + attributes : consts.ProfileXPath, + feedXPath : consts.ProfileFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "profile" + } + }, + "search" : { + storeArgs : { + url : consts.AtomSearchDo, + attributes : consts.ProfileXPath, + feedXPath : consts.ProfileFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "profile" + } + }, + "dynamic" : { + storeArgs : { + attributes : consts.ProfileXPath, + feedXPath : consts.ProfileFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "profile" + } + }, + "communityMembers" : { + storeArgs : { + url : communities.AtomCommunityMembers, + attributes : communities.MemberXPath, + feedXPath : communities.CommunityFeedXPath, + paramSchema: CommunityMembersParamSchema + }, + rendererArgs : { + type : "communityMembers" + } + } + }, + + /** + * A profile action, defines default behaviour for when + * items in the grid are clicked on or hovered on, + * it is possible to override these actions + */ + profileAction: new ProfileAction(), + + /** + * This is the default grid that will be created if no + * arguments are given. + */ + defaultOption: "colleagues", + + /**Constructor function + * @method constructor + * */ + constructor: function(args){ + if(args.type == "peopleManaged" || args.type == "reportingChain" || args.type == "profile") { + this.hideSorter = true; + } + + var nls = this.renderer.nls; + + if (args.type == "communityMembers") { + + this._sortInfo = { + displayName: { + title: nls.displayName, + sortMethod: "sortByTitle", + sortParameter: "title" + }, + recent: { + title: nls.created, + sortMethod: "sortByCreated", + sortParameter: "created" + } + }; + this._activeSortAnchor = this._sortInfo.created; + this._activeSortIsDesc = true; } else { - qurl = pathUtil.concat(this.baseUrl, url); + this._sortInfo = { + displayName: { + title: nls.displayName, + sortMethod: "sortByDisplayName", + sortParameter: "displayName" + }, + recent: { + title: nls.recent, + sortMethod: "sortByRecent", + sortParameter: "recent" + } + + }; + this._activeSortAnchor = this._sortInfo.recent; + this._activeSortIsDesc = true; } - } + + }, - if (!options) { - options = { - method : "GET", - handleAs : "text" - }; + contextRootMap: { + profiles: "profiles" + }, + + /** + * Override buildUrl to add outputType, format and email/userid's + * + * @method buildUrl + * @param url base url + * @param args arguments that will be passed to the store + * @param endpoint An endpoint which may contain custom service mappings. + * @returns Built url + */ + buildUrl: function(url, args, endpoint) { + var params = { + outputType : "profile", + format : "full" + }; + + if (this.query) { + params = lang.mixin(params, this.query); + } + if (this.type == "colleagues") { + params = lang.mixin(params, { connectionType : "colleague" }); + } else if (this.type == "communityMembers") { + params = lang.mixin(params, { communityUuid : this.communityUuid }); + } + + if (this.email) { + params = lang.mixin(params, { email : this.email }); + } + if (this.email1 && this.email2) { + params = lang.mixin(params, { email : this.email1 + "," + this.email2 }); + } + if (this.userid) { + params = lang.mixin(params, { userid : this.userid }); + } + if (this.userid1 && this.userid2) { + params = lang.mixin(params, { userid : this.userid1 + "," + this.userid2 }); + } + + return this.constructUrl(url, params, this.getUrlParams(), endpoint); + }, + + /** + * The post create function is called, after the grid has been created. + * The function will call the super classes post create + * then load the semantic tag service. The semantic tag service + * is Javascript for creating business card functionality. + * @method postCreate + */ + postCreate: function() { + this.inherited(arguments); + if(this.displayBusinessCard){ + SemanticTagService.loadSemanticTagService(); + } + }, + + /** + * Creates a renderer for the grid.The renderer is responsible for + * loading the grid's HTML content. + * @method createDefaultRenderer + * @param args sets the template the renderer will use, by checking args.type, but for + * profile grids this will always be "profile" + * @returns an instance of a profile gird renderer. + */ + createDefaultRenderer : function(args) { + return new ProfileGridRenderer(args,this); + }, + + /** + * In the grid HTML an element can have an event attached + * using dojo-attach-event="onClick: handleClick". + * This method is the handler for the onclick event. + * @method handleClick + * @param el the element that fired the event + * @param data all of the items from the current row of the grid. + * @param ev the event + */ + handleClick: function(el, data, ev) { + if (this.profileAction) { + console.log(data); + this._stopEvent(ev); + + this.profileAction.execute(data, this, ev); + } + }, + + /** + * @method getSortInfo + * @returns A list of strings that describe how the grid can be sorted + * for profile grids these strings are "Display Name" and "Recent" + */ + getSortInfo: function() { + return { + active: { + anchor: this._activeSortAnchor, + isDesc: this._activeSortIsDesc + }, + list: [this._sortInfo.displayName, this._sortInfo.recent] + }; + + }, + + sortByDisplayName: function(el, data, ev){ + this._sort("displayName", true, el, data, ev); + }, + + sortByRecent: function(el, data, ev){ + this._sort("recent", true, el, data, ev); + }, + + sortByCreated: function(el, data, ev){ + this._sort("created", true, el, data, ev); + }, + + sortByTitle: function(el, data, ev){ + this._sort("title", true, el, data, ev); } - options.name = this.name; + + // Internals - var promise = new Promise(); - promise.response = new Promise(); + }); - var self = this; - this.transport.request(qurl, options).response.then(function(response) { - - // Check for form based authentication - if(self.authType == "form"){ - var authRequiredFlag = self._isAuthRequiredFormBasedEP(response, options); - if(authRequiredFlag){ - self._authenticate(url, options, promise); - } + return ProfileGrid; +}); +}, +'url:sbt/connections/controls/profiles/templates/TagListRow.html':"
  • \r\n\t${term}\r\n\t${frequency}\r\n
  • \r\n", +'sbt/controls/dialog/Dialog':function(){ +require({cache:{ +'url:sbt/controls/dialog/templates/Dialog.html':"
    \r\n\t
    \r\n\t\t \r\n\t\t\r\n\t\t\tx\r\n\t\t\r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t
    \r\n\t\t\t\t\t

    ${title}

    \r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\"${nls.Close}\"\r\n\t\t\t\t\t\tX\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t\t
    \r\n\t\t\t\t\t
    \r\n\t\t\t\t\t
    \r\n\t\t\t\t
    \r\n\t\t\t\t
    \r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n
    \r\n"}}); +/* + * © 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. + */ + +/** + * + */ +define([ "../../declare", "../../lang", + "../../i18n!./nls/dialog", + "../../widget/_TemplatedDialog", + "../../text!./templates/Dialog.html" ], + function(declare, lang, nls, _TemplatedDialog, DialogTemplate) { + + /** + * @class Dialog + * @namespace sbt.controls.dialog + * @module sbt.controls.dialog.Dialog + */ + var Dialog = declare([ _TemplatedDialog ], { + + dialogStyle : "width: 525px;", + + templateString : DialogTemplate, + + buttonClass : "lotusFormButton", + + /** + * Constructor method for the grid. + * Creates a default store and renderer, if none have been already created + * @method constructor + * @param args + */ + constructor: function(args) { + this.nls = lang.mixin({}, nls, args.nls || {}); + if (args.nls) { + delete args.nls; } - promise.fulfilled(response.data); - promise.response.fulfilled(response); - }, function(error) { - if (!error.message) { - error.message = self.getErrorMessage(error.cause); - } - var authRequiredPromise = self._isAuthRequired(error, options); - authRequiredPromise.then( - function(response) { - if (response) { - self._authenticate(url, options, promise); - } else { - promise.rejected(error); - promise.response.rejected(error); - } - }, - function(error) { - promise.rejected(error); - promise.response.rejected(error); - } - ); - }); + lang.mixin(this, args || {}); + }, - return promise; - }, - - /* - * Sends a request using XMLHttpRequest with the given URL and options. - * - * @method xhr - * @param {String} [method] The HTTP method to use to make the request. Must be uppercase. Default is 'GET'. - * @param {Object} [args] - * @param {String} [args.url] - * @param {Function} [args.handle] - * @param {Function} [args.load] - * @param {Function} [args.error] - * @param {Boolean} [hasBody] - */ - xhr: function(method,args,hasBody) { - var self = this; - var _args = lang.mixin({},args); - // We make sure that args has a 'url' member, with or without a proxy - if(!_args.url) { - if(this.proxy) { - _args.url = this.proxy.rewriteUrl(this.baseUrl,_args.serviceUrl,this.proxyPath); - } else { - _args.url = pathUtil.concat(this.baseUrl,_args.serviceUrl); + /** + * Construct the UI for this dialog from a template, setting this.domNode. + * + * @method buildRendering + */ + buildRendering: function() { + this.inherited(arguments); + + // create the dialog content + if (this.dialogContent) { + var widget = this.dialogContent; + if (lang.isString(widget)) { + widget = new _TemplatedWidget({ + templateString : widget + }); + } + widget.dialog = this; + + this.widget = widget; + this.contentNode.appendChild(widget.domNode); } - } - // Make sure the initial methods are not called - // seems that Dojo still call error(), even when handle is set - delete _args.load; delete _args.error; - _args.handle = function(data,ioArgs) { - if(data instanceof Error) { - var error = data; - if(!error.message){ - error.message = self.getErrorMessage(error.cause); - } - var isForbiddenErrorButAuthenticated = false; - // check for if authentication is required - if(error.code == 403 && self.authenticationErrorCode == 403){ - // case where 403 is configured to be treated similar to 401 (unAuthorized) - // checking if we are getting 403 inspite of being already authenticated (eg. Get Public Files/Folders API on Smartcloud - if(self.isAuthenticated){ - isForbiddenErrorButAuthenticated = true; - } - } - if ((error.code == 401)|| (!isForbiddenErrorButAuthenticated && error.code == self.authenticationErrorCode)) { - var autoAuthenticate = _args.autoAuthenticate || self.autoAuthenticate; - if(autoAuthenticate == undefined){ - autoAuthenticate = true; - } - if(autoAuthenticate){ - if(self.authenticator) { - options = { - dialogLoginPage:self.loginDialogPage, - loginPage:self.loginPage, - transport:self.transport, - proxy: self.proxy, - proxyPath: self.proxyPath, - loginUi: _args.loginUi || self.loginUi, - name: self.name, - callback: function() { - self.xhr(method,args,hasBody); - } - }; - if(self.authenticator.authenticate(options)) { - return; - } - } - } - } - - // notify handle and error callbacks is available - self._notifyError(args, error, ioArgs); - } else { - // notify handle and load callbacks is available - self._notifyResponse(args, data, ioArgs); - } - }; - this.transport.xhr(method, _args, hasBody); - }, - - /* - * @method xhrGet - * @param args - */ - xhrGet: function(args) { - this.xhr("GET",args); - }, - - /* - * @method xhrPost - * @param args - */ - xhrPost: function(args){ - this.xhr("POST", args, true); - }, - - /* - * @method xhrPut - * @param args - */ - xhrPut: function(args){ - this.xhr("PUT", args, true); - }, - - /* - * @method xhrDelete - * @param args - */ - xhrDelete: function(args){ - this.xhr("DELETE", args); - }, - - /** - * authenticate to an endpoint - * - * @method authenticate - * @param {Object} [args] Argument object - * @param {boolean} [args.forceAuthentication] Whether authentication is to be forced in case user is already authenticated. - * @param {String} [args.loginUi] LoginUi to be used for authentication. possible values are: 'popup', 'dialog' and 'mainWindow' - * @param {String} [args.loginPage] login page to be used for authentication. this property should be used in case default - * login page is to be overridden. This only applies to 'popup' and 'mainWindow' loginUi - * @param {String} [args.dialogLoginPage] dialog login page to be used for authentication. this property should be used in - * case default dialog login page is to be overridden. This only applies to 'dialog' loginUi. - */ - authenticate : function(args) { - var promise = new Promise(); - args = args || {}; - if (args.forceAuthentication || !this.isAuthenticated) { - var options = { - dialogLoginPage : this.loginDialogPage, - loginPage : this.loginPage, - transport : this.transport, - proxy : this.proxy, - proxyPath : this.proxyPath, - loginUi : args.loginUi || this.loginUi, - name: this.name, - callback: function(response) { - promise.fulfilled(response); - }, - cancel: function(response) { - promise.rejected(response); - } - }; - this.authenticator.authenticate(options); - } else { - promise.fulfilled(true); - } - return promise; - }, - - /** - * Logout from an endpoint - * - * @method logout - * @param {Object} [args] Argument object - */ - logout : function(args) { - var promise = new Promise(); - args = args || {}; - var self = this; - var actionURL = ""; - if (!args.actionUrl) { - var proxy = this.proxy.proxyUrl; - actionURL = proxy.substring(0, proxy.lastIndexOf("/")) + "/authHandler/" + this.proxyPath + "/logout"; - } else { - actionURL = args.actionUrl; - } - this.transport.xhr('POST',{ - handleAs : "json", - url : actionURL, - load : function(response) { - self.isAuthenticated = false; - promise.fulfilled(response); - }, - error : function(response) { - self.isAuthenticated = false; - promise.rejected(response); - } - }, true); - return promise; - }, - - /** - * Find whether endpoint is authenticated or not. - * - * @method isAuthenticated - * @param {Object} [args] Argument object - */ - isAuthenticated : function(args) { - var promise = new Promise(); - args = args || {}; - var self = this; - var actionURL = ""; - if (!args.actionUrl) { - var proxy = this.proxy.proxyUrl; - actionURL = proxy.substring(0, proxy.lastIndexOf("/")) + "/authHandler/" + this.proxyPath + "/isAuth"; - } else { - actionURL = args.actionUrl; - } - this.transport.xhr('POST',{ - handleAs : "json", - url : actionURL, - load : function(response) { - self.isAuthenticated = true; - promise.fulfilled(response); - }, - error : function(response) { - promise.rejected(response); + + // optionally hide the execute and Cancel buttons + if (this.hideExecute && this.executeButton) { + this.executeButton.style.display = "none"; } - }, true); - return promise; - }, - - /** - Find whether endpoint authentication is valid or not. - - @method isAuthenticationValid - @param {Object} [args] Argument object - @param {Function} [args.load] This is the function which isAuthenticationValid invokes when - authentication information is retrieved. - @param {Function} [args.error] This is the function which isAuthenticationValid invokes if an error occurs. - result property in response object returns true/false depending on whether authentication is valid or not. - */ - isAuthenticationValid : function(args) { - var promise = new Promise(); - args = args || {}; - var self = this; - var actionURL = ""; - if (!args.actionUrl) { - var proxy = this.proxy.proxyUrl; - actionURL = proxy.substring(0, proxy.lastIndexOf("/")) + "/authHandler/" + this.proxyPath + "/isAuthValid"; - } else { - actionURL = args.actionUrl; - } - this.transport.xhr('POST',{ - handleAs : "json", - url : actionURL, - load : function(response) { - self.isAuthenticated = response.result; - promise.fulfilled(response); - }, - error : function(response) { - promise.rejected(response); + if (this.hideCancel && this.cancelButton) { + this.cancelButton.style.display = "none"; } - }, true); - return promise; - }, - - // Internal stuff goes here and should not be documented - - /* - * Invoke error function with the error - */ - _notifyError: function(args, error, ioArgs) { - if (args.handle) { - try { - args.handle(error, ioArgs); - } catch (ex) { - // TODO log an error - var msg = ex.message; - } - } - if (args.error) { - try { - args.error(error, ioArgs); - } catch (ex) { - // TODO log an error - var msg = ex.message; - } - } - }, - - /* - * Invoke handle and/or load function with the response - */ - _notifyResponse: function(args, data, ioArgs) { - if (args.handle) { - try { - args.handle(data, ioArgs); - } catch (ex) { - // TODO log an error - var msg = ex.message; - } - } - if (args.load) { - try { - args.load(data, ioArgs); - } catch (ex) { - // TODO log an error - var msg = ex.message; - } - } - }, - - /* - * Invoke automatic authentication for the specified request. - */ - _authenticate: function(url, options, promise) { - var self = this; - var authOptions = { - dialogLoginPage: this.loginDialogPage, - loginPage: this.loginPage, - transport: this.transport, - proxy: this.proxy, - proxyPath: this.proxyPath, - actionUrl: options.actionUrl, - loginUi: options.loginUi || this.loginUi, - name: this.name, - callback: function() { - self.request(url, options).response.then( - function(response) { - promise.fulfilled(response.data); - promise.response.fulfilled(response); - }, function(error) { - promise.rejected(error); - promise.response.rejected(error); - } - ); - }, - cancel: function() { - self._authRejected = true; - var error = new Error(); - error.message = "Authentication is required and has failed or has not yet been provided."; - error.code = 401; - promise.rejected(error); - promise.response.rejected(error); + }, + + /** + * Add a new button to the dialog + * + * @method addButton + * @param label + * @param style + * @param callback + */ + addButton: function(label, style, callback) { + var button = dom.create("input", { + type: "button", + "class": this.buttonClass, + "style": style || "", + role: "button", + value: label || "" + }, this.buttonsNode); + if (callback) { + button.onclick = callback; } - }; - - return this.authenticator.authenticate(authOptions); - }, - - /* - * Return true if automatic authentication is required. This method returns a promise with the success callback returning - * a boolean whether authentication is required. It first checks if the client is already authenticated - * and if yes, whether the authentication is valid. Else, it checks for the status code and other - * configuration paramters to decide if authentication is required. - */ - _isAuthRequired : function(error, options) { - var promise = new Promise(); - var status = error.response.status || null; - var isAuthErr = status == 401 || status == this.authenticationErrorCode; - if (this.isAuthenticated) { - if (!isAuthErr) { - promise.fulfilled(false); - } else { - this.isAuthenticationValid().then( - function(response) { - promise.fulfilled(!response.result); - }, - function(response) { - promise.rejected(response); - } - ); - } - } else { - // User can mention autoAuthenticate as part service wrappers call that is the args json variable or - // as a property of endpoint in managed-beans.xml. - // isAutoAuth variable is true when autoAuthenticate property is true in args json variable or - // autoAuthenticate property in endpoint defination in managed-beans.xml is true. It is false otherwise. - var isAutoAuth = options.autoAuthenticate || this.autoAuthenticate; - if (isAutoAuth == undefined) { - isAutoAuth = true; - } - // The response is returned as a boolean value as an argument to the success callback of the promise. This - // value is true when the error code is 401 or any authentication error code for a particular endpoint - // (isAuthErr variable) and autoAuthenticate parameter is mentioned true (based on isAutoAuth variable) - // and authenticator property the endpoint (could be js object of type Basic or OAuth)is defined and the - // authentication was not rejected earlier. - // It is false otherwise. The true value of this expression triggers the authentication process from the client. - promise.fulfilled(isAuthErr && isAutoAuth && this.authenticator && !this._authRejected); - } - return promise; - }, - - /* - * Method ensures we trigger authentication for Smartcloud when response code is 200 and content is login page - */ - _isAuthRequiredFormBasedEP : function (response, options){ - if(response.status == 200 && response.getHeader("Content-Type") == "text/html"){ - return true; - }else{ - return false; + this.buttonsNode.appendChild(button); + return button; } - }, - - getErrorMessage: function(error) { - var text = error.responseText || (error.response&&error.response.text) ; - if (text) { - try { - var dom = xml.parse(text); - var messages = dom.getElementsByTagName("message"); - if (messages && messages.length != 0) { - text = messages[0].text || messages[0].textContent; - text = lang.trim(text); - } - } catch(ex) { - } - var trimmedText = text.replace(/(\r\n|\n|\r)/g,""); - if(!(trimmedText)){ - return error.message; - }else{ - return text; - } - } else { - return error; - } - }, - - getProxyUrl: function(){ - return this.proxy.proxyUrl + "/" + this.proxyPath; - }, + }); - /** - * Takes a url with a context root to replace, and returns a url with the context root replaced. - * - * e.g. url: 'http://example.com/${replaceMe}' - * If this endpoint has serviceMappings like: - * { - * replaceMe: 'replacement' - * } - * - * returns 'http://example.com/replacement' - * - * If there is no replacement available, the replacement will be the string inside the braces. e.g. 'http://example.com/replaceMe' will be returned. - * - * @method modifyUrlContextRoot - * - * @param {String} url - * @param {Object} [defaultContextRootMap] If specified, this object will be used for replacements in the event there is no equivalent serviceMapping object. - */ - modifyUrlContextRoot: function(url, defaultContextRootMap){ - var defaultMap = defaultContextRootMap ? {} : lang.mixin({}, defaultContextRootMap); - var map = lang.mixin(defaultMap, this.serviceMapping); - - return stringUtil.transform(url, map, function(value, key){ - if(!value){ - return key; - } - else{ - return value; - } - }, this); - } - -}); - -return Endpoint; + return Dialog; }); }, -'url:sbt/connections/controls/bookmarks/templates/BootstrapBookmarkRow.html':"\t\r\n\t\r\n\t\t\r\n\t

    \r\n\t\t\t${title}\r\n\t\t

    \r\n\t\t\t\t\r\n\t\r\n", -'sbt/connections/controls/profiles/ProfileTagsGrid':function(){ +'sbt/smartcloud/ProfileService':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -4168,159 +3265,499 @@ return Endpoint; * implied. See the License for the specific language governing * permissions and limitations under the License. */ - /** - * @module sbt.connections.controls.profiles.ProfileTagsGrid - */ -define([ "../../../declare", - "../../../lang", - "../../../config", - "../../../controls/grid/Grid", - "./ProfileTagsGridRenderer", - "./ProfileTagAction", - "../../../store/parameter", - "../../../connections/ProfileConstants"], - function(declare, lang, sbt, Grid, ProfileTagsGridRenderer, ProfileTagAction, parameter, consts) { + * Social Business Toolkit SDK. + * @author Vimal Dhupar + * + * Javascript APIs for IBM SmartCloud Profiles Service. + * @module sbt.smartcloud.ProfileService +**/ - /** - * @class ProfileTagsGrid - * @namespace sbt.connections.controls.profiles - * @module sbt.connections.controls.profiles.ProfileTagsGrid +define(["../declare","../lang", "../config","../stringUtil","../Cache","./Subscriber","../Jsonpath","../base/BaseService", "../base/JsonDataHandler", "./ProfileConstants", "../base/BaseEntity","../Promise"], + function(declare, lang, config, StringUtil, Cache, Subscriber, JsonPath, BaseService, JsonDataHandler, Consts, BaseEntity, Promise) { + /** + * Profile class representing the Smartcloud User Profile. + * + * @class Profile + * @namespace sbt.smartcloud */ - var ProfileTagsGrid = declare(Grid, { - - /** - * @param lite Specifies how much tag information you want to retrieve. The options are lite or full. - */ - format : "full", - - /** - * @param options, This is a list of all - * the different types of profile tags grids available. - * Depending on which one is selected specific arguments will be given to - * the atom store and grid renderer. - */ - options : { - "list" : { - storeArgs : { - url : consts.AtomTagsDo, - feedXPath : consts.ProfileTagsXPath, - attributes : consts.ProfileTagsXPath, - namespaces : consts.Namespaces - }, - rendererArgs : { - type : "list" - } - } + var Profile = declare(BaseEntity, { + /** + * Profile Class Constructor + * + * @constructor + * @param args + */ + constructor : function(args) { }, - + /** - * A profile tag action, defines default behaviour for when - * items in the grid are clicked on or hovered on, - * it is possible to override these actions + * Loads the profile object with the profile entry document associated + * with the profile. By default, a network call is made to load the + * profile entry document in the profile object. + * + * @method load + * @param {Object} [args] Argument object + * */ - profileTagAction: new ProfileTagAction(), + load: function(args) { + var profileId = this.getId(); + var promise = this.service._validateProfileId(profileId); + if (promise) { + return promise; + } + + var self = this; + var callbacks = { + createEntity : function(service,data,response) { + return new JsonDataHandler({ + data : data, + jsonpath : Consts.ProfileJsonPath + }); + } + }; + var requestArgs = {}; + requestArgs.userid = profileId; + lang.mixin(requestArgs, args || {format:"json"}); + var options = { + handleAs : "json", + query : requestArgs + }; + return this.service.getEntity(consts.GetProfile, options, profileId, callbacks, args); + }, + + /** + * Returns the id of the User + * @method getId + * @return {String} id of the User + **/ + getId: function () { + return this.getAsString("id"); + }, + + /** + * Returns the id of the User + * @method getUserid + * @return {String} id of the User + **/ + getUserid: function () { + return this.getAsString("id"); + }, + + /** + * Returns the object id of the User + * @method getObjectId + * @return {String} id of the User + */ + getObjectId: function () { + return this.getAsString("objectId"); + }, + + /** + * Get display name of the User + * @method getDisplayName + * @return {String} display name of the User + */ + getDisplayName: function () { + return this.getAsString("displayName"); + }, + + /** + * Get display name of the User + * @method getName + * @return {String} display name of the User + */ + getName: function () { + return this.getAsString("displayName"); + }, + + /** + * Get email of the User + * @method getEmail + * @return {String} email of the User + */ + getEmail: function () { + return this.getAsString("emailAddress"); + }, + + /** + * Get thumbnail URL of the User + * @method getThumbnailUrl + * @return {String} thumbnail URL of the User + */ + getThumbnailUrl: function () { + var image = this.getAsString("thumbnailUrl"); + if(image) + image = this.service.endpoint.baseUrl+"/contacts/img/photos/"+ image; // TODO : work in making this generic + return image; + }, + + /** + * Get address of the profile + * @method getAddress + * @return {String} Address object of the profile + */ + getAddress: function () { + var address = this.getAsArray("address"); + address = this.dataHandler.extractFirstElement(address); + return address; + }, + + /** + * Get department of the profile + * @method getDepartment + * @return {String} department of the profile + */ + getDepartment: function () { + return this.getAsString("department"); + }, + + /** + * Get job title of the profile + * @method getJobTitle + * @return {String} job title of the profile + */ + getJobTitle: function () { + return this.getAsString("jobTitle"); + }, + + /** + * Get profile URL of the profile + * @method getProfileUrl + * @return {String} profile URL of the profile + */ + getProfileUrl: function () { + return this.getAsString("profileUrl"); + }, + + /** + * Get telephone number of the profile + * @method getTelehoneNumber + * @return {String} Telephone number object of the profile + */ + getTelephoneNumber: function () { + return this.getAsString("telephone"); + }, + + /** + * Get Country of the profile + * @method getCountry + * @return {String} country of the profile + */ + getCountry: function () { + return this.getAsString("country"); + }, + + /** + * Get Organization Id of the profile + * @method getOrgId + * @return {String} Organization Id of the profile + */ + getOrgId: function () { + return this.getAsString("orgId"); + }, + + /** + * Get Organization of the profile + * @method getOrg + * @return {String} Organization of the profile + */ + getOrg: function () { + return this.getAsString("org"); + }, + + /** + * Get "About Me"/description of the profile + * @method getAbout + * @return {String} description of the profile + */ + getAbout: function () { + return this.getAsString("about"); + } + }); + + /** + * Callbacks used when reading an entry that contains a Profile. + */ + var ProfileCallbacks = { + createEntity : function(service,data,response) { + var entryHandler = new JsonDataHandler({ + data : data, + jsonpath : Consts.ProfileJsonPath + }); + + return new Profile({ + service : service, + id : entryHandler.getEntityId(), + dataHandler : entryHandler + }); + } + }; + + /** + * Callbacks used when reading a feed that contains multiple Profiles. + */ + var ProfileFeedCallbacks = { + createEntities : function(service,data,response) { + return new JsonDataHandler({ + data : data, + jsonpath : Consts.ProfileJsonPath + }); + }, + createEntity : function(service,data,response) { + var entryHandler = new JsonDataHandler({ + data : data, + jsonpath : Consts.ProfileJsonPath + }); + + return new Profile({ + service : service, + id : entryHandler.getEntityId(), + dataHandler : entryHandler + }); + } + }; + + /** + * Profile service class associated with a profile service of IBM SmartCloud. + * + * @class ProfileService + * @namespace sbt.smartcloud + */ + var ProfileService = declare(BaseService, { + _profiles: null, + + /** + * + * @constructor + * @param args + */ + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } + if(!this._cache){ + if(config.Properties.ProfileCacheSize || Consts.DefaultCacheSize){ + this._cache = new Cache(config.Properties.ProfileCacheSize || Consts.DefaultCacheSize); + } + } + }, + /** - * This is the default grid that will be created if no - * arguments are given. + * Return the default endpoint name if client did not specify one. + * @returns {String} */ - defaultOption: "list", + getDefaultEndpointName: function() { + return "smartcloud"; + }, + + /** + * Get the profile of a user. + * + * @method getProfile + * @param {String} userId Userid of the profile + * @param {Object} args Argument object + */ + getProfile : function(userId, args) { + var idObject = this._toIdObject(userId); + var promise = this._validateIdObject(idObject); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin(idObject, args || {format:"json"}); + var options = { + method : "GET", + handleAs : "json", + query : args || { format: "json" } + }; + var entityId = encodeURIComponent(idObject.userid); + var url = this.constructUrl(Consts.GetProfileByGUID, {}, {idToBeReplaced : entityId}); + return this.getEntity(url, options, entityId, this.getProfileCallbacks()); + }, - /**Constructor function - * @method constructor - * */ - constructor: function(args) { + /** + * Get the profile of a user. + * + * @method getProfileByGUID + * @param {String} userId Userid of the profile + * @param {Object} args Argument object + * @deprecated Use getProfile instead. + */ + getProfileByGUID : function(userId, args) { + return this.getProfile(userId, args); }, - contextRootMap: { - profiles: "profiles" + /** + * Get the profile of a logged in user. + * + * @method getMyProfile + * @param {Object} args Argument object + */ + getMyProfile : function(args) { + var self = this; + var url = Consts.GetUserIdentity; + + var promise = new Promise(); + this.endpoint.request(url, { handleAs : "json" }).then(function(response) { + + var idObject = self._toIdObject(response.subscriberid); + var promise1 = self._validateIdObject(idObject); + if (promise1) { + return promise1; + } + + var requestArgs = lang.mixin(idObject, args || {format:"json"}); + var options = { + method : "GET", + handleAs : "json", + query : requestArgs + }; + var entityId = encodeURIComponent(idObject.userid); + var url = self.constructUrl(Consts.GetProfileByGUID, {}, {idToBeReplaced : entityId}); + (self.getEntity(url, options, entityId, self.getProfileCallbacks())).then(function(response) { + promise.fulfilled(response); + }, + function(error) { + promise.rejected(error); + }); + }, + function(error) { + promise.rejected(error); + } + ); + return promise; }, /** - * Override buildUrl to add format, target and source + * Get the contact details of a user. * - * @method buildUrl - * @param url base url - * @param args arguments that will be passed to the store - * @param endpoint An endpoint which may contain custom service mappings. - * @returns Built url + * @method getContact + * @param {String} userId Userid of the profile + * @param {Object} args Argument object */ - buildUrl: function(url, args, endpoint) { - var params = { format : this.format }; - - if (this.query) { - params = lang.mixin(params, this.query); + getContact : function(userId, args) { + var idObject = this._toIdObject(userId); + var promise = this._validateIdObject(idObject); + if (promise) { + return promise; } - if (this.targetEmail) { - params = lang.mixin(params, { targetEmail : this.targetEmail }); - } - if (this.targetKey) { - params = lang.mixin(params, { targetKey : this.targetKey }); - } - if (this.sourceEmail) { - params = lang.mixin(params, { sourceEmail : this.sourceEmail }); - } - if (this.sourceKey) { - params = lang.mixin(params, { sourceKey : this.sourceKey }); - } - return this.constructUrl(url, params, this.getUrlParams(), endpoint); + var requestArgs = lang.mixin(idObject, args || {format:"json"}); + var options = { + method : "GET", + handleAs : "json", + query : requestArgs + }; + var entityId = idObject.userid; + var url = this.constructUrl(Consts.GetContactByGUID, {}, {idToBeReplaced : entityId}); + return this.getEntity(url, options, entityId, this.getProfileCallbacks()); }, /** - * The post create function is called, after the grid has been created. - * The function will call the super classes post create - * then load the semantic tag service. The semantic tag service - * is Javascript for creating business card functionality. - * @method postCreate + * Get the contact details of a user. + * + * @method getContactByGUID + * @param {String} userId Userid of the profile + * @param {Object} args Argument object + * @deprecated Use getContact instead. */ - postCreate: function() { - this.inherited(arguments); + getContactByGUID : function(userId, args) { + return this.getContact(userId, args); }, /** - * Creates a renderer for the grid.The renderer is responsible for - * loading the grid's HTML content. - * @method createDefaultRenderer - * @param args sets the template the renderer will use, by checking args.type, but for - * profile grids this will always be "profile" - * @returns an instance of a profile gird renderer. + * Get logged in user's Connections + * + * @method getMyConnections + * @param {Object} args Argument object */ - createDefaultRenderer : function(args) { - return new ProfileTagsGridRenderer(args,this); + getMyConnections : function(args) { + var options = { + method : "GET", + handleAs : "json", + query : args || {format:"json"} + }; + return this.getEntities(Consts.GetMyConnections, options, this.getProfileFeedCallbacks()); }, /** - * In the grid HTML an element can have an event attached - * using dojo-attach-event="onClick: handleClick". - * This method is the handler for the onclick event. - * @method handleClick - * @param el the element that fired the event - * @param data all of the items from the current row of the grid. - * @param ev the event + * Get logged in user's Contacts + * + * @method getMyContacts + * @param {Object} args Argument object */ - handleClick: function(el, data, ev) { - if (this.profileTagAction) { - console.log(data); - this._stopEvent(ev); - - this.profileTagAction.execute(data, { grid : this.grid }, ev); - } - } + getMyContacts : function(args) { + var options = { + method : "GET", + handleAs : "json", + query : args || {format:"json"} + }; + return this.getEntities(Consts.GetMyContacts, options, this.getProfileFeedCallbacks()); + }, - // Internals + /** + * Get logged in user's Contacts considering the startIndex and count as provided by the user + * + * @method getMyContactsByIndex + * @param startIndex + * @param count + * @param {Object} args Argument object + */ + getMyContactsByIndex : function(startIndex, count, args) { + var requestArgs = { "startIndex" : startIndex, "count" : count }; + var options = { + method : "GET", + handleAs : "json", + query : lang.mixin(requestArgs , args || {format:"json"}) + }; + return this.getEntities(Consts.GetMyContacts, options, this.getProfileFeedCallbacks()); + }, - }); - - return ProfileTagsGrid; + /** + * Return callbacks for a profile entry + **/ + getProfileCallbacks : function() { + return ProfileCallbacks; + }, + + /** + * Return callbacks for a profile feed + **/ + getProfileFeedCallbacks : function() { + return ProfileFeedCallbacks; + }, + + _toIdObject : function(profileOrId) { + var idObject = {}; + if (lang.isString(profileOrId)) { + idObject.userid = profileOrId; + } else if (profileOrId instanceof Profile) { + idObject.userid = profileOrId.getUserid(); + } + return idObject; + }, + + _validateIdObject : function(idObject) { + if (!idObject.userid) { + return this.createBadRequestPromise("Invalid argument, userid must be specified."); + } + }, + _validateProfileId : function(profileId) { + if (!profileId || profileId.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected userid"); + } + } + }); + return ProfileService; }); + }, -'sbt/connections/controls/bootstrap/FileRendererMixin':function(){ -require({cache:{ -'url:sbt/connections/controls/bootstrap/templates/FileRow.html':"\r\n \r\n \r\n \r\n \r\n \r\n \"\"${_nls.download}\r\n \r\n \r\n \r\n

    \r\n ${title} \r\n

    \r\n
    \r\n
      \r\n
    • \r\n \r\n \t\t\t\t\t\t${authorName}\r\n \t\t\t\t\t\t${authorUid}\r\n\t\t\t\t\t\r\n ${_nls.created} ${createdLabel}\r\n
    • \r\n
    • \r\n ${hitCount} ${_nls.downloads}\r\n
    • \r\n
    • \r\n ${commentCount} ${_nls.comments}\r\n
    • \r\n
    \r\n
    \r\n \r\n \r\n \r\n\r\n\r\n\r\n"}}); +'url:sbt/connections/controls/search/templates/SearchBoxTemplate.html':"\r\n\t\r\n\t\t\r\n\t\t\t
    \r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t
    ${nls.refine}
    \r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t${nls.search}\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n
    ", +'sbt/connections/ProfileConstants':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012,2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -4334,24 +3771,222 @@ require({cache:{ * implied. See the License for the specific language governing * permissions and limitations under the License. */ - /** - * + * Social Business Toolkit SDK. Definition of constants for CommunityService. */ -define(["../../../lang", "../../../controls/grid/bootstrap/GridRendererMixin", - "../../../text!./templates/FileRow.html" ], - function(lang, GridRendererMixin, FileRow) { +define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - /** - * @module sbt.controls.grid.bootstrap.FileRendererMixin - */ - return lang.mixin(GridRendererMixin, { template : FileRow }); - + return lang.mixin({ + + /** + * Default size for the profile cache + */ + DefaultCacheSize : 10, + + /** + * Fields used to populate the Address object + */ + AddressFields : [ "streetAddress", "extendedAddress", "locality", "region", "postalCode", "countryName" ], + + /** + * XPath expressions used when parsing a Connections Profiles ATOM feed + */ + ProfileFeedXPath : conn.ConnectionsFeedXPath, + /** + * Namespace expressions used when parsing a Connections Profiles ATOM feed + */ + ProfileNamespaces : conn.Namespaces, + + /** + * Connection type colleague + */ + TypeColleague : "colleague", + + /** + * Status flag + */ + StatusPending : "pending", + + /** + * XPath expressions to be used when reading a Profile Entry + */ + ProfileXPath : lang.mixin({},conn.AtomEntryXPath,{ + uid : "a:contributor/snx:userid",// overwriting this for ProfileService + entry : "/a:feed/a:entry",// overwriting this for ProfileService + userid : "a:contributor/snx:userid", + name : "a:contributor/a:name", + email : "a:contributor/a:email", + altEmail : "a:content/h:div/h:span/h:div[@class='x-groupwareMail']", // TODO do we need this? it's a dupe of groupwareMail + photoUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/image']/@href", + fnUrl : "a:content/h:div/h:span/h:div/h:a[@class='fn url']/@href", + soundUrl : "a:content/h:div/h:span/h:div/h:a[@class='sound url']/@href", + jobTitle : "a:content/h:div/h:span/h:div[@class='title']", + organizationUnit : "a:content/h:div/h:span/h:div[@class='org']/h:span[@class='organization-unit']", + telephoneNumber : "a:content/h:div/h:span/h:div[@class='tel']/h:span[@class='value']", + building : "a:content/h:div/h:span/h:div/h:span[@class='x-building']", + floor : "a:content/h:div/h:span/h:div/h:span[@class='x-floor']", + officeNumber : "a:content/h:div/h:span/h:div/h:span[@class='x-office-number']", + streetAddress : "a:content/h:div/h:span/h:div/h:div[@class='street-address']", + extendedAddress : "a:content/h:div/h:span/h:div/h:div[@class='extended-address x-streetAddress2']", + locality : "a:content/h:div/h:span/h:div/h:span[@class='locality']", + postalCode : "a:content/h:div/h:span/h:div/h:span[@class='postal-code']", + region : "a:content/h:div/h:span/h:div/h:span[@class='region']", + countryName : "a:content/h:div/h:span/h:div/h:div[@class='country-name']", + groupwareMail : "a:content/h:div/h:span/h:div[@class='x-groupwareMail']", + blogUrl : "a:content/h:div/h:span/h:div/h:a[@class='x-blog-url url']/@href", + role : "a:content/h:div/h:span/h:div[@class='role']", + managerUid : "a:content/h:div/h:span/h:div[@class='x-manager-uid']", + isManager : "a:content/h:div/h:span/h:div[@class='x-is-manager']" + }), + + /** + * XPath expressions to be used when reading a ColleagueConnection Entry + */ + ColleagueConnectionXPath : lang.mixin({}, conn.AtomEntryXPath, { + entry : "/a:feed/a:entry" + }), + + /** + * XPath expressions to be used when reading a Community Entry with VCard content + */ + ProfileVCardXPath : lang.mixin({}, conn.AtomEntryXPath, { + // used by getEntityData + entry : "/a:feed/a:entry", + // used by getEntityId + uid : "a:contributor/snx:userid", + // used by parseVCard + vcard : "a:content", + userid : "a:contributor/snx:userid", + name : "a:contributor/a:name", + email : "a:contributor/a:email", + altEmail : "EMAIL;X_GROUPWARE_MAIL", // TODO do we need this? it's a dupe of groupwareMail + photoUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/image']/@href", + fnUrl : "URL", + soundUrl : "SOUND;VALUE=URL", + jobTitle : "TITLE", + organizationUnit : "a:content/h:div/h:span/h:div[@class='org']/h:span[@class='organization-unit']", + telephoneNumber : "TEL;WORK", + building : "X_BUILDING", + floor : "X_FLOOR", + officeNumber : "X_OFFICE_NUMBER", + workLocation : "ADR;WORK", + streetAddress : "a:content/h:div/h:span/h:div/h:div[@class='street-address']", + extendedAddress : "a:content/h:div/h:span/h:div/h:div[@class='extended-address x-streetAddress2']", + locality : "a:content/h:div/h:span/h:div/h:span[@class='locality']", + postalCode : "a:content/h:div/h:span/h:div/h:span[@class='postal-code']", + region : "a:content/h:div/h:span/h:div/h:span[@class='region']", + countryName : "a:content/h:div/h:span/h:div/h:div[@class='country-name']", + groupwareMail : "EMAIL;X_GROUPWARE_MAIL" + }), + + /** + * XPath expressions to be used when reading a Profile Tag feed + */ + ProfileTagsXPath : { + // used by getEntitiesDataArray + entries : "/app:categories/a:category", + // used to access data from the feed + targetEmail : "app:categories/snx:targetEmail", + numberOfContributors : "@snx:numberOfContributors", + // used by getEntityData + entry : "/app:categories/a:category", + // used by getEntityId + uid : "@term", + // used by getters + id : "@term", + term : "@term", + frequency : "@snx:frequency", + intensity : "@snx:intensityBin", + visibility : "@snx:visibilityBin", + contributorName : "a:name", + contributorUserid : "a:userid", + contributorEmail : "a:email" + }, + + /** + * XPath expressions to be used when reading an invite entry + */ + InviteXPath : lang.mixin({}, conn.AtomEntryXPath, { + connectionType: "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/connection/type']/@term", + status: "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/status']/@term" + }), + + /** + * XML elements to be used when creating a Profile Entry + * + **/ + profileCreateAttributes : { + guid : "com.ibm.snx_profiles.base.guid", + email : "com.ibm.snx_profiles.base.email", + uid : "com.ibm.snx_profiles.base.uid", + distinguishedName : "com.ibm.snx_profiles.base.distinguishedName", + displayName : "com.ibm.snx_profiles.base.displayName", + givenNames : "com.ibm.snx_profiles.base.givenNames", + surname : "com.ibm.snx_profiles.base.surname", + userState :"com.ibm.snx_profiles.base.userState" + }, + + /** + * Retrieve a profile entry. + */ + AtomProfileDo : "/${profiles}{authType}/atom/profile.do", + + /** + * Update a profile entry. + */ + AtomProfileEntryDo : "/${profiles}{authType}/atom/profileEntry.do", + + /** + * Retrieve a feed that lists the contacts that a person has designated as colleagues. + */ + AtomConnectionsDo : "/${profiles}{authType}/atom/connections.do", + + /** + * Retrieve the profiles of the people who comprise a specific user's report-to chain. + */ + AtomReportingChainDo : "/${profiles}{authType}/atom/reportingChain.do", + + /** + * Retrieve the people managed by a specified person. + */ + AtomPeopleManagedDo : "/${profiles}{authType}/atom/peopleManaged.do", + + /** + * Retrieve status updates for a specified person. + */ + AtomConnectionsInCommonDo : "/${profiles}{authType}/atom/connectionsInCommon.do", + + /** + * Search for a set of profiles that match a specific criteria and return them in a feed. + */ + AtomSearchDo : "/${profiles}{authType}/atom/search.do", + + /** + * Retrieve the profiles of the people who report to a specific user. + */ + AtomPeopleManagedDo : "/${profiles}{authType}/atom/peopleManaged.do", + + /** + * Retrieve the tags assigned to a profile from the Profiles tag collection. + */ + AtomTagsDo : "/${profiles}{authType}/atom/profileTags.do", + + /** + * Admin API - create a new profile. + */ + AdminAtomProfileDo : "/${profiles}/admin/atom/profiles.do", + + /** + * Admin API - delete a profile. + */ + AdminAtomProfileEntryDo : "/${profiles}/admin/atom/profileEntry.do" + + },conn); }); }, -'sbt/declare':function(){ +'sbt/connections/nls/ProfileService':function(){ /* - * © Copyright IBM Corp. 2012 + * © Copyright IBM Corp. 2012,2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -4367,18 +4002,17 @@ define(["../../../lang", "../../../controls/grid/bootstrap/GridRendererMixin", */ /** - * Social Business Toolkit SDK - declare() function. - * - * @module sbt.declare + * Social Business Toolkit SDK - Default resource bundle for ProfileService */ -define(['./_bridge/declare'],function(declare) { - return declare; +define({ + root: ({ + invalid_argument : "Invalid Argument" + }) }); - }, -'sbt/connections/controls/profiles/ProfileGrid':function(){ +'sbt/xpath':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -4394,337 +4028,281 @@ define(['./_bridge/declare'],function(declare) { */ /** - * @module sbt.connections.controls.profiles.ProfileGrid + * Social Business Toolkit SDK - XPath utilities. + * + * @module sbt.xpath */ -define([ "../../../declare", - "../../../config", - "../../../lang", - "../../../controls/grid/Grid", - "./ProfileGridRenderer", - "./ProfileAction", - "../../../connections/controls/vcard/SemanticTagService", - "../../../store/parameter", - "../../../connections/ProfileConstants", - "../../../connections/CommunityConstants"], - function(declare, sbt, lang, Grid, ProfileGridRenderer, ProfileAction, SemanticTagService, parameter, consts, communities) { - - var sortVals = { - displayName: "displayName", - recent: "3" - }; - - var communityMembersSortVals = { - displayName: "displayName", - created: "created" - }; - - var ParamSchema = { - pageNumber: parameter.oneBasedInteger("page"), - pageSize: parameter.oneBasedInteger("ps"), - sortBy: parameter.sortField("sortBy",sortVals), - sortOrder: parameter.sortOrder("sortOrder") - }; - - var CommunityMembersParamSchema = { - pageNumber: parameter.oneBasedInteger("page"), - pageSize: parameter.oneBasedInteger("ps"), - sortBy: parameter.sortField("sortBy", communityMembersSortVals), - sortOrder: parameter.sortOrder("sortOrder") - }; +define(['./declare'],function(declare) { + /* + * @class sbt.xpath.XPathExpr + */ + var XPathExpr = declare(null, { + ie: false, + constructor: function(xpath, nsArray){ + this.xpath = xpath; + this.nsArray = nsArray || {}; + if (!document.evaluate) { + this.ie = true; + this.nsString = ""; + if (this.nsArray) { + for(var ns in this.nsArray) { + this.nsString += ' xmlns:' + ns + '="' + this.nsArray[ns] + '"'; + } + } + } + }, - /** - * @class ProfileGrid - * @namespace sbt.connections.controls.profiles - * @module sbt.connections.controls.profiles.ProfileGrid - */ - var ProfileGrid = declare(Grid, { - - /** - * @param options, This is a list of all - * the different types of profile grids available. - * Depending on which one is selected specific arguments will be given to - * the atom store and grid renderer. - */ - options : { - "profile" : { - storeArgs : { - url : consts.AtomProfileDo, - attributes : consts.ProfileXPath, - feedXPath : consts.ProfileFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "profile" - } - }, - "colleagues" : { - storeArgs : { - url : consts.AtomConnectionsDo, - attributes : consts.ProfileXPath, - feedXPath : consts.ProfileFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "profile" - } - }, - "connectionsInCommon" : { - storeArgs : { - url : consts.AtomConnectionsInCommonDo, - attributes : consts.ProfileXPath, - feedXPath : consts.ProfileFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "profile" - } - }, - "peopleManaged" : { - storeArgs : { - url : consts.AtomPeopleManagedDo, - attributes : consts.ProfileXPath, - feedXPath : consts.ProfileFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "profile" - } - }, - "reportingChain" : { - storeArgs : { - url : consts.AtomReportingChainDo, - attributes : consts.ProfileXPath, - feedXPath : consts.ProfileFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "profile" - } - }, - "search" : { - storeArgs : { - url : consts.AtomSearchDo, - attributes : consts.ProfileXPath, - feedXPath : consts.ProfileFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "profile" - } - }, - "dynamic" : { - storeArgs : { - attributes : consts.ProfileXPath, - feedXPath : consts.ProfileFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "profile" - } - }, - "communityMembers" : { - storeArgs : { - url : communities.AtomCommunityMembers, - attributes : communities.MemberXPath, - feedXPath : communities.CommunityFeedXPath, - paramSchema: CommunityMembersParamSchema - }, - rendererArgs : { - type : "communityMembers" - } - } - }, - - /** - * A profile action, defines default behaviour for when - * items in the grid are clicked on or hovered on, - * it is possible to override these actions - */ - profileAction: new ProfileAction(), - - /** - * This is the default grid that will be created if no - * arguments are given. - */ - defaultOption: "colleagues", - - /**Constructor function - * @method constructor - * */ - constructor: function(args){ - if(args.type == "peopleManaged" || args.type == "reportingChain" || args.type == "profile") { - this.hideSorter = true; - } - - var nls = this.renderer.nls; + selectSingleNode : function(xmlDomCtx) { + var doc = xmlDomCtx.ownerDocument || xmlDomCtx; + if (this.ie) { + try { + doc.setProperty("SelectionLanguage", "XPath"); + doc.setProperty("SelectionNamespaces", this.nsString); + if (xmlDomCtx === doc) xmlDomCtx = doc.documentElement; + return xmlDomCtx.selectSingleNode(this.xpath); + } catch (ex) { + throw "XPath is not supported"; + } + } else { + var _this = this; + if (xmlDomCtx.documentElement) xmlDomCtx = xmlDomCtx.documentElement; - if (args.type == "communityMembers") { - - this._sortInfo = { - displayName: { - title: nls.displayName, - sortMethod: "sortByTitle", - sortParameter: "title" - }, - recent: { - title: nls.created, - sortMethod: "sortByCreated", - sortParameter: "created" - } - }; - this._activeSortAnchor = this._sortInfo.created; - this._activeSortIsDesc = true; + var result = doc.evaluate(this.xpath, xmlDomCtx, + function(prefix) { + return _this.nsArray[prefix]; + }, XPathResult.FIRST_ORDERED_NODE_TYPE, null); + return result.singleNodeValue; + } + }, + + selectNumber : function(xmlDomCtx){ + var doc = xmlDomCtx.ownerDocument || xmlDomCtx; + if (this.ie) { + return this.selectText(xmlDomCtx); } else { - this._sortInfo = { - displayName: { - title: nls.displayName, - sortMethod: "sortByDisplayName", - sortParameter: "displayName" - }, - recent: { - title: nls.recent, - sortMethod: "sortByRecent", - sortParameter: "recent" - } - - }; - this._activeSortAnchor = this._sortInfo.recent; - this._activeSortIsDesc = true; + var _this = this; + var result = doc.evaluate(this.xpath, xmlDomCtx, + function(prefix) { + return _this.nsArray[prefix]; + }, XPathResult.NUMBER_TYPE, null); + return result.numberValue; } - - }, - - contextRootMap: { - profiles: "profiles" }, - - /** - * Override buildUrl to add outputType, format and email/userid's - * - * @method buildUrl - * @param url base url - * @param args arguments that will be passed to the store - * @param endpoint An endpoint which may contain custom service mappings. - * @returns Built url - */ - buildUrl: function(url, args, endpoint) { - var params = { - outputType : "profile", - format : "full" - }; - - if (this.query) { - params = lang.mixin(params, this.query); - } - if (this.type == "colleagues") { - params = lang.mixin(params, { connectionType : "colleague" }); - } else if (this.type == "communityMembers") { - params = lang.mixin(params, { communityUuid : this.communityUuid }); - } - - if (this.email) { - params = lang.mixin(params, { email : this.email }); - } - if (this.email1 && this.email2) { - params = lang.mixin(params, { email : this.email1 + "," + this.email2 }); - } - if (this.userid) { - params = lang.mixin(params, { userid : this.userid }); - } - if (this.userid1 && this.userid2) { - params = lang.mixin(params, { userid : this.userid1 + "," + this.userid2 }); - } + + selectNodes : function(xmlDomCtx) { + var doc = xmlDomCtx.ownerDocument || xmlDomCtx; + if (this.ie) { + try { + doc.setProperty("SelectionLanguage", "XPath"); + doc.setProperty("SelectionNamespaces", this.nsString); + if (xmlDomCtx === doc) xmlDomCtx = doc.documentElement; + return xmlDomCtx.selectNodes(this.xpath); + } catch (ex) { + throw "XPath is not supported"; + } + } else { + var _this = this; + var result = doc.evaluate(this.xpath, xmlDomCtx, + function(prefix) { + return _this.nsArray[prefix]; + }, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + var r = []; + for(var i = 0; i < result.snapshotLength; i++) { + r.push(result.snapshotItem(i)); + } + return r; + } + }, + + selectText : function(node) { + var result = this.selectSingleNode(node); + return result ? (result.text || result.textContent) : null; + } + }); + + return { + /** + * Selects nodes from XML data object + * + * @method selectNodes + * @param {Object} + * node xml data to be parsed + * @param {String} + * xpath xpath expression + * @param {Array} + * nsArray Array of namespaces for the xml. + * @return {Array} Array of nodes + * @static + */ + selectNodes : function(node, xpath, nsArray) { + var expr = new XPathExpr(xpath, nsArray); + return expr.selectNodes(node); + }, - return this.constructUrl(url, params, this.getUrlParams(), endpoint); - }, + /** + * Selects single node from XML data object + * + * @method selectSingleNode + * @param {Object} + * node xml data to be parsed + * @param {String} + * xpath xpath expression + * @param {Array} + * nsArray Array of namespaces for the xml. + * @return {Object} selected node object + * @static + */ + selectSingleNode : function(node, xpath, nsArray) { + var expr = new XPathExpr(xpath, nsArray); + return expr.selectSingleNode(node); + }, + - /** - * The post create function is called, after the grid has been created. - * The function will call the super classes post create - * then load the semantic tag service. The semantic tag service - * is Javascript for creating business card functionality. - * @method postCreate + /** + * Selects text from a single node from XML data object + * + * @method selectText + * @param {Object} + * node xml data to be parsed + * @param {String} + * xpath xpath expression + * @param {Array} + * nsArray Array of namespaces for the xml. + * @return {String} inner text of the node object + * @static + */ + selectText : function(node, xpath, nsArray) { + var expr = new XPathExpr(xpath, nsArray); + return expr.selectText(node); + }, + + /** + * + * @param node + * @param xpath + * @param nsArray + * @returns + */ + selectNumber : function(node, xpath, nsArray){ + var expr = new XPathExpr(xpath, nsArray); + return expr.selectNumber(node); + } + }; +}); +}, +'url:sbt/connections/controls/communities/templates/BootstrapCommunityRow.html':"\r\n\t\r\n\t\t\r\n\t\t${title}\r\n\t\r\n", +'sbt/connections/controls/astream/_ActivityStream':function(){ +/* + * © 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. + */ +define(["../../../declare", "../../../lang", "../../../dom", "../../../connections/controls/_ConnectionsWidget", "../../../connections/controls/astream/_SbtAsConfigUtil"], function(declare, lang, dom, _ConnectionsWidget, _SbtAsConfigUtil){ + /** + * Wrapper for the connections ActivityStream Dijit. + * + * @class sbt.controls.astream._ActivityStream + */ + var _ActivityStream = declare([_ConnectionsWidget], + { + /* + * The ConfigUtil will be held here. + * + * @property configUtil + * @type Object + * @default null */ - postCreate: function() { - this.inherited(arguments); - if(this.displayBusinessCard){ - SemanticTagService.loadSemanticTagService(); - } - }, - - /** - * Creates a renderer for the grid.The renderer is responsible for - * loading the grid's HTML content. - * @method createDefaultRenderer - * @param args sets the template the renderer will use, by checking args.type, but for - * profile grids this will always be "profile" - * @returns an instance of a profile gird renderer. + _configUtil: null, + + /* + * The constructor. This will set up the connections ActivityStream dijit with a config object, and create the ShareBox and SideNav. + * Takes EITHER a feedUrl and an optional extensions object, OR an ActivityStream config object. + * If a feedUrl is specified any config object supplied will be ignored. + * + * @method constructor + * + * @param {Object} args + * @params {String} args.activityStreamNode The id of the html element to attach the ActivityStream to. + * @params {String} args.shareBoxNode The id of the html element to attach the share box to. + * @params {String} args.sideNavNode The id of the html element to attach the views side nav to. + * @params {String} args.feedUrl The url of the feed to populate the ActivityStream with. + * @params {Object} [args.extensions] A simple list of extensions to load. + * @params {Boolean} [args.extensions.commenting] If true load the commenting extension. + * @params {Boolean} [args.extensions.saving] If true load the saving extension. + * @params {Boolean} [args.extensions.refreshButton] If true load the refresh button extension. + * @params {Boolean} [args.extensions.DeleteButton] If true load the delete button extension. + * + * @params {Object} args.config An ActivityStream config object. Only specify this without a feedUrl argument. + * @param {String} activityStreamNode: The node to attach the ActivityStream to. This should have its div created in the defaultTemplate. */ - createDefaultRenderer : function(args) { - return new ProfileGridRenderer(args,this); + constructor: function(args){ + if(args.feedUrl && args.feedUrl.indexOf("anonymous") !== -1){ + this.xhrHandler.isPublic = true; + } + + this._mixinXhrHandler(); + + var _configUtil = new _SbtAsConfigUtil(this.xhrHandler); + + _configUtil.buildSbtConfig(args).then(function(cfg){ + window.activityStreamConfig = cfg; + new com.ibm.social.as.ActivityStream({ + configObject: cfg, + domNode: args.activityStreamNode || "activityStreamNode", + isGadget: false, + selectedState: true + }); + }); }, - /** - * In the grid HTML an element can have an event attached - * using dojo-attach-event="onClick: handleClick". - * This method is the handler for the onclick event. - * @method handleClick - * @param el the element that fired the event - * @param data all of the items from the current row of the grid. - * @param ev the event + /* + * Overwrite the ActivityStream's XhrHandler with our own. + * + * @method mixinXhrHandler */ - handleClick: function(el, data, ev) { - if (this.profileAction) { - console.log(data); - this._stopEvent(ev); - - this.profileAction.execute(data, this, ev); + _mixinXhrHandler: function(){ + if(com.ibm.social.as.util.xhr.XhrHandler.init !== undefined){ + com.ibm.social.as.util.xhr.XhrHandler.init(this.xhrHandler); + } + else{ + lang.mixin(com.ibm.social.as.util.AbstractHelper.prototype, this.xhrHandler); } }, /** - * @method getSortInfo - * @returns A list of strings that describe how the grid can be sorted - * for profile grids these strings are "Display Name" and "Recent" + * Function to update the ActivityStream with the latest data. + * + * @method update */ - getSortInfo: function() { - return { - active: { - anchor: this._activeSortAnchor, - isDesc: this._activeSortIsDesc - }, - list: [this._sortInfo.displayName, this._sortInfo.recent] - }; - - }, - - sortByDisplayName: function(el, data, ev){ - this._sort("displayName", true, el, data, ev); - }, - - sortByRecent: function(el, data, ev){ - this._sort("recent", true, el, data, ev); - }, - - sortByCreated: function(el, data, ev){ - this._sort("created", true, el, data, ev); - }, - - sortByTitle: function(el, data, ev){ - this._sort("title", true, el, data, ev); + update: function(){ + dojo.publish("com/ibm/social/as/event/updatestate", [true]); } - - // Internals }); - - return ProfileGrid; + return _ActivityStream; }); + }, -'url:sbt/smartcloud/controls/profiles/templates/ColleagueItem.html':"
    \r\n \r\n \"${name}\"\r\n \r\n
    \r\n", -'sbt/Gadget':function(){ +'url:sbt/connections/controls/activities/templates/BootstrapActivityRow.html':"\r\n\r\n\t\r\n\t\t

    ${title}

    \r\n\t\r\n", +'sbt/connections/controls/profiles/ProfileGridRenderer':function(){ +require({cache:{ +'url:sbt/connections/controls/profiles/templates/ProfileRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.telephone} ${telephone}
    \r\n\t\t\t
    ${nls.email}: ${email}
    \r\n\t\t\t
    ${nls.altEmail}: ${altEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n", +'url:sbt/connections/controls/profiles/templates/SharedConnectionsRow.html':"\r\n\t\r\n\t\t

    Connections Shared By Frank Adams & Amy Blanks

    \r\n\t\t

    \r\n\t\t\t${sharedColleagueName}\r\n\t\t

    \r\n\t\t\r\n\t\t

    ${sharedColleagueEmail}

    \r\n\t\r\n\r\n", +'url:sbt/connections/controls/profiles/templates/StatusUpdateRow.html':"\r\n\t\r\n\t\t\r\n\t\t
    \r\n\t\t
    \r\n\t\t \r\n\t\t ${name} ${statusUpdate}\r\n\t\t \r\n\t\t \r\n\t\t
    \r\n\t\t
    \r\n\t\t \t
      \r\n\t\t \t
    • \r\n\t\t\t\t\t\t\"\"\r\n\t\t\t\t\t \r\n\t\t\t\t\t \r\n\t\t\t\t\t\t ${statusLastUpdate}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
    • \r\n\t\t\t\t
    \r\n\t\t
    \r\n\t\t
    \r\n\t\t\r\n\t\r\n", +'url:sbt/connections/controls/profiles/templates/CommunityMemberRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${contributorName}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.role}: ${role}
    \r\n\t\t\t
    ${nls.email} ${contributorEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n", +'url:sbt/connections/controls/profiles/templates/BootstrapProfile.html':"\r\n\t\r\n\t\t\"${name}\"\r\n\t\r\n\t\r\n\t

    \r\n \t\t${name}\r\n \t

    \r\n\t\r\n\r\n"}}); /* - * © Copyright IBM Corp. 2012 + * © 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. @@ -4740,19 +4318,100 @@ define([ "../../../declare", */ /** - * Social Business Toolkit SDK - OpenSocial specific helpers. + * */ -define(function() { +define(["../../../declare", + "../ConnectionsGridRenderer", + "../../../i18n!./nls/ProfileGridRenderer", + "../../../text!./templates/ProfileRow.html", + "../../../text!./templates/SharedConnectionsRow.html", + "../../../text!./templates/StatusUpdateRow.html", + "../../../text!./templates/CommunityMemberRow.html", + "../../../text!./templates/BootstrapProfile.html"], + function(declare, ConnectionsGridRenderer, nls, profileTemplate, + sharedConnTemplate, statusUpdateTemplate, communityMemberTemplate,bootstrapProfile) { + + /** + * @class ProfileGridRenderer + * @namespace sbt.connections.controls.profiles + * @module sbt.connections.controls.profiles.ProfileGridRenderer + */ + var ProfileGridRenderer = declare(ConnectionsGridRenderer, { -//sbt.getUserPref = function(ns,name) { -// -//}; + /**The strings used in the grid, these are stored in a separate file, in the nls folder*/ + _nls: nls, + + /** + * The constructor function + * @method constructor + * @param args + */ + constructor: function(args,grid) { + if(grid.theme == "bootstrap"){ + this.template = bootstrapProfile; + }else{ + if (args.type == "profile") { + this.template = profileTemplate; + } else if(args.type == "statusUpdates"){ + this.template = statusUpdateTemplate; + } else if (args.type == "communityMembers") { + this.template = communityMemberTemplate; + } + } + + }, + /** + * Sets the css class for the row + * @method rowClass + * @param grid The Grid Dijit + * @param item the current row + * @param i the number of the current row, ie 0, 1, 2 etc + * @param items all of the rows in the grid + */ + rowClass: function(grid, item, i, items) { + item.rowClass = (i === 0 ? "lotusFirst" : (i % 2 === 1 ? "lotusAltRow" : null)); + }, + + /** + * Displays a tooltip by calling the getTooltip function in the ProfileAction class + * @method tooltip + * @param grid The Grid Dijit + * @param item the element to display the tooltip + * @param i the number of the current row + * @param items all of the items in the grid row + * @returns A Tooltip the default for profiles is to display the vCard + */ + tooltip: function(grid, item, i, items) { + if (grid.profileAction) { + return grid.profileAction.getTooltip(item); + } + }, + + /** + * Generates the profile photo URL for displaying the photos of community members + * @method photoUrl + * @param grid The Grid Dijit + * @param item the element containing the uid + * @param i the number of the current row + * @param items all of the items in the grid row + * @returns A profile photo URL for retrieving a user's profile picture + */ + photoUrl: function(grid, item, i, items) { + var store = grid.store; + var endpoint = store.getEndpoint(); + var photoUrl = endpoint.baseUrl + "/profiles/photo.do?email=" + item.getValue("email"); + + return photoUrl; + } + }); + + return ProfileGridRenderer; }); }, -'sbt/authenticator/OAuth':function(){ +'sbt/authenticator/templates/messageSSO':function(){ /* - * © Copyright IBM Corp. 2012 + * © 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. @@ -4767,78 +4426,52 @@ define(function() { * permissions and limitations under the License. */ -/** - * Social Business Toolkit SDK. - * Definition of the authentication mechanism for OAuth 1.0. - */ -define(['../declare','../lang', '../util'], function(declare, lang, util) { +function cancelOnClick() { + var argsMap = getArgsMap();// get map of query string arguments + var redirectURL = decodeURIComponent(argsMap.redirectURL); + var loginUi = decodeURIComponent(argsMap.loginUi); + if (loginUi == "popup") { + opener.location.reload(); + window.close(); + } else { + window.location.href = redirectURL; + } +} - /** - * OAuth 1.0 authentication. - * - * This class triggers the authentication for a service. - */ - return declare(null, { - - url: "", - loginUi: "", // mainWindow, dialog or popup - - constructor: function(args){ - lang.mixin(this, args || {}); - }, - - /** - * Method that authenticates the current user - */ - authenticate: function(options) { - var self = this; - require(["sbt/config"], function(config) { - var mode = options.loginUi || config.Properties["loginUi"] || this.loginUi; - var width = config.Properties["login.oauth.width"] || 800; - var height = config.Properties["login.oauth.height"] || 450; - if(mode=="popup") { - return self._authPopup(options, self.url, width, height); - } else if(mode=="dialog") { - return self._authDialog(options, self.url, width, height); - } else { - return self._authMainWindow(options, self.url); - } - }); - }, - - _authMainWindow: function(options, sbtUrl) { - var url = sbtUrl + "?oaredirect="+encodeURIComponent(window.location.href); - newwindow=window.location.href = url; - return true; - - }, - - _authPopup: function(options, sbtUrl, width, height) { - require(["sbt/config"], function(config){ - config.callback = options.callback; - var url = sbtUrl + "?loginUi=popup"; - - var windowQueryMap = { - height: height, - width: width - }; - var windowQuery = util.createQuery(windowQueryMap, ","); - newwindow = window.open(url,'Authentication',windowQuery); - return true; - }); - }, - - _authDialog: function(options, sbtUrl, width, height) { - require(["sbt/_bridge/ui/OAuthDialog"], function(dialog) { - dialog.show(sbtUrl, width, height); - }); - return true; - } - }); -}); +function onLoginPageLoad() { + var argsMap = getArgsMap();// get map of query string arguments + if(argsMap.loginUi == "popup"){ + var ssoStrings = window.globalSSOStrings; + document.getElementById('reloginMessage').appendChild(document.createTextNode(decodeURIComponent(ssoStrings.message))); + document.getElementById('ssoLoginFormOK').value = decodeURIComponent(ssoStrings.relogin_button_text); + }else{ + document.getElementById('reloginMessage').appendChild(document.createTextNode(decodeURIComponent(argsMap.message))); + document.getElementById('ssoLoginFormOK').value = decodeURIComponent(argsMap.relogin_button_text); + } + +} + +function getArgsMap() { + try { + var qString = location.search.substring(1);// getting query string args + var qStringParams = qString.split("&");// getting array of all query + // string arg key value pairs + var argsMap = {}; + var i; + for (i = 0; i < qStringParams.length; i++) { + var argArray = qStringParams[i].split("="); + argsMap[argArray[0]] = argArray[1]; + } + return argsMap; + } catch (err) { + console.log("Error making agrs map in messageSSO.js " + err); + } +} }, -'url:sbt/connections/controls/search/templates/SingleSearchPopUp.html':"
      \r\n \r\n
    ", -'sbt/connections/controls/bookmarks/BookmarkGrid':function(){ +'sbt/connections/controls/profiles/ProfileTagsGridRenderer':function(){ +require({cache:{ +'url:sbt/connections/controls/profiles/templates/TagListRow.html':"
  • \r\n\t${term}\r\n\t${frequency}\r\n
  • \r\n", +'url:sbt/connections/controls/profiles/templates/TagListHeader.html':"
    \r\n\t

    ${tagHeader}

    \r\n
    "}}); /* * © Copyright IBM Corp. 2013 * @@ -4854,316 +4487,121 @@ define(['../declare','../lang', '../util'], function(declare, lang, util) { * implied. See the License for the specific language governing * permissions and limitations under the License. */ -define(["../../../declare", - "../../../controls/grid/Grid", - "../../../store/parameter", - "../../../connections/BookmarkConstants", - "../../../connections/CommunityConstants", - "./BookmarkGridRenderer"], - function(declare,Grid,parameter,consts,communityConstants,BookmarkGridRenderer){ - - /** - * Sorting values - */ - var sortVals = { - date: "created", - popularity: "popularity" - }; - - /** - * Sorting and paging parameters - */ - var ParamSchema = { - pageNumber: parameter.oneBasedInteger("page"), - pageSize: parameter.oneBasedInteger("ps"), - sortBy: parameter.sortField("sortBy",sortVals), - sortOrder: parameter.sortOrder("sortOrder") - }; - - /** - * @class BookmarkGrid - * @namespace sbt.connections.controls.bookmarks - * @module sbt.connections.controls.bookmarks.BookmarkGrid - */ - var BookmarkGrid = declare(Grid,{ - - /** - * Specifies how the bookmark should open, new tab, same window etc. - * Should match values for the name parameter from the window.open function - * _blank is default, - * _parent - URL is loaded into the parent frame - * _self - URL replaces the current page - * _top - URL replaces any framesets that may be loaded - */ - targetName: "_blank", - - - options : { - "any" : { - storeArgs : { - url : consts.AtomBookmarksAll, - attributes : consts.BookmarkXPath, - feedXPath : consts.BookmarkFeedXPath, - paramSchema : ParamSchema - }, - rendererArgs : null - }, - "community": { - storeArgs : { - url : communityConstants.AtomCommunityBookmarks, - attributes : consts.BookmarkXPath, - feedXPath : consts.BookmarkFeedXPath, - paramSchema : ParamSchema - }, - rendererArgs : null - } - }, - - /** - * Default grid option. - */ - defaultOption: "any", - - /** - * The grid constructor function - * @method constructor - * @param args - */ - constructor: function(args){ - - var nls = this.renderer.nls; - this._sortInfo = { - date: { - title: nls.date, - sortMethod: "sortByDate", - sortParameter: "date" - }, - popularity: { - title: nls.popularity, - sortMethod: "sortByPopularity", - sortParameter: "popularity" - } - }, - this._activeSortAnchor = this._sortInfo.date; - this._activeSortIsDesc = true; - }, - - /** - * Used to add parameters to the URL - * @method buildUrl - * @param url the url to add parameters to - * @param args - * @param endpoint An endpoint which may contain custom service mappings. - * @returns the url with parameters - */ - buildUrl: function(url, args, endpoint) { - var urlParams; - - if(this.type == "private"){ - urlParams = { access: "private"}; - }else if(this.type == "public") { - urlParams = {access: "public"}; - }else if(this.type == "community"){ - urlParams = {communityUuid: this.communityUuid}; - }else{ - urlParams = {access: "any"}; - } - - return this.constructUrl(url, urlParams, {}, endpoint); - }, - - /** - * Creates a Renderer for this grid. - * @param args - * @returns {BookmarkGridRenderer} - */ - createDefaultRenderer: function(args){ - return new BookmarkGridRenderer(args,this); - }, - - /** - * Gets sorting information, such as - * if the results are ascending or descending, and the sort anchors - * @method getSortInfo - * @returns An object containing sorting information - */ - getSortInfo: function() { - return { - active: { - anchor: this._activeSortAnchor, - isDesc: this._activeSortIsDesc - }, - list: [this._sortInfo.date, this._sortInfo.popularity] - }; - }, - - /** - * Filter the bookmarks by specified tag - * @method filterByTag - * @param el The Grid Dom node - * @param data The Grid's data - * @param ev The Event - */ - filterByTag: function(el, data, ev){ - this._stopEvent(ev); - - var options = { - tag: el.text - }; - - this._filter(options,data); - }, - - /** - * Sorts the grid by date of creation. - * @method sortByDate - * @param el The Grid dom Element - * @param data the Grid's data - * @param ev the event - */ - sortByDate: function(el, data, ev){ - this._sort("date", true, el, data, ev); - }, - - /** - * Sort the Grid by popularity - * @method sortByPopularity - * @param el The grid element - * @param data the Grids data - * @param ev The event - */ - sortByPopularity: function(el, data, ev){ - this._sort("popularity", true, el, data, ev); - }, - - /** - * Event Handler for onClick events - * @method handleClick - * @param el the grid element - * @param data the grids data - * @param ev the event - */ - handleClick: function(el, data, ev){ - - this._stopEvent(ev); - this.bookmarkAction.execute(data,this); - }, - /** - * Default Action for handling click events and returning tooltip text. - */ - bookmarkAction: { - - /** - * Returns a string to be used in a tooltip or title. - * @method getTooltip - * @param item - * @returns A String to be used in a tooltip. - */ - getTooltip: function(item){ - return item.getValue("title"); - }, - - /** - * The code is executed from an onClick event - * @method execute - * @param data the Data associated with the grid - */ - execute: function(data,context){ - var url = data.getValue("url"); - window.open(url,context.targetName); - } - } - - }); - - - return BookmarkGrid; - -}); -}, -'sbt/_bridge/json':function(){ /** - * Dojo AMD JSON implementation. - */ -define(['dojo/json'],function(json) { - return json; -}); -}, -'sbt/compat':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. */ +define(["../../../declare", "../../../dom","../../../lang", + "../../../stringUtil", "../../../xpath", "../../../xml", + "../ConnectionsGridRenderer", + "../../../i18n!sbt/connections/controls/profiles/nls/ProfileTagsGridRenderer", + "../../../text!sbt/connections/controls/profiles/templates/TagListRow.html", + "../../../text!sbt/connections/controls/profiles/templates/TagListHeader.html"], + function(declare, dom, lang, stringUtil, xpath, xml, ConnectionsGridRenderer, nls, tagListTmpl, tagListHdrTmpl) { + + /** + * @class ProfileTagsGridRenderer + * @namespace sbt.connections.controls.profiles + * @module sbt.connections.controls.profiles.ProfileTagsGridRenderer + */ + var ProfileTagsGridRenderer = declare(ConnectionsGridRenderer, { -/** - * Social Business Toolkit SDK - Compatibility with older browsers - * - * @module sbt.compat - */ -define([],function() { - if (!Array.prototype.indexOf){ - Array.prototype.indexOf = function(item, start) { - var index = start || 0; - var max = this.length; - for (; index < max; index++) { - if (this[index] === item) { return index; } - } - return -1; - }; - } - return { - - }; -}); -}, -'sbt/connections/controls/bootstrap/ProfileRendererMixin':function(){ -require({cache:{ -'url:sbt/connections/controls/bootstrap/templates/ProfileRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.telephone} ${telephone}
    \r\n\t\t\t
    ${nls.email}: ${email}
    \r\n\t\t\t
    ${nls.altEmail}: ${altEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n"}}); -/* - * © 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. - */ + /** + * The strings used in the grid, these are stored in a separate file, in the nls folder + */ + _nls: nls, + + containerClass: "lotusChunk", + tagListClass: "lotusList lotusEditable lotusTags lotusMeta", + + _numberOfContributors: 0, + + /** + * The constructor function + * @method constructor + * @param args + */ + constructor: function(args, grid) { + if (args.type == "list") { + this.template = tagListTmpl; + this.listHeaderTemplate = tagListHdrTmpl; + } + }, + + render: function(grid, el, items, data) { + while (el.childNodes[0]) { + dom.destroy(el.childNodes[0]); + } + var size = items.length; + if (size === 0) { + this.renderEmpty(grid, el); + } + else { + this._computeRenderValues(grid, el, items, data); + + //this.renderTagHeader(grid, el, items, data); + //this.renderInputForm(grid, el, items, data); + this.renderTagListHeader(grid, el, items, data); + var container = this.renderContainer(grid, el, items, data); + for (var i=0; i\r\n\t
    \r\n\t\t \r\n\t\t\r\n\t\t\tx\r\n\t\t\r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t
    \r\n\t\t\t\t\t

    ${title}

    \r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\"${nls.Close}\"\r\n\t\t\t\t\t\tX\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t\t
    \r\n\t\t\t\t\t
    \r\n\t\t\t\t\t
    \r\n\t\t\t\t
    \r\n\t\t\t\t
    \r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n\r\n", +'sbt/connections/FileService':function(){ /* * © Copyright IBM Corp. 2013 * @@ -5281,8525 +4645,2957 @@ define([ "../declare", "../lang", "../config", "../stringUtil", "./ProfileConsta */ /** - * The Bookmarks API can be used to save, organize, and share Internet and intranet bookmarks. The Bookmarks API allows - * application programs to read and write to the collections of bookmarks stored in the Bookmarks application.. + * JavaScript API for IBM Connections File Service. * - * @module sbt.connections.BookmarkService + * @module sbt.connections.FileService */ -define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./BookmarkConstants", "./ConnectionsService", - "../base/AtomEntity", "../base/XmlDataHandler", "./Tag"], - function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler, Tag) { - - var BookmarkTmpl = "${getTitle}${isPrivate}${getContent}${getTags}"; - var CategoryPrivateFlag = "" - CategoryTmpl = ""; - var CategoryBookmark = ""; - - /** - * Bookmark class represents an entry for a Bookmarks feed returned by the - * Connections REST API. - * - * @class Bookmark - * @namespace sbt.connections - */ - var Bookmark = declare(AtomEntity, { - xpath : consts.BookmarkXPath, - namespaces : consts.BookmarkNamespaces, - categoryScheme : CategoryBookmark, - /** - * Construct a Bookmark entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, +define( + [ "../declare", "../lang", "../stringUtil", "../Promise", "./FileConstants", "./ConnectionsService", "../base/BaseEntity", "../base/XmlDataHandler", + "../config", "../util", "../xml" ], + function(declare, lang, stringUtil, Promise, consts, ConnectionsService, BaseEntity, XmlDataHandler, config, util, xml) { - /** - * Return the value of IBM Connections bookmark ID from bookmark ATOM - * entry document. - * - * @method getBookmarkUuid - * @return {String} ID of the bookmark - */ - getBookmarkUuid : function() { - return this.getAsString("BookmarkUuid"); - }, - - /** - * Sets id of IBM Connections bookmark. - * - * @method setBookmarkUuid - * @param {String} bookmarkUuid of the bookmark - */ - setBookmarkUuid : function(BookmarkUuid) { - return this.setAsString("BookmarkUuid", BookmarkUuid); - }, - - /** - * Return the value of private flag - * - * @method isPrivate - * @return {String} accessibility flag of the bookmark - */ - isPrivate : function() { - return this.getAsBoolean("privateFlag"); - }, - - /** - * Sets the value of private flag - * - * @method setPrivate - * @param {String} accessibility flag of the bookmark - */ - setPrivate : function(privateFlag) { - return this.setAsBoolean("privateFlag", privateFlag); - }, - - /** - * Return the value of IBM Connections bookmark URL from bookmark ATOM - * entry document. - * - * @method getUrl - * @return {String} Bookmark URL of the bookmark - */ - getUrl : function() { - return this.getAsString("link"); - }, - - /** - * Sets title of IBM Connections bookmark. - * - * @method setUrl - * @param {String} title Title of the bookmark - */ - setUrl : function(link) { - return this.setAsString("link", link); - }, - - /** - * Return the click count of the IBM Connections bookmark. - * - * @method getClickCount - * @return {String} click count of the bookmark - */ - getClickCount : function() { - return this.getAsString("clickcount"); - }, - - /** - * Return the category type of the IBM Connections bookmark. - * - * @method getCategoryType - * @return {String} content of the bookmark - */ - getCategoryType : function() { - return this.getAsString("categoryType"); - }, - - /** - * Return the edit link for IBM Connections bookmark. - * - * @method getEditLink - * @return {String} edit link of the bookmark - */ - getEditLink : function() { - return this.getAsString("linkEdit"); - }, - - /** - * Return the same link for IBM Connections bookmark. - * - * @method getSameLink - * @return {String} same link of the bookmark - */ - getSameLink : function() { - return this.getAsString("linkSame"); - }, + var FolderTmpl = "${getCategory}${getId}${getFolderLabel}${getTitle}${getSummary}${getVisibility}${getVisibilityShare}"; + var FolderLabelTmpl = ""; + var FileVisibilityShareTmpl = " "; + var FileFeedTmpl = "${getEntries}"; + var FileEntryTmpl = "${getCategory}${getId}${getUuid}${getLabel}${getTitle}${getSummary}${getVisibility}${getItem}${getTags}${getNotification}"; + var FileItemEntryTmpl = "${getCategory}${getItem}"; + var FileCommentsTmpl = "${getCategory}${getDeleteComment}${getContent}"; + var FileCategoryTmpl = ""; + var FileContentTmpl = "${content}"; + var FileDeleteCommentTmpl = "${deleteWithRecord}"; + var FileIdTmpl = "${id}"; + var FileUuidTmpl = "${uuid}"; + var FileLabelTmpl = ""; + var FileTitleTmpl = "${title}"; + var FileSummaryTmpl = "${summary}"; + var FileVisibilityTmpl = "${visibility}"; + var FileItemIdTmpl = "${fileId}"; + var TagsTmpl = " "; + var NotificationTmpl = "${notification}"; - /** - * Gets an author of IBM Connections Bookmark. - * - * @method getAuthor - * @return {Member} Author of the bookmark - */ - getAuthor : function() { - return this.getAsObject([ "authorId", "authorName", "authorEmail", "authorUri" ]); - }, + /** + * Library class associated with a library. + * + * @class Library + * @namespace sbt.connections + */ + var Library = declare(BaseEntity, { - /** - * Return tags of IBM Connections bookmark - * document. - * - * @method getTags - * @return {Object} Array of tags of the bookmark - */ - getTags : function() { - return this.getAsArray("tags"); - }, + /** + * Returned the Library Id + * + * @method getId + * @returns {String} Id + */ + getId : function() { + return this.getAsString("id"); + }, - /** - * Set new tags to be associated with this IBM Connections bookmark. - * - * @method setTags - * @param {Object} Array of tags to be added to the bookmark - */ + /** + * Returned the Library Uuid + * + * @method getLibrrayUuid + * @returns {String} Uuid + */ + getLibraryUuid : function() { + return this.getAsString("uuid"); + }, - setTags : function(tags) { - return this.setAsArray("tags", tags); - }, + /** + * Returned the library size + * + * @method getLibrarySize + * @returns {Number} library size + */ + getLibrarySize : function() { + return this.getAsNumber("librarySize"); + }, - /** - * Loads the bookmark object with the atom entry associated with the - * bookmark. By default, a network call is made to load the atom entry - * document in the bookmark object. - * - * @method load - * @param {Object} [args] Argument object - */ - load : function(args) { - // detect a bad request by validating required arguments - var bookmarkUrl = this.getUrl(); - var promise = this.service._validateBookmarkUrl(bookmarkUrl); - if (promise) { - return promise; - } + /** + * Returned the library quota + * + * @method getLibraryQuota + * @returns {Number} library quota + */ + getLibraryQuota : function() { + return this.getAsNumber("libraryQuota"); + }, - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - self.setDataHandler(new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BookmarkXPath - })); - return self; - } - }; - var requestArgs = lang.mixin({ - url : bookmarkUrl - }, args || {}); + /** + * Returned the total removed size + * + * @method getTotalRemovedSize + * @returns {Number} total removed size + */ + getTotalRemovedSize : function() { + return this.getAsNumber("totalRemovedSize"); + }, - var options = { - handleAs : "text", - query : requestArgs - }; - return this.service.getEntity(consts.AtomBookmarkCreateUpdateDelete, options, bookmarkUrl, callbacks); - }, + /** + * Returned the total results + * + * @method getTotalResults + * @returns {Number} total results + */ + getTotalResults : function() { + return this.getAsNumber("totalResults"); + } + }); + + /** + * Comment class associated with a file comment. + * + * @class Comment + * @namespace sbt.connections + */ + var Comment = declare(BaseEntity, { - /** - * Remove this bookmark - * - * @method remove - * @param {Object} [args] Argument object - */ - remove : function(args) { - return this.service.deleteBookmark(this.getUrl(), args); - }, + /** + * Returned the Comment Id + * + * @method getCommentId + * @returns {String} File Id + */ + getCommentId : function() { + return this.id || this.getAsString("uid"); + }, + /** + * Returns Comment Title + * + * @method getTitle + * @returns {String} title + */ + getTitle : function() { + return this.getAsString("title"); + }, + /** + * Returns the Comment Content + * + * @method getContent + * @returns {String} content + */ + getContent : function() { + return this.getAsString("content"); + }, + /** + * Returns The create Date + * + * @method getCreated + * @returns {Date} create Date + */ + getCreated : function() { + return this.getAsDate("created"); + }, + /** + * Returns The modified Date + * + * @method getModified + * @returns {Date} modified Date + */ + getModified : function() { + return this.getAsDate("modified"); + }, + /** + * Returns the version label + * + * @method getVersionLabel + * @returns {String} version label + */ + getVersionLabel : function() { + return this.getAsString("versionLabel"); + }, + /** + * Returns the updated Date + * + * @method getModified + * @returns {Date} modified Date + */ + getUpdated : function() { + return this.getAsDate("updated"); + }, + /** + * Returns the published Date + * + * @method getPublished + * @returns {Date} modified Date + */ + getPublished : function() { + return this.getAsDate("published"); + }, + /** + * Returns the modifier + * + * @method getModifier + * @returns {Object} modifier + */ + getModifier : function() { + return this.getAsObject([ "modifierName", "modifierUserId", "modifierEmail", "modifierUserState" ]); + }, + /** + * Returns the author + * + * @method getAuthor + * @returns {Object} author + */ + getAuthor : function() { + return this.getAsObject([ "authorName", "authorUserId", "authorEmail", "authorUserState" ]); + }, + /** + * Returns the language + * + * @method getLanguage + * @returns {String} language + */ + getLanguage : function() { + return this.getAsString("language"); + }, + /** + * Returns the flag for delete with record + * + * @method getDeleteWithRecord + * @returns {Boolean} delete with record + */ + getDeleteWithRecord : function() { + return this.getAsBoolean("deleteWithRecord"); + } + }); - /** - * Update this bookmark - * - * @method update - * @param {Object} [args] Argument object - */ - update : function(args) { - return this.service.updateBookmark(this, args); - }, - - /** - * Save this bookmark - * - * @method save - * @param {Object} [args] Argument object - */ - save : function(args) { - if (this.getBookmarkUuid()) { - return this.service.updateBookmark(this, args); - } else { - return this.service.createBookmark(this, args); - } - } + /** + * File class associated with a file. + * + * @class File + * @namespace sbt.connections + */ + var File = declare(BaseEntity, { - }); - - /* - * Callbacks used when reading a feed that contains bookmark entries. - */ - var ConnectionsBookmarkFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BookmarkFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new Bookmark({ - service : service, - data : data - }); - } - }; - - /* - * Callbacks used when reading a feed that contains bookmark entries. - */ - var ConnectionsTagsFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.TagsXPath - }); - }, - createEntity : function(service,data,response) { - var entryHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.TagsXPath - }); - return new Tag({ - service : service, - id : entryHandler.getEntityId(), - dataHandler : entryHandler - }); - } - }; - - /** - * BookmarkService class. - * - * @class BookmarkService - * @namespace sbt.connections - */ - var BookmarkService = declare(ConnectionsService, { - - contextRootMap: { - dogear : "dogear" - }, - - serviceName : "dogear", - - /** - * Constructor for BookmarkService - * - * @constructor - * @param args - */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } - }, - - /** - * Get the All Bookmarks feed to see a list of all bookmarks to which the - * authenticated user has access. - * - * @method getAllBookmarks - * - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of all bookmarks. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getAllBookmarks : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - return this.getEntities(consts.AtomBookmarksAll, options, this.getBookmarkFeedCallbacks()); - }, - - /** - * Get the popular Bookmarks feed. - * - * @method getPopularBookmarks - * - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of all bookmarks. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getPopularBookmarks : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomBookmarksPopular, options, this.getBookmarkFeedCallbacks()); - }, - - /** - * A feed of bookmarks that others notified me about. - * - * @method getBookmarksMyNotifications - * - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of all bookmarks. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getBookmarksMyNotifications : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomBookmarksMyNotifications, options, this.getBookmarkFeedCallbacks()); - }, - - /** - * A feed of bookmarks about which I notified others.. - * - * @method getBookmarksMySentNotifications - * - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of all bookmarks. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getBookmarksMySentNotifications : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomBookmarksINotifiedMySentNotifications, options, this.getBookmarkFeedCallbacks()); - }, - - /** - * Retrieve a bookmark instance. - * - * @method getBookmark - * @param {String } bookmarkUrl - * @param {Object} args Object containing the query arguments to be - * sent (defined in IBM Connections Bookmarks REST API) - */ - getBookmark : function(bookmarkUrl, args) { - var bookmark = new Bookmark({ - service : this, - _fields : { link : bookmarkUrl } - }); - return bookmark.load(args); - }, - - /** - * Create a bookmark by sending an Atom entry document containing the - * new bookmark. - * - * @method createBookmark - * @param {String} url Url to post to when creating the bookmark. - * @param {String/Object} bookmarkOrJson Bookmark object which denotes the bookmark to be created. - * @param {Object} [args] Argument object - */ - createBookmark : function(bookmarkOrJson, args) { - var bookmark = this._toBookmark(bookmarkOrJson); - var promise = this._validateBookmark(bookmark, false, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - if (data) { - var dataHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BookmarkXPath - }); - bookmark.setDataHandler(dataHandler); - bookmark.setData(data); - } else { - bookmark.setData(data); - var referenceId = this.getLocationParameter(response, "referenceId"); - bookmark.setBookmarkUuid(referenceId); - } - return bookmark; - }; - - var url = consts.AtomBookmarkCreateUpdateDelete; - - if (args && args.url) { - url = args.url; - delete args.url; - } - - var options = { - method : "POST", - query : args || {}, - headers : consts.AtomXmlHeaders, - data : this._constructBookmarkPostData(bookmark) - }; - - return this.updateEntity(url, options, callbacks, args); - }, - - /** - * Update a bookmark by sending a replacement bookmark entry document - * to the existing bookmark's edit web address. - * All existing bookmark entry information will be replaced with the new data. To avoid - * deleting all existing data, retrieve any data you want to retain first, and send it back - * with this request. For example, if you want to add a new tag to a bookmark entry, retrieve - * the existing tags, and send them all back with the new tag in the update request. - * - * @method updateBookmark - * @param {String/Object} bookmarkOrJson Bookmark object - * @param {Object} [args] Argument object - */ - updateBookmark : function(bookmarkOrJson,args) { - var bookmark = this._toBookmark(bookmarkOrJson); - var promise = this._validateBookmark(bookmark, true, args); - if (promise) { - return promise; - } - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - var bookmarkUuid = bookmark.getBookmarkUuid(); - if (data) { - var dataHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BookmarkXPath - }); - bookmark.setDataHandler(dataHandler); - } - bookmark.setBookmarkUuid(bookmarkUuid); - return bookmark; - }; - - var requestArgs = lang.mixin({ - url : bookmark.getUrl() - }, args || {}); - var options = { - method : "PUT", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : this._constructBookmarkPostData(bookmark) - }; - return this.updateEntity(consts.AtomBookmarkCreateUpdateDelete, options, callbacks, args); - }, - - /** - * Delete a bookmark, use the HTTP DELETE method. - * - * @method deleteBookmark - * @param {String} bookmarkUuid bookmark id of the bookmark or the bookmark object (of the bookmark to be deleted) - * @param {Object} [args] Argument object - */ - deleteBookmark : function(bookmarkUrl,args) { - var promise = this._validateBookmarkUrl(bookmarkUrl); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ - url : bookmarkUrl - }, args || {}); - - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - - return this.deleteEntity(consts.AtomBookmarkCreateUpdateDelete, options, bookmarkUrl); - }, - - /** - * Get the tags feed to see a list of the tags for all bookmarks. - * - * @method getBookmarksTags - * @param {Object} [args] Object representing various parameters. - * The parameters must be exactly as they are supported by IBM - * Connections. - */ - getBookmarksTags : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomBookmarksTags, options, this.getTagsFeedCallbacks(), args); - }, - - /** - * Create a Bookmark object with the specified data. - * - * @method newBookmark - * @param {Object} args Object containing the fields for the - * new bookmark - */ - newBookmark : function(args) { - return this._toBookmark(args); - }, - - /* - * Callbacks used when reading a feed that contains Bookmark entries. - */ - getBookmarkFeedCallbacks: function() { - return ConnectionsBookmarkFeedCallbacks; - }, - - /* - * Callbacks used when reading a feed that contains Bookmark entries. - */ - getTagsFeedCallbacks: function() { - return ConnectionsTagsFeedCallbacks; - }, - - /* - * Return a Bookmark instance from Bookmark or JSON or String. Throws - * an error if the argument was neither. - */ - _toBookmark : function(bookmarkOrJsonOrString) { - if (bookmarkOrJsonOrString instanceof Bookmark) { - return bookmarkOrJsonOrString; - } else { - if (lang.isString(bookmarkOrJsonOrString)) { - bookmarkOrJsonOrString = { - bookmarkUuid : bookmarkOrJsonOrString - }; - } - return new Bookmark({ - service : this, - _fields : lang.mixin({}, bookmarkOrJsonOrString) - }); - } - }, - - /* - * Validate a bookmark UUID, and return a Promise if invalid. - */ - _validateBookmarkUuid : function(bookmarkUuid) { - if (!bookmarkUuid || bookmarkUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected bookmarkUuid."); - } - }, - - /* - * Validate a bookmark UUID, and return a Promise if invalid. - */ - _validateBookmarkUrl : function(bookmarkUrl) { - if (!bookmarkUrl || bookmarkUrl.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected bookmarkUrl."); - } - }, - - /* - * Validate a bookmark, and return a Promise if invalid. - */ - _validateBookmark : function(bookmark,checkUuid) { - if (!bookmark || !bookmark.getTitle()) { - return this.createBadRequestPromise("Invalid argument, bookmark with title must be specified."); - } - if (checkUuid && !bookmark.getBookmarkUuid()) { - return this.createBadRequestPromise("Invalid argument, bookmark with UUID must be specified."); - } - }, - - /* - * Construct a post data for a Bookmark - */ - _constructBookmarkPostData : function(bookmark) { - var transformer = function(value,key) { - if (key == "getTags") { - var tags = value; - value = ""; - for (var tag in tags) { - value += stringUtil.transform(CategoryTmpl, { - "tag" : tags[tag] - }); - } - } else if (key == "getTitle" && !value) { - value = bookmark.getTitle(); - } else if (key == "getUrl" && !value) { - value = bookmark.getUrl(); - } else if (key == "getContent" && !value) { - value = bookmark.getContent(); - } else if (key == "isPrivate" && !value) { - if(bookmark.isPrivate()){ - value = CategoryPrivateFlag; - }else{ - value = ""; - } - } - return value; - }; - var postData = stringUtil.transform(BookmarkTmpl, bookmark, transformer, bookmark); - return stringUtil.trim(postData); - } - - }); - return BookmarkService; -}); - -}, -'sbt/connections/ProfileService':function(){ -/* - * © 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. - */ - -/** - * JavaScript API for IBM Connections Profile Service. - * - * @module sbt.connections.ProfileService - */ -define([ "../declare", "../lang", "../config", "../stringUtil", "./ProfileConstants", "./ConnectionsService", "../base/BaseEntity", "../base/AtomEntity", "../base/XmlDataHandler", "../base/VCardDataHandler", "../Cache", "../util" ], function( - declare,lang,config,stringUtil,consts,ConnectionsService,BaseEntity,AtomEntity,XmlDataHandler, VCardDataHandler, Cache, util) { - - var CategoryProfile = ""; - var updateProfileXmlTemplate = "\nBEGIN:VCARD\nVERSION:2.1\n${jobTitle}${address}${telephoneNumber}${building}${floor}END:VCARD\n"; - var updateProfileAttributeTemplate = "${attributeName}:${attributeValue}\n"; - var updateProfileAddressTemplate = "ADR;WORK:;;${streetAddress},${extendedAddress};${locality};${region};${postalCode};${countryName}\n"; - var ContentTmpl = "${content}"; - var createProfileTemplate = "${guid}${email}${uid}${distinguishedName}${displayName}${givenNames}${surname}${userState}"; - var createProfileAttributeTemplate = "${attributeName}text${attributeValue}"; - var createProfileTagsTemplate = "${createTags}" - var CategoryTmpl = ""; - - var CategoryConnection = ""; - var CategoryConnectionType = ""; - var CategoryStatus = ""; - - var OAuthString = "/oauth"; - var basicAuthString = ""; - var defaultAuthString = ""; - - /** - * Profile class. - * - * @class Profile - * @namespace sbt.connections - */ - - /* - * ProfileDataHandler class. - */ - - - - var Profile = declare(AtomEntity, { - - xpath : consts.ProfileXPath, - namespaces : consts.ProfileNamespaces, - categoryScheme : CategoryProfile, - _update : false, - - /** - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Data handler for profile object based on the query paramter - "output", used to get the profile. - * If the value of output paramter is "vcard", the VCardDataHandler is associated with - * the profile object else, by default, XmlDataHandler is associated with the object. - * - * @param {Object} service ProfileService instance associated with the profile object - * @param {Object} data Profile document associated with the profile object - * @response {Object} response Response object returned after the operation for get/create/update - * of the profile - * @namespaces {Object} namespace NameSpace object associated with the profile - * @xpath {Object} xpath XPath object associated with the profile - */ - - - createDataHandler : function(service, data, response, namespaces, xpath) { - if (response.options && response.options.query && response.options.query.output == "vcard") { - return new VCardDataHandler({ - service: service, - data : data, - namespaces : namespaces, - xpath : consts.ProfileVCardXPath - }); - } else { - return new XmlDataHandler({ - service: service, - data : data, - namespaces : namespaces, - xpath : xpath - }); - } - }, - - /** - * Get id of the profile - * - * @method getUserid - * @return {String} id of the profile - * - */ - getUserid : function() { - return this.getAsString("userid"); - }, - - /** - * Get name of the profile - * - * @method getName - * @return {String} name of the profile - * - */ - getName : function() { - return this.getAsString("name"); - }, - - /** - * Get email of the profile - * - * @method getEmail - * @return {String} email of the profile - */ - getEmail : function() { - return this.getAsString("email"); - }, - - /** - * Get groupware mail of the profile - * - * @method getGroupwareMail - * @return {String} groupware mail of the profile - */ - getGroupwareMail : function() { - return this.getAsString("groupwareMail"); - }, - - /** - * Get thumbnail URL of the profile - * - * @method getThumbnailUrl - * @return {String} thumbnail URL of the profile - */ - getThumbnailUrl : function() { - return this.getAsString("photoUrl"); - }, - - /** - * Get job title of the profile - * - * @method getJobTitle - * @return {String} job title of the profile - */ - getJobTitle : function() { - return this.getAsString("jobTitle"); - }, - - /** - * Get department of the profile - * - * @method getDepartment - * @return {String} department of the profile - */ - getDepartment : function() { - return this.getAsString("organizationUnit"); - }, - - /** - * Get address of the profile - * - * @method getAddress - * @return {Object} Address object of the profile - */ - getAddress : function() { - return this.getAsObject(consts.AddressFields); - }, - /** - * Get telephone number of the profile - * - * @method getTelephoneNumber - * @return {String} Phone number of the profile - */ - getTelephoneNumber : function() { - return this.getAsString("telephoneNumber"); - }, - - /** - * Get profile URL of the profile - * - * @method getProfileUrl - * @return {String} profile URL of the profile - */ - getProfileUrl : function() { - return this.getAsString("fnUrl"); - }, - /** - * Get building name of the profile - * - * @method getBuilding - * @return {String} building name of the profile - */ - getBuilding : function() { - return this.getAsString("building"); - }, - /** - * Get floor address of the profile - * - * @method getFloor - * @return {String} floor address of the profile - */ - getFloor : function() { - return this.getAsString("floor"); - }, - - /** - * Get Pronunciation URL of the profile - * - * @method getPronunciationUrl - * @return {String} Pronunciation URL of the profile - */ - getPronunciationUrl : function() { - return this.getAsString("soundUrl"); - }, - - /** - * Get summary of the profile - * - * @method getSummary - * @return {String} description of the profile - */ - getSummary : function() { - return this.getAsString("summary"); - }, - - /** - * Set work phone number of the profile in the field object - * - * @method setTelephoneNumber - * @param {String} telephoneNumber work phone number of the profile - */ - setTelephoneNumber : function(telephoneNumber) { - this.setAsString("telephoneNumber", telephoneNumber); - }, - - /** - * Set building of the profile in the field object - * - * @method setBuilding - * @param {String} building building name of the profile - */ - setBuilding : function(building) { - this.setAsString("building", building); - }, - - /** - * Set floor number of the profile in the field object - * - * @method setFloor - * @param {String} floor floor number of the profile - */ - setFloor : function(floor) { - this.setAsString("floor", floor); - }, - - /** - * Set job title of the profile in the field object - * - * @method setJobTitle - * @param {String} title job title of the profile - */ - setJobTitle : function(title) { - this.setAsString("jobTitle", title); - }, - - /** - * Set the location of the file input element in the markup for editing - * profile photo in the field object - * - * @method setPhotoLocation - * @param {String} imgLoc location of the file input element - */ - setPhotoLocation : function(imgLoc) { - this.setAsString("imageLocation", imgLoc); - }, - - /** - * Set the address of the profile in the field object - * - * @method setAddress - * @param {Object} address Address object of the profile. - */ - setAddress : function(address) { - this.setAsObject(address); - }, - - /** - * Loads the profile object with the profile entry document associated - * with the profile. By default, a network call is made to load the - * profile entry document in the profile object. - * - * @method load - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - * - */ - load : function(args) { - var profileId = this.getUserid() || this.getEmail(); - var promise = this.service._validateProfileId(profileId); - if (promise) { - return promise; - } - - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - self.setData(data, response); - return self; - } - }; - var requestArgs = {}; - if (this.service.isEmail(profileId)) { - requestArgs.email = profileId; - } else { - requestArgs.userid = profileId; - } - lang.mixin(requestArgs, args || {}); - var options = { - handleAs : "text", - query : requestArgs - }; - - var url = this.service.constructUrl(consts.AtomProfileDo, {}, {authType : this.service._getProfileAuthString()}); - return this.service.getEntity(url, options, profileId, callbacks, args); - }, - - /** - * Updates the profile of a user. - * - * @method update - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - update : function(args) { - return this.service.updateProfile(this, args); - }, - - /** - * Get colleagues of the profile. - * - * @method getColleagues - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getColleagues : function(args){ - return this.service.getColleagues(this, args); - }, - /** - * Get colleague connections of the profile. - * - * @method getColleagueConnections - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getColleagueConnections : function(args){ - return this.service.getColleagueConnections(this, args); - }, - - /** - * Return content element to be included in post data for the creation or updaton of new profile entry. - * - * @method createContent - * @returns {String} - */ - createContent : function() { - if(this._update){ - this._update = false; - var transformer = function(value,key) { - if (key == "address") { - value = this.service._isAddressSet(this) ? stringUtil.transform(updateProfileAddressTemplate, {"streetAddress" : this._fields["streetAddress"], - "extendedAddress" : this._fields["extendedAddress"], "locality" : this._fields["locality"], "region" : this._fields["region"], - "postalCode" : this._fields["postalCode"], "countryName" : this._fields["countryName"]}) : null; - } - else{ - value = (this._fields[key])? stringUtil.transform(updateProfileAttributeTemplate, {"attributeName" : consts.ProfileVCardXPath[key], "attributeValue" : this._fields[key]}) : null; - - } - return value; - }; - var content = stringUtil.transform(updateProfileXmlTemplate, this, transformer, this); - if (content) { - return stringUtil.transform(ContentTmpl, { "contentType" : "text", "content" : content }); - } - return ""; - }else{ - var transformer = function(value,key) { - if(this._fields[key]){ - value = stringUtil.transform(createProfileAttributeTemplate, {"attributeName" : consts.profileCreateAttributes[key], "attributeValue" : this._fields[key]}); - return value; - } - }; - var content = stringUtil.transform(createProfileTemplate, this, transformer, this); - if(content){ - return stringUtil.transform(ContentTmpl, { "contentType" : "application/xml", "content" : content }); - } - return ""; - } - - }, - - /** - * Return tags elements to be included in post data for creation and updation of profile entry. - * - * @method createTags - * @returns {String} - */ - createTags : function() { - return ""; - } - - }); - - /** - * ColleagueConnection class. - * - * @class ConnectionEntry - * @namespace sbt.connections - */ - var ColleagueConnection = declare(AtomEntity, { - - /** - * - * @constructor - * @param args - */ - constructor : function(args) { - } - }); - - /** - * ProfileTag class. - * - * @class ProfileTag - * @namespace sbt.connections - */ - var ProfileTag = declare(BaseEntity, { - - /** - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Get term of the profile tag - * - * @method getTerm - * @return {String} term of the profile tag - * - */ - getTerm : function() { - return this.getAsString("term"); - }, - - /** - * Get frequency of the profile tag - * - * @method getFrequency - * @return {Number} frequency of the profile tag - * - */ - getFrequency : function() { - return this.getAsNumber("frequency"); - }, - - /** - * Get intensity of the profile tag - * - * @method getIntensity - * @return {Number} intensity of the profile tag - * - */ - getIntensity : function() { - return this.getAsNumber("intensity"); - }, - - /** - * Get visibility of the profile tag - * - * @method getVisibility - * @return {Number} visibility of the profile tag - * - */ - getVisibility : function() { - return this.getAsNumber("visibility"); - } - - }); - - /** - * Invite class. - * - * @class Invite - * @namespace sbt.connections - */ - var Invite = declare(AtomEntity, { - - xpath : consts.InviteXPath, - contentType : "html", - categoryScheme : CategoryConnection, - - /** - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Return extra entry data to be included in post data for this entity. - * - * @returns {String} - */ - createEntryData : function() { - var entryData = ""; - entryData += stringUtil.transform(CategoryConnectionType, this, function(v,k) { return v; }, this); - entryData += stringUtil.transform(CategoryStatus, this, function(v,k) { return v; }, this); - return stringUtil.trim(entryData); - }, - - /** - * Return tags elements to be included in post data for creation and updation of invite entry. - * - * @method createTags - * @returns {String} - */ - createTags : function() { - return ""; - }, - - - /** - * Return the connection type associated with this invite. - * - * @method getConnectionType - * @return {String} status - */ - getConnectionType : function() { - var connectionType = this.getAsString("connectionType"); - return connectionType || consts.TypeColleague; - }, - - /** - * Set the connection type associated with this invite. - * - * @method setConnectionType - * @param {String} status - */ - setConnectionType : function(connectionType) { - return this.setAsString("connectionType", connectionType); - }, - - /** - * Return the status associated with this invite. - * - * @method getStatus - * @return {String} status - */ - getStatus : function() { - var status = this.getAsString("status"); - return status || consts.StatusPending; - }, - - /** - * Set the status associated with this invite. - * - * @method setStatus - * @param {String} status - */ - setStatus : function(status) { - return this.setAsString("status", status); - }, - - /** - * Return the connection id associated with this invite. - * - * @method getConnectionId - * @return {String} connectionId - */ - getConnectionId : function() { - return this.getAsString("connectionId"); - }, - - /** - * Set connection id associated with this invite. - * - * @method setConnectionId - * @param connectionId - * @return {Invite} - */ - setConnectionId : function(connectionId) { - return this.setAsString("connectionId", connectionId); - } - }); - - /** - * Callbacks used when reading an entry that contains a Profile. - */ - var ProfileCallbacks = { - createEntity : function(service,data,response) { - return new Profile({ - service : service, - data : data, - response: response - }); - } - }; - - /** - * Callbacks used when reading a feed that contains Profile entries. - */ - var ProfileFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.ProfileFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new Profile({ - service : service, - data: data, - response: response - }); - } - }; - - /** - * Callbacks used when reading a feed that contains ColleagueConnections - */ - var ColleagueConnectionFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.ProfileFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new ColleagueConnection({ - service : service, - data: data, - response: response - }); - } - }; - - /** - * Callbacks used when reading a feed that contains Profile Tag entries. - */ - var ProfileTagFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.ProfileTagsXPath - }); - }, - createEntity : function(service,data,response) { - var entryHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.ProfileTagsXPath - }); - return new ProfileTag({ - service : service, - id : entryHandler.getEntityId(), - dataHandler : entryHandler - }); - } - }; - - /** - * ProfileService class. - * - * @class ProfileService - * @namespace sbt.connections - */ - var ProfileService = declare(ConnectionsService, { - - contextRootMap: { - profiles: "profiles" - }, - - serviceName : "profiles", - - /** - * - * @constructor - * @param args - */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } - if(!this._cache){ - if(config.Properties.ProfileCacheSize || consts.DefaultCacheSize){ - this._cache = new Cache(config.Properties.ProfileCacheSize || consts.DefaultCacheSize); - } - } - }, - - /** - * Create a Profile object with the specified data. - * - * @method newProfile - * @param {Object} args Object containing the fields for the - * new Profile - */ - newProfile : function(args) { - return this._toProfile(args); - }, - - /** - * Create a Invite object with the specified data. - * - * @method newInvite - * @param {Object} args Object containing the fields for the - * new Invite - */ - newInvite : function(args) { - return this._toInvite(args); - }, - - /** - * Get the profile of a user. - * - * @method getProfile - * @param {String} userIdOrEmail Userid or email of the profile - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getProfile : function(userIdOrEmail, args) { - var profile = this._toProfile(userIdOrEmail); - var promise = this._validateProfile(profile); - if (promise) { - return promise; - } - return profile.load(args); - }, - - /** - * Update an existing profile - * - * @method updateProfile - * @param {Object} profileOrJson Profile object to be updated - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - updateProfile : function(profileOrJson,args) { - var profile = this._toProfile(profileOrJson); - profile._update = true; - var promise = this._validateProfile(profile); - if (promise) { - return promise; - } - - var requestArgs = {}; - profile.getUserid() ? requestArgs.userid = profile.getUserid() : requestArgs.email = profile.getEmail(); - lang.mixin(requestArgs, args || {}); - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - return profile; - }; - - var options = { - method : "PUT", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : profile.createPostData() - }; - var url = this.constructUrl(consts.AtomProfileEntryDo, {}, {authType : this._getProfileAuthString()}); - - return this.updateEntity(url, options, callbacks, args); - }, - - /** - * Get the tags for the specified profile - * - * @method getTags - * @param {String} id userId/email of the profile - * @param {Object} args Object representing various query parameters that can be passed. The parameters must - * be exactly as they are supported by IBM Connections. - */ - getTags : function(id, args) { - // detect a bad request by validating required arguments - var idObject = this._toTargetObject(id); - var promise = this._validateTargetObject(idObject); - if (promise) { - return promise; - } - - var options = { - method : "GET", - handleAs : "text", - query : lang.mixin(idObject, args || {}) - }; - var url = this.constructUrl(consts.AtomTagsDo, {}, {authType : this._getProfileAuthString()}); - - return this.getEntities(url, options, this.getProfileTagFeedCallbacks(), args); - }, - - /** - * Get the colleagues for the specified profile - * - * @method getColleagues - * @param {String} id userId/email of the profile - * @param {Object} args Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getColleagues : function(id, args) { - // detect a bad request by validating required arguments - var idObject = this._toIdObject(id); - var promise = this._validateIdObject(idObject); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin(idObject, { - connectionType : "colleague", - outputType : "profile" - }, args || {}); - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - var url = this.constructUrl(consts.AtomConnectionsDo, {}, {authType : this._getProfileAuthString()}); - return this.getEntities(url, options, this.getProfileFeedCallbacks(), args); - }, - - /** - * Get the colleagues for the specified profile as Collegue Connection entries - * - * @method getColleagueConnections - * @param {String} id userId/email of the profile - * @param {Object} args Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getColleagueConnections : function(id, args) { - // detect a bad request by validating required arguments - var idObject = this._toIdObject(id); - var promise = this._validateIdObject(idObject); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin(idObject, { - connectionType : "colleague", - outputType : "connection" - }, args || {}); - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - var url = this.constructUrl(consts.AtomConnectionsDo, {}, {authType : this._getProfileAuthString()}); - return this.getEntities(url, options, this.getColleagueConnectionFeedCallbacks(), args); - }, - - /** - * Get the reporting chain for the specified person. - * - * @method getReportingChain - * @param {String} id userId/email of the profile - * @param {Object} args Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getReportingChain : function(id, args) { - // detect a bad request by validating required arguments - var idObject = this._toIdObject(id); - var promise = this._validateIdObject(idObject); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin(idObject, args || {}); - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - var url = this.constructUrl(consts.AtomReportingChainDo, {}, {authType : this._getProfileAuthString()}); - return this.getEntities(url, options, this.getProfileFeedCallbacks(), args); - }, - - /** - * Get the people managed for the specified person. - * - * @method getPeopleManaged - * @param {String} id userId/email of the profile - * @param {Object} args Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getPeopleManaged : function(id, args) { - // detect a bad request by validating required arguments - var idObject = this._toIdObject(id); - var promise = this._validateIdObject(idObject); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin(idObject, args || {}); - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - var url = this.constructUrl(consts.AtomPeopleManagedDo, {}, {authType : this._getProfileAuthString()}); - return this.getEntities(url, options, this.getProfileFeedCallbacks(), args); - }, - - /** - * Search for a set of profiles that match a specific criteria and return them in a feed. - * - * @method search - * @param {Object} args Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - search : function(args) { - // detect a bad request by validating required arguments - if (!args) { - return this.createBadRequestPromise("Invalid arguments, one or more of the input parameters to narrow the search must be specified."); - } - - var options = { - method : "GET", - handleAs : "text", - query : args - }; - var url = this.constructUrl(consts.AtomSearchDo, {}, {authType : this._getProfileAuthString()}); - return this.getEntities(url, options, this.getProfileFeedCallbacks(), args); - }, - - /** - * Updates the profile photo of a user. - * @method updateProfilePhoto - * @param {Object} fileControlOrId The Id of html control or the html control - * @param @param {String} id userId/email of the profile - * @param {Object} [args] The additional parameters - */ - updateProfilePhoto: function (fileControlOrId, id, args) { - var promise = this.validateField("File Control Or Id", fileControlOrId); - if (promise) { - return promise; - } - promose = this.validateHTML5FileSupport(); - if(promise){ - return promise; - } - - var idObject = this._toIdObject(id); - var files = null; - if (typeof fileControlOrId == "string") { - var fileControl = document.getElementById(fileControlOrId); - filePath = fileControl.value; - files = fileControl.files; - } else if (typeof fileControlOrId == "object") { - filePath = fileControlOrId.value; - files = fileControlOrId.files; - } else { - return this.createBadRequestPromise("File Control or ID is required"); - } - - if(files.length != 1){ - return this.createBadRequestPromise("Only one file needs to be provided to this API"); - } - - var file = files[0]; - var formData = new FormData(); - formData.append("file", file); - var requestArgs = lang.mixin(idObject, args || {}); - var url = this.constructUrl(config.Properties.serviceUrl + "/files/" + this.endpoint.proxyPath + "/" + "connections" + "/" + "UpdateProfilePhoto" + "/" + encodeURIComponent(file.name), - args && args.parameters ? args.parameters : {}); - var headers = { - "Content-Type" : false, - "Process-Data" : false // processData = false is reaquired by jquery - }; - var options = { - method : "PUT", - headers : headers, - query : requestArgs || {}, - data : formData - }; - var callbacks = { - createEntity : function(service, data, response) { - return data; // Since this API does not return any response in case of success, returning empty data - } - }; - - return this.updateEntity(url, options, callbacks); - }, - - /** - * Invite a person to become your colleague. - * - * @method inviteColleague - * @param id - * @param inviteOrJson - * @param args - */ - createInvite : function(id, inviteOrJson, args) { - // detect a bad request by validating required arguments - var idObject = this._toIdObject(id); - var promise = this._validateIdObject(idObject); - if (promise) { - return promise; - } - - var invite = this._toInvite(inviteOrJson); - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - invite.setData(data); - var connectionId = this.getLocationParameter(response, "connectionId"); - invite.setConnectionId(connectionId); - return invite; - }; - - var requestArgs = lang.mixin(idObject, args || {}); - var options = { - method : "POST", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : invite.createPostData() - }; - - var url = this.constructUrl(consts.AtomConnectionsDo, {}, {authType : this._getProfileAuthString()}); - return this.updateEntity(url, options, callbacks, args); - }, - - /** - * Update profile tags. When you update profile tags, the existing tag information added by you is replaced with the new tag information. - * To avoid this, retrieve the tags that you want to retain first, and send them back with this request. - * - * @method updateTags - * @param {Array} tags - * @param {String} targetEmailOrUserId email address or userid of the person whose profile you want to apply the tags to - * @param {String} sourceEmailOrUserId email address or useridof the creator of the tags - * @param args - */ - updateTags : function(tags, targetEmailOrUserId, sourceEmailOrUserId, args) { - // detect a bad request by validating required arguments - var promise = this._validateProfileId(targetEmailOrUserId); - if (promise) { - return promise; - } - - promise = this._validateProfileId(sourceEmailOrUserId); - if (promise) { - return promise; - } - - var requestArgs = {}; - if (this.isEmail(targetEmailOrUserId)) { - requestArgs.targetEmail = targetEmailOrUserId; - } else { - requestArgs.targetKey = targetEmailOrUserId; - } - if (this.isEmail(sourceEmailOrUserId)) { - requestArgs.sourceEmail = sourceEmailOrUserId; - } else { - requestArgs.sourceKey = sourceEmailOrUserId; - } - lang.mixin(requestArgs, args || {}); - - var callbacks = { - createEntity : function(service, data, response) { - return data; // Since this API does not return any response in case of success, returning empty data - } - }; - - var options = { - method : "PUT", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : this._createTagsPostData(tags) - }; - - - var url = this.constructUrl(consts.AtomTagsDo, {}, {authType : this._getProfileAuthString()}); - - return this.updateEntity(url, options, callbacks, args); - }, - - // - // Internals - // - - /* - * Return callbacks for a profile feed - */ - getProfileFeedCallbacks : function() { - return ProfileFeedCallbacks; - }, - - /* - * Return callbacks for a ColleagueConnection feed - */ - getColleagueConnectionFeedCallbacks : function() { - return ColleagueConnectionFeedCallbacks; - }, - - /* - * Return callbacks for a profile entry - */ - getProfileCallbacks : function() { - return ProfileCallbacks; - }, - - /* - * Return callbacks for a profile tag feed - */ - getProfileTagFeedCallbacks : function() { - return ProfileTagFeedCallbacks; - }, - - /* - * Convert profile or key to id object - */ - _toIdObject : function(profileOrId) { - var idObject = {}; - if (lang.isString(profileOrId)) { - var userIdOrEmail = profileOrId; - if (this.isEmail(userIdOrEmail)) { - idObject.email = userIdOrEmail; - } else { - idObject.userid = userIdOrEmail; - } - } else if (profileOrId instanceof Profile) { - if (profileOrId.getUserid()) { - idObject.userid = profileOrId.getUserid(); - } - else if (profileOrId.getEmail()) { - idObject.email = profileOrId.getEmail(); - } - } - return idObject; - }, - - /* - * Convert profile or key to target object - */ - _toTargetObject : function(profileOrId) { - var targetObject = {}; - if (lang.isString(profileOrId)) { - var userIdOrEmail = profileOrId; - if (this.isEmail(userIdOrEmail)) { - targetObject.targetEmail = userIdOrEmail; - } else { - targetObject.targetKey = userIdOrEmail; - } - } else if (profileOrId instanceof Profile) { - if (profileOrId.getUserid()) { - targetObject.targetKey = profileOrId.getUserid(); - } - else if (profileOrId.getEmail()) { - targetObject.targetEmail = profileOrId.getEmail(); - } - } - return targetObject; - }, - - /* - * Validate an ID object - */ - _validateIdObject : function(idObject) { - if (!idObject.userid && !idObject.email) { - return this.createBadRequestPromise("Invalid argument, userid or email must be specified."); - } - }, - - /* - * Validate an Target object - */ - _validateTargetObject : function(idObject) { - if (!idObject.targetKey && !idObject.targetEmail) { - return this.createBadRequestPromise("Invalid argument, userid or email must be specified."); - } - }, - - /* - * Return a Profile instance from Profile or JSON or String. Throws - * an error if the argument was neither. - */ - _toProfile : function(profileOrJsonOrString,args) { - if (profileOrJsonOrString instanceof Profile) { - return profileOrJsonOrString; - } else { - var profileJson = profileOrJsonOrString; - if (lang.isString(profileOrJsonOrString)) { - profileJson = {}; - if(this.isEmail(profileOrJsonOrString)){ - profileJson.email = profileOrJsonOrString; - }else{ - profileJson.userid = profileOrJsonOrString; - } - }else{ // handle the case when the profileJson has id attribute. id can take either userid or email. - if(profileJson && profileJson.id && !profileJson.userid && !profileJson.email){ - this.isEmail(profileJson.id) ? profileJson.email = profileJson.id : profileJson.userid = profileJson.id; - delete profileJson.id; - } - } - return new Profile({ - service : this, - _fields : lang.mixin({}, profileJson) - }); - } - }, - - /* - * Return a Invite instance from Invite or JSON or String. Throws - * an error if the argument was neither. - */ - _toInvite : function(inviteOrJsonOrString,args) { - if (inviteOrJsonOrString instanceof Invite) { - return inviteOrJsonOrString; - } else { - if (lang.isString(inviteOrJsonOrString)) { - inviteOrJsonOrString = { - content : inviteOrJsonOrString - }; - } - return new Invite({ - service : this, - _fields : lang.mixin({}, inviteOrJsonOrString) - }); - } - }, - - /* - * Returns true if an address field has been set. - */ - _isAddressSet : function(profile){ - return (profile._fields["streetAddress"] || profile._fields["extendedAddress"] || profile._fields["locality"] || profile._fields["region"] || profile._fields["postalCode"] || profile._fields["countryName"]); - }, - - /* - * Validate a Profile object - */ - _validateProfile : function(profile) { - if (!profile || (!profile.getUserid() && !profile.getEmail())) { - return this.createBadRequestPromise("Invalid argument, profile with valid userid or email must be specified."); - } - }, - - /* - * Validate a Profile id - */ - _validateProfileId : function(profileId) { - if (!profileId || profileId.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected userid or email"); - } - }, - - _getProfileAuthString : function(){ - if (this.endpoint.authType == consts.AuthTypes.Basic) { - return basicAuthString; - } else if (this.endpoint.authType == consts.AuthTypes.OAuth) { - return OAuthString; - } else { - return defaultAuthString; - } - }, - - _createTagsPostData : function(tags) { - var value = ""; - for (var i=0; i< tags.length;i++) { - value += stringUtil.transform(CategoryTmpl, { "tag" : tags[i] }); - } - var postData = stringUtil.transform(createProfileTagsTemplate, {"createTags" : value}); - return stringUtil.trim(postData); - } - - }); - return ProfileService; -}); - -}, -'url:sbt/connections/controls/search/templates/DefaultSummary.html':"
    \r\n \r\n ${summaryIcon}\r\n \r\n \r\n ${communityParent}\r\n ${parentageMeta}\r\n \r\n ${summaryTypeLabel}  \r\n \r\n ${resultSummary}  \r\n
    \r\n\r\n${resultComment}", -'sbt/lang':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ - -/** - * Social Business Toolkit SDK - Some language utilities. - */ -define(['./_bridge/lang'],function(lang) { - // The actual implementation is library dependent - return lang; -}); - -}, -'url:sbt/connections/controls/forums/templates/BootstrapForumRow.html':"\r\n\t\r\n \r\n \r\n \r\n ${title}\r\n \r\n \r\n \r\n\r\n\r\n", -'url:sbt/connections/controls/search/templates/tr.html':"${content}", -'sbt/connections/ActivityStreamConstants':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ -/** - * Social Business Toolkit SDK. Definition of constants for ActivityStreamService. - */ -define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - - return lang.mixin({}, conn, { - - ASUser: { - ME : "@me", - PUBLIC : "@public", - COMMUNITY : "urn:lsid:lconn.ibm.com:communities.community:",//Suffix Community with it id wherever this constant is used. - UBLOG : "ublog" - }, - ASGroup: { - ALL : "@all", - FOLLOWING : "@following", - FRIENDS : "@friends", - SELF : "@self", - INVOLVED : "@involved", - NOTESFORME : "@notesforme", - NOTESFROMME : "@notesfromme", - RESPONSES : "@responses", - ACTIONS : "@actions", - SAVED : "@saved" - }, - ASApplication: { - ALL : "@all", - COMMUNITIES : "@communities", - TAGS : "@tags", - PEOPLE : "@people", - STATUS : "@status", - NOTESFORME : "@notesforme", - NOTESFROMME : "@notesfromme", - RESPONSES : "@responses", - COMMENTS : "comments" - }, - Verb: { - ACCEPT : "accept", - ACCESS : "access", - ACKNOWLEDGE : "acknowledge", - ADD : "add", - AGREE : "agree", - APPEND : "append", - APPROVE : "approve", - ARCHIVE : "archive", - ASSIGN : "assign", - AT : "at", - ATTACH : "attach", - ATTEND : "attend", - AUTHOR : "author", - AUTHORIZE : "authorize", - - BORROW : "borrow", - BUILD : "build", - - CANCEL : "cancel", - CLOSE : "close", - COMMENT : "comment", - COMPLETE : "complete", - CONFIRM : "confirm", - CONSUME : "consume", - CHECKIN : "checkin", - CREATE : "create", - - DELETE : "delete", - DELIVER : "deliver", - DENY : "deny", - DISAGREE : "disagree", - DISLIKE : "dislike", - - EXPERIENCE : "experience", - - FAVORITE : "favorite", - FIND : "find", - FLAG_AS_INAPPROPRIATE : "flag-as-inappropriate", - FOLLOW : "follow", - - GIVE : "give", - - HOST : "host", - - IGNORE : "ignore", - INSERT : "insert", - INSTALL : "install", - INTERACT : "interact", - INVITE : "invite", - - JOIN : "join", - - LEAVE : "leave", - LIKE : "like", - LISTEN : "listen", - LOSE : "lose", - - MAKE_FRIEND : "make-friend", - - OPEN : "open", - - POST : "post", - PLAY : "play", - PRESENT : "present", - PURCHASE : "purchase", - - QUALIFY : "qualify", - - READ : "read", - RECEIVE : "receive", - REJECT : "reject", - REMOVE : "remove", - REMOVE_FRIEND : "remove-friend", - REPLACE : "replace", - REQUEST : "request", - REQUEST_FRIEND : "request-friend", - RESOLVE : "resolve", - RETURN : "return", - RETRACT : "retract", - RSVP_MAYBE : "rsvp-maybe", - RSVP_NO : "rsvp-no", - RSVP_YES : "rsvp-yes", - - SATISFY : "satisfy", - SAVE : "save", - SCHEDULE : "schedule", - SEARCH : "search", - SELL : "sell", - SEND : "send", - SHARE : "share", - SPONSOR : "sponsor", - START : "start", - STOP_FOLLOWING : "stop-following", - SUBMIT : "submit", - - TAG : "tag", - TERMINATE : "terminate", - TIE : "tie", - - UNFAVORITE : "unfavorite", - UNLIKE : "unlike", - UNSAVE : "unsave", - UNSATISFY : "unsatisfy", - UNSHARE : "unshare", - UPDATE : "update", - USE : "use", - - WATCH : "watch", - WIN : "win" - }, - ActivityStreamUrls: { - activityStreamBaseUrl : "/${connections}/opensocial/", - activityStreamRestUrl : "/rest/activitystreams/", - activityStreamUBlogRestUrl : "/rest/ublog/" - }, - errorMessages:{ - args_object : "argument passed to get stream should be an Object", - required_communityid : "Community ID is required" - } - }); -}); -}, -'sbt/base/BaseEntity':function(){ -/* - * © Copyright IBM Corp. 2012, 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. - */ - -/** - * Javascript Base APIs for IBM Connections - * - * @module sbt.base.BaseEntity - */ -define([ "../declare", "../lang", "../log", "../stringUtil" ], - function(declare,lang,log,stringUtil) { - - var BadRequest = 400; - - var requests = {}; - - /** - * BaseEntity class - * - * @class BaseEntity - * @namespace sbt.base - */ - var BaseEntity = declare(null, { - - /** - * The identifier for this entity. - */ - id : null, - - /** - * The service associated with the entity. - */ - service : null, - - /** - * The DataHandler associated with this entity. - */ - dataHandler : null, - - /** - * The fields which have been updated in this entity. - * - * @private - */ - _fields : null, - - /** - * Constructor for BaseEntity - * - * @constructor - * @param {Object} args Arguments for this entity. - */ - constructor : function(args) { - lang.mixin(this, args); - - if (!this._fields) { - this._fields = {}; - } - - if (!this.service) { - var msg = "Invalid BaseEntity, an associated service must be specified."; - throw new Error(msg); - } - }, - - /** - * Called to set the entity DataHandler after the entity - * was loaded. This will cause the existing fields to be cleared. - * - * @param datahandler - */ - setDataHandler : function(dataHandler) { - this._fields = {}; - this.dataHandler = dataHandler; - }, - - /** - * Called to set the entity data after the entity - * was loaded. This will cause the existing fields to be cleared. - * - * @param data - */ - setData : function(data, response) { - this._fields = {}; - this.dataHandler.setData(data); - }, - - /** - * Return true if this entity has been loaded. - * - * @returns true if this entity has been loaded - */ - isLoaded : function() { - if (this.dataHandler) { - return this.dataHandler.getData() ? true : false; - } - return false; - }, - - /** - * Get the string value of the specified field. - * - * @method getAsString - * @param fieldName - * @returns - */ - getAsString : function(fieldName) { - this._validateFieldName(fieldName, "getAsString"); - - if (this._fields.hasOwnProperty(fieldName)) { - return this._fields[fieldName]; - } else if (this.dataHandler) { - return this.dataHandler.getAsString(fieldName); - } else { - return null; - } - }, - - /** - * Get the number value of the specified field. - * - * @method getAsNumber - * @param fieldName - * @returns - */ - getAsNumber : function(fieldName) { - this._validateFieldName(fieldName, "getAsNumber"); - - if (this._fields.hasOwnProperty(fieldName)) { - return this._fields[fieldName]; - } else if (this.dataHandler) { - return this.dataHandler.getAsNumber(fieldName); - } else { - return null; - } - }, - - /** - * Get the date value of the specified field. - * - * @method getAsDate - * @param fieldName - * @returns - */ - getAsDate : function(fieldName) { - this._validateFieldName(fieldName, "getAsDate"); - - if (this._fields.hasOwnProperty(fieldName)) { - return this._fields[fieldName]; - } else if (this.dataHandler) { - return this.dataHandler.getAsDate(fieldName); - } else { - return null; - } - }, - - /** - * Get the boolean value of the specified field. - * - * @method getAsBoolean - * @param fieldName - * @returns - */ - getAsBoolean : function(fieldName) { - this._validateFieldName(fieldName, "getAsBoolean"); - - if (this._fields.hasOwnProperty(fieldName)) { - return this._fields[fieldName]; - } else if (this.dataHandler) { - return this.dataHandler.getAsBoolean(fieldName); - } else { - return false; - } - }, - - /** - * Get the array value of the specified field. - * - * @method getAsArray - * @param fieldName - * @returns - */ - getAsArray : function(fieldName) { - this._validateFieldName(fieldName, "getAsArray"); - - if (this._fields.hasOwnProperty(fieldName)) { - return this._fields[fieldName]; - } else if (this.dataHandler) { - return this.dataHandler.getAsArray(fieldName); - } else { - return null; - } - }, - - /** - * Get the nodes array value of the specified field. - * - * @method getAsNodesArray - * @param fieldName - * @returns - */ - getAsNodesArray : function(fieldName) { - this._validateFieldName(fieldName, "getAsNodesArray"); - - if (this._fields.hasOwnProperty(fieldName)) { - return this._fields[fieldName]; - } else if (this.dataHandler) { - return this.dataHandler.getAsNodesArray(fieldName); - } else { - return null; - } - }, - /** - * Get an object containing the values of the specified fields. - * - * @method getAsObject - * @param fieldNames - * @returns - */ - getAsObject : function(fieldNames, objectNames) { - var obj = {}; - for (var i=0; i 0) { - this._fields[fieldName] = arrayOrString.split(/[ ,]+/); - } else { - this._fields[fieldName] = []; - } - } else { - if (arrayOrString) { - this._fields[fieldName] = [ arrayOrString ]; - } else { - delete this._fields[fieldName]; - } - } - - return this; - }, - - /** - * Set an object containing the values of the specified fields. - * - * @method setAsObject - * @param theObject - * @returns - */ - setAsObject : function(theObject) { - for (var property in theObject) { - if (theObject.hasOwnProperty(property)) { - var value = theObject[property]; - if (value) { - this._fields[property] = value; - } else { - delete this._fields[property]; - } - } - } - }, - - /** - * Remove the value of the specified field. - * - * @method remove - * @param fieldName - */ - remove : function(fieldName) { - delete this._fields[fieldName]; - }, - - /** - * Return the json representation of the entity - * - * @method toJson - * @returns {Object} - */ - toJson : function() { - return (this.dataHandler) ? this.dataHandler.toJson() : {}; - }, - - /* - * Validate there is a valid field name - */ - _validateFieldName : function(fieldName, method, value) { - if (!fieldName) { - var msg = stringUtil.substitute("Invalid argument for BaseService.{1} {0},{2}", [ fieldName, method, value || "" ]); - throw new Error(msg); - } - } - }); - - return BaseEntity; -}); - -}, -'sbt/xpath':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ - -/** - * Social Business Toolkit SDK - XPath utilities. - * - * @module sbt.xpath - */ -define(['./declare'],function(declare) { - /* - * @class sbt.xpath.XPathExpr - */ - var XPathExpr = declare(null, { - ie: false, - constructor: function(xpath, nsArray){ - this.xpath = xpath; - this.nsArray = nsArray || {}; - if (!document.evaluate) { - this.ie = true; - this.nsString = ""; - if (this.nsArray) { - for(var ns in this.nsArray) { - this.nsString += ' xmlns:' + ns + '="' + this.nsArray[ns] + '"'; - } - } - } - }, - - selectSingleNode : function(xmlDomCtx) { - var doc = xmlDomCtx.ownerDocument || xmlDomCtx; - if (this.ie) { - try { - doc.setProperty("SelectionLanguage", "XPath"); - doc.setProperty("SelectionNamespaces", this.nsString); - if (xmlDomCtx === doc) xmlDomCtx = doc.documentElement; - return xmlDomCtx.selectSingleNode(this.xpath); - } catch (ex) { - throw "XPath is not supported"; - } - } else { - var _this = this; - if (xmlDomCtx.documentElement) xmlDomCtx = xmlDomCtx.documentElement; - - var result = doc.evaluate(this.xpath, xmlDomCtx, - function(prefix) { - return _this.nsArray[prefix]; - }, XPathResult.FIRST_ORDERED_NODE_TYPE, null); - return result.singleNodeValue; - } - }, - - selectNumber : function(xmlDomCtx){ - var doc = xmlDomCtx.ownerDocument || xmlDomCtx; - if (this.ie) { - return this.selectText(xmlDomCtx); - } else { - var _this = this; - var result = doc.evaluate(this.xpath, xmlDomCtx, - function(prefix) { - return _this.nsArray[prefix]; - }, XPathResult.NUMBER_TYPE, null); - return result.numberValue; - } - }, - - selectNodes : function(xmlDomCtx) { - var doc = xmlDomCtx.ownerDocument || xmlDomCtx; - if (this.ie) { - try { - doc.setProperty("SelectionLanguage", "XPath"); - doc.setProperty("SelectionNamespaces", this.nsString); - if (xmlDomCtx === doc) xmlDomCtx = doc.documentElement; - return xmlDomCtx.selectNodes(this.xpath); - } catch (ex) { - throw "XPath is not supported"; - } - } else { - var _this = this; - var result = doc.evaluate(this.xpath, xmlDomCtx, - function(prefix) { - return _this.nsArray[prefix]; - }, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - var r = []; - for(var i = 0; i < result.snapshotLength; i++) { - r.push(result.snapshotItem(i)); - } - return r; - } - }, - - selectText : function(node) { - var result = this.selectSingleNode(node); - return result ? (result.text || result.textContent) : null; - } - }); - - return { - /** - * Selects nodes from XML data object - * - * @method selectNodes - * @param {Object} - * node xml data to be parsed - * @param {String} - * xpath xpath expression - * @param {Array} - * nsArray Array of namespaces for the xml. - * @return {Array} Array of nodes - * @static - */ - selectNodes : function(node, xpath, nsArray) { - var expr = new XPathExpr(xpath, nsArray); - return expr.selectNodes(node); - }, - - /** - * Selects single node from XML data object - * - * @method selectSingleNode - * @param {Object} - * node xml data to be parsed - * @param {String} - * xpath xpath expression - * @param {Array} - * nsArray Array of namespaces for the xml. - * @return {Object} selected node object - * @static - */ - selectSingleNode : function(node, xpath, nsArray) { - var expr = new XPathExpr(xpath, nsArray); - return expr.selectSingleNode(node); - }, - - - /** - * Selects text from a single node from XML data object - * - * @method selectText - * @param {Object} - * node xml data to be parsed - * @param {String} - * xpath xpath expression - * @param {Array} - * nsArray Array of namespaces for the xml. - * @return {String} inner text of the node object - * @static - */ - selectText : function(node, xpath, nsArray) { - var expr = new XPathExpr(xpath, nsArray); - return expr.selectText(node); - }, - - /** - * - * @param node - * @param xpath - * @param nsArray - * @returns - */ - selectNumber : function(node, xpath, nsArray){ - var expr = new XPathExpr(xpath, nsArray); - return expr.selectNumber(node); - } - }; -}); -}, -'sbt/base/XmlDataHandler':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ - -/** - * Social Business Toolkit SDK. Helpers for the base capabilities of data - * handlers. - * - * @module sbt.base.DataHandler - */ -define([ "../declare", "../lang", "../stringUtil", "../xml", "../xpath", "./DataHandler" ], - function(declare,lang,stringUtil,xml,xpath,DataHandler) { - - /** - * XmlDataHandler class - * - * @class XmlDataHandler - * @namespace sbt.base - */ - var XmlDataHandler = declare(DataHandler, { - - /** - * Data type for this DataHandler is 'xml' - */ - dataType : "xml", - - /** - * Set of XPath expressions used by this handler. Required for entity: - * uid, entry Required for summary: totalResults, startIndex, - * itemsPerPage - */ - xpath : null, - - /** - * Set of namespaces used by this handler. - */ - namespaces : null, - - /** - * Set of values that have already been read. - */ - _values : null, - - /** - * Summary of a feed. - */ - _summary : null, - - /** - * @constructor - * @param {Object} - * args Arguments for this data handler. - */ - constructor : function(args) { - lang.mixin(this, args); - - this._values = {}; // TODO option to disable cache - this.data = this._fromNodeOrString(args.data); - }, - - /** - * Called to set the handler data. - * - * @param data - */ - setData : function(data) { - this._values = {}; // TODO option to disable cache - this.data = this._fromNodeOrString(data); - }, - - /** - * @method getAsString - * @param property - * @returns - */ - getAsString : function(property) { - this._validateProperty(property, "getAsString"); - - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._selectText(property); - } - return this._values[property]; - } else { - return _selectText(property); - } - }, - - /** - * @method getAsNumber - * @param property - * @returns - */ - getAsNumber : function(property) { - this._validateProperty(property, "getAsNumber"); - - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._selectNumber(property); - } - return this._values[property]; - } else { - return this._selectNumber(property); - } - }, - - /** - * @method getAsDate - * @param property - * @returns - */ - getAsDate : function(property) { - this._validateProperty(property, "getAsDate"); - - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._selectDate(property); - } - return this._values[property]; - } else { - return this._selectDate(property); - } - }, - - /** - * @method getAsBoolean - * @param property - * @returns - */ - getAsBoolean : function(property) { - this._validateProperty(property, "getAsBoolean"); - - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._selectBoolean(property); - } - return this._values[property]; - } else { - return this._selectBoolean(property); - } - }, - - /** - * @method getAsArray - * @param property - * @returns - */ - getAsArray : function(property) { - this._validateProperty(property, "getAsArray"); - - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._selectArray(property); - } - return this._values[property]; - } else { - return this._selectArray(property); - } - }, - - /** - * @method getNodesArray - * @param property - * @returns - */ - getAsNodesArray : function(property) { - this._validateProperty(property, "getNodesArray"); - - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._selectNodesArray(property); - } - return this._values[property]; - } else { - return this._selectNodesArray(property); - } - }, - - /** - * @method getEntityId - * @returns - */ - getEntityId : function() { - return stringUtil.trim(this.getAsString("uid")); - }, - - /** - * getEntityData - * - * @returns - */ - getEntityData : function(document) { - var entry = this.xpath["entry"]; - if (!entry) { - return document; - } - if (!this._values["entry"]) { - var nodes = xpath.selectNodes(document, entry, this.namespaces); - this._values["entry"] = nodes[0] || null; - } - return this._values["entry"]; - }, - - /** - * @method getSummary - * @returns - */ - getSummary : function() { - if (!this._summary && this._getXPath("totalResults")) { - this._summary = { - totalResults : xpath.selectNumber(this.data, this._getXPath("totalResults"), this.namespaces), - startIndex : xpath.selectNumber(this.data, this._getXPath("startIndex"), this.namespaces), - itemsPerPage : xpath.selectNumber(this.data, this._getXPath("itemsPerPage"), this.namespaces) - }; - } - return this._summary; - }, - - /** - * @method getEntitiesDataArray - * @returns {Array} - */ - getEntitiesDataArray : function() { - var entries = this.xpath["entries"]; - if (!entries) { - return this.data; - } - if (!this._values["entries"]) { - this._values["entries"] = xpath.selectNodes(this.data, entries, this.namespaces); - } - return this._values["entries"]; - }, - - /** - * @method toJson - * @returns {Object} - */ - toJson : function() { - var jsonObj = {}; - - for (var name in this.xpath) { - if (this.xpath.hasOwnProperty(name)) { - jsonObj[name] = this.getAsString(name); - } - } - - return jsonObj; - }, - - /* - * Convert the input to a node by parsing as string and using - * getEntityData, if not already one - */ - _fromNodeOrString : function(nodeOrString) { - if (lang.isString(nodeOrString)) { - nodeOrString = stringUtil.trim(nodeOrString); - var document = xml.parse(nodeOrString); - return this.getEntityData(document); - } - return nodeOrString; - }, - - /* - * Return xpath expression from the set or the property itself (assume - * it's already xpath) - */ - _getXPath : function(property) { - return this.xpath[property] || property; - }, - - /* - * Validate that the property is valid - */ - _validateProperty : function(property, method) { - if (!property) { - var msg = stringUtil.substitute("Invalid argument for XmlDataHandler.{1} {0}", [ property, method ]); - throw new Error(msg); - } - }, - - /* - * Select xpath as string - */ - _selectText : function(property) { - if (!this.data) { - return null; - } - return stringUtil.trim(xpath.selectText(this.data, this._getXPath(property), this.namespaces)); - }, - - /* - * Select xpath as number - */ - _selectNumber : function(property) { - if (!this.data) { - return null; - } - return xpath.selectNumber(this.data, this._getXPath(property), this.namespaces); - }, - - /* - * Select xpath as date - */ - _selectDate : function(property) { - if (!this.data) { - return null; - } - var text = this._selectText(property); - return text ? new Date(Date.parse(text)) : null; - }, - - /* - * Select xpath as boolean - */ - _selectBoolean : function(property) { - if (!this.data) { - return false; - } - var nodes = xpath.selectNodes(this.data, this._getXPath(property), this.namespaces); - var ret = false; - if (nodes) { - if (nodes.length == 1) { - // handle case were node has text value equal true/false - var text = stringUtil.trim(nodes[0].text || nodes[0].textContent); - if (text) { - text = text.toLowerCase(); - if ("false" == text) { - return false; - } - if ("true" == text) { - return true; - } - } - } - ret = (nodes.length > 0); - } - return ret; - }, - - /* - * Select xpath as array - */ - _selectArray : function(property) { - if (!this.data) { - return null; - } - var nodes = xpath.selectNodes(this.data, this._getXPath(property), this.namespaces); - var ret = null; - if (nodes) { - ret = []; - for ( var i = 0; i < nodes.length; i++) { - ret.push(stringUtil.trim(nodes[i].text || nodes[i].textContent)); - } - } - return ret; - }, - - /* - * Select xpath as nodes array - */ - _selectNodesArray : function(property) { - if (!this.data) { - return null; - } - return xpath.selectNodes(this.data, this._getXPath(property), this.namespaces); - } - - - }); - return XmlDataHandler; -}); -}, -'url:sbt/connections/controls/profiles/templates/StatusUpdateRow.html':"\r\n\t\r\n\t\t\r\n\t\t
    \r\n\t\t
    \r\n\t\t \r\n\t\t ${name} ${statusUpdate}\r\n\t\t \r\n\t\t \r\n\t\t
    \r\n\t\t
    \r\n\t\t \t
      \r\n\t\t \t
    • \r\n\t\t\t\t\t\t\"\"\r\n\t\t\t\t\t \r\n\t\t\t\t\t \r\n\t\t\t\t\t\t ${statusLastUpdate}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
    • \r\n\t\t\t\t
    \r\n\t\t
    \r\n\t\t
    \r\n\t\t\r\n\t\r\n", -'sbt/connections/FollowConstants':function(){ -/* - * © 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. - */ -/** - * Social Business Toolkit SDK. - * Definition of constants for FollowService. - */ -define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - - return lang.mixin(conn, { - - /** - * Activities Source - * - * @property ActivitiesSource - * @type String - * @for sbt.connections.FollowedResource - */ - ActivitiesSource : "activities", - - /** - * Activity Resource Type - * - * @property ActivityResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - ActivityResourceType : "activity", - - /** - * Blogs Source - * - * @property BlogsSource - * @type String - * @for sbt.connections.FollowedResource - */ - BlogsSource : "blogs", - - /** - * Blog Resource Type - * - * @property BlogResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - BlogResourceType : "blog", - - /** - * Communities Source - * - * @property CommunitiesSource - * @type String - * @for sbt.connections.FollowedResource - */ - CommunitiesSource : "communities", - - /** - * Community Resource Type - * - * @property CommunitiesResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - CommunitiesResourceType : "community", - - /** - * Files Source - * - * @property FilesSource - * @type String - * @for sbt.connections.FollowedResource - */ - FilesSource : "files", - - /** - * File Resource Type - * - * @property FileResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - FileResourceType : "file", - - /** - * FileFolder Resource Type - * - * @property FileFolderResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - FileFolderResourceType : "file_folder", - - /** - * Forums Source - * - * @property ForumsSource - * @type String - * @for sbt.connections.FollowedResource - */ - ForumsSource : "forums", - - /** - * Forum Resource Type - * - * @property ForumResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - ForumResourceType : "forum", - - /** - * ForumTopic Resource Type - * - * @property ForumTopicResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - ForumTopicResourceType : "forum_topic", - - /** - * Profile Source - * - * @property ProfilesSource - * @type String - * @for sbt.connections.FollowedResource - */ - ProfilesSource : "profiles", - - /** - * Profile Resource Type - * - * @property ProfilesResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - - ProfilesResourceType : "profile", - - /** - * Wikis Source - * - * @property WikisSource - * @type String - * @for sbt.connections.FollowedResource - */ - WikisSource : "wikis", - - /** - * Wiki Resource Type - * - * @property WikiResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - WikiResourceType : "wiki", - - /** - * WikiPage Resource Type - * - * @property WikiPageResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - WikiPageResourceType : "wiki_page", - - /** - * Tags Source - * - * @property TagsSource - * @type String - * @for sbt.connections.FollowedResource - */ - TagsSource : "tags", - - /** - * Tag Resource Type - * - * @property TagResourceType - * @type String - * @for sbt.connections.FollowedResource - */ - TagResourceType : "tag", - - - /** - * Get the followed resources feed + /** + * Returns the file Id * - * @method getFollowedResources - * @param {String} source String specifying the resource. Options are: - * - * activities - * blogs - * communities - * files - * forums - * profiles - * wikis - * tags - * - * @param {String} resourceType String representing the resource type. Options are: + * @method getFileId + * @returns {String} file Id + */ + getFileId : function() { + return this.id || this.getAsString("uid") || this._fields.id; + }, + /** + * Returns the label + * + * @method getLabel + * @returns {String} label + */ + getLabel : function() { + return this.getAsString("label"); + }, + /** + * Returns the self URL + * + * @method getSelfUrl + * @returns {String} self URL + */ + getSelfUrl : function() { + return this.getAsString("selfUrl"); + }, + /** + * Returns the alternate URL + * + * @method getAlternateUrl + * @returns {String} alternate URL + */ + getAlternateUrl : function() { + return this.getAsString("alternateUrl"); + }, + /** + * Returns the download URL + * + * @method getDownloadUrl + * @returns {String} download URL + */ + getDownloadUrl : function() { + return config.Properties.serviceUrl + "/files/" + this.service.endpoint.proxyPath + "/" + "connections" + "/" + "DownloadFile" + "/" + + this.getFileId() + "/" + this.getLibraryId(); + ; + }, + /** + * Returns the type + * + * @method getType + * @returns {String} type + */ + getType : function() { + return this.getAsString("type"); + }, + /** + * Returns the Category + * + * @method getCategory + * @returns {String} category + */ + getCategory : function() { + return this.getAsString("category"); + }, + /** + * Returns the size + * + * @method getSize + * @returns {Number} length + */ + getSize : function() { + return this.getAsNumber("length"); + }, + /** + * Returns the Edit Link + * + * @method getEditLink + * @returns {String} edit link + */ + getEditLink : function() { + return this.getAsString("editLink"); + }, + /** + * Returns the Edit Media Link + * + * @method getEditMediaLink + * @returns {String} edit media link + */ + getEditMediaLink : function() { + return this.getAsString("editMediaLink"); + }, + /** + * Returns the Thumbnail URL + * + * @method getThumbnailUrl + * @returns {String} thumbnail URL + */ + getThumbnailUrl : function() { + return this.getAsString("thumbnailUrl"); + }, + /** + * Returns the Comments URL + * + * @method getCommentsUrl + * @returns {String} comments URL + */ + getCommentsUrl : function() { + return this.getAsString("commentsUrl"); + }, + /** + * Returns the author + * + * @method getAuthor + * @returns {Object} author + */ + getAuthor : function() { + return this.getAsObject([ "authorName", "authorUserId", "authorEmail", "authorUserState" ]); + }, + /** + * Returns the Title + * + * @method getTitle + * @returns {String} title + */ + getTitle : function() { + return this.getAsString("title"); + }, + /** + * Returns the published date + * + * @method getPublished + * @returns {Date} published date + */ + getPublished : function() { + return this.getAsDate("published"); + }, + /** + * Returns the updated date + * + * @method getUpdated + * @returns {Date} updated date + */ + getUpdated : function() { + return this.getAsDate("updated"); + }, + /** + * Returns the created date + * + * @method getCreated + * @returns {Date} created date + */ + getCreated : function() { + return this.getAsDate("created"); + }, + /** + * Returns the modified date + * + * @method getModified + * @returns {Date} modified date + */ + getModified : function() { + return this.getAsDate("modified"); + }, + /** + * Returns the last accessed date + * + * @method getLastAccessed + * @returns {Date} last accessed date + */ + getLastAccessed : function() { + return this.getAsDate("lastAccessed"); + }, + /** + * Returns the modifier + * + * @method getModifier + * @returns {Object} modifier + */ + getModifier : function() { + return this.getAsObject([ "modifierName", "modifierUserId", "modifierEmail", "modifierUserState" ]); + }, + /** + * Returns the visibility + * + * @method getVisibility + * @returns {String} visibility + */ + getVisibility : function() { + return this.getAsString("visibility"); + }, + /** + * Returns the library Id + * + * @method getLibraryId + * @returns {String} library Id + */ + getLibraryId : function() { + return this.getAsString("libraryId"); + }, + + /** + * Sets the library Id + * + * @method setLibraryId + * @param libaryId + */ + setLibraryId : function(libraryId) { + return this.setAsString("libraryId", libraryId); + }, + /** + * Returns the library Type + * + * @method getLibraryType + * @returns {String} library Type + */ + getLibraryType : function() { + return this.getAsString("libraryType"); + }, + /** + * Returns the version Id + * + * @method getVersionUuid + * @returns {String} version Id + */ + getVersionUuid : function() { + return this.getAsString("versionUuid"); + }, + /** + * Returns the version label + * + * @method getVersionLabel + * @returns {String} version label + */ + getVersionLabel : function() { + return this.getAsString("versionLabel"); + }, + /** + * Returns the propagation + * + * @method getPropagation + * @returns {String} propagation + */ + getPropagation : function() { + return this.getAsString("propagation"); + }, + /** + * Returns the recommendations Count + * + * @method getRecommendationsCount + * @returns {Number} recommendations Count + */ + getRecommendationsCount : function() { + return this.getAsNumber("recommendationsCount"); + }, + /** + * Returns the comments Count + * + * @method getCommentsCount + * @returns {Number} comments Count + */ + getCommentsCount : function() { + return this.getAsNumber("commentsCount"); + }, + /** + * Returns the shares Count + * + * @method getSharesCount + * @returns {Number} shares Count + */ + getSharesCount : function() { + return this.getAsNumber("sharesCount"); + }, + /** + * Returns the folders Count + * + * @method getFoldersCount + * @returns {Number} folders Count + */ + getFoldersCount : function() { + return this.getAsNumber("foldersCount"); + }, + /** + * Returns the attachments Count + * + * @method getAttachmentsCount + * @returns {Number} attachments Count + */ + getAttachmentsCount : function() { + return this.getAsNumber("attachmentsCount"); + }, + /** + * Returns the versions Count + * + * @method getVersionsCount + * @returns {Number} versions Count + */ + getVersionsCount : function() { + return this.getAsNumber("versionsCount"); + }, + /** + * Returns the references Count * - * If source=activities - * activity + * @method getReferencesCount + * @returns {Number} references Count + */ + getReferencesCount : function() { + return this.getAsNumber("referencesCount"); + }, + /** + * Returns the total Media Size * - * If source=blogs - * blog - * - * If source=communities - * community - * - * If source=files - * file - * file_folder - * + * @method getTotalMediaSize + * @returns {Number} total Media Size + */ + getTotalMediaSize : function() { + return this.getAsNumber("totalMediaSize"); + }, + /** + * Returns the Summary * - * If source=forums - * forum - * forum_topic - * + * @method getSummary + * @returns {String} Summary + */ + getSummary : function() { + return this.getAsString("summary"); + }, + /** + * Returns the Content URL * - * If source=profiles - * profile - * - * If source=wikis - * wiki - * wiki_page - * + * @method getContentUrl + * @returns {String} Content URL + */ + getContentUrl : function() { + return this.getAsString("contentUrl"); + }, + /** + * Returns the Content Type * - * If source=tags - * tag + * @method getContentType + * @returns {String} Content Type + */ + getContentType : function() { + return this.getAsString("contentType"); + }, + /** + * Returns the objectTypeId * - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of members of a - * community. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. + * @method getObjectTypeId + * @returns {String} objectTypeId */ - FollowedResourceFeedXPath : conn.ConnectionsFeedXPath, - - /** - * XPath expressions to be used when reading a followed resource entry - */ - FollowedResourceXPath : lang.mixin({}, conn.AtomEntryXPath, { - followedResourceUuid : "a:id", - categoryType : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", - source : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/source']/@term", - resourceType : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-type']/@term", - resourceId : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-id']/@term", - relatedUrl : "a:link[@rel='related']/@href" - }), - - /** - * XPath expressions to be used when reading a followed resource entry - */ - OneFollowedResourceXPath : lang.mixin({}, conn.AtomEntryXPath, { - entry : "/a:feed/a:entry", - followedResourceUuid : "a:id", - categoryType : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", - source : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/source']/@term", - resourceType : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-type']/@term", - resourceId : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-id']/@term", - relatedUrl : "a:link[@rel='related']/@href" - }), - - /** - * Get, follow or stop following a resource. - */ - AtomFollowAPI : "/{service}/follow/atom/resources", - - /** - * Get, follow or stop following a resource. - */ - AtomStopFollowAPI : "/{service}/follow/atom/resources/{resourceId}" - }); -}); -}, -'sbt/connections/controls/communities/CommunityMembersAction':function(){ -/* - * © 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. - */ - -/** - * - */ -define( - [ "../../../declare", "../../../controls/grid/GridAction", - "sbt/connections/CommunityService", - "sbt/connections/CommunityConstants" ], - - function(declare, GridAction, CommunityService, CommunityConstants) { - - /** - * @class ProfileAction - * @namespace sbt.connections.controls.communities - * @module sbt.connections.controls.communities.CommunityMembersAction - */ - var CommunityMembersAction = declare( - GridAction, - { - - /** Strings used in the actions */ - nls : { - tooltip : "Go to ${name}" - }, - - /** - * ProfileAction Constructor function - * - * @method constructor - */ - constructor : function() { - }, - - /** - * Handles displaying a tooltip for an item For - * profiles, the tooltip by default will be a business - * card So nothing is done in this function - * - * @method getTooltip - * @param item - * The element that will use the tooltip - */ - getTooltip : function(item) { - return item.getValue("title"); - }, - - /** - * The execute function is called from the handle click - * function For Profiles by default the business card - * functionality is used which works from the Semantic - * tag service so nothing is done here. - * - * @method execute - * @param item - * The item which fired the event - * @param opts - * @param event - * The event - */ - execute : function(item, grid, event) { - var url = grid.renderer.getProfileUrl(grid,item.getValue("id")); - window.open(url); - }, - - /** - * The removeMember function is called from the - * removeMember function and removes members from the - * community specified by currentCommunity - * - * @method removeMember - * @param grid - * The grid to update after the member has - * been removed. - * @param communityService - * The community service instance used to - * remove the member. - * @param currentCommunity - * The ID of the community from which to - * remove the member. - * @param data - * The data row from which the event was - * fired. - */ - removeMember : function(grid, currentCommunity, data) { - _removeMember(grid, currentCommunity, data); - }, - - /** - * Updates a community member. - * - * @method updateMember - * @param grid - * The grid to update. - * @param el - * the element that fired the event - * @param data - * all of the items from the current row of - * the grid. - * @param ev - * the event - * @param grid - * The grid to update after the member has - * been removed. - * - * @param communityUuid - * The ID of the community from which to - * remove the member. - * @param data - * The data row from which the event was - * fired. - */ - updateMember : function(grid, el, data, ev, communityUuid) { - var communityService = new CommunityService(); - var rbOwnerId = "rbOwner" + data.uid; - var rbOwner = document.getElementById(rbOwnerId); - communityService.getMembers(communityUuid).then( - function(members) { - for ( var i = 0; i < members.length; i++) { - var member = members[i]; - if (member.getUserid() == data.uid) { - if (rbOwner.checked) { - member.setRole(CommunityConstants.Owner); - } else { - member.setRole(CommunityConstants.Member); - } - - // Update community - var promise = communityService.updateMember( - communityUuid, member); - - promise.then(function(data) { - grid.update(null); - }, function(error) { - console.log(error); - }); - break; - } - } - }, function(error) { - console.log(error); - }); - }, - - /** - * Closes the edit form. - * - * @method removeMember - * @param grid - * The grid to update. - * @param el - * the element that fired the event - * @param data - * all of the items from the current row of - * the grid. - * @param ev - * the event - * @param grid - * The grid to update after the member has - * been removed. - * @param data - * The data row from which the event was - * fired. - */ - closeEditForm : function(grid, el, data, ev) { - var id = "editTable" + data.uid; - document.getElementById(id).style.display = "none"; - }, - - /** - * Opens the edit form. - * - * @method openEditForm - * @param data - * The data row from which the event was - * fired. - */ - openEditForm : function(data) { - var id = "editTable" + data.uid; - document.getElementById(id).style.display = "block"; - }, - - - /** - * Removes a community member. - * - * @method removeMember - * @param grid - * The grid to update. - * @param el - * the element that fired the event - * @param data - * all of the items from the current row of - * the grid. - * @param ev - * the event - * @param grid - * The grid to update after the member has - * been removed. - * - * @param communityUuid - * The ID of the community from which to - * remove the member. - * @param data - * The data row from which the event was - * fired. - */ - removeMember : function(grid, el, data, ev, communityUuid) { - var communityService = new CommunityService(); - - communityService.getMembers(currentCommunity).then( - function(members) { - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if (member.getUserid() == data.uid) { - // Remove member - communityService.getCommunity(currentCommunity).then( - function(community) { - community.removeMember(member.getUserid(), {}).then( - function(memberId) { - grid.update(null); - el.parentNode.removeChild(container); - }, - function(error) { - console.log(error); - }); - }, - function(error) { - console.log(error); - }); - break; - } - } - }, function(error) { - console.log(error); - }); - } - }); - return CommunityMembersAction; - }); - -}, -'sbt/authenticator/templates/messageSSO':function(){ -/* - * © 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. - */ - -function cancelOnClick() { - var argsMap = getArgsMap();// get map of query string arguments - var redirectURL = decodeURIComponent(argsMap.redirectURL); - var loginUi = decodeURIComponent(argsMap.loginUi); - if (loginUi == "popup") { - opener.location.reload(); - window.close(); - } else { - window.location.href = redirectURL; - } -} - -function onLoginPageLoad() { - var argsMap = getArgsMap();// get map of query string arguments - if(argsMap.loginUi == "popup"){ - var ssoStrings = window.globalSSOStrings; - document.getElementById('reloginMessage').appendChild(document.createTextNode(decodeURIComponent(ssoStrings.message))); - document.getElementById('ssoLoginFormOK').value = decodeURIComponent(ssoStrings.relogin_button_text); - }else{ - document.getElementById('reloginMessage').appendChild(document.createTextNode(decodeURIComponent(argsMap.message))); - document.getElementById('ssoLoginFormOK').value = decodeURIComponent(argsMap.relogin_button_text); - } - -} - -function getArgsMap() { - try { - var qString = location.search.substring(1);// getting query string args - var qStringParams = qString.split("&");// getting array of all query - // string arg key value pairs - var argsMap = {}; - var i; - for (i = 0; i < qStringParams.length; i++) { - var argArray = qStringParams[i].split("="); - argsMap[argArray[0]] = argArray[1]; - } - return argsMap; - } catch (err) { - console.log("Error making agrs map in messageSSO.js " + err); - } -} -}, -'url:sbt/connections/controls/communities/templates/BootstrapCommunityMember.html':"\r\n\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t\t

    \r\n \t\t\t\t${title}\r\n \t\t\t

    \r\n\t\r\n", -'sbt/smartcloud/ProfileService':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ -/** - * Social Business Toolkit SDK. - * @author Vimal Dhupar - * - * Javascript APIs for IBM SmartCloud Profiles Service. - * @module sbt.smartcloud.ProfileService -**/ - -define(["../declare","../lang", "../config","../stringUtil","../Cache","./Subscriber","../Jsonpath","../base/BaseService", "../base/JsonDataHandler", "./ProfileConstants", "../base/BaseEntity","../Promise"], - function(declare, lang, config, StringUtil, Cache, Subscriber, JsonPath, BaseService, JsonDataHandler, Consts, BaseEntity, Promise) { - /** - * Profile class representing the Smartcloud User Profile. - * - * @class Profile - * @namespace sbt.smartcloud - */ - var Profile = declare(BaseEntity, { + getObjectTypeId : function() { + return this.getAsString("objectTypeId"); + }, /** - * Profile Class Constructor - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Loads the profile object with the profile entry document associated - * with the profile. By default, a network call is made to load the - * profile entry document in the profile object. - * - * @method load - * @param {Object} [args] Argument object - * - */ - load: function(args) { - var profileId = this.getId(); - var promise = this.service._validateProfileId(profileId); - if (promise) { - return promise; - } - - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - return new JsonDataHandler({ - data : data, - jsonpath : Consts.ProfileJsonPath - }); - } - }; - var requestArgs = {}; - requestArgs.userid = profileId; - lang.mixin(requestArgs, args || {format:"json"}); - var options = { - handleAs : "json", - query : requestArgs - }; - return this.service.getEntity(consts.GetProfile, options, profileId, callbacks, args); + * Returns the lock state + * + * @method getLockType + * @returns {String} lock state + */ + getLockType : function() { + return this.getAsString("lock"); }, - /** - * Returns the id of the User - * @method getId - * @return {String} id of the User - **/ - getId: function () { - return this.getAsString("id"); + * Returns the permission ACLs + * + * @method getAcls + * @returns {String} ACLs + */ + getAcls : function() { + return this.getAsString("acls"); }, - /** - * Returns the id of the User - * @method getUserid - * @return {String} id of the User - **/ - getUserid: function () { - return this.getAsString("id"); + * Returns the hit count + * + * @method getHitCount + * @returns {Number} hit count + */ + getHitCount : function() { + return this.getAsNumber("hitCount"); }, - /** - * Returns the object id of the User - * @method getObjectId - * @return {String} id of the User + * Returns the anonymous hit count + * + * @method getAnonymousHitCount + * @returns {Number} anonymous hit count */ - getObjectId: function () { - return this.getAsString("objectId"); + getAnonymousHitCount : function() { + return this.getAsNumber("anonymousHitCount"); }, - /** - * Get display name of the User - * @method getDisplayName - * @return {String} display name of the User + * Returns the tags + * + * @method getTags + * @returns {Array} tags */ - getDisplayName: function () { - return this.getAsString("displayName"); + getTags : function() { + return this.getAsArray("tags"); }, - /** - * Get display name of the User - * @method getName - * @return {String} display name of the User + * Returns the tags + * + * @method setTags + * @param {Array} tags */ - getName: function () { - return this.getAsString("displayName"); + setTags : function(tags) { + return this.setAsArray("tags", tags); }, - /** - * Get email of the User - * @method getEmail - * @return {String} email of the User + * Sets the label + * + * @method setLabel + * @param {String} label */ - getEmail: function () { - return this.getAsString("emailAddress"); + setLabel : function(label) { + return this.setAsString("label", label); }, - /** - * Get thumbnail URL of the User - * @method getThumbnailUrl - * @return {String} thumbnail URL of the User + * Sets the summary + * + * @method setSummary + * @param {String} summary */ - getThumbnailUrl: function () { - var image = this.getAsString("thumbnailUrl"); - if(image) - image = this.service.endpoint.baseUrl+"/contacts/img/photos/"+ image; // TODO : work in making this generic - return image; + setSummary : function(summary) { + return this.setAsString("summary", summary); }, - /** - * Get address of the profile - * @method getAddress - * @return {String} Address object of the profile + * Sets the visibility + * + * @method setVisibility + * @param {String} visibility */ - getAddress: function () { - var address = this.getAsArray("address"); - address = this.dataHandler.extractFirstElement(address); - return address; + setVisibility : function(visibility) { + return this.setAsString("visibility", visibility); }, - + /** - * Get department of the profile - * @method getDepartment - * @return {String} department of the profile + * Sets Indicator whether the currently authenticated user wants to receive notifications as people edit the document. Options are on or off. + * @param {Boolean} notification + * @returns */ - getDepartment: function () { - return this.getAsString("department"); + setNotification : function(notification) { + return this.setAsBoolean("notification", notification ? "on" : "off"); }, - /** - * Get job title of the profile - * @method getJobTitle - * @return {String} job title of the profile + * Loads the file object with the atom entry associated with the file. By default, a network call is made to load the atom entry document in the + * file object. + * + * @method load + * @param {Object} [args] Argument object + * @param {Boolean} [isPublic] Optinal flag to indicate whether to load public file which does not require authentication */ - getJobTitle: function () { - return this.getAsString("jobTitle"); + load : function(args, isPublic, url) { + // detect a bad request by validating required arguments + var fileUuid = this.getFileId(); + var promise = this.service.validateField("fileId", fileUuid); + if (promise) { + return promise; + } + if(isPublic) { + promise = this.service.validateField("libraryId", this.getLibraryId()); + if (promise) { + return promise; + } + } + + var self = this; + var callbacks = { + createEntity : function(service, data, response) { + self.dataHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.FileXPath + }); + return self; + } + }; + + var requestArgs = lang.mixin({ + fileUuid : fileUuid + }, args || {}); + var options = { + // handleAs : "text", + query : requestArgs + }; + + if (!url) { + if (isPublic) { + url = this.service.constructUrl(consts.AtomFileInstancePublic, null, { + "documentId" : fileUuid, + "libraryId" : this.getLibraryId() + }); + } + else { + url = this.service.constructUrl(consts.AtomFileInstance, null, { + "documentId" : fileUuid + }); + } + } + return this.service.getEntity(url, options, fileUuid, callbacks); }, - /** - * Get profile URL of the profile - * @method getProfileUrl - * @return {String} profile URL of the profile + * Save this file + * + * @method save + * @param {Object} [args] Argument object */ - getProfileUrl: function () { - return this.getAsString("profileUrl"); + save : function(args) { + if (this.getFileId()) { + return this.service.updateFileMetadata(this, args); + } }, - /** - * Get telephone number of the profile - * @method getTelehoneNumber - * @return {String} Telephone number object of the profile + * Adds a comment to the file. + * + * @method addComment + * @param {String} comment the comment to be added + * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. */ - getTelephoneNumber: function () { - return this.getAsString("telephone"); + addComment : function(comment, args) { + return this.service.addCommentToFile(this.getAuthor().authorUserId, this.getFileId(), comment, args); }, - /** - * Get Country of the profile - * @method getCountry - * @return {String} country of the profile + * Pin th file, by sending a POST request to the myfavorites feed. + * + * @method pin + * @param {Object} [args] Argument object. */ - getCountry: function () { - return this.getAsString("country"); + pin : function(args) { + return this.service.pinFile(this.getFileId(), args); }, - /** - * Get Organization Id of the profile - * @method getOrgId - * @return {String} Organization Id of the profile + * Unpin the file, by sending a DELETE request to the myfavorites feed. + * + * @method unPin + * @param {Object} [args] Argument object. */ - getOrgId: function () { - return this.getAsString("orgId"); + unpin : function(args) { + return this.service.unpinFile(this.getFileId(), args); }, - /** - * Get Organization of the profile - * @method getOrg - * @return {String} Organization of the profile + * Lock the file + * + * @method lock + * @param {Object} [args] Argument object */ - getOrg: function () { - return this.getAsString("org"); + lock : function(args) { + return this.service.lockFile(this.getFileId(), args); }, - /** - * Get "About Me"/description of the profile - * @method getAbout - * @return {String} description of the profile + * UnLock the file + * + * @method unlock + * @param {Object} [args] Argument object */ - getAbout: function () { - return this.getAsString("about"); + unlock : function(args) { + return this.service.unlockFile(this.getFileId(), args); + }, + /** + * Deletes the file. + * + * @method remove + * @param {Object} [args] Argument object + */ + remove : function(args) { + return this.service.deleteFile(this.getFileId(), args); + }, + /** + * Update the Atom document representation of the metadata for the file + * + * @method update + * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + update : function(args) { + return this.service.updateFileMetadata(this, args); + }, + /** + * Downloads the file + * + * @method download + */ + download : function() { + return this.service.downloadFile(this.getFileId(), this.getLibraryId()); } + }); - + /** - * Callbacks used when reading an entry that contains a Profile. - */ - var ProfileCallbacks = { - createEntity : function(service,data,response) { - var entryHandler = new JsonDataHandler({ - data : data, - jsonpath : Consts.ProfileJsonPath - }); + * Callbacks used when reading a feed that contains File entries. + */ + var FileFeedCallbacks = { + createEntities : function(service, data, response) { + return new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.FileFeedXPath + }); + }, + createEntity : function(service, data, response) { + var entry = null; + if (typeof data == "object") { + entry = data; + } else { + var feedHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.FileXPath + }); + entry = feedHandler.data; + } + var entryHandler = new XmlDataHandler({ + data : entry, + namespaces : consts.Namespaces, + xpath : consts.FileXPath + }); + return new File({ + service : service, + dataHandler : entryHandler + }); + } + }; - return new Profile({ - service : service, - id : entryHandler.getEntityId(), - dataHandler : entryHandler - }); - } - }; - - /** - * Callbacks used when reading a feed that contains multiple Profiles. - */ - var ProfileFeedCallbacks = { - createEntities : function(service,data,response) { - return new JsonDataHandler({ - data : data, - jsonpath : Consts.ProfileJsonPath - }); - }, + /** + * Callbacks used when reading a feed that contains File Comment entries. + */ + var CommentCallbacks = { + createEntities : function(service, data, response) { + return new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommentFeedXPath + }); + }, + createEntity : function(service, data, response) { + var entry = null; + if (typeof data == "object") { + entry = data; + } else { + var feedHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommentXPath + }); + entry = feedHandler.data; + } + var entryHandler = new XmlDataHandler({ + data : entry, + namespaces : consts.Namespaces, + xpath : consts.CommentXPath + }); + return new Comment({ + service : service, + dataHandler : entryHandler + }); + } + }; + + /** + * FileService class. + * + * @class FileService + * @namespace sbt.connections + */ + var FileService = declare(ConnectionsService, { + + contextRootMap : { + files : "files" + }, - createEntity : function(service,data,response) { - var entryHandler = new JsonDataHandler({ - data : data, - jsonpath : Consts.ProfileJsonPath - }); + serviceName : "files", + + /** + * Constructor for FileService + * + * @constructor + * @param args + */ + constructor : function(args) { + var endpointName = args ? (args.endpoint ? args.endpoint : this.getDefaultEndpointName()) : this.getDefaultEndpointName(); + if (!this.endpoint) { + this.endpoint = config.findEndpoint(endpointName); + } + }, + + /** + * Returns information about the current users library. + * + */ + getMyLibrary : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : { ps:1, includeQuota:true } || args || {} + }; + + var self = this; + var callbacks = { + createEntity : function(service, data, response) { + var entryHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.LibraryXPath + }); + return new Library({ + service : self, + dataHandler : entryHandler + }); + } + }; + + return this.getEntity(consts.AtomFilesMy, options, "my", callbacks); + }, + + /** + * Returns a File instance from File or JSON or String. Throws an error if the argument was neither. + * + * @param {Object} fileOrJsonOrString The file Object or json String for File + */ + newFile : function(fileOrJsonOrString) { + if (fileOrJsonOrString instanceof File) { + return fileOrJsonOrString; + } else { + if (lang.isString(fileOrJsonOrString)) { + fileOrJsonOrString = { + id : fileOrJsonOrString + }; + } + return new File({ + service : this, + _fields : lang.mixin({}, fileOrJsonOrString) + }); + } + }, + + /** + * Loads File with the ID passed + * + * @method getFile + * @param {String} fileId the Id of the file to be loaded + * @param {Object} [args] Argument object + */ + getFile : function(fileId, args) { + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; + } + var file = this.newFile({ + id : fileId + }); + return file.load(args); + + }, + + /** + * Loads Community File + * + * @method getFile + * @param {String} fileId the Id of the file to be loaded + * @param {String} communityId the Id of the community to which it belongs + * @param {Object} [args] Argument object + */ + getCommunityFile : function(fileId, communityId, args) { + var promise = this.validateField("fileId", fileId); + if (!promise) { + promise = this.validateField("communityId", communityId); + } + if (promise) { + return promise; + } + var file = this.newFile({ + id : fileId + }); + var url = this.constructUrl(consts.AtomGetCommunityFile, null, { + communityId : communityId, + documentId : file.getFileId() + }); + return file.load(args, null, url); + + }, + /** + * Get my files from IBM Connections + * + * @method getMyFiles + * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getMyFiles : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; - return new Profile({ - service : service, - id : entryHandler.getEntityId(), - dataHandler : entryHandler - }); - } - }; - - /** - * Profile service class associated with a profile service of IBM SmartCloud. - * - * @class ProfileService - * @namespace sbt.smartcloud - */ - var ProfileService = declare(BaseService, { - _profiles: null, + return this.getEntities(consts.AtomFilesMy, options, this.getFileFeedCallbacks()); + }, - /** - * - * @constructor - * @param args - */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } - if(!this._cache){ - if(config.Properties.ProfileCacheSize || Consts.DefaultCacheSize){ - this._cache = new Cache(config.Properties.ProfileCacheSize || Consts.DefaultCacheSize); - } - } - }, + /** + * Get community files from IBM Connections (community files refer to + * files which the user uploaded to the community. Calling this function + * will not list files that have been shared with this community). + * + * @method getCommunityFiles + * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getCommunityFiles : function(communityId, args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; - /** - * Return the default endpoint name if client did not specify one. - * @returns {String} - */ - getDefaultEndpointName: function() { - return "smartcloud"; - }, - - /** - * Get the profile of a user. - * - * @method getProfile - * @param {String} userId Userid of the profile - * @param {Object} args Argument object - */ - getProfile : function(userId, args) { - var idObject = this._toIdObject(userId); - var promise = this._validateIdObject(idObject); - if (promise) { - return promise; - } + var url = this.constructUrl(consts.AtomGetAllFilesInCommunity, null, { + communityId : communityId + }); - var requestArgs = lang.mixin(idObject, args || {format:"json"}); - var options = { - method : "GET", - handleAs : "json", - query : args || { format: "json" } - }; - var entityId = encodeURIComponent(idObject.userid); - var url = this.constructUrl(Consts.GetProfileByGUID, {}, {idToBeReplaced : entityId}); - return this.getEntity(url, options, entityId, this.getProfileCallbacks()); - }, - - /** - * Get the profile of a user. - * - * @method getProfileByGUID - * @param {String} userId Userid of the profile - * @param {Object} args Argument object - * @deprecated Use getProfile instead. - */ - getProfileByGUID : function(userId, args) { - return this.getProfile(userId, args); - }, - - /** - * Get the profile of a logged in user. - * - * @method getMyProfile - * @param {Object} args Argument object - */ - getMyProfile : function(args) { - var self = this; - var url = Consts.GetUserIdentity; - - var promise = new Promise(); - this.endpoint.request(url, { handleAs : "json" }).then(function(response) { - - var idObject = self._toIdObject(response.subscriberid); - var promise1 = self._validateIdObject(idObject); - if (promise1) { - return promise1; - } - - var requestArgs = lang.mixin(idObject, args || {format:"json"}); - var options = { - method : "GET", - handleAs : "json", - query : requestArgs - }; - var entityId = encodeURIComponent(idObject.userid); - var url = self.constructUrl(Consts.GetProfileByGUID, {}, {idToBeReplaced : entityId}); - (self.getEntity(url, options, entityId, self.getProfileCallbacks())).then(function(response) { - promise.fulfilled(response); - }, - function(error) { - promise.rejected(error); - }); - }, - function(error) { - promise.rejected(error); - } - ); - return promise; - }, - - /** - * Get the contact details of a user. - * - * @method getContact - * @param {String} userId Userid of the profile - * @param {Object} args Argument object - */ - getContact : function(userId, args) { - var idObject = this._toIdObject(userId); - var promise = this._validateIdObject(idObject); - if (promise) { - return promise; - } + return this.getEntities(url, options, this.getFileFeedCallbacks()); + }, + /** + * Get files shared with logged in user from IBM Connections + * + * @method getFilesSharedWithMe + * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getFilesSharedWithMe : function(args) { - var requestArgs = lang.mixin(idObject, args || {format:"json"}); - var options = { - method : "GET", - handleAs : "json", - query : requestArgs - }; - var entityId = idObject.userid; - var url = this.constructUrl(Consts.GetContactByGUID, {}, {idToBeReplaced : entityId}); - return this.getEntity(url, options, entityId, this.getProfileCallbacks()); - }, - - /** - * Get the contact details of a user. - * - * @method getContactByGUID - * @param {String} userId Userid of the profile - * @param {Object} args Argument object - * @deprecated Use getContact instead. - */ - getContactByGUID : function(userId, args) { - return this.getContact(userId, args); - }, - - /** - * Get logged in user's Connections - * - * @method getMyConnections - * @param {Object} args Argument object - */ - getMyConnections : function(args) { - var options = { - method : "GET", - handleAs : "json", - query : args || {format:"json"} - }; - return this.getEntities(Consts.GetMyConnections, options, this.getProfileFeedCallbacks()); - }, - - /** - * Get logged in user's Contacts - * - * @method getMyContacts - * @param {Object} args Argument object - */ - getMyContacts : function(args) { - var options = { - method : "GET", - handleAs : "json", - query : args || {format:"json"} - }; - return this.getEntities(Consts.GetMyContacts, options, this.getProfileFeedCallbacks()); - }, - - /** - * Get logged in user's Contacts considering the startIndex and count as provided by the user - * - * @method getMyContactsByIndex - * @param startIndex - * @param count - * @param {Object} args Argument object - */ - getMyContactsByIndex : function(startIndex, count, args) { - var requestArgs = { "startIndex" : startIndex, "count" : count }; - var options = { - method : "GET", - handleAs : "json", - query : lang.mixin(requestArgs , args || {format:"json"}) - }; - return this.getEntities(Consts.GetMyContacts, options, this.getProfileFeedCallbacks()); - }, - - /** - * Return callbacks for a profile entry - **/ - getProfileCallbacks : function() { - return ProfileCallbacks; - }, - - /** - * Return callbacks for a profile feed - **/ - getProfileFeedCallbacks : function() { - return ProfileFeedCallbacks; - }, - - _toIdObject : function(profileOrId) { - var idObject = {}; - if (lang.isString(profileOrId)) { - idObject.userid = profileOrId; - } else if (profileOrId instanceof Profile) { - idObject.userid = profileOrId.getUserid(); - } - return idObject; - }, - - _validateIdObject : function(idObject) { - if (!idObject.userid) { - return this.createBadRequestPromise("Invalid argument, userid must be specified."); - } - }, - _validateProfileId : function(profileId) { - if (!profileId || profileId.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected userid"); - } - } - }); - return ProfileService; -}); + var options = { + method : "GET", + handleAs : "text", -}, -'url:sbt/connections/controls/search/templates/li.html':"
  • ${content}
  • ", -'url:sbt/connections/controls/forums/templates/ReplyHeader.html':"\r\n\t${nls.replies}\r\n\t${nls.topic}\r\n\t\r\n\t${nls.author}\r\n\t${nls.date}\r\n", -'sbt/connections/controls/profiles/nls/ProfileTagsGridRenderer':function(){ -/* - * © 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. - */ + query : lang.mixin({ + direction : "inbound" + }, args ? args : {}) + }; -// NLS_CHARSET=UTF-8 -define({ - root: { - taggedByPerson : "Tagged by 1 person:", - taggedByPeople : "Tagged by {numberOfContributors} people:", - taggedByMe : "My tags for this profile:", - taggedBy : "Tagged by {tagSource}:" - } -}); + return this.getEntities(consts.AtomFilesShared, options, this.getFileFeedCallbacks()); + }, + /** + * Get files shared by the logged in user from IBM Connections + * + * @method getFilesSharedByMe + * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getFilesSharedByMe : function(args) { - -}, -'url:sbt/connections/controls/vcard/templates/ProfileVCard.html':"\r\n ${userName}\r\n ${userId}\r\n", -'url:sbt/connections/controls/forums/templates/ForumRow.html':"\r\n
    \r\n \r\n

    \r\n \r\n ${title}\r\n \r\n ${title}\r\n

    \r\n \r\n ${threadCount}\r\n \r\n ${getDateLabel}
    ${authorName}\r\n\r\n\r\n", -'url:sbt/connections/controls/communities/templates/BootstrapCommunityRow.html':"\r\n\t\r\n\t\t\r\n\t\t${title}\r\n\t\r\n", -'url:sbt/connections/controls/communities/templates/CommunityMemberRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.role}: ${role}
    \r\n\t\t\t
    ${nls.email} ${email}
    \r\n\t\t\t\r\n\t\t\t\t${nls.edit}    \r\n\t\t\t\t${nls.remove}\r\n\t\t\t\r\n\t\t\t
    \r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t${nls.role}:\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t
    \r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n", -'url:sbt/smartcloud/controls/profiles/templates/ProfilePanel.html':"
    \r\n\t
    \r\n\t\t
    \r\n\t\t\t\"${getThumbnailAlt}\"\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t${getDisplayName}\r\n\t\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t${getAbout}\r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n
    ", -'sbt/defer':function(){ -/* - * © 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. - */ + var options = { + method : "GET", + handleAs : "text", -/** - * Defer plugin. - * @author Carlos Manias - */ -define([], function(text) { - return { - load: function (id, require, load) { - require([id], function (value) { - load(value); - }); - } - }; -}); + query : lang.mixin({ + direction : "outbound" + }, args ? args : {}) + }; -}, -'url:sbt/connections/controls/files/templates/CommentRow.html':"\r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \"\"\r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n ${commentEditedLabel}\r\n \r\n \r\n \t\t\t\t\t\t\t${authorName}\r\n \t\t\t\t\t\t\t${authorUserId}\r\n \t\t\t\t\t\t\t\r\n \t\t\t\t\t\t\t\r\n ${_nls.commented} ${createdLabel}\r\n \r\n
    \r\n
    \r\n
    \r\n ${formattedContent}
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n", -'sbt/itemFactory':function(){ -/* - * © 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. - */ + return this.getEntities(consts.AtomFilesShared, options, this.getFileFeedCallbacks()); + }, + /** + * Get public files from IBM Connections + * + * @method getPublicFiles + * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getPublicFiles : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {}, + headers : {} + }; -/** - * I18n utilities - */ -define(["./lang", "./xpath", "./base/core"], function(lang, xpath, core) { - - var XPathCountFunction = /^count\(.*\)$/; + return this.getEntities(consts.AtomFilesPublic, options, this.getFileFeedCallbacks()); + }, + /** + * Get my folders from IBM Connections + * + * @method getMyFolders + * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getMyFolders : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; - /** - * @module sbt.itemFactory - */ - return { - - createItems: function(document, attributes, thisObject, decoder) { - var nodes = xpath.selectNodes(document, core.feedXPath.entry, core.namespaces); - var items = []; - if (nodes.length == 0) { - nodes = xpath.selectNodes(document, "a:entry", core.namespaces); - } - for (var i=0; i
    "; - var CategoryMember = ""; - var CategoryServiceConfig = "" - - var ServiceConfigsDataHandler = declare(XmlDataHandler, { - /** - * @method getSummary - * @returns - */ - getSummary : function() { - var languageTermsArray = this._selectArray("language"); - var languageLabelsArray = this._selectArray("languageLabels"); - var displayLanguagesMap = []; - for(var i=0;i Rest API used : /files/basic/api/communitylibrary//document//feed + * + * @method addCommentToCommunityFile + * @param {String} fileId + * @param {String} comment + * @param {String} communityId + * @param {Object} [args] + * @return {Comment} comment + */ + addCommentToCommunityFile : function(fileId, comment, communityId, args) { + var url = this.constructUrl(consts.AtomAddCommentToCommunityFile, null, { + communityId : communityId, + documentId : fileId + }); + return this.addCommentToFile(null, fileId, comment, url, args); + }, - xpath : consts.MemberXPath, - namespaces : consts.Namespaces, - categoryScheme : CategoryMember, - - /** - * Construct a Member entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Return the value of IBM Connections bookmark URL from bookmark ATOM - * entry document. - * - * @method getUrl - * @return {String} Bookmark URL of the bookmark - */ - getRole : function() { - return this.getAsString("role"); - } - }); - - /** - * ReportEntry class represents the elements in a report created to flag inappropriate content. - * - * @class ReportEntry - * @namespace sbt.connections - */ - var ReportEntry = declare(AtomEntity, { + /** + * Update the Atom document representation of the metadata for a file from logged in user's library. + * + * @method updateFileMetadata + * @param {Object} fileOrJson file or json representing the file to be updated + * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + updateFileMetadata : function(fileOrJson, url, args) { - xpath : consts.ReportEntryXPath, - namespaces : consts.Namespaces, - - /** - * Construct a ReportEntry entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Returns the type of issue reported - * The default values are: - * 001 - * Legal issue - * 002 - * Human resource issue - * - * @method getCategoryIssue - * @return {String} Issue type - */ - getCategoryIssue : function() { - return this.getAsString("categoryIssue"); - }, - - /** - * Return the related link url entry that you want to flag - * - * @method getReportedItemLink - * @return {String} Reported item link url - */ - getReportedItemLink : function() { - return this.getAsString("reportItemLink"); - }, - - /** - * Return the related link url of the ATOM entry document .Required when flagging blog posts or blog comnments - * - * @method getRelatedLink - * @return {String} Related link url - */ - getRelatedLink : function() { - return this.getAsString("relatedLink"); - }, - - /** - * Return the id of the concerned entry - * - * @method getReferredEntryId - * @return {String} Reported item id - */ - getReferredEntryId : function() { - return this.getAsString("inRefTo"); - } - }); - - /** - * ReportEntry class represents the elements in a report created to flag inappropriate content. - * - * @class ReportEntry - * @namespace sbt.connections - */ - var ModerationActionEntry = declare(AtomEntity, { + var promise = this.validateField("fileOrJson", fileOrJson); + if (promise) { + return promise; + } - xpath : consts.ModerationActionEntryXPath, - namespaces : consts.Namespaces, - - /** - * Construct a ModerationActionEntry entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Returns the type of moderation action to be taken - * The options for premoderation are: - * approve - * reject - * The options for post-moderation are: - * dismiss - * quarantine - * restore - * For Blogs, the option return is also supported for post-moderation of posts, but not comments. - * - * @method getModerationAction - * @return {String} Issue type - */ - getModerationAction : function() { - return this.getAsString("moderationAction"); - }, - - /** - * Return the related link url of the entry on which you want to take action using a link element. - * This element is used in the Blogs API. - * - * @method getRelatedLink - * @return {String} Related link url - */ - getRelatedLink : function() { - return this.getAsString("relatedLink"); - }, - - /** - * Return the resource-id of the concerned entry - * - * @method getReferredEntryId - * @return {String} Moderated item id - */ - getReferredEntryId : function() { - return this.getAsString("inRefTo"); - } - }); - - /* - * Callbacks used when reading a connections service configs feed. - */ - var ConnectionsServiceConfigsCallbacks = { - createEntities : function(service,data,response) { - return new ServiceConfigsDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.ConnectionsServiceDocsFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new ServiceConfig({ - service : service, - data : data, - response : response - }); - } - }; + var file = this.newFile(fileOrJson); + var options = { + method : "PUT", + query : args || {}, + headers : consts.AtomXmlHeaders, + data : this._constructPayload(file._fields, file.getFileId()) + }; - /** - * ConnectionService class. - * - * @class ConnectionService - * @namespace sbt.connections - */ - var ConnectionsService = declare(BaseService, { + if (!url) { + url = this.constructUrl(consts.AtomUpdateFileMetadata, null, { + documentId : file.getFileId() + }); + } + return this.updateEntity(url, options, this.getFileFeedCallbacks()); + }, - /** - * Constructor for ConnectionsService - * - * @constructor - * @param args - */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } - }, + /** + * Method to update Community File's Metadata

    Rest API used : /files/basic/api/library//document//entry

    + * @method updateCommunityFileMetadata + * @param {Object} fileOrJson + * @param {String} libraryId + * @param {Object} [args] + * @return {File} + */ + updateCommunityFileMetadata : function(fileOrJson, communityId, args) { + var promise = this.validateField("fileOrJson", fileOrJson); + if (promise) { + return promise; + } + var file = this.newFile(fileOrJson); + promise = new Promise(); + var _this = this; + var update = function() { + var url = _this.constructUrl(consts.AtomUpdateCommunityFileMetadata, null, { + libraryId : file.getLibraryId(), + documentId : file.getFileId() + }); + _this.updateFileMetadata(file, url, args).then(function(file) { + promise.fulfilled(file); + }, function(error) { + promise.rejected(error); + }); + }; + if (file.isLoaded()) { + update(); + } else { + var url = _this.constructUrl(consts.AtomGetCommunityFile, null, { + communityId : communityId, + documentId : file.getFileId() + }); + file.load(null, null, url).then(function() { + update(); + }, function(error) { + promise.rejected(error); + }); + } + return promise; + }, - /** - * Return the default endpoint name if client did not specify one. - * @returns {String} - */ - getDefaultEndpointName : function() { - return "connections"; - }, - - /** - * Retrieve configuration information for the server. - * - * @method getServiceConfigs - * - */ - getServiceConfigEntries : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - url = this.constructUrl(consts.ServiceConfigs, null, { - service : this.serviceName - }); - return this.getEntities(url, options, ConnectionsServiceConfigsCallbacks); - } + /** + * Pin a file, by sending a POST request to the myfavorites feed. + * + * @method pinFile + * @param {String} fileId ID of file which needs to be pinned + * @param {Object} [args] Argument object. + */ + pinFile : function(fileId, args) { - }); - return ConnectionsService; -}); -}, -'sbt/connections/controls/files/FileGrid':function(){ -/* - * © 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. - */ + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; + } + var parameters = args ? lang.mixin({}, args) : {}; + parameters["itemId"] = fileId; -/** - * - */ -define( - [ "../../../declare", "../../../lang", "../../../dom", - "../../../stringUtil", "../../../config", - "../../../store/parameter", "../../../controls/grid/Grid", - "./FileGridRenderer", "./FileAction", - "../../../connections/controls/vcard/SemanticTagService", - "../../../connections/FileService", - "../../../connections/FileConstants" ], -function(declare, lang, dom, stringUtil, sbt, parameter, Grid, - FileGridRenderer, FileAction, SemanticTagService, FileService, - FileConstants) { + var options = { + method : "POST", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + }, + query : parameters + }; - var sortVals = { - name : "title", - updated : "modified", - downloads : "downloaded", - comments : "commented", - likes : "recommended", - files : "itemCount", - created : "created", - modified : "modified" - }; + var callbacks = { + createEntity : function(service, data, response) { + return "Success"; + } + }; - var ParamSchema = { - pageNumber : parameter.oneBasedInteger("page"), - pageSize : parameter.oneBasedInteger("ps"), - sortBy : parameter.sortField("sortBy", sortVals), - sortOrder : parameter.sortOrder("sortOrder") - }; + return this.updateEntity(consts.AtomPinFile, options, callbacks); - /** - * @class FileGrid - * @namespace sbt.connections.controls.files - * @module sbt.connections.controls.files.FileGrid - */ - var FileGrid = declare( - Grid, - { + }, - gridSortType : "", - fileService : null, + /** + * Unpin a file, by sending a DELETE request to the myfavorites feed. + * + * @method unpinFile + * @param {String} fileId ID of file which needs to be unpinned + * @param {Object} [args] Argument object. + */ + unpinFile : function(fileId, args) { + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; + } - /** - * Options determine which type of file grid will be - * created - */ - options : { - "myFiles" : { - storeArgs : { - url : FileConstants.AtomFilesMy, - attributes : FileConstants.FileXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "file" - } - }, - "publicFiles" : { - storeArgs : { - url : FileConstants.AtomFilesPublic, - attributes : FileConstants.FileXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "file" - } - }, - "myPinnedFiles" : { - storeArgs : { - url : FileConstants.AtomFilesMyPinned, - attributes : FileConstants.FileXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "file" - } - }, - "myFolders" : { - storeArgs : { - url : FileConstants.AtomFoldersMy, - attributes : FileConstants.FolderXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "folder" - } - }, - "publicFolders" : { - storeArgs : { - url : FileConstants.AtomFoldersPublic, - attributes : FileConstants.FolderXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "folder" - } - }, - "myPinnedFolders" : { - storeArgs : { - url : FileConstants.AtomGetPinnedFolders, - attributes : FileConstants.FolderXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "folder" - } - }, - "activeFolders" : { - storeArgs : { - url : FileConstants.AtomFoldersActive, - attributes : FileConstants.FolderXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "folder" - } - }, - "recycledFiles" : { - storeArgs : { - url : FileConstants.AtomFilesRecycled, - attributes : FileConstants.FileXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "recycledFile" - } - }, - "myFileComments" : { - storeArgs : { - url : FileConstants.AtomFileCommentsMy, - attributes : FileConstants.CommentXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "comment" - } - }, - "fileShares" : { - storeArgs : { - url : FileConstants.AtomFilesShared, - attributes : FileConstants.FileXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "file" - } - }, - "communityFiles" : { - storeArgs : { - url : FileConstants.AtomGetAllCommunityFiles, - attributes : FileConstants.FileXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "file" - } - }, - "filesSharedByMe" : { - storeArgs : { - url : FileConstants.AtomFilesShared, - attributes : FileConstants.FileXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "file" - } - }, - "filesSharedWithMe" : { - storeArgs : { - url : FileConstants.AtomFilesShared, - attributes : FileConstants.FileXPath, - paramSchema : ParamSchema - }, - rendererArgs : { - type : "file" - } - } + var parameters = args ? lang.mixin({}, args) : {}; + parameters["itemId"] = fileId; + var options = { + method : "DELETE", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" }, + query : parameters + }; - contextRootMap : { - files : "files" - }, + return this.deleteEntity(consts.AtomPinFile, options, fileId); - /** - * The default grid, if no options are selected - */ - defaultOption : "publicFiles", + }, - /** - * FileAction defines the default actions for files, - * which can be overridden - */ - fileAction : null, + /** + * Add a file or files to a folder. + * + * You cannot add a file from your local directory to a folder; the file must already have been uploaded to the Files application. To add a file + * to a folder you must be an editor of the folder. + * + * @method addFilesToFolder + * @param {String} folderId the Id of the folder + * @param {List} fileIds list of file Ids to be added to the folder + * @param {Object} [args] Argument object. + */ + addFilesToFolder : function(fileIds, folderId, args) { - /** - * Constructor function - * - * @method constructor - */ - constructor : function(args) { - - this.fileAction = new FileAction(this), - - this.fileService = new FileService(args); - - /** - * gridSortType is used to determine what sorting - * anchors should be used, for example folders have - * different sort anchors than files, file comments - * have no anchors etc - */ - if (args.type == "fileShares" - || args.type == "library" - || args.type == "pinnedFiles") { - gridSortType = "file"; - } else if (args.type == "fileComments" - || args.type == "recycledFiles") { - gridSortType = ""; - } else if (args.type == "publicFiles") { - gridSortType = "publicFiles"; - } else { - gridSortType = "folder"; - } + var promise = this.validateField("fileIds", fileIds); + if (!promise) { + promise = this.validateField("folderId", folderId); + } - var nls = this.renderer.nls; - this._sortInfo = { - name : { - title : nls.name, - sortMethod : "sortByName", - sortParameter : "name" - }, - updated : { - title : nls.updated, - sortMethod : "sortByLastUpdated", - sortParameter : "updated" - }, - downloads : { - title : nls.downloads, - sortMethod : "sortByDownloads", - sortParameter : "downloads" - }, - comments : { - title : nls.comments, - sortMethod : "sortByComments", - sortParameter : "comments" - }, - likes : { - title : nls.likes, - sortMethod : "sortByLikes", - sortParameter : "likes" - }, - created : { - title : nls.created, - sortMethod : "sortByCreatedDate", - sortParameter : "created" - }, - files : { - title : nls.files, - sortMethod : "sortByNumberOfFiles", - sortParameter : "files" - } - }; + var options = { + method : "POST", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + } + }; + var url = this.constructUrl(consts.AtomAddFilesToFolder, null, { + collectionId : folderId + }); - if (args.type == "publicFiles") { - this._activeSortAnchor = this._sortInfo.created; - this._activeSortIsDesc = false; - } else if (args.type == "folders") { - this._activeSortAnchor = this._sortInfo.name; - this._activeSortIsDesc = true; - } else { - this._activeSortAnchor = this._sortInfo.updated; - this._activeSortIsDesc = true; - } + var separatorChar = "?"; + for ( var counter in fileIds) { + url += separatorChar + "itemId=" + fileIds[counter]; + separatorChar = "&"; + } - if (args && args.pinFile) { - this.renderer.pinFiles = args.pinFile; - } + var callbacks = { + createEntity : function(service, data, response) { + return "Success"; + } + }; - }, + return this.updateEntity(url, options, callbacks); - /** - * Override buildUrl to add direction, userId and fileId - * - * @method buildUrl - * @param url - * base url - * @param args - * arguments that will be passed to the store - * @param endpoint - * An endpoint which may contain custom - * service mappings. - * @returns Built url - */ - buildUrl : function(url, args, endpoint) { - var params = { - format : this.format - }; + }, - if (this.query) { - params = lang.mixin(params, this.query); - } - if (this.direction) { - params = lang.mixin(params, { - direction : this.direction - }); - } - if(this.type == "filesSharedWithMe"){ - params = lang.mixin(params, { - direction : "inbound" - }); - }else if (this.type == "filesSharedByMe"){ - params = lang.mixin(params, { - direction : "outbound" - }); - } + /** + * Gets the files pinned by the logged in user. + * + * @method getPinnedFiles + * @param {Object} [args] Argument object for the additional parameters like pageSize etc. + */ + getPinnedFiles : function(args) { - return this.constructUrl(url, params, this - .getUrlParams(), endpoint); - }, + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; - /** - * Return the url parameters to be used - * - * @returns {Object} - */ - getUrlParams : function() { - var params = { - authType : this.getAuthType() - }; + return this.getEntities(consts.AtomFilesMyPinned, options, this.getFileFeedCallbacks()); + }, - if (this.userId) { - params = lang.mixin(params, { - userId : this.userId - }); - } - if (this.documentId) { - params = lang.mixin(params, { - documentId : this.documentId - }); - } - - if(this.communityId){ - params = lang.mixin(params, { - communityId : this.communityId - }); - } + /** + * Delete a file. + * + * @method deleteFile + * @param {String} fileId Id of the file which needs to be deleted + * @param {Object} [args] Argument object + */ + deleteFile : function(fileId, args) { - return params; - }, + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; + } - /** - * Instantiates a FileGridRenderer - * - * @method createDefaultRenderer - * @param args - * @returns {FileGridRenderer} - */ - createDefaultRenderer : function(args) { - return new FileGridRenderer(args,this); + var options = { + method : "DELETE", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + } + }; + var url = this.constructUrl(consts.AtomDeleteFile, null, { + documentId : fileId + }); + + return this.deleteEntity(url, options, fileId); + }, + + /** + * Lock a file + * + * @method lockFile + * @param {String} fileId Id of the file which needs to be locked + * @param {Object} [args] Argument object + */ + lockFile : function(fileId, args) { + var parameters = args ? lang.mixin({}, args) : {}; + parameters["type"] = "HARD"; + + var options = { + method : "POST", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" }, + query : args || {} + }; + var url = this.constructUrl(consts.AtomLockUnlockFile, parameters, { + documentId : fileId + }); - /** - * Called after the grid is created The - * semanticTagService is loaded, which is responsible - * for displaying business card functionality. - * - * @method postCreate - */ - postCreate : function() { - this.inherited(arguments); - if(this.displayBusinessCard){ - SemanticTagService.loadSemanticTagService(); - } + var callbacks = { + createEntity : function(service, data, response) { + return "Success"; + } + }; + + return this.updateEntity(url, options, callbacks, args); + }, + + /** + * unlock a file + * + * @method lockFile + * @param {String} fileId Id of the file which needs to be unlocked + * @param {Object} [args] Argument object + */ + unlockFile : function(fileId, args) { + var parameters = args ? lang.mixin({}, args) : {}; + parameters["type"] = "NONE"; + + var options = { + method : "POST", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" }, + query : args || {} + }; + var url = this.constructUrl(consts.AtomLockUnlockFile, parameters, { + documentId : fileId + }); - /** - * Event handler for onClick events - * - * @method handleClick - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - handleClick : function(el, data, ev) { - if (this.fileAction) { - this._stopEvent(ev); + var callbacks = { + createEntity : function(service, data, response) { + return "Success"; + } + }; - this.fileAction.execute(data, { - grid : this.grid - }, ev); - } - }, + return this.updateEntity(url, options, callbacks, args); + }, - /** - * @method getSortInfo - * @returns A List of Strings,that describe how the grid - * can be sorted - */ - getSortInfo : function() { - if (gridSortType == "file") { + /** + * Uploads a new file for logged in user. + * + * @method uploadFile + * @param {Object} fileControlOrId The Id of html control or the html control + * @param {Object} [args] The additional parameters for upload + */ + uploadFile : function(fileControlOrId, args) { - return { - active : { - anchor : this._activeSortAnchor, - isDesc : this._activeSortIsDesc - }, - list : [ this._sortInfo.name, - this._sortInfo.updated, - this._sortInfo.downloads, - this._sortInfo.comments, - this._sortInfo.likes ] - }; - } else if (gridSortType == "folder") { - return { - active : { - anchor : this._activeSortAnchor, - isDesc : this._activeSortIsDesc - }, - list : [ this._sortInfo.name, - this._sortInfo.updated, - this._sortInfo.created, - this._sortInfo.files ] - }; - } else if (gridSortType == "publicFiles") { - return { - active : { - anchor : this._activeSortAnchor, - isDesc : this._activeSortIsDesc - }, - list : [ this._sortInfo.created, - this._sortInfo.downloads, - this._sortInfo.comments, - this._sortInfo.likes ] - }; - } - }, + var promise = this.validateField("File Control Or Id", fileControlOrId); + if (promise) { + return promise; + } + promise = this.validateHTML5FileSupport(); + if (promise) { + return promise; + } + + var files = null; + if (typeof fileControlOrId == "string") { + var fileControl = document.getElementById(fileControlOrId); + files = fileControl.files; + } else if (typeof fileControlOrId == "object") { + files = fileControlOrId.files; + } else { + return this.createBadRequestPromise("File Control or ID is required"); + } + + if (files.length == 0) { + return this.createBadRequestPromise("No files selected for upload"); + } - /** - * Sort the grid rows by name - * - * @method sortByName - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - sortByName : function(el, data, ev) { - this._sort("name", true, el, data, ev); - }, + var file = files[0]; + var data = new FormData(); + data.append("file", file); - /** - * Sort the grid rows by last modified date - * - * @method sortByLastUpdated - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - sortByLastUpdated : function(el, data, ev) { - this._sort("updated", true, el, data, ev); - }, + return this.uploadFileBinary(data, file.name, args); + }, - /** - * Sort the grid rows by the amount of times a file has - * been downloaded. - * - * @method sortByDownloads - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - sortByDownloads : function(el, data, ev) { - this._sort("downloads", true, el, data, ev); - }, + /** + * Uploads a new file for logged in user. + * + * @method uploadFile + * @param {Object} binaryContent The binary content of the file + * @param {String} filename The name of the file + * @param {Object} [args] The additional parameters of metadata of file for upload like visibility, tag, etc. + */ + uploadFileBinary : function(binaryContent, fileName, args) { - /** - * Sort the grid rows by the amount of comments a file - * has. - * - * @method sortByComments - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - sortByComments : function(el, data, ev) { - this._sort("comments", true, el, data, ev); - }, + var promise = this.validateField("Binary Content", binaryContent); + if (promise) { + return promise; + } + promise = this.validateField("File Name", fileName); + if (promise) { + return promise; + } + if (util.getJavaScriptLibrary().indexOf("Dojo 1.4.3") != -1) { + return this.createBadRequestPromise("Dojo 1.4.3 is not supported for File upload"); + } + // /files/<>/<>/<>/fileName eg. /files/smartcloud/connections/UploadFile/fileName?args + var url = this.constructUrl(config.Properties.serviceUrl + "/files/" + this.endpoint.proxyPath + "/" + "connections" + "/" + "UploadFile" + + "/" + encodeURIComponent(fileName), args && args.parameters ? args.parameters : {}); + var headers = { + "Content-Type" : false, + "Process-Data" : false // processData = false is reaquired by jquery + }; + var options = { + method : "POST", + headers : headers, + query : args || {}, + data : binaryContent + }; - /** - * Sort the grid rows by the number of "likes" that a - * file has. - * - * @method sortByLikes - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - sortByLikes : function(el, data, ev) { - this._sort("likes", true, el, data, ev); - }, + return this.updateEntity(url, options, this.getFileFeedCallbacks()); + }, - /** - * Sort the grid rows by when the files were first - * created - * - * @method sortByCreatedDate - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - sortByCreatedDate : function(el, data, ev) { - this._sort("created", true, el, data, ev); - }, + /** + * Upload new version of a file. + * + * @method uploadNewVersion + * @param {Object} fileId The ID of the file + * @param {Object} fileControlOrId The Id of html control or the html control + * @param {Object} [args] The additional parameters ffor updating file metadata + */ + uploadNewVersion : function(fileId, fileControlOrId, args) { - /** - * Sorts the grid, based on the number of files - * contained in each folder. This is for grids that - * display folders. - * - * @method sortByNumberOfFiles - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - sortByNumberOfFiles : function(el, data, ev) { - this._sort("files", true, el, data, ev); - }, + var promise = this.validateField("File Control Or Id", fileControlOrId); + if (!promise) { + promise = this.validateField("File ID", fileId); + } + if (promise) { + return promise; + } + promise = this.validateHTML5FileSupport(); + if (promise) { + return promise; + } + var files = null; + if (typeof fileControlOrId == "string") { + var fileControl = document.getElementById(fileControlOrId); + filePath = fileControl.value; + files = fileControl.files; + } else if (typeof fileControlOrId == "object") { + filePath = fileControlOrId.value; + files = fileControlOrId.files; + } else { + return this.createBadRequestPromise("File Control or ID is required"); + } - /** - * Event handler to show and hide the more options in - * the files grid - * - * @method showMore - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - showMore : function(el, data, ev) { - /** TODO to be implemented in iteration 9 */ - }, + var file = files[0]; + var data = new FormData(); + data.append("file", file); - /** - * @method onUpdate This is called after the grid is - * updated In this implementation, a list of - * pinned files is received from the server then - * all of the pin file links, are retrieved by - * class name, then if the file is a pinned - * file, its css class will be changed to - * reflect this NOTE: this function will only - * execute, if file pin functionality is passed - * as an argument to the grid - */ - onUpdate : function() { + return this.uploadNewVersionBinary(data, fileId, file.name, args); + }, - if (this.renderer.pinFiles) { + /** + * Uploads new Version of a File. + * + * @method uploadNewVersionBinary + * @param {Object} binaryContent The binary content of the file + * @param {String} fileId The ID of the file + * @param {Object} [args] The additional parameters for upding file metadata + */ + uploadNewVersionBinary : function(binaryContent, fileId, fileName, args) { - // Get all of the pin file img tags, we do this - // by classname - var pinElements = document - .getElementsByClassName(this.renderer.unPinnedClass); - // ids will hold the ID of each element, the id - // of the element is the uuid of the file. - var ids = []; - // set the Ids into the ids array - for ( var x = 0; x < pinElements.length; x++) { - ids[x] = pinElements[x].id; - } + var promise = this.validateField("Binary Content", binaryContent); + if (promise) { + return promise; + } + promise = this.validateField("File ID", fileId); + if (promise) { + return promise; + } + promise = this.validateField("File Name", fileName); + if (promise) { + return promise; + } + if (util.getJavaScriptLibrary().indexOf("Dojo 1.4.3") != -1) { + return this.createBadRequestPromise("Dojo 1.4.3 is not supported for File Upload"); + } + // /files/<>/<>/<>/fileId?args eg./files/smartcloud/connections/UpdateFile/fileId/fileName?args + var url = this.constructUrl(config.Properties.serviceUrl + "/files/" + this.endpoint.proxyPath + "/" + "connections" + "/" + + "UploadNewVersion" + "/" + encodeURIComponent(fileId) + "/" + encodeURIComponent(fileName), + args && args.parameters ? args.parameters : {}); + var headers = { + "Content-Type" : false, + "Process-Data" : false // processData = false is reaquired by jquery + }; + var options = { + method : "PUT", + headers : headers, + data : binaryContent + }; + var promise = new Promise(); + var _this = this; - // create an args object containing these three - // vars to hitch. - var pinClass = this.renderer.pinnedClass; - var unPinnedClass = this.renderer.unPinnedClass - var renderer = this.renderer; - var args = { - pinClass : pinClass, - unPinnedClass : unPinnedClass, - ids : ids, - renderer : renderer - }; + this.updateEntity(url, options, this.getFileFeedCallbacks()).then(function(file) { + if (args) { + _this.updateFile(file.getFileId(), args).then(function(updatedFile) { + promise.fulfilled(updatedFile); + }); + } else { + promise.fulfilled(file); + } + }, function(error) { + promise.rejected(error); + }); + return promise; + }, - // we use the array of ids, and not the array of - // elements - // because as we remove a class from an element, - // the array of elements will dynamically reduce - this - ._hitch( - args, - this.fileService - .getPinnedFiles() - .then( - function(files) { - for ( var k = 0; k < args.ids.length; k++) { - for ( var i = 0; i < files.length; i++) { - if (args.ids[k] == files[i] - .getId()) { - args.renderer - ._removeClass( - args.ids[k], - args.unPinnedClass); - args.renderer - ._addClass( - args.ids[k], - args.pinClass); - } - } - } - }, - function(error) { - console - .log("error getting pinned files"); - })); + /** + * Updates metadata of a file programatically using a PUT call + * @param [String] fileId the File ID + * @param [Object] args The parameters for update. Supported Input parameters are commentNotification, created, identifier, includePath, + * mediaNotification, modified, recommendation, removeTag, sendNotification, sharePermission, shareSummary, shareWith, tag and visibility + * @returns + */ + updateFile : function(fileId, args) { + var promise = this.validateField("File ID", fileId); + if (promise) { + return promise; + } + var url = this.constructUrl(consts.AtomFileInstance, null, { + documentId : fileId + }); + var separatorChar = "?"; + if (args && args.tags) { + var tags = args.tags.split(","); + for ( var counter in tags) { + url += separatorChar + "tag=" + stringUtil.trim(tags[counter]); + separatorChar = "&"; + } + delete args.tags; + } + if (args && args.removeTags) { + var removeTags = args.removeTags.split(","); + for ( var counter in removeTags) { + url += separatorChar + "removeTag=" + stringUtil.trim(removeTags[counter]); + separatorChar = "&"; + } + delete args.removeTags; + } - } + var options = { + method : "PUT", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" }, + query : args || {} + }; - /** - * This function pins(favourites) a file, It will send a - * request to the server using the file service API, And - * when the request returns successfully, the css clas - * of the link will be change to reflect that the file - * is now pinned. If the file is already pinned, it will - * remove the pin from the file. - * - * @method doPinFile - * @param el - * The element that fired the event - * @param data - * The data associated with this table row - * @param ev - * The event, onclick - */ - doPinFile : function(el, data, ev) { - var uuid = ""; - if (data.getValue("uid")) { - uuid = data.getValue("uid"); - } + return this.updateEntity(url, options, this.getFileFeedCallbacks()); + }, - // create an args object containing these three vars - // to hitch. - var pinClass = this.renderer.pinnedClass; - var unPinnedClass = this.renderer.unPinnedClass; - var renderer = this.renderer; - var args = { - pinClass : pinClass, - unPinnedClass : unPinnedClass, - el : el, - renderer : renderer - }; + /** + * Downloads a file. + * + * @method downloadFile + * @param {String} fileId The ID of the file + * @param {String} libraryId The library ID of the file + */ + downloadFile : function(fileId, libraryId) { + var url = config.Properties.serviceUrl + "/files/" + this.endpoint.proxyPath + "/" + "connections" + "/" + "DownloadFile" + "/" + fileId + + "/" + libraryId; + window.open(url); + }, - if (el.firstElementChild.className == this.renderer.unPinnedClass) { - this - ._hitch( - args, - this.fileService - .pinFile(uuid) - .then( - function( - response) { - args.renderer - ._removeClass( - args.el.firstElementChild, - args.unPinnedClass); - args.renderer - ._addClass( - args.el.firstElementChild, - args.pinClass); + actOnCommentAwaitingApproval : function(commentId, action, actionReason) { + + }, + actOnFileAwaitingApproval : function(fileId, action, actionReason) { + + }, + /** + * Add a file to a folder or list of folders. + * + * You cannot add a file from your local directory to a folder; the file must already have been uploaded to the Files application. To add a file + * to a folder you must be an editor of the folder. + * + * @method addFilesToFolder + * @param {String} fileId the Id of the file + * @param {List} folderIds list of folder Ids + * @param {String} [userId] the userId of the user in case of own file + * @param {Object} [args] Argument object. + */ + addFileToFolders : function(fileId, folderIds, userId, args) { + var promise = this.validateField("fileId", fileId); + if (!promise) { + promise = this.validateField("folderIds", folderIds); + } + if (promise) { + return promise; + } - }, - function( - response) { - console - .log("Error pinning file"); - })); - } else if (el.firstElementChild.className == this.renderer.pinnedClass) { - this - ._hitch( - args, - this.fileService - .unpinFile(uuid) - .then( - function(data) { - args.renderer - ._removeClass( - args.el.firstElementChild, - args.pinClass); - args.renderer - ._addClass( - args.el.firstElementChild, - args.unPinnedClass); - }, - function(error) { - console - .log("error removing pin from file"); - })); - } + var url = null; - } + if (!userId) { + url = this.constructUrl(consts.AtomAddMyFileToFolders, null, { + documentId : fileId + }); + } else { + url = this.constructUrl(consts.AtomAddFileToFolders, null, { + userId : userId, + documentId : fileId + }); + } - // Internals + var payload = this._constructPayloadForMultipleEntries(folderIds, "itemId", "collection"); - }); + var options = { + method : "POST", + headers : consts.AtomXmlHeaders, + data : payload + }; - return FileGrid; -}); -}, -'sbt/text':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ + var callbacks = { + createEntity : function(service, data, response) { + } + }; -/** - * Social Business Toolkit SDK. - * @module sbt.text - */ -define(['./_bridge/text'],function(text) { - return text; -}); + return this.updateEntity(url, options, callbacks); + }, + /** + * Create a new Folder + * + * @method createFolder

    Rest API used : /files/basic/api/collections/feed + * + * @param {String} name name of the folder to be created + * @param {String} [description] description of the folder + * @param {String} [shareWith] If the folder needs to be shared, specify the details in this parameter.
    Pass Coma separated List of id, + * (person/community/group) or role(reader/Contributor/owner) in order + * @return {Object} Folder + */ + createFolder : function(name, description, shareWith) { + var promise = this.validateField("folderName", name); + if (promise) { + return promise; + } + var url = consts.AtomCreateFolder; + var payload = this._constructPayloadFolder(name, description, shareWith, "create"); + var options = { + method : "POST", + headers : lang.mixin(consts.AtomXmlHeaders, { + "X-Update-Nonce" : "{X-Update-Nonce}" + }), + data : payload + }; -}, -'sbt/_bridge/i18n':function(){ -/* - * © 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. - */ + return this.updateEntity(url, options, this.getFileFeedCallbacks()); -/** - * Social Business Toolkit SDK. - */ -define(['dojo/i18n', 'dojo/date/locale'],function(i18n, dateLocale) { - var load = function(id, require, callback){ - i18n.load(id, require, callback); - }; - - return { - load : load, - - getLocalizedTime: function(date) { - return dateLocale.format(date, { selector:"time",formatLength:"short" }); - }, - - getLocalizedDate: function(date) { - return dateLocale.format(date, { selector:"date",formatLength:"medium" }); - } - }; -}); + }, + /** + * Delete Files From Recycle Bin + * + * @param {String} userId The ID of user + */ + deleteAllFilesFromRecycleBin : function(userId) { + var url = null; -}, -'sbt/data/AtomReadStore':function(){ -/* - * © 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. - */ + if (!userId) { + url = consts.AtomDeleteMyFilesFromRecyclebBin; + } else { + url = this.constructUrl(consts.AtomDeleteAllFilesFromRecyclebBin, null, { + userId : userId + }); + } + var options = { + method : "DELETE" + }; + return this.deleteEntity(url, options, ""); + }, -/** - * @module sbt.data.AtomReadStore - */ -define(["../declare","../config", "../lang", "../base/core", "../xml", "../xpath", "../entities"], function(declare, config, lang, core, xml, xpath, entities) { - - /** - * A data store for Atom XML based services or documents. This store is still under development - * and doesn't support filtering or paging yet. - * - * @class AtomReadStore - * @namespace sbt.data - */ - var AtomReadStore = declare(null, { - // private - _endpoint : null, - _xmlData : null, - // read only - totalResults : 0, - startIndex : 0, - itemsPerPage : 5, - items : null, - // public - url : "", - sendQuery : true, - unescapeHTML : false, - urlPreventCache : false, - atom : core.feedXPath, - attributes : core.entryXPath, - namespaces : core.namespaces, - paramSchema: {}, - - /** - * Constructor for the AtomRead store. - * - * @param args - * An anonymous object to initialize properties. It expects the following values: - * url: The url to a service or an XML document that represents the store - * unescapeHTML: A boolean to specify whether or not to unescape HTML text - * sendQuery: A boolean indicate to add a query string to the service URL - * endpoint: the endpoint to be used - */ - constructor: function(args) { - this._endpoint = config.findEndpoint(args.endpoint || "connections"); + /** + * Delete all Versions of a File before the given version + * + * @param {String} fileId the ID of the file + * @param {String} [versionLabel] The version from which all will be deleted + * @param {Object} [args] additional arguments + */ + deleteAllVersionsOfFile : function(fileId, versionLabel, args) { - if (args) { - this.url = args.url; - this.attributes = args.attributes || this.attributes; - this.atom = args.feedXPath || this.atom; - this.namespaces = args.namespaces || this.namespaces; - this.paramSchema = args.paramSchema || this.paramSchema; - this.rewriteUrl = args.rewriteUrl; - this.label = args.label || this.label; - this.sendQuery = (args.sendQuery || args.sendquery || this.sendQuery); - this.unescapeHTML = args.unescapeHTML; - if ("urlPreventCache" in args) { - this.urlPreventCache = args.urlPreventCache ? true : false; - } - } - if(!this.url) { - throw new Error("sbt.data.AtomReadStore: A service URL must be specified when creating the data store"); - } - }, - - /** - * @method getEndpoint - * @returns - */ - getEndpoint: function() { - return this._endpoint; - }, - - setUrl: function(url){ - this.url = url; - }, - - getUrl: function(){ - return this.url; - }, - - setAttributes: function(attributes){ - this.attributes = attributes; - }, - - /* - * Returns defaultValue if and only if *item* does not have a value for *attribute*. - */ - getValue: function(item, attribute, defaultValue) { - var xpathCountFunction = /^count\(.*\)$/; - this._assertIsItem(item); - this._assertIsAttribute(attribute); - - if (!item._attribs[attribute]) { - var access = this.attributes[attribute]; - if (lang.isFunction(access)) { - item._attribs[attribute] = access(item, attribute); - }else if (access.match(xpathCountFunction)){ - item._attribs[attribute] = xpath.selectNumber(item.element, this.attributes[attribute], this.namespaces)+""; - } else { - var nodes = xpath.selectNodes(item.element, this.attributes[attribute], this.namespaces); - if (nodes && nodes.length == 1) { - item._attribs[attribute] = nodes[0].text || nodes[0].textContent; - } else if (nodes) { - item._attribs[attribute] = []; - for (var j=0; j\r\n ${name}\r\n ${uuid}\r\n ${selectedWidgetId}\r\n", -'sbt/smartcloud/controls/profiles/ColleagueGrid':function(){ -define(["../../../declare", - "./ProfileGrid", - "./ColleagueGridRenderer"], - function(declare,ProfileGrid,ColleagueGridRenderer){ - - var ColleagueGrid = declare(ProfileGrid,{ - - hideViewAll: false, - - createDefaultRenderer : function(args) { - return new ColleagueGridRenderer(args); - }, - - handleViewAll: function(item, opts, event){ - this.hideViewAll = true; - this.renderer.template = this.renderer.fullTemplate; - this.renderer.render(this, this.domNode, opts.items, opts); - - } - }); - - - - return ColleagueGrid; -}); -}, -'sbt/connections/controls/profiles/ProfileAction':function(){ -/* - * © 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. - */ + var options = { + method : "DELETE", + query : args || {}, + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + } + }; -/** - * - */ -define([ "../../../declare", "../../../controls/grid/GridAction" ], - function(declare, GridAction) { + return this.deleteEntity(url, options, commentId); + }, - /** - * @class ProfileAction - * @namespace sbt.connections.controls.profiles - * @module sbt.connections.controls.profiles.ProfileAction - */ - var ProfileAction = declare(GridAction, { - - /**Strings used in the actions */ - nls: { - tooltip: "Go to ${name}" - }, - - /**ProfileAction Constructor function - * @method constructor - * */ - constructor: function() { - }, - - /** - * Handles displaying a tooltip for an item - * For profiles, the tooltip by default will be a business card - * So nothing is done in this function - * @method getTooltip - * @param item The element that will use the tooltip - */ - getTooltip: function(item) { - - //for default the semantic tag service will pop up the business card - //so do nothing here + /** + * Delete File from RecycleBin of a user + * @param {String} fileId the Id of the file + * @param {String} [userId] the Id of the user + * @param {Object} args the additional arguments + * @returns + */ + deleteFileFromRecycleBin : function(fileId, userId, args) { + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; + } - }, - - /** - * The execute function is called from the handle click function - * For Profiles by default the business card functionality is used - * which works from the Semantic tag service so nothing is done here. - * @method execute - * @param item The item which fired the event - * @param grid The profile grid class - * @param event The event - */ - execute: function(item, grid, event) { - var url = grid.renderer.getProfileUrl(grid,item.getValue("id")); - window.open(url); - } + var url = null; - }); + if (userId) { + url = this.constructUrl(consts.AtomDeleteFileFromRecycleBin, null, { + userId : userId, + documentId : fileId + }); + } else { + url = this.constructUrl(consts.AtomDeleteMyFileFromRecycleBin, null, { + documentId : fileId + }); + } - return ProfileAction; -}); -}, -'sbt/connections/nls/ConnectionsService':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ + var options = { + method : "DELETE", + query : args || {}, + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + } + }; -/** - * Social Business Toolkit SDK - Default resource bundle for ConnectionsService - */ -define({ - root: ({ - invalid_argument : "Invalid Argument" - }) -}); -}, -'sbt/connections/controls/communities/CommunityMembersGridRenderer':function(){ -require({cache:{ -'url:sbt/connections/controls/communities/templates/CommunityMemberRow.html':"\r\n\t\r\n\t\t

    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.role}: ${role}
    \r\n\t\t\t
    ${nls.email} ${email}
    \r\n\t\t\t\r\n\t\t\t\t${nls.edit}    \r\n\t\t\t\t${nls.remove}\r\n\t\t\t\r\n\t\t\t
    \r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t${nls.role}:\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t
    \r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n", -'url:sbt/connections/controls/communities/templates/BootstrapCommunityMember.html':"\r\n\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t\t

    \r\n \t\t\t\t${title}\r\n \t\t\t

    \r\n\t\r\n"}}); -/* - * © 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. - */ + return this.deleteEntity(url, options, fileId); + }, -/** - * - */ -define(["../../../declare", - "../ConnectionsGridRenderer", - "../../../i18n!./nls/CommunityMembersGridRenderer", - "../../../text!./templates/CommunityMemberRow.html", - "../../../text!./templates/BootstrapCommunityMember.html"], - function(declare, ConnectionsGridRenderer, nls, communityMemberTemplate, - bootstrapCommunityMemberTemplate) { - - /** - * @class ProfileGridRenderer - * @namespace sbt.connections.controls.communities - * @module sbt.connections.controls.communities.CommunityMembersGrid - */ - var CommunityMembersGridRenderer = declare(ConnectionsGridRenderer, { + /** + * deletes a File Share + * @param {String} fileId the ID of the file + * @param {String} userId the ID of the user + * @param {Object} args the additional arguments + */ + deleteFileShare : function(fileId, userId, args) { + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; + } - /**The strings used in the grid, these are stored in a separate file, in the nls folder*/ - _nls: nls, - - /** - * The constructor function - * @method constructor - * @param args - */ - constructor: function(args,grid) { - if (grid.theme == "bootstrap"){ - this.template = bootstrapCommunityMemberTemplate; - }else{ - if (args.type == "communityMembers") { - this.template = communityMemberTemplate; - } - } - - - }, + var requestArgs = lang.mixin({ + sharedWhat : fileId + }, args || {}); - /** - * Sets the css class for the row - * @method rowClass - * @param grid The Grid Dijit - * @param item the current row - * @param i the number of the current row, ie 0, 1, 2 etc - * @param items all of the rows in the grid - */ - rowClass: function(grid, item, i, items) { - item.rowClass = (i === 0 ? "lotusFirst" : (i % 2 === 1 ? "lotusAltRow" : null)); - }, - - /** - * Displays a tooltip by calling the getTooltip function in the ProfileAction class - * @method tooltip - * @param grid The Grid Dijit - * @param item the element to display the tooltip - * @param i the number of the current row - * @param items all of the items in the grid row - * @returns A Tooltip the default for profiles is to display the vCard - */ - tooltip: function(grid, item, i, items) { - if (grid.profileAction) { - return grid.profileAction.getTooltip(item); - } - }, - - /** - * Generates the profile photo URL for displaying the photos of community members - * @method photoUrl - * @param grid The Grid Dijit - * @param item the element containing the uid - * @param i the number of the current row - * @param items all of the items in the grid row - * @returns A profile photo URL for retrieving a user's profile picture - */ - photoUrl: function(grid, item, i, items) { - var store = grid.store; - var endpoint = store.getEndpoint(); - var photoUrl = endpoint.baseUrl + "/profiles/photo.do?email=" + item.getValue("email"); - - return photoUrl; - } - }); - - return CommunityMembersGridRenderer; -}); -}, -'url:sbt/connections/controls/communities/templates/CommunityRow.html':"\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t\r\n\t\t\t\t${title}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t|\r\n\t\t\t\r\n\t\t\t\t\"\"\r\n\t\t\t\t${nls.moderated} \r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\"\"\r\n\t\t\t\t${nls.restricted} \r\n\t\t\t\r\n\t\t

    \r\n\t\t
    \r\n\t\t\t\r\n\t\t\t\t${numOfMembers}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${nls.updatedBy}\r\n\t\t\t\t\t\r\n \t\t\t\t\t\t${contributorName}\r\n \t\t\t\t\t ${contributorUserid}\r\n\t\t\t\t \r\n\t\t\t\t\r\n\t\t\t\t|\r\n\t\t\t\t${updatedDate}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${tagsLabel}\r\n\t\t\t\t\t${tagsAnchors}\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t

    ${summary}

    \r\n\t\t
    \r\n\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\r\n", -'sbt/base/BaseService':function(){ -/* - * © Copyright IBM Corp. 2012, 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. - */ + if (userId) { + requestArgs.sharedWith = userId; + } -/** - * Javascript Base APIs for IBM Connections - * - * @module sbt.base.BaseService - * @author Carlos Manias - */ -define(["../config", "../declare", "../lang", "../log", "../stringUtil", "../Cache", "../Promise", "../util" ], - function(config, declare,lang,log,stringUtil,Cache,Promise, util) { - // TODO sbt/config is required here to solve module loading - // issues with jquery until we remove the global sbt object - - var BadRequest = 400; - - var requests = {}; + var url = consts.AtomDeleteFileShare; - /** - * BaseService class. - * - * @class BaseService - * @namespace sbt.base - */ - var BaseService = declare(null, { - - /** - * The Endpoint associated with the service. - */ - endpoint : null, + var options = { + method : "DELETE", + query : requestArgs, + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + } + }; - /* - * The Cache associated with the service. - */ - _cache : null, - - /* - * Regular expression used to remove // from url's - */ - _regExp : new RegExp("/{2}"), - - /** - * A map of default context roots to custom, if any. This will be implemented in subClasses of BaseService. - */ - contextRootMap: {}, + return this.deleteEntity(url, options, fileId); + }, - /** - * Constructor for BaseService - * - * An endpoint is required so subclasses must check if one - * was created here and if not set the default endpoint. - * - * @constructor - * @param {Object} args Arguments for this service. - */ - constructor : function(args) { - args = args || {}; - - // set endpoint if specified in args - if (args.endpoint) { - if (lang.isString(args.endpoint)) { - this.endpoint = config.findEndpoint(args.endpoint); - } else { - this.endpoint = args.endpoint; - } - } + /** + * Deletes a Folder + * @param {String} folderId the ID of the folder + */ + deleteFolder : function(folderId) { + var promise = this.validateField("folderId", folderId); + if (promise) { + return promise; + } - // optionally create a cache - if (args.cacheSize) { - this._cache = new Cache(args.cacheSize); - } - }, + var options = { + method : "DELETE", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + } + }; + var url = this.constructUrl(consts.AtomDeleteFFolder, null, { + collectionId : folderId + }); - /** - * Construct a url using the specified parameters - * - * @method constructUrl - * @param url Base part of the URL to construct - * @param params Params to be encoded in the URL - * @param urlParams Params to be encoded in the URL query - * @returns The constructed URL - */ - constructUrl : function(url,params,urlParams) { - if (!url) { - throw new Error("BaseService.constructUrl: Invalid argument, url is undefined or null."); - } - - if(this.endpoint){ - lang.mixin(this.contextRootMap, this.endpoint.serviceMappings); - - url = stringUtil.transform(url, this.contextRootMap, function(value, key){ - if(!value){ - return key; - } - else{ - return value; - } - }, this); - } - - if (urlParams) { - url = stringUtil.replace(url, urlParams); - - if (url.indexOf("//") != -1) { - // handle empty values - url = url.replace(this._regExp, "/"); - } - } - if (params) { - for (param in params) { - if (url.indexOf("?") == -1) { - url += "?"; - } else if (url.indexOf("&") != (url.length - 1)) { - url += "&"; - } - var value = encodeURIComponent(params[param]); - if (value) { - url += param + "=" + value; - } - } - } - return url; - }, - - /** - * Get a collection of entities. - * - * @method getEntities - * @param url The URL to get the entities. - * @param options Optional. Options for the request. - * @param callbacks Callbacks used to parse the response and create the entities. - * @returns {sbt/Promise} - */ - getEntities : function(url,options,callbacks) { - url = this.constructUrl(url); - var self = this; - var promise = new Promise(); - this.request(url,options,null,promise).response.then( - function(response) { - promise.response = response; - try { - var feedHandler = callbacks.createEntities.apply(self, [ self, response.data, response ]); - var entitiesArray = feedHandler.getEntitiesDataArray(); - var entities = []; - for ( var i = 0; i < entitiesArray.length; i++) { - var entity = callbacks.createEntity.apply(self, [ self, entitiesArray[i], response ]); - entities.push(entity); - } - promise.summary = feedHandler.getSummary(); - promise.fulfilled(entities); - } catch (cause) { - var error = new Error("Error parsing response caused by: "+cause); - error.cause = cause; - promise.rejected(error); - } - }, - function(error) { - promise.rejected(error); - } - ); - return promise; - }, + return this.deleteEntity(url, options, folderId); + }, - /** - * Get a single entity. - * - * @method getEntity - * @param url The URL to get the entity. - * @param options Options for the request. - * @param callbacks Callbacks used to parse the response and create the entity. - * @returns {sbt/Promise} - */ - getEntity : function(url,options,entityId,callbacks) { - url = this.constructUrl(url); - var promise = this._validateEntityId(entityId); - if (promise) { - return promise; - } - - // check cache - var promise = new Promise(); - var data = this.getFromCache(entityId); - if (data) { - promise.fulfilled(data); - return promise; - } + /** + * Get all user Files + * @param {String} userId the ID of the user + * @param {Object} args the addtional arguments + * @returns {Object} Files + */ + getAllUserFiles : function(userId, args) { - var self = this; - this.request(url,options,entityId,promise).response.then( - function(response) { - promise.response = response; - try { - var entity = callbacks.createEntity.apply(self, [ self, response.data, response ]); - if (self._cache && entityId) { - self.fullFillOrRejectPromises.apply(self, [ entityId, entity, response ]); - } else { - promise.fulfilled(entity); - } - } catch (cause) { - var error = new Error("Invalid response"); - error.cause = cause; - if (self._cache && entityId) { - self.fullFillOrRejectPromises.apply(self, [ entityId, error ]); - } else { - promise.rejected(error); - } - } - }, - function(error) { - if (self._cache && entityId) { - self.fullFillOrRejectPromises.apply(self, [ entityId, error ]); - } else { - promise.rejected(error); - } - } - ); - return promise; - }, - - /** - * Update the specified entity. - * - * @method updateEntity - * @param url The URL to update the entity. - * @param options Options for the request. - * @param callbacks Callbacks used to parse the response. - * @param sbt/Promise - */ - updateEntity : function(url, options, callbacks) { - url = this.constructUrl(url); - var self = this; - var promise = new Promise(); - this.endpoint.request(url,options,null,promise).response.then( - function(response) { - promise.response = response; - var entity = callbacks.createEntity.apply(self, [ self, response.data, response ]); - // callback can return a promise if an additional - // request is required to load the associated entity - if (entity instanceof Promise) { - entity.then( - function(response) { - // it is the responsibility of the createEntity callback to clear the cache in this case. - promise.fulfilled(response); - }, - function(error) { - promise.rejected(error); - } - ); - } else { - if(entity.id){ - self.removeFromCache(entity.id); - } - if(entity.id && entity.data){ - self.addToCache(entity.id, entity); - } - promise.fulfilled(entity); - } - }, - function(error) { - promise.rejected(error); - } - ); - return promise; - }, + var promise = this.validateField("userId", userId); + if (promise) { + return promise; + } - /** - * Delete the specified entity. - * - * @method deleteEntity - * @param url The URL to delete the entity. - * @param options Options for the request. - * @param entityId Id of the entity to delete. - * @param sbt/Promise - */ - deleteEntity : function(url,options,entityId) { - url = this.constructUrl(url); - var promise = this._validateEntityId(entityId); - if (promise) { - return promise; - } + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; - var self = this; - var promise = new Promise(); - this.endpoint.request(url,options,entityId,promise).response.then( - function(response) { - promise.response = response; - promise.fulfilled(entityId); - self.removeFromCache(entityId); - }, - function(error) { - promise.rejected(error); - } - ); - return promise; - }, - - /** - * Perform an XML HTTP Request with cache support. - * - * @method request - * @param url URL to request - * @param options Options for the request. - * @param entityId Id of the rntity associated with the request. - * @param promise Promise being returned - * @param sbt/Promise - */ - request : function(url,options,entityId,promise) { - url = this.constructUrl(url); - if (this._cache && entityId) { - this.pushPromise(entityId, promise); - } - return this.endpoint.request(url,options); - }, + var url = this.constructUrl(consts.AtomGetAllUsersFiles, null, { + userId : userId + }); - /** - * Push set of promise onto stack for specified request id. - * - * @method pushPromise - * @param id Id of the request. - * @param promise Promise to push. - */ - pushPromise : function(id,promise) { - log.debug("pushPromise, id : {0}, promise : {1}", id, promise); - if (!requests[id]) { - requests[id] = []; - } - requests[id].push(promise); - }, + return this.getEntities(url, options, this.getFileFeedCallbacks()); + }, - /** - * Notify set of promises and pop from stack for specified request id. - * - * @method fullFillOrRejectPromises - * @param id - * @param data - * @param response - */ - fullFillOrRejectPromises : function(id,data,response) { - log.debug("fullFillOrRejectPromises, id : {0}, data : {1}, response : {2}", id, data, response); - this.addToCache(id, data); - var r = requests[id]; - if (r) { - delete requests[id]; - for ( var i = 0; i < r.length; i++) { - var promise = r[i]; - this.fullFillOrReject.apply(this, [ promise, data, response ]); - } - } - }, + /** + * Get file Comments + * @param {String} fileId the ID of the file + * @param {String} [userId] the ID of the user + * @param {Boolean} [isAnnonymousAccess] flag to indicate annonymous access + * @param {String} [commentId] the ID of the comment + * @param {String} [communityId] required in case the file in a community file + * @param {Object} args the additional arguments + * @returns {Array} Comments List + */ + getFileComments : function(fileId, userId, isAnnonymousAccess, commentId, communityId, args) { - /** - * Fullfill or reject specified promise. - * - * @method fullFillOrReject - * @param promise - * @param data - * @param response - */ - fullFillOrReject : function(promise,data,response) { - if (promise) { - try { - promise.response = response; - if (data instanceof Error) { - promise.rejected(data); - } else { - promise.fulfilled(data); - } - } catch (error) { - log.debug("fullFillOrReject: " + error.message); - } - } - }, + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; + } - /** - * Add the specified data into the cache. - * - * @method addToCache - * @param id - * @param data - */ - addToCache : function(id, data) { - if (this._cache && !(data instanceof Error)) { - this._cache.put(id, data); - } - }, - - /** - * Remove the cached data for the specified id. - * - * @method removeFromCache - * @param id - */ - removeFromCache : function(id) { - if (this._cache) { - this._cache.remove(id); - } - }, - - /** - * Get the cached data for the specified id. - * - * @method getFromCache - * @param id - */ - getFromCache : function(id) { - if (this._cache) { - return this._cache.get(id); - } - }, - - /** - * Create a bad request Error. - * - * @method createBadRequestError - * @param message - * @returns {Error} - */ - createBadRequestError : function(message) { - var error = new Error(); - error.code = BadRequest; - error.message = message; - return error; - }, - - /** - * Create a bad request Promise. - * - * @method createBadRequestPromise - * @param message - * @returns {sbt/Promise} - */ - createBadRequestPromise : function(message) { - return new Promise(this.createBadRequestError(message)); - }, - - /** - * Return true if the specified id is an email. - * - * @method isEmail - * @param id - * @returns {Boolean} - */ - isEmail : function(id) { - return id && id.indexOf('@') >= 0; - }, - - /** - * Extract the Location parameter from a URL. - * - * @method getLocationParameter - * @param ioArgs - * @param name - * @returns {String} - */ - getLocationParameter: function (response, name) { - var location = response.getHeader("Location") || undefined; - if (location) { - return this.getUrlParameter(location, name); - } - }, - - /** - * Extract the specified parameter from a URL. - * - * @mehtod getUrlParameter - * @param url - * @param name - * @returns {Boolean} - */ - getUrlParameter : function (url, name) { - return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url)||[,""])[1].replace(/\+/g, '%20'))||null; - }, - - /** - * Validate a string field, and return a Promise if invalid. - * - * @param fieldName - * @param fieldValue - */ - validateField : function(fieldName, fieldValue) { - if (!fieldValue) { - var message = "Invalid value {0} for field {1}, the field must not be empty or undefined."; - message = stringUtil.substitute(message, [ fieldValue || "'undefined'", fieldName ]); - return this.createBadRequestPromise(message); - } - }, - - /** - * Validate a map of fields, and return a Promise for first invalid field found. - * - * @param fieldMap - */ - validateFields : function(fieldMap) { - for(var name in fieldMap){ - var value = fieldMap[name]; - var promise = this.validateField(name, value); - if (promise) { - return promise; - } - } - }, - - /** - * Validate HTML5 File API Support for browser and JS Library - */ - validateHTML5FileSupport : function() { - if (!window.File || !window.FormData) { - var message = "HTML 5 File API is not supported by the Browser."; - return this.createBadRequestPromise(message); + var url = null; + if(communityId){ + url = this.constructUrl(consts.AtomAddCommentToCommunityFile, null, { + communityId : communityId, + documentId : fileId + }); } - // Dojo 1.4.3 does not support HTML5 FormData - if(util.getJavaScriptLibrary().indexOf("Dojo 1.4") != -1) { - return this.createBadRequestPromise("Dojo 1.4.* is not supported for Update Profile Photo"); + else if (commentId) { + if (userId) { + url = this.constructUrl(consts.AtomGetFileComment, null, { + userId : userId, + documentId : fileId, + commentId : commentId + }); + } else { + url = this.constructUrl(consts.AtomGetMyFileComment, null, { + documentId : fileId, + commentId : commentId + }); + } + } else { + var promise = this.validateField("userId", userId); + if (promise) { + return promise; + } + if (isAnnonymousAccess) { + url = this.constructUrl(consts.AtomFileCommentsPublic, null, { + userId : userId, + documentId : fileId + }); + } else { + url = this.constructUrl(consts.AtomFileCommentsMy, null, { + userId : userId, + documentId : fileId + }); + } } - }, - - /* - * Validate the entityId and if invalid notify callbacks - */ - _validateEntityId : function(entityId) { - if (!entityId || !lang.isString(entityId)) { - var message = "Invalid argument {0}, expected valid entity identifier."; - message = stringUtil.substitute(message, [ entityId || "'undefined'" ]); - return this.createBadRequestPromise(message); - } - }, - - /** - * Returns HTML5 File Control object - * @param {Object} fileControlOrId FileControl or ID of File Control - * @returns {Object} FileControl - */ - getFileControl : function(fileControlOrId) { - var fileControl = null; - if (typeof fileControlOrId == "string") { - fileControl = document.getElementById(fileControlOrId); - } else if (typeof fileControlOrId == "object") { - fileControl = fileControlOrId; - } - return fileControl; - } - }); - return BaseService; -}); + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; -}, -'sbt/pathUtil':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ + return this.getEntities(url, options, this.getCommentFeedCallbacks()); + }, + + /** + * Method to get All comments of a Community File + *

    + * Rest API Used : + * /files/basic/api/communitylibrary//document//feed + *

    + * @method getAllCommunityFileComments + * @param {String} fileId + * @param {String} communityId + * @param {Object} [args] + * @returns {Array} comments + */ + getAllCommunityFileComments : function(fileId, communityId, args) { + + var promise = this.validateField("fileId", fileId); + if(!promise){ + promise = this.validateField("communityId", communityId); + } + if (promise) { + return promise; + } + + return this.getFileComments(fileId, null, null, null, communityId, args); + }, -/** - * Social Business Toolkit SDK - URL utilities - */ -define(['./stringUtil'],function(stringUtil) { - return { - concat: function(path1,path2) { - if(!path1) { - return path2; + /** + * Get Files from recycle bin + * @param {Object} [args] the additional arguments + * @returns {Object} Files + */ + getFileFromRecycleBin : function(fileId, userId, args) { + + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; } - if(!path2) { - return path1; + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = this.constructUrl(consts.AtomGetFileFromRecycleBin, null, { + userId : userId, + documentId : fileId + }); + + var callbacks = { + createEntity : function(service, data, response) { + self.dataHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.FileXPath + }); + return self; + } + }; + + return this.getEntity(url, options, callbacks); + }, + + /** + * Get Files awaiting approval + * @param {Object} [args] the additional arguments + * @returns {Object} Files + */ + getFilesAwaitingApproval : function(args) { + + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomGetFilesAwaitingApproval, options, this.getFileFeedCallbacks()); + }, + + /** + * Get File Shares + * @param {Object} [args] the additional arguments + * @returns {Object} Files + */ + getFileShares : function(args) { + + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomGetFileShares, options, this.getFileFeedCallbacks()); + }, + + /** + * Get Files in a folder + * @param {String} folderId the ID of the folder + * @param {Object} [args] the additional arguments + * @returns {Object} Files + */ + getFilesInFolder : function(folderId, args) { + + var url = this.constructUrl(consts.AtomGetFilesInFolder, null, { + collectionId : folderId + }); + + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(url, options, this.getFileFeedCallbacks()); + + }, + + /** + * Get Files in my recycle bin + * @param {Object} [args] the addtional arguments + * @returns + */ + getFilesInMyRecycleBin : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomGetFilesInMyRecycleBin, options, this.getFileFeedCallbacks()); + }, + + /** + * Get a file with given version + * @param {String} fileId the ID of the file + * @param {String} versionId the ID of the version + * @param {Object} [args] the additional arguments + * @returns {Object} File + */ + getFileWithGivenVersion : function(fileId, versionId, args) { + + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; } - if(stringUtil.endsWith(path1,"/")) { - path1 = path1.substring(0,path1.length-1); + if (!versionId) { + return this.getFile(fileId, args); } - if(stringUtil.startsWith(path2,"/")) { - path2 = path2.substring(1); + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = this.constructUrl(consts.AtomGetFileWithGivenVersion, null, { + documentId : fileId, + versionId : versionId + }); + + var callbacks = { + createEntity : function(service, data, response) { + self.dataHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.FileXPath + }); + return self; + } + }; + + return this.getEntity(url, options, callbacks); + }, + + /** + * Get a folder + * @param {String} folderId the ID of the folder + * @returns + */ + getFolder : function(folderId) { + var promise = this.validateField("folderId", folderId); + if (promise) { + return promise; } - return path1 + "/" + path2; + var options = { + method : "GET", + handleAs : "text" + }; + var url = this.constructUrl(consts.AtomGetFolder, null, { + collectionId : folderId + }); + + var callbacks = { + createEntity : function(service, data, response) { + self.dataHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.FileXPath + }); + return self; + } + }; + + return this.getEntity(url, options, callbacks); }, - isAbsolute: function(url) { - return url.indexOf("://")>=0; - } - } -}); -}, -'sbt/base/VCardDataHandler':function(){ -/* - * © 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. - */ -/** - * JavaScript API for IBM Connections Profile Service. - * - * @module sbt.connections.ProfileService - */ -define([ "../declare", "../lang", "../config", "../stringUtil", "./XmlDataHandler" ], - function(declare,lang,config,stringUtil,XmlDataHandler) { + /** + * Get Folders With Recently Added Files + * @param {Object} [args] the additional arguents + * @returns {Object} List of Files + */ + getFoldersWithRecentlyAddedFiles : function(args) { - /** - * VCardDataHandler class. - * - * @class ProfileDataHandler - * @namespace sbt.connections - */ - var VCardDataHandler = declare(XmlDataHandler, { - - lineDelim : "\n", - itemDelim : ":", - - _vcard : null, - - /** - * @constructor - * @param {Object} - * args Arguments for this data handler. - */ - constructor : function(args) { - this.parseVCard(); - }, - - /** - * Parse the vcard data from the specified element. - * - * @method parseVCard - */ - parseVCard : function() { - var content = stringUtil.trim(this.getAsString("vcard")); - var lines = content.split(this.lineDelim); - this._vcard = {}; - for (var i=1; i\r\n\t\r\n\t\t

    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.telephone} ${telephone}
    \r\n\t\t\t
    ${nls.email}: ${email}
    \r\n\t\t\t
    ${nls.altEmail}: ${altEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n", -'sbt/authenticator/SSO':function(){ -/* - * © 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. - */ -/** - * Social Business Toolkit SDK. - * Definition of an authentication mechanism. - */ -define(["../declare", "../lang", "../util", "../i18n!../nls/messageSSO"],function(declare, lang, util, ssoMessages) { -/** - * Proxy SSO authentication. - * - * This class triggers the authentication for a service. - */ -return declare(null, { - loginUi: "", - messageSSO: "/sbt/authenticator/templates/MessageSSO.html", - dialogMessageSSO: "authenticator/templates/MessageDialogSSO.html", - url: "", - - constructor: function(args){ - lang.mixin(this, args || {}); - }, - - authenticate: function(options) { - var self = this; - require(['sbt/config'], function(config){ - var mode = options.loginUi || config.Properties["loginUi"] || self.loginUi; - var messagePage = options.messageSSO || config.Properties["messageSSO"] || self.messageSSO; - var dialogMessagePage = options.dialogMessageSSO || config.Properties["dialogMessageSSO"] || self.dialogMessageSSO; - if(mode=="popup") { - self._authPopup(options, messagePage, self.url); - } else if(mode=="dialog") { - self._authDialog(options, dialogMessagePage); - } else { - self._authMainWindow(options, messagePage, self.url); - } - }); - return true; - - }, - - _authPopup: function(options, messagePage, sbtUrl) { - var urlParamsMap = { - loginUi: 'popup' - }; - var urlParams = util.createQuery(urlParamsMap, "&"); - var url = sbtUrl+messagePage + '?' + urlParams; - - var windowParamsMap = { - width: window.screen.availWidth / 2, - height: window.screen.availHeight / 2, - left: window.screen.availWidth / 4, - top: window.screen.availHeight / 4, - menubar: 0, - toolbar: 0, - status: 0, - location: 0, - scrollbars: 1, - resizable: 1 - }; - var windowParams = util.createQuery(windowParamsMap, ","); - var loginWindow = window.open(url,'Authentication', windowParams); - loginWindow.globalSSOStrings = ssoMessages; - loginWindow.globalEndpointAlias = options.name; - loginWindow.focus(); - - return true; - }, - - _authDialog: function(options, dialogLoginPage) { - require(["sbt/_bridge/ui/SSO_Dialog", "sbt/dom"], function(dialog, dom) { - dialog.show(options, dialogLoginPage, ssoMessages); - dom.setText('reloginMessage', ssoMessages.message); - dom.setAttr(dom.byId('ssoLoginFormOK'), "value", ssoMessages.relogin_button_text); - }); - - return true; - }, - - _authMainWindow: function(options, loginPage, sbtUrl) { - var urlParamsMap = { - redirectURL: document.URL, - loginUi: 'mainWindow', - message_title: ssoMessages.message_title, - message: ssoMessages.message, - relogin_button_text: ssoMessages.relogin_button_text - }; - - var urlParams = util.createQuery(urlParamsMap, "&"); - var url = sbtUrl+loginPage + '?' + urlParams; - var loginWindow = window.location.href = url; - - return true; - } -} -); -}); -}, -'sbt/store/AtomStore':function(){ -/* - * © 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. - */ + return this.updateEntity(consts.AtomPinFolder, options, callbacks); -/** - * @module sbt.store.AtomStore - */ -define(["../declare","../config","../lang", "../base/core", "../xml", "../xpath", "../itemFactory", "../Promise", - "dojo/_base/Deferred", "dojo/promise/Promise", "dojo/store/util/QueryResults", "../entities"], - function(declare, config, lang, core, xml, xpath, itemFactory, SbtPromise, Deferred, Promise, QueryResults, entities) { - - /** - * @class sbt.store.AtomStore - */ - var AtomStorePromise = declare(Promise, { - // private - _store : null, - _isRejected : false, - _isFulfilled : false, - _isCancelled : false, - _callbacks : [], - _errbacks : [], - _endpoint : null, - _xmlData : null, - // read only - totalResults : null, - startIndex : 0, - itemsPerPage : 5, - items : null, - // public - url : "", - sendQuery : true, - unescapeHTML : false, - atom : core.feedXPath, - attributes : core.entryXPath, - namespaces : core.namespaces, - paramSchema: {}, - total: null, - - /** - * Constructor for the AtomStore promise. - * @param args requires - * endpoint: the endpoint to be used - */ - constructor: function(args, query, options) { - this._endpoint = config.findEndpoint(args.endpoint || "connections"); - this._options = options; - this._callbacks = []; - this._errbacks = []; - this.total = new SbtPromise(); - - if (args) { - this.url = args.url; - this.attributes = args.attributes || this.attributes; - this.atom = args.feedXPath || this.atom; - this.namespaces = args.namespaces || this.namespaces; - this.sendQuery = args.hasOwnProperty("sendQuery") ? args.sendQuery : this.sendQuery; - this.unescapeHTML = args.unescapeHTML || this.unescapeHTML; - this.paramSchema = args.paramSchema || this.paramSchema; - } - - // add paging information to the query - if (this.paramSchema.pageNumber) { - var page = Math.floor(options.start / options.count) + 1; - query.pageNumber = query.pageNumber || page; - } - if (this.paramSchema.startIndex) { - query.startIndex = query.startIndex || options.start; - } - if (this.paramSchema.pageSize) { - query.pageSize = query.pageSize || options.count; - } - - // add the sorting information to the query - if (options.sort && options.sort[0]) { - if (options.sort[0].attribute) { - query.sortBy = options.sort[0].attribute; - } + }, - if(options.sort[0].descending === true) { - query.sortOrder = "desc"; - } - else if(options.sort[0].descending === false) { - query.sortOrder = "asc"; - } - } + /** + * Remove a File from a Folder + * + * @param {String} folderId the ID of the folder + * @param {Stirng} fileId The ID of the File + */ + removeFileFromFolder : function(folderId, fileId) { - var fetchArgs = { - query : query - }; + var promise = this.validateField("folderId", folderId); + if (promise) { + return promise; + } + promise = this.validateField("fileId", fileId); + if (promise) { + return promise; + } + var parameters = args ? lang.mixin({}, args) : {}; + parameters["itemId"] = fileId; - this._doFetch(fetchArgs); - }, + var url = this.constructUrl(consts.AtomRemoveFileFromFolder, null, { + collectionId : folderId + }); + var options = { + method : "DELETE", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + }, + query : parameters + }; - /* - * Add new callbacks to the promise. - */ - then: function(callback, errback, progback) { - if (this._isFulfilled) { - callback(this.items); - return; - } - - if (callback) { - this._callbacks.push(callback); - } - if (errback) { - this._errbacks.push(errback); - } - }, + return this.deleteEntity(url, options, fileId); - /* - * Inform the deferred it may cancel its asynchronous operation. - */ - cancel: function(reason, strict) { - this._isCancelled = true; - }, + }, - /* - * Checks whether the promise has been resolved. - */ - isResolved: function() { - return this._isRejected || this._isFulfilled; - }, + /** + * Restore a File from Recycle Bin (trash) + * + * @param {String} fileId the ID of the file + * @param {String} userId the ID of the user + */ + restoreFileFromRecycleBin : function(fileId, userId) { + + var promise = this.validateField("fileId", fileId); + if (promise) { + return promise; + } + promise = this.validateField("userId", userId); + if (promise) { + return promise; + } + var parameters = args ? lang.mixin({}, args) : {}; + parameters["undelete"] = "true"; - /* - * Checks whether the promise has been rejected. - */ - isRejected: function() { - return this._isRejected; - }, + var options = { + method : "POST", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + }, + query : parameters + }; - /* - * Checks whether the promise has been resolved or rejected. - */ - isFulfilled: function() { - return this._isFulfilled; - }, + var callbacks = { + createEntity : function(service, data, response) { + self.dataHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.FileXPath + }); + return self; + } + }; - /* - * Checks whether the promise has been canceled. - */ - isCanceled: function() { - return this._isCancelled; - }, - - // Internals - - /* - * Given a query and set of defined options, such as a start and count of items to return, - * this method executes the query and makes the results available as data items. - */ - _doFetch: function(args) { - var self = this; - var scope = args.scope || self; - - var serviceUrl = this._getServiceUrl(args.query); - if (!serviceUrl) { - if (args.onError) { - args.onError.call(new Error("sbt.store.AtomStore: No service URL specified.")); - } - return; - } - - this._endpoint.xhrGet({ - serviceUrl : serviceUrl, - handleAs : "text", - preventCache: true, - load : function(response) { - try { - // parse the data - self.response = response; - self._xmlData = xml.parse(response); - self.totalResults = parseInt(xpath.selectText(self._xmlData, self.atom.totalResults, self.namespaces)); - self.startIndex = parseInt(xpath.selectText(self._xmlData, self.atom.startIndex, self.namespaces)); - self.itemsPerPage = parseInt(xpath.selectText(self._xmlData, self.atom.itemsPerPage, self.namespaces)); - self.items = self._createItems(self._xmlData); - - - if (self._options.onComplete) { - self._options.onComplete.call(self._options.scope || self, self.items, self._options); - } - // invoke callbacks - self.total.fulfilled(self.totalResults); - self._fulfilled(self.items); - } catch (error) { - self.total._rejected(error); - self._rejected(error); - } - }, - error : function(error) { - self.total._rejected(error); - self._rejected(error); - } - }); - }, - - /* - * Create the service url and include query params - */ - _getServiceUrl: function(query) { - if (!this.sendQuery) { - return this.url; - } - if (!query) { - return this.url; - } - if (lang.isString(query)) { - return this.url + (~this.url.indexOf('?') ? '&' : '?') + query; - } - - var pairs = []; - var paramSchema = this.paramSchema; - for(var key in query) { - if (key in paramSchema) { - var val = paramSchema[key].format(query[key]); - if (val) { - pairs.push(val); - } - } else { - pairs.push(encodeURIComponent(key) + "=" + encodeURIComponent(query[key])); - } - } - if (pairs.length == 0) { - return this.url; - } - - return this.url + (~this.url.indexOf('?') ? '&' : '?') + pairs.join("&"); - }, - - /* - * Create a query string from an object - */ - _createQuery: function(queryMap) { - if (!queryMap) { - return null; - } - var pairs = []; - for(var name in queryMap){ - var value = queryMap[name]; - pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(value)); - } - return pairs.join("&"); - }, + var url = this.constructUrl(consts.AtomRestoreFileFromRecycleBin, null, { + userId : userId, + documentId : fileId + }); - _createItems: function(document) { - var nodes = xpath.selectNodes(document, this.atom.entries, this.namespaces); - var items = []; - for (var i=0; i 0) { - var callback = this._callbacks.shift(); - callback(totalCount); - } - }, - - _rejected : function(error) { - if (this._isCancelled) { - return; - } - this._isRejected = true; - while (this._errbacks.length > 0) { - var errback = this._errbacks.shift(); - errback(error); - } - } - - }); - - /** - * @module sbt.store.AtomStore - */ - var AtomStore = declare(null, { - - // Indicates the property to use as the identity property. The values of this - // property should be unique. - idProperty: "id", - - _args : null, - - /** - * Constructor for the Atom store. - * - * @param args - * An anonymous object to initialize properties. It expects the following values: - * url: The url to a service or an XML document that represents the store - * unescapeHTML: A boolean to specify whether or not to unescape HTML text - * sendQuery: A boolean indicate to add a query string to the service URL - */ - constructor: function(args) { - this._args = args; + /** + * Share a File with community(ies) + * + * @param {String} fileId the ID of the file + * @param {Object} communityIds The list of community IDs + * @param {Object} args the additional arguments + */ + shareFileWithCommunities : function(fileId, communityIds, args) { - //if(!args.url) { - // throw new Error("sbt.store.AtomStore: A service URL must be specified when creating the data store"); - //} - }, - - /** - * @method getEndpoint - * @returns - */ - getEndpoint: function() { - return config.findEndpoint(this._args.endpoint || "connections"); - }, - - /** - * Retrieves an object by its identity - * @method get - * @param id - */ - get: function(id) { - throw new Error("sbt.store.AtomStore: Not implemented yet!"); - }, + var promise = this.validateField("fileId", fileId); + if (!promise) { + promise = this.validateField("communityIds", communityIds); + } + if (promise) { + return promise; + } - /** - * Returns an object's identity - * @method getIdentity - * @param object - */ - getIdentity: function(object) { - return object.id; - }, - - setUrl: function(url){ - this._args.url = url; - }, - - getUrl: function(){ - return this._args.url; - }, - - setAttributes: function(attributes){ - this._args.attributes = attributes; - }, - - /** - * Queries the store for objects. This does not alter the store, but returns a set of data from the store. - * @method query - * @param query - * @param options - */ - query: function(query, options) { - var results = new AtomStorePromise(this._args, query, options); - return QueryResults(results); - } - }); - return AtomStore; - -}); + var url = this.constructUrl(consts.AtomShareFileWithCommunities, null, { + documentId : fileId + }); -}, -'sbt/connections/controls/bootstrap/CommunityRendererMixin':function(){ -require({cache:{ -'url:sbt/connections/controls/bootstrap/templates/CommunityRow.html':"\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t\r\n\t\t\t\t${title}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t|\r\n\t\t\t\r\n\t\t\t\t\"${nls.moderated}\"\r\n\t\t\t\t${nls.moderated} \r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\"${nls.restricted}\"\r\n\t\t\t\t${nls.restricted} \r\n\t\t\t\r\n\t\t

    \r\n\t\t
    \r\n\t\t\t\r\n\t\t\t\t${numOfMembers}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${nls.updatedBy}\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t${contributorName}\r\n\t\t\t\t\t\t${contributorUserid}\r\n\t\t\t\t\t \r\n\t\t\t\t\r\n\t\t\t\t|\r\n\t\t\t\t${updatedDate}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${tagsLabel}\r\n\t\t\t\t\t${tagsAnchors}\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t

    ${summary}

    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n", -'url:sbt/connections/controls/bootstrap/templates/TagAnchor.html':"${tagName}"}}); -/* - * © 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. - */ + var payload = this._constructPayloadForMultipleEntries(communityIds, "itemId", "community"); -/** - * - */ -define(["../../../lang", "../../../controls/grid/bootstrap/GridRendererMixin", - "../../../text!./templates/CommunityRow.html", - "../../../text!./templates/TagAnchor.html" ], - function(lang, GridRendererMixin, CommunityRow, TagAnchor) { + var options = { + method : "POST", + headers : consts.AtomXmlHeaders, + data : payload + }; - /** - * @module sbt.controls.grid.bootstrap.CommunityRendererMixin - */ - return lang.mixin(GridRendererMixin, { template : CommunityRow, tagAnchorTemplate: TagAnchor }); - -}); -}, -'sbt/authenticator/GadgetOAuth':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ + var callbacks = { + createEntity : function(service, data, response) { + return response; + } + }; -/** - * Social Business Toolkit SDK. - * Definition of the authentication mechanism for OAuth 1.0. - */ -define([ "../declare", "../lang" ], function(declare,lang) { + return this.updateEntity(url, options, callbacks); + }, - /** - * OpenSocial OAuth authentication. - * - * This class triggers the authentication for a service. - */ - return declare(null, { + /** + * Unpin a folder, by sending a DELETE request to the myfavorites feed. + * + * @method unpinFolder + * @param {String} folderId ID of folder which needs to be unpinned + * @param {Object} [args] Argument object. + */ + unpinFolder : function(folderId, args) { + var promise = this.validateField("folderId", folderId); + if (promise) { + return promise; + } - constructor : function(args) { - lang.mixin(this, args || {}); - }, + var parameters = args ? lang.mixin({}, args) : {}; + parameters["itemId"] = folderId; - /** - * Method that authenticates the current user - */ - authenticate : function(options) { - var onOpen = function() { - }; - var onClose = function() { - }; - var response = options.error.response; - var popup = new gadgets.oauth.Popup(response.oauthApprovalUrl, null, onOpen, onClose); - popup.createOpenerOnClick(); - } - }); -}); -}, -'sbt/nls/messageSSO':function(){ -/* - * © 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. - */ + var options = { + method : "DELETE", + headers : { + "X-Update-Nonce" : "{X-Update-Nonce}" + }, + query : parameters + }; -/** - * Social Business Toolkit SDK - Default resource bundle for validate module. - */ + return this.deleteEntity(consts.AtomPinFolder, options, folderId); + }, -define({ - root: ({ - message_title: "ReAuthenticate", - message:"Authentication expired, Please login again.", - relogin_button_text: "Re-Login" - }) -}); -}, -'url:sbt/smartcloud/controls/profiles/templates/ProfileRow.html':"\r\n\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t \r\n\t\t\t\t\r\n\t\t\t\t\t${name}\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t

    \r\n\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t${title}\r\n\t\t\t\t${orgName}\r\n\t\t\t
    \r\n\t\t\t
    ${address}
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t\r\n\t\t\tNetwork Contact\r\n\t\t\r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t ${primaryTelephone}\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t \r\n\t\t\t${email}\r\n\t\t
    \r\n\t\r\n\r\n", -'url:sbt/connections/controls/profiles/templates/ColleagueItemFull.html':"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \"${name}\r\n \r\n ${uid}\r\n ${name}\r\n \r\n
    \r\n
    \r\n \r\n ${name}\r\n ${uid}\r\n ${name}\r\n \r\n
    \r\n", -'sbt/base/DataHandler':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ + /** + * Update comment created by logged in user + * @param {String} fileId the ID of the file + * @param {String}commentId the ID of the comment + * @param {String} comment the updated comment + * @param {Object} args the additional arguments + * @returns + */ + updateMyComment : function(fileId, commentId, comment, args) { -/** - * Social Business Toolkit SDK. Helpers for the base capabilities of data - * handlers. - * - * @module sbt.base.DataHandler - */ -define([ "../declare", "../lang" ], function(declare,lang) { + return updateComment(fileId, commentId, comment, null, args); + }, - /** - * DataHandler class - * - * @class DataHandler - * @namespace sbt.base - */ - var DataHandler = declare(null, { + /** + * updates a comment + * @param {String} fileId the ID of the file + * @param {String} commentId the ID of the comment + * @param {String} comment the comment + * @param {String} [userId] the ID of the user + * @param {Object} [args] the additional arguments + * @returns {Object} the updated Comment + */ + updateComment : function(fileId, commentId, comment, userId, args) { - /** - * Data type for this DataHandler - */ - dataType : null, + var promise = this.validateField("fileId", fileId); + if (!promise) { + promise = this.validateField("comment", comment); + } + if (promise) { + return promise; + } + if (!promise) { + promise = this.validateField("commentId", commentId); + } + if (promise) { + return promise; + } + var options = { + method : "POST", + query : args || {}, + headers : consts.AtomXmlHeaders, + data : this._constructPayloadForComment(false, comment) + }; + var url = null; - /** - * Data for this DataHandler - */ - data : null, + if (!userId) { + url = this.constructUrl(consts.AtomUpdateMyComment, null, { + documentId : fileId, + commentId : commentId + }); + } else { + url = this.constructUrl(consts.AtomUpdateComment, null, { + userId : userId, + documentId : fileId, + commentId : commentId + }); + } + return this.updateEntity(url, options, this.getCommentFeedCallbacks()); + }, - /** - * @constructor - * @param {Object} - * args Arguments for this data handler. - */ - constructor : function(args) { - lang.mixin(this, args); - }, + /** + * Add a file to a folder. + * + * You cannot add a file from your local directory to a folder; the file must already have been uploaded to the Files application. To add a file + * to a folder you must be an editor of the folder. + * + * @method addFileToFolder + * @param {String} fileId the Id of the file + * @param {String} folderId the ID of the folder + * @param {String} [userId] the userId of the user in case of own file + * @param {Object} [args] Argument object. + */ + addFileToFolder : function(fileId, folderId, userId, args) { - /** - * Called to set the handler data. - * - * @param data - */ - setData : function(data) { - this.data = data; - }, - - /** - * Called to get the handler data. - * - * @param data - */ - getData : function() { - return this.data; - }, - - /** - * @method getAsString - * @param data - * @returns - */ - getAsString : function(property) { - return null; - }, + return this.addFileToFolders(fileId, [ folderId ], userId, args); + }, - /** - * @method getAsNumber - * @returns - */ - getAsNumber : function(property) { - return null; - }, + /* + * Callbacks used when reading a feed that contains File entries. + */ + getFileFeedCallbacks : function() { + return FileFeedCallbacks; + }, - /** - * @method getAsDate - * @returns - */ - getAsDate : function(property) { - return null; - }, + /* + * Callbacks used when reading a feed that contains File Comment entries. + */ + getCommentFeedCallbacks : function() { + return CommentCallbacks; + }, + + _constructPayloadFolder : function(name, description, shareWith, operation, entityId) { + var _this = this; + var shareWithId = null; + var shareWithWhat = null; + var shareWithRole = null; + if (shareWith && stringUtil.trim(shareWith) != "") { + var parts = shareWith.split(","); + if (parts.length == 3) { + shareWithId = parts[0]; + shareWithWhat = parts[1]; + shareWithRole = parts[2]; + } + } + var trans = function(value, key) { + if (key == "category") { + value = xml.encodeXmlEntry("collection"); + } else if (key == "id") { + value = xml.encodeXmlEntry(entityId); + } else if (key == "label") { + value = xml.encodeXmlEntry(name); + } else if (key == "title") { + value = xml.encodeXmlEntry(name); + } else if (key == "summary") { + value = xml.encodeXmlEntry(description); + } else if (key == "visibility") { + value = xml.encodeXmlEntry("private"); + } else if (key == "shareWithId" && shareWithId) { + value = xml.encodeXmlEntry(shareWithId); + } else if (key == "shareWithWhat" && shareWithWhat) { + value = xml.encodeXmlEntry(shareWithWhat); + } else if (key == "shareWithRole" && shareWithRole) { + value = xml.encodeXmlEntry(shareWithRole); + } + return value; + }; + var transformer = function(value, key) { + if (key == "getCategory") { + value = stringUtil.transform(FileCategoryTmpl, _this, trans, _this); + } else if (key == "getId" && entityId) { + value = stringUtil.transform(FileIdTmpl, _this, trans, _this); + } else if (key == "getFolderLabel") { + value = stringUtil.transform(FolderLabelTmpl, _this, trans, _this); + } else if (key == "getTitle") { + value = stringUtil.transform(FileTitleTmpl, _this, trans, _this); + } else if (key == "getSummary") { + value = stringUtil.transform(FileSummaryTmpl, _this, trans, _this); + } else if (key == "getVisibility") { + value = stringUtil.transform(FileVisibilityTmpl, _this, trans, _this); + } else if (key == "getVisibilityShare" && shareWithId) { + value = stringUtil.transform(FileVisibilityShareTmpl, _this, trans, _this); + } + return value; + }; + var postData = stringUtil.transform(FolderTmpl, this, transformer, this); + return stringUtil.trim(postData); + }, - /** - * @method getAsBoolean - * @returns - */ - getAsBoolean : function(property) { - return null; - }, + _constructPayloadForMultipleEntries : function(listOfIds, multipleEntryId, category) { + var payload = FileFeedTmpl; + var entriesXml = ""; + var categoryXml = ""; + var itemXml = ""; + var currentId = ""; + var transformer = function(value, key) { + if (key == "category") { + value = xml.encodeXmlEntry(category); + } else if (key == "getCategory") { + value = categoryXml; + } else if (key == "fileId") { + value = xml.encodeXmlEntry(currentId); + } else if (key == "getItem") { + value = itemXml; + } else if (key == "getEntries") { + value = entriesXml; + } + return value; + }; + var _this = this; - /** - * @method getAsArray - * @returns - */ - getAsArray : function(property) { - return null; - }, + for ( var counter in listOfIds) { + currentId = listOfIds[counter]; + var entryXml = FileItemEntryTmpl; + if (category) { + categoryXml = stringUtil.transform(FileCategoryTmpl, _this, transformer, _this); + } + itemXml = stringUtil.transform(FileItemIdTmpl, _this, transformer, _this); + entryXml = stringUtil.transform(entryXml, _this, transformer, _this); + entriesXml = entriesXml + entryXml; + } - /** - * @method getEntityId - * @returns - */ - getEntityId : function(data) { - return null; - }, + if (entriesXml != "") { + payload = stringUtil.transform(payload, _this, transformer, _this); + } + return payload; + }, + + _constructPayloadForComment : function(isDelete, comment) { - /** - * @param parent - * @returns - */ - getEntityData : function(parent) { - return data; - }, + var payload = FileCommentsTmpl; + var categoryXml = ""; + var contentXml = ""; + var deleteXml = ""; + var _this = this; - /** - * @method getSummary - * @returns - */ - getSummary : function() { - return null; - }, + var transformer = function(value, key) { + if (key == "category") { + value = xml.encodeXmlEntry("comment"); + } else if (key == "content") { + value = xml.encodeXmlEntry(comment); + } else if (key == "deleteWithRecord") { + value = "true"; + } else if (key == "getCategory" && categoryXml != "") { + value = categoryXml; + } else if (key == "getContent" && contentXml != "") { + value = contentXml; + } else if (key == "getDeleteComment" && deleteXml != "") { + value = deleteXml; + } + return value; + }; - /** - * @method getEntitiesDataArray - * @returns {Array} - */ - getEntitiesDataArray : function() { - return []; - }, - - /** - * @method toJso - * @returns {Object} - */ - toJson : function() { - } + categoryXml = stringUtil.transform(FileCategoryTmpl, _this, transformer, _this); - }); - return DataHandler; -}); -}, -'url:sbt/connections/controls/forums/templates/ForumTopicRow.html':"\r\n\t\r\n\t\t\r\n \r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t${title}\r\n\t\t\t${isTopicLocked}\r\n\t\t

    \r\n\t\t\r\n\t\r\n\t\r\n\t\r\n\t${threadCount}\r\n\t\r\n\t${getDateLabel}\r\n", -'sbt/connections/controls/activities/nls/ActivityGridRenderer':function(){ -/* - * © 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. - */ + contentXml = stringUtil.transform(FileContentTmpl, _this, transformer, _this); + if (isDelete) { + deleteXml = stringUtil.transform(FileDeleteCommentTmpl, _this, transformer, _this); + } -// NLS_CHARSET=UTF-8 -define({ - root: { - updatedBy: "Updated by", - modified: "Last Updated", - dueDate: "Due Date: ", - name: "Name", - feed : "Feed for these Activities", - tags:"Tags: " - } -}); -}, -'sbt/connections/controls/profiles/ProfilePanel':function(){ -require({cache:{ -'url:sbt/connections/controls/profiles/templates/ProfilePanel.html':"
    \r\n\t
    \r\n\t\t
    \r\n\t\t\t\"${getThumbnailAlt}\"\r\n\t\t
    \r\n\t
    \r\n\t\r\n\t
    \r\n\t\t\r\n\t\t\t\r\n\t\t\t${getName}\r\n\t\t\t\r\n\t\t\t${getUserid}\r\n\t\t\r\n\t
    \r\n\t\r\n\t
    \r\n\t\t ${getJobTitle}
    \r\n\t\t${getTelephoneNumber}
    \r\n\t\t${getEmail}
    \r\n\t
    \r\n
    "}}); -/* - * © 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. - */ + payload = stringUtil.transform(payload, this, transformer, this); + return payload; + }, + + _constructPayload : function(payloadMap, documentId) { -/** - * @module sbt.connections.controls.profiles.ProfilePanel - */ -define(["../../../declare", "../../../lang", "../../../config", - "../../../connections/ProfileService", - "../../../controls/panel/_ProfilePanel", - "../../../text!sbt/connections/controls/profiles/templates/ProfilePanel.html"], - function(declare, lang, config, ProfileService, _ProfilePanel, PanelTmpl) { + var payload = FileEntryTmpl; + var categoryXml = ""; + var idXml = ""; + var uuidXml = ""; + var labelXml = ""; + var titleXml = ""; + var summaryXml = ""; + var visibilityXml = ""; + var itemXml = ""; + var tagsXml = ""; + var notificationXml = ""; + var currentValue = null; + var transformer = function(value, key) { + if (currentValue) { + value = xml.encodeXmlEntry(currentValue); + } else if (key == "getCategory" && categoryXml != "") { + value = categoryXml; + } else if (key == "getId" && idXml != "") { + value = idXml; + } else if (key == "getUuid" && uuidXml != "") { + value = uuidXml; + } else if (key == "getLabel" && labelXml != "") { + value = labelXml; + } else if (key == "getTitle" && titleXml != "") { + value = titleXml; + } else if (key == "getSummary" && summaryXml != "") { + value = summaryXml; + } else if (key == "getVisibility" && visibilityXml != "") { + value = visibilityXml; + } else if (key == "getItem" && itemXml != "") { + value = itemXml; + } else if (key == "getTags" && tagsXml != "") { + value = tagsXml; + } else if (key == "getNotification" && notificationXml != "") { + value = notificationXml; + } + return value; + }; - var basicPeopleMe = "/connections/opensocial/basic/rest/people/@me/"; - var oauthPeopleMe = "/connections/opensocial/oauth/rest/people/@me/"; - - /** - * @module sbt.connections.controls.profiles.ProfilePanel - */ - var ProfilePanel = declare([ _ProfilePanel ], { - - template: PanelTmpl, - profileService: null, - - constructor: function(args) { - }, - - getMyProfile: function() { - var endpoint = this._getEndpoint(); - var path = basicPeopleMe; - if (endpoint.authType == 'oauth') { - path = oauthPeopleMe; - } - - var self = this; - endpoint.request(path, { handleAs : "json", preventCache : true }).then( - function(response) { - var userid = response.entry.id.replace('urn:lsid:lconn.ibm.com:profiles.person:', ''); - self.getProfile(userid); - }, - function(error) { - self._displayError(error); - } - ); - }, - - getProfile: function(id) { - var self = this; - var promise = this._getProfileService().getProfile(id); - promise.then( - function(profile) { - self.profile = profile; - self.showProfile(); - }, - function(error) { - self.profile = null; - self._displayError(error); - } - ); - }, - - // Internals - - _getProfileService: function() { - if (!this.profileService) { - this.profileService = new ProfileService(this._getEndpointName()); - } - return this.profileService; - }, - - _getEndpoint: function() { - return config.findEndpoint(this._getEndpointName()); - }, - - _getEndpointName: function() { - return this.endpoint || "connections"; - } - - }); - - return ProfilePanel; -}); -}, -'url:sbt/connections/controls/files/templates/BootstrapFolderRow.html':"\r\n \r\n \r\n \r\n ${title} \r\n \r\n\r\n \r\n \r\n", -'sbt/_bridge/ready':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ + for ( var currentElement in payloadMap) { + currentValue = payloadMap[currentElement]; + if (currentElement.indexOf("category") != -1) { + categoryXml = stringUtil.transform(FileCategoryTmpl, this, transformer, this); + } else if (currentElement.indexOf("id") != -1) { + idXml = stringUtil.transform(FileIdTmpl, this, transformer, this); + } else if (currentElement.indexOf("uuid") != -1) { + uuidXml = stringUtil.transform(FileUuidTmpl, this, transformer, this); + } else if (currentElement.indexOf("label") != -1) { + labelXml = stringUtil.transform(FileLabelTmpl, this, transformer, this); + titleXml = stringUtil.transform(FileTitleTmpl, this, transformer, this); + } else if (currentElement.indexOf("summary") != -1) { + summaryXml = stringUtil.transform(FileSummaryTmpl, this, transformer, this); + } else if (currentElement.indexOf("visibility") != -1) { + visibilityXml = stringUtil.transform(FileVisibilityTmpl, this, transformer, this); + } else if (currentElement.indexOf("itemId") != -1) { + itemXml = stringUtil.transform(FileItemIdTmpl, this, transformer, this); + } else if (currentElement.indexOf("tags") != -1) { + var tags = currentValue; + for ( var tag in tags) { + tagsXml += stringUtil.transform(TagsTmpl, { + "tag" : tags[tag] + }); + } + } else if (currentElement.contains("notification")) { + notificationXml = stringUtil.transform(NotificationTmpl, this, transformer, this); + } + } + currentValue = null; -/** - * Social Business Toolkit SDK - ready() function. - */ -define(['dojo/ready'],function(ready) { - return function(fct) { - ready(fct); - }; + payload = stringUtil.transform(payload, this, transformer, this); + return payload; + } + }); + return FileService; }); -}, -'sbt/connections/WikiConstants':function(){ -/* - * © 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. - */ -/** - * Social Business Toolkit SDK. - * Definition of constants for WikiService. - */ -define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - /** - * XPath expressions to be used when reading a wiki or wiki page entry - */ - var BaseWikiXPath = lang.mixin({ - uuid : "td:uuid", - label : "td:label", - permissions : "td:permissions", - tags : "a:category[not(@scheme)]/@term", - modifierName : "td:modifier/a:name", - modifierEmail : "td:modifier/a:email", - modifierUserid : "td:modifier/snx:userid", - modifierUserState : "td:modifier/snx:userState", - created : "td:created", - modified : "td:modified", - member : "ca:member", - memberId : "ca:member/@ca:id", - memberType : "ca:member/@ca:type", - memberRole : "ca:member/@ca:role" - }, conn.AtomEntryXPath); +}, +'url:sbt/connections/controls/astream/templates/ActivityStreamContent.html':"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n", +'sbt/smartcloud/controls/profiles/ColleagueGridRenderer':function(){ +require({cache:{ +'url:sbt/smartcloud/controls/profiles/templates/ColleagueItem.html':"
    \r\n \r\n \"${name}\"\r\n \r\n
    \r\n", +'url:sbt/smartcloud/controls/profiles/templates/ColleagueItemFull.html':"\r\n \t\r\n \r\n \"${name}\r\n \r\n \r\n \r\n ${name}\r\n \r\n\r\n", +'url:sbt/smartcloud/controls/profiles/templates/ViewAll.html':"\r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n ${viewAllTitle}\r\n \r\n
    "}}); +define(["../../../declare", + "../BaseGridRenderer", + "../../../text!./templates/ColleagueItem.html", + "../../../stringUtil", + "../../../lang", + "../../../dom", + "./nls/ColleagueGridRenderer", + "../../../text!./templates/ColleagueItemFull.html", + "../../../text!./templates/ViewAll.html"], + +function(declare, BaseGridRenderer, ColleagueItemTemplate, stringUtil, lang, dom, nls, colleagueItemFullTemplate, viewAllTemplate){ - return lang.mixin(conn, { - - /** - * XPath expressions used when parsing a Connections Wiki ATOM feed - */ - WikiFeedXPath : conn.ConnectionsFeedXPath, - - /** - * XPath expressions to be used when reading a wiki entry - */ - WikiXPath : lang.mixin({ - communityUuid : "snx:communityUuid", - themeName : "td:themeName", - librarySize : "td:librarySize", - libraryQuota : "td:libraryQuota", - totalRemovedSize : "td:totalRemovedSize" - }, BaseWikiXPath, conn.AtomEntryXPath), - - /** - * XPath expressions to be used when reading a wiki page entry - */ - WikiPageXPath : lang.mixin({ - lastAccessed : "td:lastAccessed", - versionUuid : "td:versionUuid", - versionLabel : "td:versionLabel", - propagation : "td:propagation", - totalMediaSize : "td:totalMediaSize", - recommendations : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", - comment : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/comment']", - hit : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/hit']", - anonymous_hit : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/anonymous_hit']", - share : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/share']", - collections : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/collections']", - attachments : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/attachments']", - versions : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/versions']" - }, BaseWikiXPath, conn.AtomEntryXPath), - - /** - * This returns a feed of wikis to which the authenticated user has access. - */ - WikisAll : "/{wikis}/{authType}/api/wikis/feed", - - /** - * This returns a feed of wikis to which everyone who can log into the Wikis application has access. - */ - WikisPublic : "/{wikis}/{authType}/api/wikis/public", - - /** - * This returns a feed of wikis of which the authenticated user is a member. - */ - WikisMy : "/{wikis}/{authType}/api/mywikis/feed", - - /** - * This returns a feed of wikis to which everyone who can log into the Wikis application has access. - */ - WikisMostCommented : "/{wikis}/{authType}/anonymous/api/wikis/mostcommented", - - /** - * This returns a feed of wikis to which everyone who can log into the Wikis application has access. - */ - WikisMostRecommended : "/{wikis}/{authType}/api/wikis/mostrecommended", - - /** - * This returns a feed of wikis to which everyone who can log into the Wikis application has access. - */ - WikisMostVisited : "/{wikis}/{authType}/api/wikis/mostvisited", + var ColleagueGridRenderer = declare(BaseGridRenderer, { + + _nls: nls, + + containerClass: "lotusChunk", + + /** The template used to construct a photo url */ + contactImageUrl: "{baseUrl}/contacts/img/photos/{photo}", - /** - * This returns a feed of the pages in a given wiki. - */ - WikiPages : "/{wikis}/{authType}/anonymous/api/wiki/{wikiLabel}/feed", + /** The template used to construct a no photo url*/ + noContactImageUrl: "{baseUrl}/contacts/img/noContactImage.gif", - /** - * Get a feed that lists all of the pages in a specific wiki that have been added or edited by the authenticated user. - */ - WikiMyPages : "/{wikis}/{authType}/api/wiki/{wikiLabel}/mypages", + /**The table row template*/ + template: ColleagueItemTemplate, + + fullTemplate: colleagueItemFullTemplate, + + viewAllTemplate: viewAllTemplate, + + /**The HTML template to show paging */ + pagerTemplate : null, + + /**The HTML template to show sorting options*/ + sortTemplate : null, + /**The HTML template for sort Anchors*/ + sortAnchor : null, + /** - * This returns a feed that lists the pages that have been deleted from wikis and are currently stored in the trash. - */ - WikiRecycleBin : "/{wikis}/{authType}/anonymous/api/wiki/{wikiLabelOrId}/recyclebin/feed", - - /** - * Retrieve an Atom document of a wiki. - */ - WikiEntry : "/{wikis}/{authType}/api/wiki/{wikiLabel}/entry", - - /** - * Returns a wiki page after authenticating the request. - */ - WikiPageEntry : "/{wikis}/{authType}/api/wiki/{wikiLabel}/page/{pageLabel}/entry", - - /** - * Post to this feed to create a wiki page. + * The constructor function + * @method constructor + * @param args */ - WikiFeed : "/{wikis}/{authType}/api/wiki/{wikiLabel}/feed" - - }); -}); -}, -'url:sbt/connections/controls/bootstrap/templates/TagAnchor.html':"${tagName}", -'sbt/MockTransport':function(){ -/* - * © 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. - */ - -/** - * Social Business Toolkit SDK. - * - * Implementation of a transport which returns mock data. - */ -define([ "./declare", "./lang", "./dom", "./xml", "./json", "./stringUtil", "./Promise" ], - function(declare, lang, dom, xml, json, stringUtil, Promise) { - return declare(null, { - - requestMap : {}, + constructor: function(args) { + }, /** - * Provides mock data if available in the DOM. + * @param grid + * @param item + * @param i + * @param items + * @returns {String} */ - request : function(url, options) { - var query = this.createQuery(options.query); - if(url && query){ - url += (~url.indexOf('?') ? '&' : '?') + query; - } - - var promise = new Promise(); - promise.response = new Promise(); - - var id = url; - var hash = stringUtil.hashCode(id); - if (this.requestMap[hash]) { - this.requestMap[hash] = this.requestMap[hash] + 1; - id += "#" + this.requestMap[hash]; - } else { - this.requestMap[hash] = 1; - } - - var domNode = dom.byId(id); - if (domNode) { - var response = domNode.text || domNode.textContent; - var handleAs = domNode.getAttribute("handleAs"); - if (handleAs == "json") { - response = json.parse(response); - } - - var status = domNode.getAttribute("status"); - - var error = domNode.getAttribute("error"); - if (error == "true") { - var error = new Error(); - error.code = Number(status || 400); - error.message = this.getErrorText(response); - error.response = this.createResponse(url, options, response, Number(status || 400), {}); - promise.rejected(error); - promise.response.rejected(error); - } else { - var location = domNode.getAttribute("location"); - var headers = { - Location : location - }; - - promise.fulfilled(response); - promise.response.fulfilled(this.createResponse(url, options, response, Number(status || 200), headers)); - } - } - else { - var message = "Unable to find mock response for: "+url; - var error = new Error(message); - error.response = { status : 400 , message : message }; - promise.rejected(error); - promise.response.rejected(error); - } - - return promise; + photoUrl: function(grid, item, i, items) { + var ep = grid.store.getEndpoint(); + if (!ep) return null; + + var photos = item.getValue("photos"); + if (photos && lang.isArray(photos) && photos.length > 1) { + return stringUtil.replace(this.contactImageUrl, { baseUrl : ep.baseUrl , photo : photos[1] }); + }else{ + return stringUtil.replace(this.noContactImageUrl, { baseUrl : ep.baseUrl }); + } }, - /* - * Create a response object - */ - createResponse: function(url, options, response, status, headers) { - var handleAs = options.handleAs || "text"; - return { - url : url, - options : options, - data : response, - text : (handleAs == "text") ? response : null, - status : status, - getHeader : function(headerName) { - return headers[headerName]; - } - }; - }, - - /* - * Create a query string from an object - */ - createQuery: function(queryMap) { - if (!queryMap) { - return null; + render: function(grid, el, items, data) { + while (el.childNodes[0]) { + dom.destroy(el.childNodes[0]); } - var pairs = []; - for(var name in queryMap){ - var value = queryMap[name]; - pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(value)); + var size = items.length; + if (size === 0) { + this.renderEmpty(grid, el); } - return pairs.join("&"); - }, - - getErrorText: function(text) { - if (text) { - try { - var dom = xml.parse(text); - var messages = dom.getElementsByTagName("message"); - if (messages && messages.length != 0) { - text = messages[0].text || messages[0].textContent; - text = lang.trim(text); - } - } catch(ex) {} - return text.replace(/(\r\n|\n|\r)/g,""); - } else { - return text; + else { + var container = this.renderContainer(grid, el, items, data); + for (var i=0; i\r\n
      \r\n
    • \r\n ${_nls.eventDateOn}\r\n \r\n ${eventStartDate}\r\n \r\n
    • \r\n ${bodyCalendarLis}\r\n ${personCard}\r\n
    \r\n", -'url:sbt/connections/controls/search/templates/MemberListItemTemplate.html':"\r\n\t\r\n\t\t${memberName}\r\n\t\tX\r\n\t  \r\n", -'url:sbt/controls/grid/bootstrap/templates/GridFooter.html':"
    \r\n
    \r\n\t\r\n\t\tShow:\r\n\t\t\r\n\t\t\t10\r\n\t\t|\r\n\t\t\r\n\t\t\t25\r\n\t\t|\r\n\t\t\r\n\t\t\t50\r\n\t\t|\r\n\t\t\r\n\t\t\t100\r\n\t\t ${nls.items}\r\n\t\r\n
    \r\n
    \r\n\t${nls.feed}\r\n
    \r\n
    ", -'sbt/authenticator/nls/SSO':function(){ +'sbt/defer':function(){ /* * © Copyright IBM Corp. 2013 * @@ -13807,31 +7603,33 @@ define([ "./declare", "./lang", "./dom", "./xml", "./json", "./stringUtil", "./P * 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 + * 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. - */ + */ /** - * Social Business Toolkit SDK - Default resource bundle for validate module. + * Defer plugin. + * @author Carlos Manias */ - - -define({ - root: ({ - message_title: "ReAuthenticate", - message:"Authentication expired, Please login again." - }) - +define([], function(text) { + return { + load: function (id, require, load) { + require([id], function (value) { + load(value); + }); + } + }; }); + }, -'url:sbt/connections/controls/forums/templates/ReplyBreadCrumb.html':"
    \r\n\r\nForums>Topics>Replies\r\n
    ", -'url:sbt/controls/grid/templates/GridFooter.html':"
    \r\n\t
      \r\n\t\tShow:\r\n\t\t
    • \r\n\t\t\t10\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t25\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t50\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t100\r\n\t\t
    • ${nls.items}\r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t
    \r\n
    \r\n
    \r\n\t${nls.feed}\r\n
    ", -'sbt/connections/WikiService':function(){ +'url:sbt/smartcloud/controls/profiles/templates/ViewAll.html':"\r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n ${viewAllTitle}\r\n \r\n
    ", +'url:sbt/connections/controls/search/templates/td.html':"${content}", +'sbt/connections/BookmarkService':function(){ /* * © Copyright IBM Corp. 2013 * @@ -13849,1265 +7647,2006 @@ define({ */ /** - * The Wikis application of IBM© Connections enables teams to create a shared repository of information. - * The Wikis API allows application programs to create new wikis, and to read and modify existing wikis. + * The Bookmarks API can be used to save, organize, and share Internet and intranet bookmarks. The Bookmarks API allows + * application programs to read and write to the collections of bookmarks stored in the Bookmarks application.. * - * @module sbt.connections.WikiService + * @module sbt.connections.BookmarkService */ -define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./WikiConstants", "./ConnectionsService", - "../base/AtomEntity", "../base/XmlDataHandler" ], - function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler) { - - var CategoryWiki = ""; - var CategoryWikiPage = ""; - - var LabelTmpl = "${getLabel}"; - var PermissionsTmpl = "${getPermissions}"; - var CategoryTmpl = ""; +define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./BookmarkConstants", "./ConnectionsService", + "../base/AtomEntity", "../base/XmlDataHandler", "./Tag"], + function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler, Tag) { + + var BookmarkTmpl = "${getTitle}${isPrivate}${getContent}${getTags}"; + var CategoryPrivateFlag = "" + CategoryTmpl = ""; + var CategoryBookmark = ""; /** - * Wiki class represents an entry for a Wiki or Wiki Page feed returned by the + * Bookmark class represents an entry for a Bookmarks feed returned by the * Connections REST API. * - * @class BaseWikiEntity + * @class Bookmark * @namespace sbt.connections */ - var BaseWikiEntity = declare(AtomEntity, { - - /** - * Set to true to include the label in the post data when - * performing an update or create operation. By default the - * label is not sent which will keep it in synch with the - * Wiki or WikiPage title. - */ - includeLabelInPost : false, - + var Bookmark = declare(AtomEntity, { + + xpath : consts.BookmarkXPath, + namespaces : consts.BookmarkNamespaces, + categoryScheme : CategoryBookmark, + /** + * Construct a Bookmark entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, + + /** + * Return the value of IBM Connections bookmark ID from bookmark ATOM + * entry document. + * + * @method getBookmarkUuid + * @return {String} ID of the bookmark + */ + getBookmarkUuid : function() { + return this.getAsString("BookmarkUuid"); + }, + + /** + * Sets id of IBM Connections bookmark. + * + * @method setBookmarkUuid + * @param {String} bookmarkUuid of the bookmark + */ + setBookmarkUuid : function(BookmarkUuid) { + return this.setAsString("BookmarkUuid", BookmarkUuid); + }, + + /** + * Return the value of private flag + * + * @method isPrivate + * @return {String} accessibility flag of the bookmark + */ + isPrivate : function() { + return this.getAsBoolean("privateFlag"); + }, + + /** + * Sets the value of private flag + * + * @method setPrivate + * @param {String} accessibility flag of the bookmark + */ + setPrivate : function(privateFlag) { + return this.setAsBoolean("privateFlag", privateFlag); + }, + /** - * Construct a BaseWikiEntity entity. + * Return the value of IBM Connections bookmark URL from bookmark ATOM + * entry document. * - * @constructor - * @param args + * @method getUrl + * @return {String} Bookmark URL of the bookmark */ - constructor : function(args) { + getUrl : function() { + return this.getAsString("link"); }, - + /** - * Return extra entry data to be included in post data for this entity. + * Sets title of IBM Connections bookmark. * - * @returns {String} + * @method setUrl + * @param {String} title Title of the bookmark */ - createEntryData : function() { - var postData = ""; - var transformer = function(value,key) { - return value; - }; - if (this.getLabel() && this.includeLabelInPost) { - postData += stringUtil.transform(LabelTmpl, this, transformer, this); - } - if (this.getPermissions()) { - postData += stringUtil.transform(PermissionsTmpl, this, transformer, this); - } - return stringUtil.trim(postData); + setUrl : function(link) { + return this.setAsString("link", link); }, /** - * Return an array containing the tags for this wiki. + * Return the click count of the IBM Connections bookmark. * - * @method getTags - * @return {Array} + * @method getClickCount + * @return {String} click count of the bookmark */ - getTags : function() { - var tags = this.getAsArray("tags"); - return this.getAsArray("tags"); + getClickCount : function() { + return this.getAsString("clickcount"); }, /** - * Return an array containing the tags for this wiki. + * Return the category type of the IBM Connections bookmark. * - * @method setTags - * @param {Array} + * @method getCategoryType + * @return {String} content of the bookmark */ - setTags : function(tags) { - return this.setAsArray("tags", tags); + getCategoryType : function() { + return this.getAsString("categoryType"); }, - + /** - * Return the value of id from Wiki ATOM - * entry document. + * Return the edit link for IBM Connections bookmark. * - * @method getWikiUuid - * @return {String} Id of the Wiki + * @method getEditLink + * @return {String} edit link of the bookmark */ - getUuid : function() { - var uid = this.getAsString("uuid"); - return extractWikiUuid(uid); + getEditLink : function() { + return this.getAsString("linkEdit"); }, - + /** - * Sets id of IBM Connections Wiki ATOM - * entry document. + * Return the same link for IBM Connections bookmark. * - * @method setWikiUuid - * @param {String} Id of the Wiki + * @method getSameLink + * @return {String} same link of the bookmark */ - setUuid : function(uuid) { - return this.setAsString("uuid", uuid); + getSameLink : function() { + return this.getAsString("linkSame"); }, /** - * Return short text label used to identify the Wiki Entry in API operation resource addresses. + * Gets an author of IBM Connections Bookmark. * - * @method getLabel - * @return {String} short text label used to identify the Wiki Entry in API operation resource addresses. + * @method getAuthor + * @return {Member} Author of the bookmark */ - getLabel : function() { - return this.getAsString("label"); + getAuthor : function() { + return this.getAsObject([ "authorId", "authorName", "authorEmail", "authorUri" ]); }, /** - * Set the short text label used to identify the Wiki Entry in API operation resource addresses. + * Return tags of IBM Connections bookmark + * document. * - * @method setLabel - * @param label short text label used to identify the Wiki Entry in API operation resource addresses. + * @method getTags + * @return {Object} Array of tags of the bookmark */ - setLabel : function(label) { - return this.setAsString("label", label); + getTags : function() { + return this.getAsArray("tags"); }, /** - * Return the set of permissions available for the Wiki Entry. + * Set new tags to be associated with this IBM Connections bookmark. * - * @method getPermissions - * @return {String} Permissions available for the Wiki Entry + * @method setTags + * @param {Object} Array of tags to be added to the bookmark */ - getPermissions : function() { - return this.getAsString("permissions"); + + setTags : function(tags) { + return this.setAsArray("tags", tags); }, - + /** - * Set the permissions available for the Wiki Entry. + * Loads the bookmark object with the atom entry associated with the + * bookmark. By default, a network call is made to load the atom entry + * document in the bookmark object. * - * @method setPermissions - * @param permissions Permissions available for the Wiki Entry + * @method load + * @param {Object} [args] Argument object */ - setPermissions : function(permissions) { - return this.setAsString("permissions", permissions); + load : function(args) { + // detect a bad request by validating required arguments + var bookmarkUrl = this.getUrl(); + var promise = this.service._validateBookmarkUrl(bookmarkUrl); + if (promise) { + return promise; + } + + var self = this; + var callbacks = { + createEntity : function(service,data,response) { + self.setDataHandler(new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BookmarkXPath + })); + return self; + } + }; + var requestArgs = lang.mixin({ + url : bookmarkUrl + }, args || {}); + + var options = { + handleAs : "text", + query : requestArgs + }; + return this.service.getEntity(consts.AtomBookmarkCreateUpdateDelete, options, bookmarkUrl, callbacks); }, - + /** - * Return modifier of the Wiki Entry. + * Remove this bookmark * - * @method getModifier - * @return {Object} Modifier of the Wiki Entry + * @method remove + * @param {Object} [args] Argument object */ - getModifier : function() { - return this.getAsObject( - [ "modifierUserid", "modifierName", "modifierEmail", "modifierUserState" ], - [ "userid", "name", "email", "userState" ]); + remove : function(args) { + return this.service.deleteBookmark(this.getUrl(), args); }, /** - * Return the date the wiki was created. + * Update this bookmark * - * @method getCreated - * @return {Date} Date the wiki was created + * @method update + * @param {Object} [args] Argument object */ - getCreated : function() { - return this.getAsDate("created"); + update : function(args) { + return this.service.updateBookmark(this, args); }, - + /** - * Return the date the wiki was modified. + * Save this bookmark * - * @method getModified - * @return {Date} Date the wiki was modified + * @method save + * @param {Object} [args] Argument object */ - getModified : function() { - return this.getAsDate("modified"); + save : function(args) { + if (this.getBookmarkUuid()) { + return this.service.updateBookmark(this, args); + } else { + return this.service.createBookmark(this, args); + } } }); + /* + * Callbacks used when reading a feed that contains bookmark entries. + */ + var ConnectionsBookmarkFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BookmarkFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new Bookmark({ + service : service, + data : data + }); + } + }; + + /* + * Callbacks used when reading a feed that contains bookmark entries. + */ + var ConnectionsTagsFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.TagsXPath + }); + }, + createEntity : function(service,data,response) { + var entryHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.TagsXPath + }); + return new Tag({ + service : service, + id : entryHandler.getEntityId(), + dataHandler : entryHandler + }); + } + }; + /** - * Wiki class represents an entry for a Wiki feed returned by the - * Connections REST API. + * BookmarkService class. * - * @class Wiki + * @class BookmarkService * @namespace sbt.connections */ - var Wiki = declare(BaseWikiEntity, { + var BookmarkService = declare(ConnectionsService, { - xpath : consts.WikiXPath, - contentType : "html", - categoryScheme : CategoryWiki, + contextRootMap: { + dogear : "dogear" + }, + + serviceName : "dogear", /** - * Construct a Wiki entity. + * Constructor for BookmarkService * * @constructor * @param args */ constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } }, /** - * Return the community©s unique ID if this wiki belongs to a community. + * Get the All Bookmarks feed to see a list of all bookmarks to which the + * authenticated user has access. * - * @method getCommunityUuid - * @return {String} Uuid of the Community + * @method getAllBookmarks + * + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of all bookmarks. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. */ - getCommunityUuid : function() { - return this.getAsString("communityUuid"); + getAllBookmarks : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + return this.getEntities(consts.AtomBookmarksAll, options, this.getBookmarkFeedCallbacks()); }, - + /** - * Set the community©s unique ID if this wiki belongs to a community. + * Get the popular Bookmarks feed. * - * @method setCommunityUuid - * @param {String} communityUuid Community Uuid of the forum - * @return {Wiki} + * @method getPopularBookmarks + * + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of all bookmarks. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. */ - setCommunityUuid : function(communityUuid) { - return this.setAsString("communityUuid", communityUuid); + getPopularBookmarks : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomBookmarksPopular, options, this.getBookmarkFeedCallbacks()); }, /** - * return the wiki theme name. + * A feed of bookmarks that others notified me about. * - * @method getThemeName - * @return {String} Wiki theme name + * @method getBookmarksMyNotifications + * + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of all bookmarks. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. */ - getThemeName : function() { - return this.getAsString("themeName"); + getBookmarksMyNotifications : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomBookmarksMyNotifications, options, this.getBookmarkFeedCallbacks()); }, - + /** - * Return the library size. + * A feed of bookmarks about which I notified others.. * - * @method getLibrarySize - * @return {Number} the library size + * @method getBookmarksMySentNotifications + * + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of all bookmarks. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. */ - getLibrarySize : function() { - return this.getAsNumber("librarySize"); + getBookmarksMySentNotifications : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomBookmarksINotifiedMySentNotifications, options, this.getBookmarkFeedCallbacks()); }, - + /** - * Return the library quota. + * Retrieve a bookmark instance. * - * @method getLibraryQuota - * @return {Number} the library quota + * @method getBookmark + * @param {String } bookmarkUrl + * @param {Object} args Object containing the query arguments to be + * sent (defined in IBM Connections Bookmarks REST API) */ - getLibraryQuota : function() { - return this.getAsNumber("libraryQuota"); + getBookmark : function(bookmarkUrl, args) { + var bookmark = new Bookmark({ + service : this, + _fields : { link : bookmarkUrl } + }); + return bookmark.load(args); }, /** - * Return the total removed size. + * Create a bookmark by sending an Atom entry document containing the + * new bookmark. * - * @method getTotalRemovedSize - * @return {Number} the total removed size + * @method createBookmark + * @param {String} url Url to post to when creating the bookmark. + * @param {String/Object} bookmarkOrJson Bookmark object which denotes the bookmark to be created. + * @param {Object} [args] Argument object */ - getTotalRemovedSize : function() { - return this.getAsNumber("totalRemovedSize"); + createBookmark : function(bookmarkOrJson, args) { + var bookmark = this._toBookmark(bookmarkOrJson); + var promise = this._validateBookmark(bookmark, false, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + if (data) { + var dataHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BookmarkXPath + }); + bookmark.setDataHandler(dataHandler); + bookmark.setData(data); + } else { + bookmark.setData(data); + var referenceId = this.getLocationParameter(response, "referenceId"); + bookmark.setBookmarkUuid(referenceId); + } + return bookmark; + }; + + var url = consts.AtomBookmarkCreateUpdateDelete; + + if (args && args.url) { + url = args.url; + delete args.url; + } + + var options = { + method : "POST", + query : args || {}, + headers : consts.AtomXmlHeaders, + data : this._constructBookmarkPostData(bookmark) + }; + + return this.updateEntity(url, options, callbacks, args); }, - + /** - * Get a list for wiki pages from this wiki. + * Update a bookmark by sending a replacement bookmark entry document + * to the existing bookmark's edit web address. + * All existing bookmark entry information will be replaced with the new data. To avoid + * deleting all existing data, retrieve any data you want to retain first, and send it back + * with this request. For example, if you want to add a new tag to a bookmark entry, retrieve + * the existing tags, and send them all back with the new tag in the update request. * - * @method getPages - * @param {Object} args + * @method updateBookmark + * @param {String/Object} bookmarkOrJson Bookmark object + * @param {Object} [args] Argument object */ - getPages : function(args) { - return this.service.getWikiPages(this.getLabel(), args); + updateBookmark : function(bookmarkOrJson,args) { + var bookmark = this._toBookmark(bookmarkOrJson); + var promise = this._validateBookmark(bookmark, true, args); + if (promise) { + return promise; + } + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + var bookmarkUuid = bookmark.getBookmarkUuid(); + if (data) { + var dataHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BookmarkXPath + }); + bookmark.setDataHandler(dataHandler); + } + bookmark.setBookmarkUuid(bookmarkUuid); + return bookmark; + }; + + var requestArgs = lang.mixin({ + url : bookmark.getUrl() + }, args || {}); + var options = { + method : "PUT", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : this._constructBookmarkPostData(bookmark) + }; + return this.updateEntity(consts.AtomBookmarkCreateUpdateDelete, options, callbacks, args); }, /** - * Loads the wiki object with the atom entry associated with the - * wiki. By default, a network call is made to load the atom entry - * document in the wiki object. + * Delete a bookmark, use the HTTP DELETE method. * - * @method load + * @method deleteBookmark + * @param {String} bookmarkUuid bookmark id of the bookmark or the bookmark object (of the bookmark to be deleted) * @param {Object} [args] Argument object */ - load : function(args) { - // detect a bad request by validating required arguments - var label = this.getLabel(); - var promise = this.service._validateWikiLabel(label); + deleteBookmark : function(bookmarkUrl,args) { + var promise = this._validateBookmarkUrl(bookmarkUrl); if (promise) { return promise; - } - - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - self.setData(data); - return self; - } + } + + var requestArgs = lang.mixin({ + url : bookmarkUrl + }, args || {}); + + var options = { + method : "DELETE", + query : requestArgs, + handleAs : "text" }; + + return this.deleteEntity(consts.AtomBookmarkCreateUpdateDelete, options, bookmarkUrl); + }, + /** + * Get the tags feed to see a list of the tags for all bookmarks. + * + * @method getBookmarksTags + * @param {Object} [args] Object representing various parameters. + * The parameters must be exactly as they are supported by IBM + * Connections. + */ + getBookmarksTags : function(args) { var options = { method : "GET", handleAs : "text", query : args || {} }; - var url = this.service.constructUrl(consts.WikiEntry, null, { "wikiLabel" : encodeURIComponent(label) }); - - return this.service.getEntity(url, options, label, callbacks); - }, - - /** - * Remove this wiki - * - * @method remove - * @param {Object} [args] Argument object - */ - remove : function(args) { - return this.service.deleteWiki(this.getLabel(), args); + return this.getEntities(consts.AtomBookmarksTags, options, this.getTagsFeedCallbacks(), args); }, - + /** - * Update this wiki + * Create a Bookmark object with the specified data. * - * @method update - * @param {Object} [args] Argument object + * @method newBookmark + * @param {Object} args Object containing the fields for the + * new bookmark */ - update : function(args) { - return this.service.updateWiki(this, args); + newBookmark : function(args) { + return this._toBookmark(args); }, - /** - * Save this wiki - * - * @method save - * @param {Object} [args] Argument object + /* + * Callbacks used when reading a feed that contains Bookmark entries. */ - save : function(args) { - if (this.getWikiUuid()) { - return this.service.updateWiki(this, args); - } else { - return this.service.createWiki(this, args); - } - } + getBookmarkFeedCallbacks: function() { + return ConnectionsBookmarkFeedCallbacks; + }, - }); - - /** - * WikiPage class represents an entry for a Wiki Page feed returned by the - * Connections REST API. - * - * @class WikiPage - * @namespace sbt.connections - */ - var WikiPage = declare(BaseWikiEntity, { - - xpath : consts.WikiPageXPath, - contentType : "html", - categoryScheme : CategoryWikiPage, - wikiLabel : null, - - /** - * Construct a Wiki entity. - * - * @constructor - * @param args + /* + * Callbacks used when reading a feed that contains Bookmark entries. */ - constructor : function(args) { + getTagsFeedCallbacks: function() { + return ConnectionsTagsFeedCallbacks; }, - /** - * Return the wiki label associated with this Wiki Page. - * - * @method getWikiLabel - * @return {String} wiki label + /* + * Return a Bookmark instance from Bookmark or JSON or String. Throws + * an error if the argument was neither. */ - getWikiLabel : function() { - if (this.wikiLabel) { - return this.wikiLabel; - } else { - return this.getAsString("label"); - } + _toBookmark : function(bookmarkOrJsonOrString) { + if (bookmarkOrJsonOrString instanceof Bookmark) { + return bookmarkOrJsonOrString; + } else { + if (lang.isString(bookmarkOrJsonOrString)) { + bookmarkOrJsonOrString = { + bookmarkUuid : bookmarkOrJsonOrString + }; + } + return new Bookmark({ + service : this, + _fields : lang.mixin({}, bookmarkOrJsonOrString) + }); + } }, - /** - * Set the wiki label associated with this Wiki Page. - * - * @method setWikiLabel - * @param {String} wiki label - * @return {WikiPage} + /* + * Validate a bookmark UUID, and return a Promise if invalid. */ - setWikiLabel : function(wikiLabel) { - this.wikiLabel = wikiLabel; - return this; + _validateBookmarkUuid : function(bookmarkUuid) { + if (!bookmarkUuid || bookmarkUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected bookmarkUuid."); + } }, - /** - * Return the last accessed date/time. - * - * @method getLastAccessed - * @return {Date} the last accessed date/time + /* + * Validate a bookmark UUID, and return a Promise if invalid. */ - getLastAccessed : function() { - return this.getAsDate("lastAccessed"); + _validateBookmarkUrl : function(bookmarkUrl) { + if (!bookmarkUrl || bookmarkUrl.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected bookmarkUrl."); + } }, - /** - * Return the version uuid. - * - * @method getVersionUuid - * @return {String} the version uuid + /* + * Validate a bookmark, and return a Promise if invalid. */ - getVersionUuid : function() { - return this.getAsString("versionUuid"); + _validateBookmark : function(bookmark,checkUuid) { + if (!bookmark || !bookmark.getTitle()) { + return this.createBadRequestPromise("Invalid argument, bookmark with title must be specified."); + } + if (checkUuid && !bookmark.getBookmarkUuid()) { + return this.createBadRequestPromise("Invalid argument, bookmark with UUID must be specified."); + } }, - - /** - * Return the version label. - * - * @method getVersionLabel - * @return {String} the version label + + /* + * Construct a post data for a Bookmark */ - getVersionLabel : function() { - return this.getAsString("versionLabel"); - }, + _constructBookmarkPostData : function(bookmark) { + var transformer = function(value,key) { + if (key == "getTags") { + var tags = value; + value = ""; + for (var tag in tags) { + value += stringUtil.transform(CategoryTmpl, { + "tag" : tags[tag] + }); + } + } else if (key == "getTitle" && !value) { + value = bookmark.getTitle(); + } else if (key == "getUrl" && !value) { + value = bookmark.getUrl(); + } else if (key == "getContent" && !value) { + value = bookmark.getContent(); + } else if (key == "isPrivate" && !value) { + if(bookmark.isPrivate()){ + value = CategoryPrivateFlag; + }else{ + value = ""; + } + } + return value; + }; + var postData = stringUtil.transform(BookmarkTmpl, bookmark, transformer, bookmark); + return stringUtil.trim(postData); + } + + }); + return BookmarkService; +}); - /** - * Return the propagation. - * - * @method getPropagation - * @return {Boolean} the propagation - */ - getPropagation : function() { - return this.getAsBoolean("propagation"); - }, +}, +'sbt/connections/controls/bootstrap/CommunityRendererMixin':function(){ +require({cache:{ +'url:sbt/connections/controls/bootstrap/templates/CommunityRow.html':"\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t\r\n\t\t\t\t${title}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t|\r\n\t\t\t\r\n\t\t\t\t\"${nls.moderated}\"\r\n\t\t\t\t${nls.moderated} \r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\"${nls.restricted}\"\r\n\t\t\t\t${nls.restricted} \r\n\t\t\t\r\n\t\t

    \r\n\t\t
    \r\n\t\t\t\r\n\t\t\t\t${numOfMembers}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${nls.updatedBy}\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t${contributorName}\r\n\t\t\t\t\t\t${contributorUserid}\r\n\t\t\t\t\t \r\n\t\t\t\t\r\n\t\t\t\t|\r\n\t\t\t\t${updatedDate}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${tagsLabel}\r\n\t\t\t\t\t${tagsAnchors}\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t

    ${summary}

    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n", +'url:sbt/connections/controls/bootstrap/templates/TagAnchor.html':"${tagName}"}}); +/* + * © 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. + */ - /** - * Return the total media size. - * - * @method getTotalMediaSize - * @return {Number} the total media size - */ - getTotalMediaSize : function() { - return this.getAsNumber("totalMediaSize"); - }, +/** + * + */ +define(["../../../lang", "../../../controls/grid/bootstrap/GridRendererMixin", + "../../../text!./templates/CommunityRow.html", + "../../../text!./templates/TagAnchor.html" ], + function(lang, GridRendererMixin, CommunityRow, TagAnchor) { + + /** + * @module sbt.controls.grid.bootstrap.CommunityRendererMixin + */ + return lang.mixin(GridRendererMixin, { template : CommunityRow, tagAnchorTemplate: TagAnchor }); + +}); +}, +'sbt/authenticator/templates/login':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ +function submitOnClick(contentForm) { + if (contentForm.username.value == "" || contentForm.password.value == "") { + document.getElementById("wrongCredsMessage").style.display = "block"; + return; + } + var argsMap = getArgsMap();// get map of query string arguments + var actionURL = decodeURIComponent(argsMap.actionURL); + var loginUi = decodeURIComponent(argsMap.loginUi); + if (loginUi.length == 0) { + loginUi = "mainWindow"; + } + if (loginUi == "popup") { + contentForm.action = actionURL + "?loginUi=popup&redirectURLToLogin=" + + encodeURIComponent(document.URL)+"&endpointAlias="+opener.globalEndpointAlias; + } else if (loginUi == "mainWindow") { + var redirectURL = argsMap.redirectURL; + contentForm.action = actionURL + + "?loginUi=mainWindow&redirectURLToLogin=" + + encodeURIComponent(document.URL) + "&redirectURL=" + + encodeURIComponent(redirectURL); + } + contentForm.submit(); +} + +function cancelOnClick() { + var argsMap = getArgsMap();// get map of query string arguments + var redirectURL = decodeURIComponent(argsMap.redirectURL); + var loginUi = decodeURIComponent(argsMap.loginUi); + if (loginUi == "popup") { + if(window.cancel){ + window.cancel(); + delete window.cancel; + } + window.close(); + } else { + window.location.href = redirectURL; + } +} + +function onLoginPageLoad() { + var argsMap = getArgsMap();// get map of query string arguments + var showWrongCredsMessage = argsMap.showWrongCredsMessage; + if (showWrongCredsMessage == "true") { + document.getElementById("wrongCredsMessage").style.display = "block"; + } + if(opener && opener.globalLoginFormStrings){ + var loginForm = opener.globalLoginFormStrings; + document.getElementById('wrongCredsMessage').appendChild(document.createTextNode(loginForm.wrong_creds_message)); + document.getElementById('basicLoginFormUsername').appendChild(document.createTextNode(loginForm.username)); + document.getElementById('basicLoginFormPassword').appendChild(document.createTextNode(loginForm.password)); + document.getElementById('basicLoginFormOK').value = loginForm.login_ok; + document.getElementById('basicLoginFormCancel').value = loginForm.login_cancel; + }else{ + document.getElementById('wrongCredsMessage').appendChild(document.createTextNode(decodeURIComponent(argsMap.wrong_creds_message))); + document.getElementById('basicLoginFormUsername').appendChild(document.createTextNode(decodeURIComponent(argsMap.username))); + document.getElementById('basicLoginFormPassword').appendChild(document.createTextNode(decodeURIComponent(argsMap.password))); + document.getElementById('basicLoginFormOK').value = decodeURIComponent(argsMap.login_ok); + document.getElementById('basicLoginFormCancel').value = decodeURIComponent(argsMap.login_cancel); + } +} + +function getArgsMap() { + try { + var qString = location.search.substring(1);// getting query string args + var qStringParams = qString.split("&");// getting array of all query + // string arg key value pairs + var argsMap = {}; + var i; + for (i = 0; i < qStringParams.length; i++) { + var argArray = qStringParams[i].split("="); + argsMap[argArray[0]] = argArray[1]; + } + return argsMap; + } catch (err) { + console.log("Error making agrs map in login.js " + err); + } +} +}, +'url:sbt/connections/controls/search/templates/em.html':"\r\n ${content}\r\n", +'url:sbt/connections/controls/search/templates/PersonCard.html':"\r\n \r\n ${authorName}\r\n ${inactiveLabel}\r\n \r\n \r\n ${authorUid}\r\n \r\n\r\n", +'sbt/connections/controls/bookmarks/BookmarkGridRenderer':function(){ +require({cache:{ +'url:sbt/connections/controls/bookmarks/templates/BookmarkRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\r\n\t

    \r\n\t\t\t${title}\r\n\t\t

    \r\n\t\t\r\n\t\t
    \r\n\t\t\t${authorName}\r\n\r\n\t\t\t| ${updatedDate}\r\n\r\n\r\n\t\t\t| \r\n\t\t\t\t${tagsLabel} \r\n\t\t\t\t\t${tagsAnchors}\r\n\r\n\t\t\t\r\n\t\t\t\r\n\r\n\t\t
    \r\n\t\t\r\n", +'url:sbt/connections/controls/bookmarks/templates/BootstrapBookmarkRow.html':"\t\r\n\t\r\n\t\t\r\n\t

    \r\n\t\t\t${title}\r\n\t\t

    \r\n\t\t\t\t\r\n\t\r\n", +'url:sbt/connections/controls/bookmarks/templates/TagAnchor.html':"${tagName}", +'url:sbt/connections/controls/bookmarks/templates/BookmarkListItem.html':"
  • \r\n\t

    ${title}

    \r\n
  • "}}); + /* + * © 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. + */ + +define(["../../../declare", "../../../localeUtil", + "../../../connections/controls/ConnectionsGridRenderer", + "../../../text!../../../connections/controls/bookmarks/templates/BookmarkRow.html", + "../../../text!../../../connections/controls/bookmarks/templates/BootstrapBookmarkRow.html", + "../../../text!../../../connections/controls/bookmarks/templates/TagAnchor.html", + "../../../i18n!../../../connections/controls/bookmarks/nls/BookmarkGridRenderer", + "../../../lang", + "../../../text!../../../connections/controls/bookmarks/templates/BookmarkListItem.html"], + function(declare, localeUtil, ConnectionsGridRenderer, BookmarkRow,BootstrapBookmarkRow, + TagAnchor, nls, lang, BookmarkListItem) { + + /** + * @class BookmarkGridRenderer + * @namespace sbt.connections.controls.bookmarks + * @module sbt.connections.controls.bookmarks.BookmarkGridRenderer + * */ + var BookmarkGridRenderer = declare(ConnectionsGridRenderer,{ + + _nls: nls, + + /** + * The Constructor function + * @method constructor + * @param args + */ + constructor: function(args,grid){ + if(grid.theme == "bootstrap"){ + this.template = BootstrapBookmarkRow; + }else{ + if (args && args.containerType) { + if(args.containerType == "ol" || args.containerType == "ul"){ + this.template = BookmarkListItem; + }else if(args.containerType == "table"){ + this.template = BookmarkRow; + } + }else{ + this.template = BookmarkRow; + } + + } + + this.tagAnchorTemplate = TagAnchor; + }, + + /** + * Displays a tooltip by calling the getTooltip function in the bookmarkAction. + * @method tooltip + * @param grid The Grid element + * @param item the element to display the tooltip + * @param i the number of the current row + * @param items all of the items in the grid row + * @returns A String used as a tooltip + */ + tooltip: function(grid, item, i, items) { + return grid.bookmarkAction.getTooltip(item); + + }, + + /** + * Gets the last updated date in human readable format. + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i the number of the current grid row + * @param items an object array containing the data for all of the grid rows + * @returns The date when the community was last updates + */ + updatedDate: function(grid, item, i, items) { + return localeUtil.getSearchUpdatedLabel((item.getValue("updated"))); + }, + + /** + * Returns a CSS style based on if a community has tags. + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i The number of the current row + * @param items an object array containing the data for all of the grid rows + * @returns {String} + */ + displayTags: function(grid, item, i, items) { + var tags = item.getValue("tags"); + if (tags.length == 0) { + return "display: none"; + } else { + return ""; + } + }, + + /** + * Get the tag label, if a community has no tags and empty string is returned + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i The number of the current row + * @param items an object array containing the data for all of the grid rows + * @returns an array of strings, that are tags for a community + */ + tagsLabel: function(grid, item, i, items) { + var tags = item.getValue("tags"); + if (tags.length == 0) { + return ""; + } else { + return this._nls.tags; + } + }, + /** + * Substitutes tag labels(Strings) from the nls file into the tag + * Anchor template which creates a tag links, and displays these tags on the page + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i The number of the current row + * @param items an object array containing the data for all of the grid rows + * @returns {String} + */ + tagsAnchors: function(grid, item, i, items) { + var tags = item.getValue("tags"); + if (tags == undefined) { + return ""; + } else { + var tagsStr=""; + if (lang.isArray(tags)) { + for (var i=0; i\r\n\t
      \r\n\t\t
    • \r\n\t\t\t${nls.previous}\r\n\t\t\t${nls.previous}\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t${pagingResults}\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t${nls.next}\r\n\t\t\t${nls.next}\r\n\t\t
    • \r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t
    \r\n\r\n\r\n\r\n", +'sbt/controls/dialog/nls/dialog':function(){ +/* + * © 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. + */ - /** - * Return the number of recommendations. - * - * @method getRecommendations - * @return {Number} the number of recommendations - */ - getRecommendations : function() { - return this.getAsNumber("recommendations"); - }, +/** + * Social Business Toolkit SDK + * + * Resource bundle for dialog control. + */ +define({ + root: ({ + OK : "OK", + Cancel : "Cancel", + Close : "Close" + }) +}); - /** - * Return the number of comments. - * - * @method getComments - * @return {Number} the number of comments - */ - getComments : function() { - return this.getAsNumber("comment"); - }, +}, +'url:sbt/connections/controls/profiles/templates/CommunityMemberRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${contributorName}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.role}: ${role}
    \r\n\t\t\t
    ${nls.email} ${contributorEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n", +'sbt/base/BaseEntity':function(){ +/* + * © Copyright IBM Corp. 2012, 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. + */ - /** - * Return the number of hits. - * - * @method getHits - * @return {Number} the number of hits - */ - getHits : function() { - return this.getAsNumber("hit"); - }, +/** + * Javascript Base APIs for IBM Connections + * + * @module sbt.base.BaseEntity + */ +define([ "../declare", "../lang", "../log", "../stringUtil" ], + function(declare,lang,log,stringUtil) { - /** - * Return the number of anonymous hits. - * - * @method getAnonymousHits - * @return {Number} the number of anonymous hits - */ - getAnonymousHits : function() { - return this.getAsNumber("anonymous_hit"); - }, + var BadRequest = 400; + + var requests = {}; + + /** + * BaseEntity class + * + * @class BaseEntity + * @namespace sbt.base + */ + var BaseEntity = declare(null, { /** - * Return the number of shares. - * - * @method getShare - * @return {Number} the number of shares + * The identifier for this entity. */ - getShare : function() { - return this.getAsNumber("share"); - }, + id : null, /** - * Return the number of collections. - * - * @method getCollections - * @return {Number} the number of collections + * The service associated with the entity. */ - getCollections : function() { - return this.getAsNumber("collections"); - }, + service : null, /** - * Return the number of attachments. - * - * @method getAttachments - * @return {Number} the number of attachments + * The DataHandler associated with this entity. */ - getAttachments : function() { - return this.getAsNumber("attachments"); - }, + dataHandler : null, /** - * Return the number of versions. + * The fields which have been updated in this entity. * - * @method getVersions - * @return {Number} the number of versions + * @private */ - getVersions : function() { - return this.getAsNumber("versions"); - }, + _fields : null, /** - * Loads the Wiki Page object with the atom entry associated with the - * wiki. By default, a network call is made to load the atom entry - * document in the Wiki Page object. + * Constructor for BaseEntity * - * @method load - * @param {Object} [args] Argument object + * @constructor + * @param {Object} args Arguments for this entity. */ - load : function(args) { - // detect a bad request by validating required arguments - var label = this.getLabel(); - var promise = this.service._validatePageLabel(label); - if (promise) { - return promise; - } - var wikiLabel = this.getWikiLabel(); - promise = this.service._validateWikiLabel(wikiLabel); - if (promise) { - return promise; + constructor : function(args) { + lang.mixin(this, args); + + if (!this._fields) { + this._fields = {}; } - - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - self.setData(data); - return self; - } - }; - - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var urlParams = { "pageLabel" : encodeURIComponent(label), "wikiLabel" : encodeURIComponent(wikiLabel) }; - var url = this.service.constructUrl(consts.WikiPageEntry, null, urlParams); - - return this.service.getEntity(url, options, label, callbacks); - }, - - /** - * Remove this Wiki Page - * - * @method remove - * @param {Object} [args] Argument object - */ - remove : function(args) { - return this.service.deleteWikiPage(this.getLabel(), args); - }, - - /** - * Update this Wiki Page - * - * @method update - * @param {Object} [args] Argument object - */ - update : function(args) { - return this.service.updateWikiPage(this, args); - }, - - /** - * Save this Wiki Page - * - * @method save - * @param {Object} [args] Argument object - */ - save : function(args) { - if (this.getWikiUuid()) { - return this.service.updateWikiPage(this, args); - } else { - return this.service.createWikiPage(this, args); + if (!this.service) { + var msg = "Invalid BaseEntity, an associated service must be specified."; + throw new Error(msg); } - } - - }); - - /* - * Method used to extract the wiki uuid for an id string. - */ - var extractWikiUuid = function(uid) { - if (uid && uid.indexOf("urn:lsid:ibm.com:td:") == 0) { - return uid.substring("urn:lsid:ibm.com:td:".length); - } else { - return uid; - } - }; - - /* - * Callbacks used when reading a feed that contains wiki entries. - */ - var WikiFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.WikiFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new Wiki({ - service : service, - data : data - }); - } - }; - - /* - * Callbacks used when reading a feed that contains wiki page entries. - */ - var WikiPageFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.WikiFeedXPath - }); - } - }; - - /* - * Callbacks used when reading an entry that contains wiki. - */ - var WikiCallbacks = { - createEntity : function(service,data,response) { - return new Wiki({ - service : service, - data : data - }); - } - }; - - /** - * WikisService class. - * - * @class WikisService - * @namespace sbt.connections - */ - var WikiService = declare(ConnectionsService, { - - contextRootMap: { - wikis: "wikis" }, - serviceName : "wikis", - /** - * Constructor for WikisService + * Called to set the entity DataHandler after the entity + * was loaded. This will cause the existing fields to be cleared. * - * @constructor - * @param args + * @param datahandler */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } + setDataHandler : function(dataHandler) { + this._fields = {}; + this.dataHandler = dataHandler; }, /** - * Create a Wiki object with the specified data. + * Called to set the entity data after the entity + * was loaded. This will cause the existing fields to be cleared. * - * @method newWiki - * @param {Object} args Object containing the fields for the new Wiki + * @param data */ - newWiki : function(args) { - return this._toWiki(args); + setData : function(data, response) { + this._fields = {}; + this.dataHandler.setData(data); }, /** - * Create a Wiki Page object with the specified data. - * - * @method newWikiPage - * @param {Object} args Object containing the fields for the new Wiki Page + * Return true if this entity has been loaded. + * + * @returns true if this entity has been loaded */ - newWikiPage : function(args) { - return this._toWikiPage(args); + isLoaded : function() { + if (this.dataHandler) { + return this.dataHandler.getData() ? true : false; + } + return false; }, /** - * This retrieves a list of wikis to which the authenticated user has access. + * Get the string value of the specified field. * - * @method getAllWikis - * @param requestArgs + * @method getAsString + * @param fieldName + * @returns */ - getAllWikis: function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - return this.getEntities(consts.WikisAll, options, WikiFeedCallbacks); + getAsString : function(fieldName) { + this._validateFieldName(fieldName, "getAsString"); + + if (this._fields.hasOwnProperty(fieldName)) { + return this._fields[fieldName]; + } else if (this.dataHandler) { + return this.dataHandler.getAsString(fieldName); + } else { + return null; + } }, - + /** - * This retrieves a list of wikis to which everyone who can log into the Wikis application has access. + * Get the number value of the specified field. * - * @method getPublicWikis - * @param requestArgs + * @method getAsNumber + * @param fieldName + * @returns */ - getPublicWikis: function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - return this.getEntities(consts.WikisPublic, options, WikiFeedCallbacks); + getAsNumber : function(fieldName) { + this._validateFieldName(fieldName, "getAsNumber"); + + if (this._fields.hasOwnProperty(fieldName)) { + return this._fields[fieldName]; + } else if (this.dataHandler) { + return this.dataHandler.getAsNumber(fieldName); + } else { + return null; + } }, - + /** - * This retrieves a list of wikis of which the authenticated user is a member. + * Get the date value of the specified field. * - * @method getMyWikis - * @param requestArgs + * @method getAsDate + * @param fieldName + * @returns */ - getMyWikis: function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - return this.getEntities(consts.WikisMy, options, WikiFeedCallbacks); + getAsDate : function(fieldName) { + this._validateFieldName(fieldName, "getAsDate"); + + if (this._fields.hasOwnProperty(fieldName)) { + return this._fields[fieldName]; + } else if (this.dataHandler) { + return this.dataHandler.getAsDate(fieldName); + } else { + return null; + } }, - + /** - * This retrieves a list all wikis sorted by wikis with the most comments first. - * This returns a list of wikis to which everyone who can log into the Wikis application has access. + * Get the boolean value of the specified field. * - * @method getMostCommentedWikis - * @param requestArgs + * @method getAsBoolean + * @param fieldName + * @returns */ - getMostCommentedWikis: function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - return this.getEntities(consts.WikisMostCommented, options, WikiFeedCallbacks); + getAsBoolean : function(fieldName) { + this._validateFieldName(fieldName, "getAsBoolean"); + + if (this._fields.hasOwnProperty(fieldName)) { + return this._fields[fieldName]; + } else if (this.dataHandler) { + return this.dataHandler.getAsBoolean(fieldName); + } else { + return false; + } }, - + /** - * This retrieves a list all wikis sorted by wikis with the most recommendations first. - * This returns a list of wikis to which everyone who can log into the Wikis application has access. + * Get the array value of the specified field. * - * @method getMostRecommendedWikis - * @param requestArgs + * @method getAsArray + * @param fieldName + * @returns */ - getMostRecommendedWikis: function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - return this.getEntities(consts.WikisMostRecommended, options, WikiFeedCallbacks); + getAsArray : function(fieldName) { + this._validateFieldName(fieldName, "getAsArray"); + + if (this._fields.hasOwnProperty(fieldName)) { + return this._fields[fieldName]; + } else if (this.dataHandler) { + return this.dataHandler.getAsArray(fieldName); + } else { + return null; + } }, - - /** - * This retrieves a list all wikis sorted by wikis with the most visits first. - * This returns a list of wikis to which everyone who can log into the Wikis application has access. + + /** + * Get the nodes array value of the specified field. * - * @method getMostVisitedWikis - * @param requestArgs + * @method getAsNodesArray + * @param fieldName + * @returns */ - getMostVisitedWikis: function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - return this.getEntities(consts.WikisMostVisited, options, WikiFeedCallbacks); + getAsNodesArray : function(fieldName) { + this._validateFieldName(fieldName, "getAsNodesArray"); + + if (this._fields.hasOwnProperty(fieldName)) { + return this._fields[fieldName]; + } else if (this.dataHandler) { + return this.dataHandler.getAsNodesArray(fieldName); + } else { + return null; + } }, - /** - * This retrieves a list all of the pages in a specific wiki. + * Get an object containing the values of the specified fields. * - * @method getWikiPages - * @param wikiLabel Value of the element of the wiki. - * @param requestArgs + * @method getAsObject + * @param fieldNames + * @returns */ - getWikiPages: function(wikiLabel, requestArgs) { - var promise = this._validateWikiLabel(wikiLabel); - if (promise) { - return promise; - } - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - var callbacks = lang.mixin(WikiPageFeedCallbacks, { - createEntity : function(service,data,response) { - return new WikiPage({ - service : service, - wikiLabel : wikiLabel, - data : data - }); + getAsObject : function(fieldNames, objectNames) { + var obj = {}; + for (var i=0; i element of the wiki. - * @param requestArgs + * @method setAsString + * @param data + * @returns */ - getMyWikiPages: function(wikiLabel, requestArgs) { - var promise = this._validateWikiLabel(wikiLabel); - if (promise) { - return promise; + setAsString : function(fieldName,string) { + this._validateFieldName(fieldName, "setAsString", string); + + if (string === null || string === undefined) { + delete this._fields[fieldName]; + } else { + this._fields[fieldName] = string.toString(); } - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - var callbacks = lang.mixin(WikiPageFeedCallbacks, { - createEntity : function(service,data,response) { - return new WikiPage({ - service : service, - wikiLabel : wikiLabel, - data : data - }); - } - }); - - var url = this.constructUrl(consts.WikiMyPages, null, { "wikiLabel" : encodeURIComponent(wikiLabel) }); - - return this.getEntities(url, options, callbacks); + return this; }, - + /** - * This retrieves a list of the pages that have been deleted from wikis and are currently stored in the trash. - * - * @method getRecycledPages - * @param wikiLabel Value of the element or the element of the wiki. - * @param requestArgs + * @method setAsNumber + * @returns */ - getRecycledWikiPages: function(wikiLabelOrId, requestArgs) { - var promise = this._validateWikiLabel(wikiLabelOrId); - if (promise) { - return promise; - } - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - var callbacks = lang.mixin(WikiPageFeedCallbacks, { - createEntity : function(service,data,response) { - return new WikiPage({ - service : service, - wikiLabelOrId : wikiLabelOrId, - data : data - }); + setAsNumber : function(fieldName,numberOrString) { + this._validateFieldName(fieldName, "setAsNumber", numberOrString); + + if (numberOrString instanceof Number) { + this._fields[fieldName] = numberOrString; + } else { + if (numberOrString) { + var n = new Number(numberOrString); + if (isNaN(n)) { + var msg = stringUtil.substitute("Invalid argument for BaseService.setAsNumber {0},{1}", [ fieldName, numberOrString ]); + throw new Error(msg); + } else { + this._fields[fieldName] = n; + } + } else { + delete this._fields[fieldName]; } - }); - - var url = this.constructUrl(consts.WikiRecycleBin, null, { "wikiLabelOrId" : encodeURIComponent(wikiLabelOrId) }); - - return this.getEntities(url, options, callbacks); + } + return this; }, - + /** - * Retrieve a wiki. - * - * @method getWiki - * @param wikiLabel Value of the element or the element of the wiki. - * @param requestArgs + * @method setAsDate + * @returns */ - getWiki: function(wikiLabel, requestArgs) { - var wiki = new Wiki({ - service : this, - _fields : { label : wikiLabel } - }); - return wiki.load(requestArgs); + setAsDate : function(fieldName,dateOrString) { + this._validateFieldName(fieldName, "setAsDate", dateOrString); + + if (dateOrString instanceof Date) { + this._fields[fieldName] = dateOrString; + } else { + if (dateOrString) { + var d = new Date(dateOrString); + if (isNaN(d.getDate())) { + var msg = stringUtil.substitute("Invalid argument for BaseService.setAsDate {0},{1}", [ fieldName, dateOrString ]); + throw new Error(msg); + } else { + this._fields[fieldName] = d; + } + } else { + delete this._fields[fieldName]; + } + } + return this; }, - + /** - * Create a wiki. - * - * @method createWiki - * @param wikiOrJson - * @param requestArgs + * @method setAsBoolean + * @returns */ - createWiki: function(wikiOrJson, requestArgs) { - var wiki = this._toWiki(wikiOrJson); - var promise = this._validateWiki(wiki, false, requestArgs); - if (promise) { - return promise; + setAsBoolean : function(fieldName,booleanOrString) { + this._validateFieldName(fieldName, "setAsBoolean", booleanOrString); + + if (booleanOrString != null) { + this._fields[fieldName] = booleanOrString ? true : false; + } else { + delete this._fields[fieldName]; } + return this; + }, - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - wiki.setData(data); - return wiki; - }; + /** + * @method setAsArray + * @returns + */ + setAsArray : function(fieldName,arrayOrString) { + this._validateFieldName(fieldName, "setAsArray", arrayOrString); - var options = { - method : "POST", - query : requestArgs || {}, - headers : consts.AtomXmlHeaders, - data : wiki.createPostData() - }; - - return this.updateEntity(consts.WikisAll, options, callbacks, requestArgs); + if (lang.isArray(arrayOrString)) { + this._fields[fieldName] = arrayOrString.slice(0); + } else if (lang.isString(arrayOrString)) { + if (arrayOrString.length > 0) { + this._fields[fieldName] = arrayOrString.split(/[ ,]+/); + } else { + this._fields[fieldName] = []; + } + } else { + if (arrayOrString) { + this._fields[fieldName] = [ arrayOrString ]; + } else { + delete this._fields[fieldName]; + } + } + + return this; }, - + /** - * Update a wiki. - * All existing wiki information will be replaced with the new data. To avoid deleting all existing data, - * retrieve any data you want to retain first, and send it back with this request. For example, if you want - * to add a new tag to a wiki definition entry, retrieve the existing tags, and send them all back with the - * new tag in the update request. + * Set an object containing the values of the specified fields. * - * @method updateWiki - * @param wikiOrJson - * @param requestArgs + * @method setAsObject + * @param theObject + * @returns */ - updateWiki: function(wikiOrJson, requestArgs) { - var wiki = this._toWiki(wikiOrJson); - var promise = this._validateWiki(wiki, true, requestArgs); - if (promise) { - return promise; + setAsObject : function(theObject) { + for (var property in theObject) { + if (theObject.hasOwnProperty(property)) { + var value = theObject[property]; + if (value) { + this._fields[property] = value; + } else { + delete this._fields[property]; + } + } } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - wiki.setData(data); - return wiki; - }; + }, - var options = { - method : "PUT", - query : requestArgs || {}, - headers : consts.AtomXmlHeaders, - data : wiki.createPostData() - }; - - var url = this.constructUrl(consts.WikiEntry, null, { "wikiLabel" : encodeURIComponent(wiki.getLabel()) }); - - return this.updateEntity(url, options, callbacks, requestArgs); + /** + * Remove the value of the specified field. + * + * @method remove + * @param fieldName + */ + remove : function(fieldName) { + delete this._fields[fieldName]; }, - + /** - * Delete a wiki. + * Return the json representation of the entity * - * @method deleteWiki - * @param wikiLabel - * @param requestArgs + * @method toJson + * @returns {Object} */ - deleteWiki: function(wikiLabel, requestArgs) { - var promise = this._validateWikiLabel(wikiLabel); - if (promise) { - return promise; - } - - var options = { - method : "DELETE", - query : requestArgs || {}, - handleAs : "text" - }; - - var url = this.constructUrl(consts.WikiEntry, null, { "wikiLabel" : encodeURIComponent(wikiLabel) }); - - return this.deleteEntity(url, options, wikiLabel); + toJson : function() { + return (this.dataHandler) ? this.dataHandler.toJson() : {}; }, - + + /* + * Validate there is a valid field name + */ + _validateFieldName : function(fieldName, method, value) { + if (!fieldName) { + var msg = stringUtil.substitute("Invalid argument for BaseService.{1} {0},{2}", [ fieldName, method, value || "" ]); + throw new Error(msg); + } + } + }); + + return BaseEntity; +}); + +}, +'sbt/Portlet':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK - Portlet specific helpers. + */ +define([],function() { + +sbt.getUserPref = function(ns,name) { + +} + +}); +}, +'sbt/smartcloud/controls/profiles/ProfileGridRenderer':function(){ +require({cache:{ +'url:sbt/smartcloud/controls/profiles/templates/ProfileRow.html':"\r\n\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t \r\n\t\t\t\t\r\n\t\t\t\t\t${name}\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t

    \r\n\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t${title}\r\n\t\t\t\t${orgName}\r\n\t\t\t
    \r\n\t\t\t
    ${address}
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t\r\n\t\t\tNetwork Contact\r\n\t\t\r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t ${primaryTelephone}\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t \r\n\t\t\t${email}\r\n\t\t
    \r\n\t\r\n\r\n", +'url:sbt/smartcloud/controls/profiles/templates/CommunityMember.html':"\r\n\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t${title}\r\n\r\n\t\t

    \r\n\t\t\r\n\t\r\n\t\r\n\t\t\r\n\t\t\tRole: ${role}\r\n\t\t\r\n\t\r\n\r\n"}}); +/* + * © 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. + */ + +/** + * @module sbt.smartcloud.controls.profiles.ProfileGridRenderer + */ +define(["../../../declare", "../../../lang", "../../../stringUtil", "../BaseGridRenderer", + "../../../i18n!./nls/ProfileGridRenderer", + "../../../text!./templates/ProfileRow.html", + "../../../text!./templates/CommunityMember.html"], + function(declare, lang, stringUtil, BaseGridRenderer, nls, profileTemplate,communityMemberTemplate) { + + /** + * @class ProfileGridRenderer + * @namespace sbt.smartcloud.controls.profiles + */ + var ProfileGridRenderer = declare(BaseGridRenderer, { + + /* + * The strings used in the grid, these are stored in a separate file, in the nls folder + */ + _nls: nls, + + /** + * The template used to display a row in the grid + */ + template: profileTemplate, + + /** + * The template used to construct a photo url + */ + contactImageUrl: "{baseUrl}/contacts/img/photos/{photo}", + + /** + * The template used to construct a no photo url + */ + noContactImageUrl: "{baseUrl}/contacts/img/noContactImage.gif", + + /** + * URL for community member photos + */ + communityMemberImageUrl: "{baseUrl}/contacts/profiles/photo/{uid}", + + /** + * The constructor function + * @method constructor + * @param args + */ + constructor: function(args) { + if(args){ + if(args.type === "communityMembers"){ + this.template = communityMemberTemplate; + } + } + }, + + /** + * Sets the css class for the row + * @method rowClass + * @param grid The Grid Dijit + * @param item the current row + * @param i the number of the current row, ie 0, 1, 2 etc + * @param items all of the rows in the grid + */ + rowClass: function(grid, item, i, items) { + item.rowClass = (i === 0 ? "lotusFirst" : (i % 2 === 1 ? "lotusAltRow" : null)); + }, + + /** + * + * @param grid + * @param item + * @param i + * @param items + * @returns {String} + */ + photoUrl: function(grid, item, i, items) { + var ep = grid.store.getEndpoint(); + if (!ep) return null; + + var photos = item.getValue("photos"); + if (photos && lang.isArray(photos) && photos.length > 1) { + return stringUtil.replace(this.contactImageUrl, { baseUrl : ep.baseUrl , photo : photos[1] }); + } else { + return stringUtil.replace(this.noContactImageUrl, { baseUrl : ep.baseUrl }); + } + }, + + getMemberPhoto: function(grid, item, i, items){ + var ep = grid.store.getEndpoint(); + if (!ep) return null; + + var id = item.getValue("uid"); + if(lang.isString(id)){ + return stringUtil.replace(this.communityMemberImageUrl, { baseUrl : ep.baseUrl , uid : id }); + }else{ + return stringUtil.replace(this.noContactImageUrl, { baseUrl : ep.baseUrl }); + } + }, + + /** + * + * @param grid + * @param item + * @param i + * @param items + * @returns {String} + */ + primaryTelephone: function(grid, item, i, items) { + var phoneNumbers = item.getValue("phoneNumbers"); + if (phoneNumbers && lang.isArray(phoneNumbers) && phoneNumbers.length > 0) { + return phoneNumbers[0]; + } else { + return undefined; + } + }, + + /** + * Displays a tooltip by calling the getTooltip function in the ProfileAction class + * @method tooltip + * @param grid The Grid control + * @param item the element to display the tooltip + * @param i the number of the current row + * @param items all of the items in the grid row + * @returns A Tooltip the default for profiles is to display the vCard + */ + tooltip: function(grid, item, i, items) { + if (grid.profileAction) { + return grid.profileAction.getTooltip(item); + } + } + + }); + + return ProfileGridRenderer; +}); +}, +'sbt/nls/Endpoint':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK - Default resource bundle for validate module. + */ + + +define({ + root: ({ + cannot_find_endpoint:"Unable to find endpoint named {0}, creating it now with an error transport." + }) + +}); +}, +'sbt/smartcloud/CommunityConstants':function(){ +/* + * ©©© Copyright IBM Corp. 2012,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. + */ + +/** + * Social Business Toolkit SDK. Definition of constants for CommunityService. + * + * @module sbt.connections.CommunityConstants + */ +define([ "../lang", "../smartcloud/SmartcloudConstants" ], function(lang,conn) { + + return lang.mixin({ + /** - * Retrieve a wiki page. - * - * @method getWikiPage - * @param wikiLabel Value of the element or the element of the wiki. - * @param requestArgs + * Namespaces to be used when reading the Communities ATOM entry or feed */ - getWikiPage: function(wikiLabel, pageLabel, requestArgs) { - var wikiPage = new WikiPage({ - service : this, - wikiLabel : wikiLabel, - _fields : { label : pageLabel } - }); - return wikiPage.load(requestArgs); - }, + CommunityNamespaces : { + a : "http://www.w3.org/2005/Atom", + app : "http://www.w3.org/2007/app", + snx : "http://www.ibm.com/xmlns/prod/sn", + opensearch: "http://a9.com/-/spec/opensearch/1.1/" + }, /** - * Create a wiki page. + * XPath expressions used when parsing a Connections Communities ATOM feed * - * @method createWikiPage - * @param pageOrJson - * @param requestArgs + * @property CommunityFeedXPath + * @type Object + * @for sbt.connections.CommunityService */ - createWikiPage: function(pageOrJson, requestArgs) { - var wikiPage = this._toWikiPage(pageOrJson); - var promise = this._validateWikiPage(wikiPage, false, requestArgs); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - wiki.setData(data); - return wiki; - }; + CommunityFeedXPath : conn.SmartcloudFeedXPath, - var options = { - method : "POST", - query : requestArgs || {}, - headers : consts.AtomXmlHeaders, - data : wikiPage.createPostData() - }; - - var url = this.constructUrl(consts.WikiFeed, null, { "wikiLabel" : encodeURIComponent(wikiPage.getWikiLabel()) }); - - return this.updateEntity(url, options, callbacks, requestArgs); - }, - /** - * Update a wiki page. + * XPath expressions to be used when reading a Community Entry * - * @method updateWikiPage - * @param pageOrJson - * @param requestArgs + * @property CommunityXPath + * @type Object + * @for sbt.connections.CommunityService */ - updateWikiPage: function(pageOrJson, requestArgs) { - var wikiPage = this._toWikiPage(pageOrJson); - var promise = this._validateWikiPage(wikiPage, true, requestArgs); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - wikiPage.setData(data); - return wikiPage; - }; - - var options = { - method : "PUT", - query : requestArgs || {}, - headers : consts.AtomXmlHeaders, - data : wikiPage.createPostData() - }; - - var urlParams = { "pageLabel" : encodeURIComponent(wikiPage.getLabel()), "wikiLabel" : encodeURIComponent(wikiPage.getWikiLabel()) }; - var url = this.constructUrl(consts.WikiPageEntry, null, urlParams); - - return this.updateEntity(url, options, callbacks, requestArgs); - }, - + CommunityXPath : lang.mixin({}, conn.AtomEntryXPath, { + communityUuid : "a:id", + communityTheme : "snx:communityTheme", + logoUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/logo']/@href", + tags : "a:category[not(@scheme)]/@term", + memberCount : "snx:membercount", + communityType : "snx:communityType", + isExternal : "snx:isExternal" + }), + /** - * Delete a wiki page. + * XPath expressions to be used when reading a Community Member Entry * - * @method deleteWikiPage - * @param wikiLabel - * @param pageLabel - * @param requestArgs + * @property MemberXPath + * @type Object + * @for sbt.connections.CommunityService */ - deleteWikiPage: function(wikiLabel, pageLabel, requestArgs) { - var promise = this._validateWikiLabel(wikiLabel); - if (promise) { - return promise; - } - promise = this._validatePageLabel(pageLabel); - if (promise) { - return promise; - } - - var options = { - method : "DELETE", - query : requestArgs || {}, - handleAs : "text" - }; - - var urlParams = { "pageLabel" : encodeURIComponent(label), "wikiLabel" : encodeURIComponent(wikiLabel) }; - var url = this.constructUrl(consts.WikiPageEntry, null, urlParams); - - return this.deleteEntity(url, options, wikiLabel); - }, - - // - // Internals - // - + MemberXPath : lang.mixin({}, conn.AtomEntryXPath, { + id : "a:contributor/snx:userid", + uid : "a:contributor/snx:userid", + role : "snx:role" + }), + /** - * Move this to BaseService + * A feed of members. + * + * Retrieve the members feed to view a list of the members who belong to a given community. + * + * Supports: asc, email, page, ps, role, since, sortField, userid + * + * @property AtomCommunityMembers + * @type String + * @for sbt.connections.CommunityService */ - constructUrl : function(url,params,urlParams) { - if (!url) { - throw new Error("BaseService.constructUrl: Invalid argument, url is undefined or null."); - } - - var _urlParams = lang.mixin( - { authType: this.endpoint.authType }, - this.contextRootMap, - this.endpoint.serviceMappings, - urlParams || {}); - url = stringUtil.replace(url, _urlParams); + AtomCommunityMembers : "${communities}/service/atom/community/members" - if (params) { - for (param in params) { - if (url.indexOf("?") == -1) { - url += "?"; - } else if (url.indexOf("&") != (url.length - 1)) { - url += "&"; - } - var value = encodeURIComponent(params[param]); - if (value) { - url += param + "=" + value; - } - } - } - return url; - }, - - /* - * Validate a Wiki and return a Promise if invalid. - */ - _validateWiki : function(wiki,checkLabel) { - if (!wiki || !wiki.getTitle()) { - return this.createBadRequestPromise("Invalid argument, wiki with title must be specified."); - } - if (checkLabel && !wiki.getLabel()) { - return this.createBadRequestPromise("Invalid argument, wiki with label must be specified."); - } - }, - - /* - * Validate a WikiPage and return a Promise if invalid. - */ - _validateWikiPage : function(wikiPage,checkLabels) { - if (!wikiPage || !wikiPage.getTitle()) { - return this.createBadRequestPromise("Invalid argument, wiki page with title must be specified."); - } - if (checkLabels && !wikiPage.getLabel()) { - return this.createBadRequestPromise("Invalid argument, wiki page with label must be specified."); - } - if (checkLabels && !wikiPage.getWikiLabel()) { - return this.createBadRequestPromise("Invalid argument, wiki page with wiki label must be specified."); - } - }, - - /* - * Validate a wiki label, and return a Promise if invalid. - */ - _validateWikiLabel : function(wikiLabel) { - if (!wikiLabel || wikiLabel.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected wiki label."); - } - }, - - /* - * Validate a wiki page label, and return a Promise if invalid. - */ - _validatePageLabel : function(pageLabel) { - if (!pageLabel || pageLabel.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected wiki page label."); - } - }, - - /* - * Validate a wiki UUID, and return a Promise if invalid. - */ - _validateWikiUuid : function(wikiUuid) { - if (!wikiUuid || wikiUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected wikiUuid."); - } - }, - - /* - * Return a Wiki instance from Wiki or JSON or String. Throws - * an error if the argument was neither. - */ - _toWiki : function(wikiOrJsonOrString) { - if (wikiOrJsonOrString instanceof Wiki) { - return wikiOrJsonOrString; - } else { - if (lang.isString(wikiOrJsonOrString)) { - wikiOrJsonOrString = { - handle : wikiOrJsonOrString - }; - } - return new Wiki({ - service : this, - _fields : lang.mixin({}, wikiOrJsonOrString) - }); - } - }, - - /* - * Return a WikiPage instance from WikiPage or JSON or String. Throws - * an error if the argument was neither. - */ - _toWikiPage : function(pageOrJsonOrString) { - if (pageOrJsonOrString instanceof WikiPage) { - return pageOrJsonOrString; - } else { - if (lang.isString(pageOrJsonOrString)) { - pageOrJsonOrString = { - handle : pageOrJsonOrString - }; - } - return new WikiPage({ - service : this, - _fields : lang.mixin({}, pageOrJsonOrString) - }); - } - } - }); - return WikiService; + }, conn); +}); +}, +'sbt/connections/controls/forums/ForumGrid':function(){ +/* + * © 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. + */ + +define(["../../../declare", + "../../../lang", + "../../../controls/grid/Grid", + "../../../store/parameter", + "./ForumGridRenderer", + "./ForumAction", + "./BackAction", + "../../../connections/ForumConstants"], + function(declare, lang, Grid, parameter, ForumGridRenderer, ForumAction, BackAction, consts){ + + /**Values that forums Can be sorted By, NOTE Sotring is not enabled in Connections*/ + var sortVals = { + created: "created", + modified: "modified" + }; + + /**URL parameters */ + var ParamSchema = { + pageNumber: parameter.oneBasedInteger("page"), + pageSize: parameter.oneBasedInteger("ps"), + sortBy: parameter.sortField("sortBy",sortVals), + sortOrder: parameter.sortOrder("sortOrder") + }; + + /** + * @class ForumGrid + * @namespace sbt.connections.controls.forum + * @module sbt.connections.controls.forum.ForumGrid + */ + var ForumGrid = declare(Grid,{ + + /**Hide the table header */ + hideHeader: false, + + options : { + "my" : { + storeArgs : { + url : consts.AtomForumsMy, + attributes : consts.ForumXPath, + feedXPath : consts.ForumsFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "my" + } + }, + "public" : { + storeArgs : { + url : consts.AtomForumsPublic, + attributes : consts.ForumXPath, + feedXPath : consts.ForumsFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "public" + } + }, + "myTopics" : { + storeArgs : { + url : consts.AtomTopicsMy, + attributes : consts.ForumTopicXPath, + feedXPath : consts.ForumsFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "myTopics" + } + }, + "forumTopics" : { + storeArgs : { + url : consts.AtomTopics, + attributes : consts.ForumTopicXPath, + feedXPath : consts.ForumsFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "forumTopics" + } + } + }, + + /**The default Forum Grid that will be created, if another type is not specified */ + defaultOption: "my", + + /**forumAction handles onClick and tooltip functions */ + forumAction : new ForumAction(), + backAction: new BackAction(), + hideBreadCrumb: true, + + /** + * The constructor function. + * @method constructor + * @param args + */ + constructor: function(args){ + if(args.hideHeader){ + this.hideHeader = args.hideHeader; + } + if(args.baseProfilesUrl){ + this.baseProfilesUrl = args.baseProfilesUrl; + } + + }, + + /** + * Creates a renderer for the grid.The renderer is responsible for + * loading the grid's HTML content. + * @method createDefaultRenderer + * @param args sets the template the renderer will use, by checking args.type + * @returns an instance of a ForumGridRenderer. + */ + createDefaultRenderer : function(args) { + return new ForumGridRenderer(args,this); + }, + + /** + * In the grid HTML an element can have an event attached + * using dojo-attach-event="onClick: handleClick". + * This method is the handler for the onclick event. + * @method handleClick + * @param el the element that fired the event + * @param data all of the items from the current row of the grid. + * @param ev the event + */ + handleClick: function(el, data, ev) { + if (this.forumAction) { + this._stopEvent(ev); + this.forumAction.execute(data, this , ev); + } + }, + + /** + * In the grid HTML an element can have an event attached + * using dojo-attach-event="onClick: handleClick". + * This method is the handler for the onclick event. + * This function is for viewing the profile of the forus author. + * @method handleClick + * @param el the element that fired the event + * @param data all of the items from the current row of the grid. + * @param ev the event + */ + + getForums: function(options){ + + this.renderer.template = this.renderer.forumTemplate; + this.renderer.headerTemplate = this.renderer.forumHeader; + this.store.setAttributes(consts.ForumXPath); + this.hideBreadCrumb = true; + var endpoint = this.store.getEndpoint(); + + if(this.params.type == "my"){ + var url = this.buildUrl(consts.AtomForumsMy, {},endpoint); + this.store.setUrl(url); + }else{ + var url = this.buildUrl(consts.AtomForumsPublic, {},endpoint); + this.store.setUrl(url); + } + + this.update(null); + }, + + /* + * Used for going back from topic replies + * to a list of topics in a forum, this keeps track of which + * forum is being view. + */ + _forumID: "", + + /** + * + * Show forum Topics + * @param forumId + * @param options + */ + getTopics: function(forumId,options){ + + if(forumId != ""){ + this._forumID = forumId; + } + + this.renderer.headerTemplate = this.renderer.topicHeader; + this.renderer.breadCrumb = this.renderer.topicBreadCrumb; + this.renderer.template = this.renderer.topicTemplate; + this.store.setAttributes(consts.ForumTopicXPath); + this.hideBreadCrumb = false; + var endpoint = this.store.getEndpoint(); + + if(this.params.type=="myTopics"){ + this.renderer.template = this.renderer.topicTemplate; + var url = this.buildUrl(consts.AtomTopicsMy, {},endpoint); + this.store.setUrl(url); + this.hideBreadCrumb = true; + }else if(this.params.type == "forumTopics"){ + this.renderer.template = this.renderer.forumTopicTemplate; + this.hideBreadCrumb = true; + var url = this.buildUrl(consts.AtomTopics+"?forumUuid="+this.forumUuid, {}, endpoint); + this.store.setUrl(url); + }else{ + var url = this.buildUrl(consts.AtomTopics+"?forumUuid="+this._forumID, {}, endpoint); + this.store.setUrl(url); + } + + this.update(null); + }, + + getTopicReplies: function(topicId,options){ + + this.renderer.template = this.renderer.replyTemplate; + this.renderer.headerTemplate = this.renderer.replyHeader; + this.store.setAttributes(consts.ForumReplyXPath); + this.hideBreadCrumb = false; + var endpoint = this.store.getEndpoint(); + + if(this.params.type=="myTopics"){ + this.renderer.breadCrumb = this.renderer.myTopicsBreadCrumb; + }else if(this.params.type == "forumTopics"){ + this.renderer.breadCrumb = this.renderer.myTopicsBreadCrumb; + }else{ + this.renderer.breadCrumb = this.renderer.replyBreadCrumb; + } + + + var url = this.buildUrl(consts.AtomReplies+"?topicUuid="+topicId,{},endpoint); + this.store.setUrl(url); + + this.update(null); + }, + + showTopics: function(el, data, ev){ + if (this.backAction) { + this._stopEvent(ev); + this.backAction.showTopics(data, this , ev); + } + }, + + showForums: function(el, data, ev){ + if (this.backAction) { + this._stopEvent(ev); + this.backAction.showForums(data, this , ev); + } + }, + + /** + * Add the since parameter to the URL, so that all forums will be + * displayed and not just those that have been recently modified. + * The since parameter returns all entries last modified since a specified date. + * Specify the date in the number of milliseconds since Unix EPOCH. + * In this case 1 is used so all forums will be displayed. + * @param url The Rest API URL for the forum feed + * @param args + * @param endpoint An endpoint which may contain custom service mappings. + * @returns + */ + buildUrl: function(url, args, endpoint) { + var params = { since: 1}; + if (this.query) { + params = lang.mixin(params, this.query); + } + if(this.forumUuid){ + params = lang.mixin(params, { forumUuid : this.forumUuid }); + } + + return this.constructUrl(url, params, {}, endpoint); + } + + + }); + + return ForumGrid; }); }, -'url:sbt/connections/controls/profiles/templates/SharedConnectionsRow.html':"\r\n\t\r\n\t\t

    Connections Shared By Frank Adams & Amy Blanks

    \r\n\t\t

    \r\n\t\t\t${sharedColleagueName}\r\n\t\t

    \r\n\t\t\r\n\t\t

    ${sharedColleagueEmail}

    \r\n\t\r\n\r\n", -'url:sbt/connections/controls/files/templates/RecycledFileRow.html':"\r\n \r\n \"\"\r\n \r\n \r\n

    \r\n \r\n ${title}\r\n \r\n

    \r\n \r\n \r\n \r\n \r\n \r\n ${modifiedLabel}\r\n \r\n \r\n ${fileSize}\r\n \r\n \r\n \r\n ${title}\r\n \r\n", -'url:sbt/connections/controls/templates/WidgetFrame.html':"", -'sbt/nls/loginForm':function(){ +'url:sbt/connections/controls/profiles/templates/ColleagueItemFull.html':"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \"${name}\r\n \r\n ${uid}\r\n ${name}\r\n \r\n
    \r\n
    \r\n \r\n ${name}\r\n ${uid}\r\n ${name}\r\n \r\n
    \r\n", +'sbt/connections/ActivityStreamConstants':function(){ /* - * © Copyright IBM Corp. 2012 + * © Copyright IBM Corp. 2012,2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15121,22 +9660,163 @@ define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", ". * implied. See the License for the specific language governing * permissions and limitations under the License. */ - /** - * Social Business Toolkit SDK - Default resource bundle for validate module. + * Social Business Toolkit SDK. Definition of constants for ActivityStreamService. */ +define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - -define({ - root: ({ - username:"User name :", - password:"Password :", - authentication_dialog_title: "Authentication", - login_ok: "Log in", - login_cancel: "Cancel", - wrong_creds_message:"Wrong Credentials" - }) - + return lang.mixin({}, conn, { + + ASUser: { + ME : "@me", + PUBLIC : "@public", + COMMUNITY : "urn:lsid:lconn.ibm.com:communities.community:",//Suffix Community with it id wherever this constant is used. + UBLOG : "ublog" + }, + ASGroup: { + ALL : "@all", + FOLLOWING : "@following", + FRIENDS : "@friends", + SELF : "@self", + INVOLVED : "@involved", + NOTESFORME : "@notesforme", + NOTESFROMME : "@notesfromme", + RESPONSES : "@responses", + ACTIONS : "@actions", + SAVED : "@saved" + }, + ASApplication: { + ALL : "@all", + COMMUNITIES : "@communities", + TAGS : "@tags", + PEOPLE : "@people", + STATUS : "@status", + NOTESFORME : "@notesforme", + NOTESFROMME : "@notesfromme", + RESPONSES : "@responses", + COMMENTS : "comments" + }, + Verb: { + ACCEPT : "accept", + ACCESS : "access", + ACKNOWLEDGE : "acknowledge", + ADD : "add", + AGREE : "agree", + APPEND : "append", + APPROVE : "approve", + ARCHIVE : "archive", + ASSIGN : "assign", + AT : "at", + ATTACH : "attach", + ATTEND : "attend", + AUTHOR : "author", + AUTHORIZE : "authorize", + + BORROW : "borrow", + BUILD : "build", + + CANCEL : "cancel", + CLOSE : "close", + COMMENT : "comment", + COMPLETE : "complete", + CONFIRM : "confirm", + CONSUME : "consume", + CHECKIN : "checkin", + CREATE : "create", + + DELETE : "delete", + DELIVER : "deliver", + DENY : "deny", + DISAGREE : "disagree", + DISLIKE : "dislike", + + EXPERIENCE : "experience", + + FAVORITE : "favorite", + FIND : "find", + FLAG_AS_INAPPROPRIATE : "flag-as-inappropriate", + FOLLOW : "follow", + + GIVE : "give", + + HOST : "host", + + IGNORE : "ignore", + INSERT : "insert", + INSTALL : "install", + INTERACT : "interact", + INVITE : "invite", + + JOIN : "join", + + LEAVE : "leave", + LIKE : "like", + LISTEN : "listen", + LOSE : "lose", + + MAKE_FRIEND : "make-friend", + + OPEN : "open", + + POST : "post", + PLAY : "play", + PRESENT : "present", + PURCHASE : "purchase", + + QUALIFY : "qualify", + + READ : "read", + RECEIVE : "receive", + REJECT : "reject", + REMOVE : "remove", + REMOVE_FRIEND : "remove-friend", + REPLACE : "replace", + REQUEST : "request", + REQUEST_FRIEND : "request-friend", + RESOLVE : "resolve", + RETURN : "return", + RETRACT : "retract", + RSVP_MAYBE : "rsvp-maybe", + RSVP_NO : "rsvp-no", + RSVP_YES : "rsvp-yes", + + SATISFY : "satisfy", + SAVE : "save", + SCHEDULE : "schedule", + SEARCH : "search", + SELL : "sell", + SEND : "send", + SHARE : "share", + SPONSOR : "sponsor", + START : "start", + STOP_FOLLOWING : "stop-following", + SUBMIT : "submit", + + TAG : "tag", + TERMINATE : "terminate", + TIE : "tie", + + UNFAVORITE : "unfavorite", + UNLIKE : "unlike", + UNSAVE : "unsave", + UNSATISFY : "unsatisfy", + UNSHARE : "unshare", + UPDATE : "update", + USE : "use", + + WATCH : "watch", + WIN : "win" + }, + ActivityStreamUrls: { + activityStreamBaseUrl : "/${connections}/opensocial/", + activityStreamRestUrl : "/rest/activitystreams/", + activityStreamUBlogRestUrl : "/rest/ublog/" + }, + errorMessages:{ + args_object : "argument passed to get stream should be an Object", + required_communityid : "Community ID is required" + } + }); }); }, 'sbt/DebugTransport':function(){ @@ -15218,10 +9898,281 @@ define([ "./declare", "./lang", "./dom", "./json", "./stringUtil", "sbt/_bridge/ }); }); }, -'sbt/connections/controls/activities/ActivityGridRenderer':function(){ -require({cache:{ -'url:sbt/connections/controls/activities/templates/ActivityRow.html':"\r\n\t\r\n\t\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t${title} \r\n\t\t\t \r\n\t\t

    \r\n\t\t\r\n\t\t
    \r\n\t\t\t${nls.updatedBy}\r\n\t\t\t\t ${authorName} \r\n\t\t\t\t\r\n\t\t\t\t| \r\n\t\t\t\t${updatedDate}\r\n\t\t\t\t\r\n\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t| \r\n\t\t\t\t${nls.dueDate}\t\t\t\t\r\n\t\t\t\t${getDueDate}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t| \r\n\t\t\t\t${nls.tags}\t\t\t\t\r\n\t\t\t\t${tags}\r\n\t\t\t\r\n\t\t
    \r\n\t\r\n", -'url:sbt/connections/controls/activities/templates/BootstrapActivityRow.html':"\r\n\r\n\t\r\n\t\t

    ${title}

    \r\n\t\r\n"}}); +'sbt/smartcloud/controls/BaseGridRenderer':function(){ +require({cache:{ +'url:sbt/controls/grid/templates/GridPager.html':"
    \r\n\t
    \r\n\t
    ${pagingResults}
    \r\n\t
      \r\n\t\t
    • \r\n\t\t\t${nls.previous}\r\n\t\t\t${nls.previous}\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t${nls.next}\r\n\t\t\t${nls.next}\r\n\t\t
    • \r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t
    \r\n
    \r\n", +'url:sbt/controls/grid/templates/GridSorter.html':"
    \r\n\t
      \r\n\t\t
    • ${nls.sortBy}
    • \r\n\t\t${sortAnchors}\r\n\t
    \r\n
    \r\n", +'url:sbt/controls/grid/templates/SortAnchor.html':"
  • \r\n\t${title}\r\n
  • \r\n"}}); +/* + * © 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. + */ + +/** + * + */ +define([ "../../declare","../../lang", "../../controls/grid/GridRenderer", + "../../text!../../controls/grid/templates/GridPager.html", + "../../text!../../controls/grid/templates/GridSorter.html", + "../../text!../../controls/grid/templates/SortAnchor.html", + "../../i18n!./nls/BaseGridRenderer" ], + function(declare, lang, GridRenderer, GridPager, GridSorter, SortAnchor, nls) { + + /** + * @module sbt.smartcloud.controls.BaseGridRenderer + * @class BaseGridRenderer + * @namespace sbt.smartcloud.controls + */ + var BaseGridRenderer = declare(GridRenderer, { + + /**Strings used in the grid*/ + nls : {}, + /**CSS class for tables*/ + tableClass : "lotusTable", + /**CSS Class for empty icon*/ + emptyClass : "lconnEmpty", + /**CSS Class for an error on an icon*/ + errorClass : "lconnEmpty", + /**The css class to use when the grid is loading,null here as an image is used instead*/ + loadingClass : "", + /**The loading image*/ + loadingImgClass : "lotusLoading", + /**The css class for the first row of the grid*/ + firstClass : "lotusFirst", + /**CSS classes for sorting*/ + defaultSortClass : "lotusActiveSort lotusDescending", + ascendingSortClass : "lotusActiveSort lotusAscending", + descendingSortClass : "lotusActiveSort lotusDescending", + /**The HTML template to use to show paging (moving forward and backward through sets of results)*/ + pagerTemplate : GridPager, + /**The HTML template to show sorting options*/ + sortTemplate : GridSorter, + /**The HTML template for sort Anchors*/ + sortAnchor : SortAnchor, + + /** + * Merge this class with the GridRenderer Class + * @method constructor + * @param args + */ + constructor : function(args) { + lang.mixin(this, args); + this.nls = lang.mixin(nls, this._nls); + } + + }); + + return BaseGridRenderer; +}); +}, +'sbt/control-main':function(){ +/* +* © Copyright IBM Corp. 2012 +* +* 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. +*/ + +/** +* @module sbt.main +*/ +define([ + 'sbt/main', + 'sbt/connections/controls/ConnectionsGridRenderer', + 'sbt/connections/controls/ViewAllAction', + 'sbt/connections/controls/WidgetWrapper', + 'sbt/connections/controls/_ConnectionsWidget', + 'sbt/controls/dialog/Dialog', + 'sbt/controls/grid/Grid', + 'sbt/controls/grid/GridAction', + 'sbt/controls/grid/GridRenderer', + 'sbt/controls/panel/_ProfilePanel', + 'sbt/smartcloud/controls/BaseGridRenderer', + 'sbt/connections/controls/activities/ActivityAction', + 'sbt/connections/controls/activities/ActivityGrid', + 'sbt/connections/controls/activities/ActivityGridRenderer', + 'sbt/connections/controls/astream/ActivityStreamWrapper', + 'sbt/connections/controls/astream/_ActivityStream', + 'sbt/connections/controls/astream/_SbtAsConfigUtil', + 'sbt/connections/controls/astream/_XhrHandler', + 'sbt/connections/controls/bookmarks/BookmarkGrid', + 'sbt/connections/controls/bookmarks/BookmarkGridRenderer', + 'sbt/connections/controls/bootstrap/CommunityRendererMixin', + 'sbt/connections/controls/bootstrap/FileRendererMixin', + 'sbt/connections/controls/bootstrap/ProfileRendererMixin', + 'sbt/connections/controls/communities/CommunityAction', + 'sbt/connections/controls/communities/CommunityGrid', + 'sbt/connections/controls/communities/CommunityGridRenderer', + 'sbt/connections/controls/communities/CommunityMembersAction', + 'sbt/connections/controls/communities/CommunityMembersGrid', + 'sbt/connections/controls/communities/CommunityMembersGridRenderer', + 'sbt/connections/controls/files/FileAction', + 'sbt/connections/controls/files/FileGrid', + 'sbt/connections/controls/files/FileGridRenderer', + 'sbt/connections/controls/forums/BackAction', + 'sbt/connections/controls/forums/ForumAction', + 'sbt/connections/controls/forums/ForumGrid', + 'sbt/connections/controls/forums/ForumGridRenderer', + 'sbt/connections/controls/nls/ConnectionsGridRenderer', + 'sbt/connections/controls/nls/WidgetWrapper', + 'sbt/connections/controls/profiles/ColleagueGrid', + 'sbt/connections/controls/profiles/ColleagueGridRenderer', + 'sbt/connections/controls/profiles/EditProfilePhoto.html', + 'sbt/connections/controls/profiles/ProfileAction', + 'sbt/connections/controls/profiles/ProfileGrid', + 'sbt/connections/controls/profiles/ProfileGridRenderer', + 'sbt/connections/controls/profiles/ProfilePanel', + 'sbt/connections/controls/profiles/ProfileTagAction', + 'sbt/connections/controls/profiles/ProfileTagsGrid', + 'sbt/connections/controls/profiles/ProfileTagsGridRenderer', + 'sbt/connections/controls/search/SearchBox', + 'sbt/connections/controls/search/SearchBoxRenderer', + 'sbt/connections/controls/search/SearchGrid', + 'sbt/connections/controls/search/SearchGridRenderer', + 'sbt/connections/controls/sharebox/InputFormWrapper', + 'sbt/connections/controls/sharebox/_InputForm', + 'sbt/connections/controls/templates/FileGridWrapperContent.html', + 'sbt/connections/controls/templates/LoadingPage.html', + 'sbt/connections/controls/templates/ProfileCardWrapperContent.html', + 'sbt/connections/controls/templates/WidgetFrame.html', + 'sbt/connections/controls/vcard/CommunityVCard', + 'sbt/connections/controls/vcard/ProfileVCard', + 'sbt/connections/controls/vcard/ProfileVCardInline', + 'sbt/connections/controls/vcard/SemanticTagService', + 'sbt/connections/controls/wrappers/FileGridWrapper', + 'sbt/connections/controls/wrappers/ProfileCardWrapper', + 'sbt/controls/dialog/nls/dialog', + 'sbt/controls/dialog/templates/Dialog.html', + 'sbt/controls/grid/bootstrap/GridRendererMixin', + 'sbt/controls/grid/templates/Grid.html', + 'sbt/controls/grid/templates/GridFooter.html', + 'sbt/controls/grid/templates/GridPager.html', + 'sbt/controls/grid/templates/GridSorter.html', + 'sbt/controls/grid/templates/SortAnchor.html', + 'sbt/smartcloud/controls/nls/BaseGridRenderer', + 'sbt/smartcloud/controls/profiles/ColleagueGrid', + 'sbt/smartcloud/controls/profiles/ColleagueGridRenderer', + 'sbt/smartcloud/controls/profiles/ProfileAction', + 'sbt/smartcloud/controls/profiles/ProfileGrid', + 'sbt/smartcloud/controls/profiles/ProfileGridRenderer', + 'sbt/smartcloud/controls/profiles/ProfilePanel', + 'sbt/connections/controls/activities/nls/ActivityGridRenderer', + 'sbt/connections/controls/activities/templates/ActivityRow.html', + 'sbt/connections/controls/astream/templates/ActivityStreamContent.html', + 'sbt/connections/controls/bookmarks/nls/BookmarkGridRenderer', + 'sbt/connections/controls/bookmarks/templates/BookmarkListItem.html', + 'sbt/connections/controls/bookmarks/templates/BookmarkRow.html', + 'sbt/connections/controls/bookmarks/templates/TagAnchor.html', + 'sbt/connections/controls/bootstrap/templates/CommunityRow.html', + 'sbt/connections/controls/bootstrap/templates/FileRow.html', + 'sbt/connections/controls/bootstrap/templates/ProfileRow.html', + 'sbt/connections/controls/bootstrap/templates/TagAnchor.html', + 'sbt/connections/controls/communities/nls/CommunityGridRenderer', + 'sbt/connections/controls/communities/nls/CommunityMembersGridRenderer', + 'sbt/connections/controls/communities/templates/CommunityMemberRow.html', + 'sbt/connections/controls/communities/templates/CommunityRow.html', + 'sbt/connections/controls/communities/templates/TagAnchor.html', + 'sbt/connections/controls/files/nls/FileGridRenderer', + 'sbt/connections/controls/files/templates/CommentRow.html', + 'sbt/connections/controls/files/templates/FileRow.html', + 'sbt/connections/controls/files/templates/FolderRow.html', + 'sbt/connections/controls/files/templates/RecycledFileRow.html', + 'sbt/connections/controls/forums/nls/ForumGridRenderer', + 'sbt/connections/controls/forums/templates/ForumRow.html', + 'sbt/connections/controls/forums/templates/MyTopicsBreadCrumb.html', + 'sbt/connections/controls/forums/templates/ReplyBreadCrumb.html', + 'sbt/connections/controls/forums/templates/ReplyHeader.html', + 'sbt/connections/controls/forums/templates/ReplyRow.html', + 'sbt/connections/controls/forums/templates/TableHeader.html', + 'sbt/connections/controls/forums/templates/TopicBreadCrumb.html', + 'sbt/connections/controls/forums/templates/TopicHeader.html', + 'sbt/connections/controls/forums/templates/TopicRow.html', + 'sbt/connections/controls/profiles/nls/ColleagueGridRenderer', + 'sbt/connections/controls/profiles/nls/ProfileGridRenderer', + 'sbt/connections/controls/profiles/nls/ProfileTagsGridRenderer', + 'sbt/connections/controls/profiles/templates/ColleagueItem.html', + 'sbt/connections/controls/profiles/templates/ColleagueItemFull.html', + 'sbt/connections/controls/profiles/templates/ColleagueRow.html', + 'sbt/connections/controls/profiles/templates/CommunityMemberRow.html', + 'sbt/connections/controls/profiles/templates/ProfilePanel.html', + 'sbt/connections/controls/profiles/templates/ProfileRow.html', + 'sbt/connections/controls/profiles/templates/SharedConnectionsRow.html', + 'sbt/connections/controls/profiles/templates/StatusUpdateRow.html', + 'sbt/connections/controls/profiles/templates/TagListHeader.html', + 'sbt/connections/controls/profiles/templates/TagListRow.html', + 'sbt/connections/controls/profiles/templates/ViewAll.html', + 'sbt/connections/controls/search/nls/SearchBoxRenderer', + 'sbt/connections/controls/search/nls/SearchGridRenderer', + 'sbt/connections/controls/search/templates/BookmarkBody.html', + 'sbt/connections/controls/search/templates/CalendarBody.html', + 'sbt/connections/controls/search/templates/CommunityBody.html', + 'sbt/connections/controls/search/templates/DefaultBody.html', + 'sbt/connections/controls/search/templates/DefaultHeader.html', + 'sbt/connections/controls/search/templates/DefaultSummary.html', + 'sbt/connections/controls/search/templates/MemberListItemTemplate.html', + 'sbt/connections/controls/search/templates/MemberListTemplate.html', + 'sbt/connections/controls/search/templates/NoResults.html', + 'sbt/connections/controls/search/templates/PersonCard.html', + 'sbt/connections/controls/search/templates/PopUpTemplate.html', + 'sbt/connections/controls/search/templates/ProfileBody.html', + 'sbt/connections/controls/search/templates/ProfileHeader.html', + 'sbt/connections/controls/search/templates/SearchBoxTemplate.html', + 'sbt/connections/controls/search/templates/SearchSuggestTemplate.html', + 'sbt/connections/controls/search/templates/SingleApplicationSearch.html', + 'sbt/connections/controls/search/templates/SingleSearchPopUp.html', + 'sbt/connections/controls/search/templates/StatusUpdateExtraHeader.html', + 'sbt/connections/controls/search/templates/StatusUpdateHeader.html', + 'sbt/connections/controls/search/templates/SuggestPopUpTemplate.html', + 'sbt/connections/controls/search/templates/a.html', + 'sbt/connections/controls/search/templates/div.html', + 'sbt/connections/controls/search/templates/em.html', + 'sbt/connections/controls/search/templates/img.html', + 'sbt/connections/controls/search/templates/li.html', + 'sbt/connections/controls/search/templates/span.html', + 'sbt/connections/controls/search/templates/td.html', + 'sbt/connections/controls/search/templates/tr.html', + 'sbt/connections/controls/search/templates/ul.html', + 'sbt/connections/controls/sharebox/templates/InputFormContent.html', + 'sbt/connections/controls/vcard/templates/CommunityVCard.html', + 'sbt/connections/controls/vcard/templates/ProfileVCard.html', + 'sbt/connections/controls/vcard/templates/ProfileVCardInline.html', + 'sbt/controls/grid/bootstrap/templates/GridPager.html', + 'sbt/controls/grid/bootstrap/templates/GridSorter.html', + 'sbt/controls/grid/bootstrap/templates/SortAnchor.html', + 'sbt/smartcloud/controls/profiles/nls/ColleagueGridRenderer', + 'sbt/smartcloud/controls/profiles/nls/ProfileGridRenderer', + 'sbt/smartcloud/controls/profiles/templates/ColleagueItem.html', + 'sbt/smartcloud/controls/profiles/templates/ColleagueItemFull.html', + 'sbt/smartcloud/controls/profiles/templates/CommunityMember.html', + 'sbt/smartcloud/controls/profiles/templates/ProfilePanel.html', + 'sbt/smartcloud/controls/profiles/templates/ProfileRow.html', + 'sbt/smartcloud/controls/profiles/templates/ViewAll.html' +],function() { + return; +}); + +}, +'sbt/MockTransport':function(){ /* * © Copyright IBM Corp. 2013 * @@ -15238,128 +10189,130 @@ require({cache:{ * permissions and limitations under the License. */ -define(["../../../declare", - "../ConnectionsGridRenderer", - "../../../i18n", - "../../../text!./templates/ActivityRow.html", - "../../../text!./templates/BootstrapActivityRow.html", - "../../../i18n!./nls/ActivityGridRenderer"], - - function(declare, ConnectionsGridRenderer, i18n, ActivityRow, BootstrapActivityRow, nls){ - - /** - * @class ActivityGridRenderer - * @namespace sbt.connections.controls.activities - * @module sbt.connections.controls.forum.ActivityGridRenderer - */ - var ActivityGridRenderer = declare(ConnectionsGridRenderer,{ - - /**Strings used by the forum grid */ - _nls:nls, - - /** - * The constructor function - * @method constructor - * @param args - */ - constructor: function(args,grid){ - - if(grid.theme == "bootstrap"){ - this.template = BootstrapActivityRow; - }else{ - this.template = ActivityRow; - } - }, - - /** - * Displays a tooltip by calling the getTooltip function in the ForumAction class - * @method tooltip - * @param grid The Grid element - * @param item the element to display the tooltip - * @param i the number of the current row - * @param items all of the items in the grid row - * @returns A String used as a tooltip - */ - tooltip: function(grid, item, i, items) { - if (grid.activitiesAction) { - return grid.activitiesAction.getTooltip(item); - } - }, - - getUserProfileHref: function(grid,item,i,items){ - return this.getProfileUrl(grid,item.getValue("authorUserId")); - }, - - /** - * Gets the last updated date for an activity - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i the number of the current grid row - * @param items an object array containing the data for all of the grid rows - * @returns The date when the community was last updates - */ - updatedDate: function(grid, item, i, items) { - var updatedLabel = item.getValue("updated"); - if(updatedLabel.length > 0){ - return i18n.getUpdatedLabel(updatedLabel); - }else{ - return ""; - } - }, - - /** - * Gets the due date for an activity - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i the number of the current grid row - * @param items an object array containing the data for all of the grid rows - * @returns The date when the community was last updates - */ - getDueDate: function(grid, item, i, items) { - var dueDate = item.getValue("dueDate"); - if(dueDate.length > 0){ - return i18n.getUpdatedLabel(dueDate); - }else{ - return ""; - } - } - - }); - - return ActivityGridRenderer; -}); -}, -'sbt/nls/util':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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 +/** + * Social Business Toolkit SDK. * - * 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. + * Implementation of a transport which returns mock data. */ +define([ "./declare", "./lang", "./dom", "./xml", "./json", "./stringUtil", "./Promise" ], + function(declare, lang, dom, xml, json, stringUtil, Promise) { + return declare(null, { + + requestMap : {}, + + /** + * Provides mock data if available in the DOM. + */ + request : function(url, options) { + var query = this.createQuery(options.query); + if(url && query){ + url += (~url.indexOf('?') ? '&' : '?') + query; + } -/** - * Social Business Toolkit SDK - Default resource bundle for validate module. - */ + var promise = new Promise(); + promise.response = new Promise(); + var id = url; + var hash = stringUtil.hashCode(id); + if (this.requestMap[hash]) { + this.requestMap[hash] = this.requestMap[hash] + 1; + id += "#" + this.requestMap[hash]; + } else { + this.requestMap[hash] = 1; + } + + var domNode = dom.byId(id); + if (domNode) { + var response = domNode.text || domNode.textContent; + var handleAs = domNode.getAttribute("handleAs"); + if (handleAs == "json") { + response = json.parse(response); + } + + var status = domNode.getAttribute("status"); + + var error = domNode.getAttribute("error"); + if (error == "true") { + var error = new Error(); + error.code = Number(status || 400); + error.message = this.getErrorText(response); + error.response = this.createResponse(url, options, response, Number(status || 400), {}); + promise.rejected(error); + promise.response.rejected(error); + } else { + var location = domNode.getAttribute("location"); + var headers = { + Location : location + }; + + promise.fulfilled(response); + promise.response.fulfilled(this.createResponse(url, options, response, Number(status || 200), headers)); + } + } + else { + var message = "Unable to find mock response for: "+url; + var error = new Error(message); + error.response = { status : 400 , message : message }; + promise.rejected(error); + promise.response.rejected(error); + } -define({ - root: ({ - error_callback:"Error running error callback : {0}", - error_console:"Error received. Error Code = {0}. Error Message = {1}" - }) - + return promise; + }, + + /* + * Create a response object + */ + createResponse: function(url, options, response, status, headers) { + var handleAs = options.handleAs || "text"; + return { + url : url, + options : options, + data : response, + text : (handleAs == "text") ? response : null, + status : status, + getHeader : function(headerName) { + return headers[headerName]; + } + }; + }, + + /* + * Create a query string from an object + */ + createQuery: function(queryMap) { + if (!queryMap) { + return null; + } + var pairs = []; + for(var name in queryMap){ + var value = queryMap[name]; + pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(value)); + } + return pairs.join("&"); + }, + + getErrorText: function(text) { + if (text) { + try { + var dom = xml.parse(text); + var messages = dom.getElementsByTagName("message"); + if (messages && messages.length != 0) { + text = messages[0].text || messages[0].textContent; + text = lang.trim(text); + } + } catch(ex) {} + return text.replace(/(\r\n|\n|\r)/g,""); + } else { + return text; + } + } + + }); }); }, -'sbt/_bridge/lang':function(){ +'url:sbt/connections/controls/communities/templates/BootstrapCommunityMember.html':"\r\n\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t\t

    \r\n \t\t\t\t${title}\r\n \t\t\t

    \r\n\t\r\n", +'sbt/connections/controls/bookmarks/BookmarkGrid':function(){ /* * © Copyright IBM Corp. 2013 * @@ -15375,62 +10328,235 @@ define({ * implied. See the License for the specific language governing * permissions and limitations under the License. */ +define(["../../../declare", + "../../../controls/grid/Grid", + "../../../store/parameter", + "../../../connections/BookmarkConstants", + "../../../connections/CommunityConstants", + "./BookmarkGridRenderer"], + function(declare,Grid,parameter,consts,communityConstants,BookmarkGridRenderer){ + + /** + * Sorting values + */ + var sortVals = { + date: "created", + popularity: "popularity" + }; + + /** + * Sorting and paging parameters + */ + var ParamSchema = { + pageNumber: parameter.oneBasedInteger("page"), + pageSize: parameter.oneBasedInteger("ps"), + sortBy: parameter.sortField("sortBy",sortVals), + sortOrder: parameter.sortOrder("sortOrder") + }; + + /** + * @class BookmarkGrid + * @namespace sbt.connections.controls.bookmarks + * @module sbt.connections.controls.bookmarks.BookmarkGrid + */ + var BookmarkGrid = declare(Grid,{ + + /** + * Specifies how the bookmark should open, new tab, same window etc. + * Should match values for the name parameter from the window.open function + * _blank is default, + * _parent - URL is loaded into the parent frame + * _self - URL replaces the current page + * _top - URL replaces any framesets that may be loaded + */ + targetName: "_blank", + + + options : { + "any" : { + storeArgs : { + url : consts.AtomBookmarksAll, + attributes : consts.BookmarkXPath, + feedXPath : consts.BookmarkFeedXPath, + paramSchema : ParamSchema + }, + rendererArgs : null + }, + "community": { + storeArgs : { + url : communityConstants.AtomCommunityBookmarks, + attributes : consts.BookmarkXPath, + feedXPath : consts.BookmarkFeedXPath, + paramSchema : ParamSchema + }, + rendererArgs : null + } + }, + + /** + * Default grid option. + */ + defaultOption: "any", + + /** + * The grid constructor function + * @method constructor + * @param args + */ + constructor: function(args){ + + var nls = this.renderer.nls; + this._sortInfo = { + date: { + title: nls.date, + sortMethod: "sortByDate", + sortParameter: "date" + }, + popularity: { + title: nls.popularity, + sortMethod: "sortByPopularity", + sortParameter: "popularity" + } + }, + this._activeSortAnchor = this._sortInfo.date; + this._activeSortIsDesc = true; + }, + + /** + * Used to add parameters to the URL + * @method buildUrl + * @param url the url to add parameters to + * @param args + * @param endpoint An endpoint which may contain custom service mappings. + * @returns the url with parameters + */ + buildUrl: function(url, args, endpoint) { + var urlParams; + + if(this.type == "private"){ + urlParams = { access: "private"}; + }else if(this.type == "public") { + urlParams = {access: "public"}; + }else if(this.type == "community"){ + urlParams = {communityUuid: this.communityUuid}; + }else{ + urlParams = {access: "any"}; + } -/** - * Social Business Toolkit SDK - Some language utilities. - */ -define(['dojo/_base/lang', 'dojo/has', 'dojo/_base/sniff'],function(lang, has) { - return { - mixin: function(dest,sources) { - return lang.mixin.apply(this, arguments); - }, - isArray: function(o) { - return lang.isArray(o); - }, - isString: function(o) { - return lang.isString(o); - }, - isFunction: function(o) { - return typeof o == 'function'; - }, - isObject: function(o) { - return typeof o == 'object'; + return this.constructUrl(url, urlParams, {}, endpoint); + }, + + /** + * Creates a Renderer for this grid. + * @param args + * @returns {BookmarkGridRenderer} + */ + createDefaultRenderer: function(args){ + return new BookmarkGridRenderer(args,this); + }, + + /** + * Gets sorting information, such as + * if the results are ascending or descending, and the sort anchors + * @method getSortInfo + * @returns An object containing sorting information + */ + getSortInfo: function() { + return { + active: { + anchor: this._activeSortAnchor, + isDesc: this._activeSortIsDesc + }, + list: [this._sortInfo.date, this._sortInfo.popularity] + }; }, - clone: function(o) { - return lang.clone(o); - }, - concatPath: function() { - var a = arguments; - if(a.length==1 && this.isArray(a[0])) { - a = a[0]; - } - var s = ""; - for(var i=0; i", -'sbt/config':function(){ +'sbt/connections/controls/forums/nls/ForumGridRenderer':function(){ /* * © Copyright IBM Corp. 2013 * @@ -15446,19 +10572,30 @@ define(['dojo/_base/lang', 'dojo/has', 'dojo/_base/sniff'],function(lang, has) { * implied. See the License for the specific language governing * permissions and limitations under the License. */ - -/** - * Definition of config module. - * This module needs a _config module to be defined at runtime. - * - * @module sbt.config - */ -define(['./defer!./_config'],function(cfg){ - return cfg; + +// NLS_CHARSET=UTF-8 +define({ + root: { + forums: "Forums", + forum: "Forum", + threads: "Topics", + latestPost: "Latest Post", + goToForum: "Go To The Forum", + viewProfile: "View Profile", + replies: "Replies", + topics: "Topic", + topic: "Topic", + author: "Author", + date: "Date", + back:"Back", + noResults: "There are no results", + feed : "Feed for these Forums" + } }); }, -'url:sbt/controls/grid/bootstrap/templates/GridSorter.html':"
    \r\n\t
    \r\n\t\t${nls.sortBy}\r\n\t\t
      \r\n\t\t\t${sortAnchors}\r\n\t\t
    \r\n\t
    \r\n
    ", -'sbt/base/AtomEntity':function(){ +'sbt/connections/controls/vcard/ProfileVCardInline':function(){ +require({cache:{ +'url:sbt/connections/controls/vcard/templates/ProfileVCardInline.html':"\r\n ${userName}\r\n ${userId}\r\n\r\n"}}); /* * © Copyright IBM Corp. 2013 * @@ -15476,401 +10613,306 @@ define(['./defer!./_config'],function(cfg){ */ /** - * AtomEntity class represents an entry from an IBM Connections ATOM feed. * - * @module sbt.base.AtomEntity */ -define([ "../declare", "../lang", "../stringUtil", "./BaseConstants", "./BaseEntity", "./XmlDataHandler" ], - function(declare,lang,stringUtil,BaseConstants,BaseEntity,XmlDataHandler) { +define(["../../../declare", + "../../../dom", + "../../../widget/_TemplatedWidget", + "../../../lang", + "../../../connections/controls/vcard/SemanticTagService", + "../../../text!./templates/ProfileVCardInline.html"], + function(declare, dom, _TemplatedWidget, lang, SemanticTagService, template) { - var EntryTmpl = "" + - "" + - "${categoryScheme}${createTitle}${createContent}${createSummary}${createContributor}${createTags}${createEntryData}" + - ""; - var TitleTmpl = "${title}"; - var ContentTmpl = "${content}"; - var SummaryTmpl = "${summary}"; - var ContributorTmpl = "${contributor}"; - var EmailTmpl = "${email}"; - var UseridTmpl = "${userid}"; - var CategoryTmpl = ""; - /** - * AtomEntity class represents an entry from an IBM Connections ATOM feed. - * - * @class AtomEntity - * @namespace sbt.base + * @module sbt.controls.vcard.connections.ProfileVCardInline */ - var AtomEntity = declare(BaseEntity, { - - contentType : "html", - categoryScheme : null, - - /** - * Construct an AtomEntity. - * - * @constructor - * @param args - */ - constructor : function(args) { - if (args.data) { - // create XML data handler - this.dataHandler = this.createDataHandler( - args.service, args.data || null, args.response || null, - args.namespaces || this.namespaces || BaseConstants.Namespaces, - args.xpath || this.xpath || BaseConstants.AtomEntryXPath - ); - } else { - this.service = args.service || this.service; - this.namespaces = args.namespaces || this.namespaces || BaseConstants.Namespaces; - this.xpath = args.xpath || this.xpath || BaseConstants.AtomEntryXPath; - } - }, - - /** - * Create the DataHandler for this entity. - * - * @method createDataHandler - */ - createDataHandler : function(service, data, response, namespaces, xpath) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : namespaces, - xpath : xpath - }); - }, - - /** - * Called to set the entity data after the entity - * was loaded. This will cause the existing fields to be cleared. - * - * @param data - */ - setData : function(data, response) { - // create XML data handler - this.dataHandler = this.createDataHandler( - this.service, - data, response || null, - this.namespaces || BaseConstants.Namespaces, - this.xpath || BaseConstants.AtomEntryXPath - ); - - this.inherited(arguments); - }, - - /** - * Return the value of id from ATOM entry document. - * - * @method getId - * @return {String} ID of the ATOM entry - */ - getId : function() { - return this.getAsString("id"); - }, - - /** - * Return the value of title from ATOM entry document. - * - * @method getTitle - * @return {String} ATOM entry title - */ - getTitle : function() { - return this.getAsString("title"); - }, + var profileVcardInline = declare([ _TemplatedWidget ], { /** - * Sets title of ATOM entry. + * The html template of the vcard. * - * @method setTitle - * @param {String} title ATOM entry title + * @property configUtil + * @type String */ - setTitle : function(title) { - return this.setAsString("title", title); - }, + templateString: template, /** - * Return the value of summary from ATOM entry document. - * - * @method getSummary - * @return {String} ATOM entry summary - */ - getSummary : function() { - return this.getAsString("summary"); - }, - - /** - * Sets summary of ATOM entry. + * Whether or not to encode HTML. * - * @method setSummary - * @param {String} title ATOM entry summary + * @property encodeHtml + * @type Boolean + * @default true */ - setSummary : function(summary) { - return this.setAsString("summary", summary); - }, + encodeHtml: true, /** - * Return the content from ATOM entry document. - * - * @method getContent - * @return {Object} Content - */ - getContent : function() { - return this.getAsString("content"); - }, - - /** - * Sets content of ATOM entry. - * - * @method setContent - * @param {String} content - */ - setContent : function(content) { - return this.setAsString("content", content); - }, - - /** - * Return array of category terms from ATOM entry document. - * - * @method getCategoryTerms - * @return {Object} Array of categories of the ATOM entry - */ - getCategoryTerms : function() { - return this.getAsArray("categoryTerm"); - }, - - /** - * Set new category terms to be associated with this ATOM entry document. - * - * @method setCategories - * @param {Object} Array of categories to be added to the ATOM entry - */ - - setCategoryTerms : function(categoryTerms) { - return this.setAsArray("categoryTerm", categoryTerms); - }, - - /** - * Gets an author of the ATOM entry - * - * @method getAuthor - * @return {Object} author Author of the ATOM entry - */ - getAuthor : function() { - return this.getAsObject( - [ "authorUserid", "authorName", "authorEmail", "authorUserState" ], - [ "userid", "name", "email", "userState" ]); - }, - - /** - * Gets a contributor of the ATOM entry + * The href of the vcard link. By default clicking the link does nothing. * - * @method getContributor - * @return {Object} contributor Contributor of the ATOM entry + * @property href + * @type String + * @default "javascript:void(0);" */ - getContributor : function() { - return this.getAsObject( - [ "contributorUserid", "contributorName", "contributorEmail", "contributorUserState" ], - [ "userid", "name", "email", "userState" ]); - }, + href: "javascript:void(0);", /** - * Sets the contributor of the ATOM entry + * The person's name to be displayed with this vcard. * - * @method setContributor - * @return {Object} contributor Contributor of the ATOM entry + * @property userName + * @type String + * @default "" */ - setContributor : function(contributor) { - return this.setAsObject(contributor); - }, + userName: "", /** - * Return the published date of the ATOM entry document. - * - * @method getPublished - * @return {Date} Published date of the entry - */ - getPublished : function() { - return this.getAsDate("published"); - }, - - /** - * Return the last updated date of the ATOM entry document. + * The connections profile id. This is the sole determinant of which vcard will be displayed. * - * @method getUpdated - * @return {Date} Last updated date of the entry + * @property userId + * @type String + * @default "" */ - getUpdated : function() { - return this.getAsDate("updated"); - }, + userId: "", /** - * Return the alternate url of the ATOM entry document. - * - * @method getAlternateUrl - * @return {String} Alternate url - */ - getAlternateUrl : function() { - return this.getAsString("alternateUrl"); - }, - - /** - * Return the self url of the ATOM entry document. + * A url flag specifying whether or not connections should return dojo with the semantic tag service. * - * @method getSelfUrl - * @return {String} Self url + * @property inclDojo + * @type Boolean + * @default false */ - getSelfUrl : function() { - return this.getAsString("selfUrl"); - }, + inclDojo: false, /** - * Return the edit url of the ATOM entry document. - * - * @method getEditUrl - * @return {String} Edit url - */ - getEditUrl : function() { - return this.getAsString("editUrl"); - }, - - /** - * Create ATOM entry XML + * The class of the html error element. * - * @method createPostData - * @returns + * @property errorClass + * @type String + * @default "" */ - createPostData : function() { - var postData = stringUtil.transform(EntryTmpl, this, function(v,k) { return v; }, this); - return stringUtil.trim(postData); - }, + errorClass: "", /** - * Return title element to be included in post data for this ATOM entry. * - * @method createTitle - * @returns {String} + * @param args */ - createTitle : function() { - var title = this.getTitle(); - if (title) { - return stringUtil.transform(TitleTmpl, { "title" : stringUtil.htmlEntity(title) }); - } - return ""; + constructor: function(args) { + lang.mixin(args); }, - /** - * Return content element to be included in post data for this ATOM entry. - * - * @method createContent - * @returns {String} - */ - createContent : function() { - var content = this.getContent(); - if (content) { - if (this.contentType == "html") { - content = (content && lang.isString(content)) ? stringUtil.htmlEntity(content) : content; - } - return stringUtil.transform(ContentTmpl, { "contentType" : this.contentType, "content" : content }); - } - return ""; + postCreate: function() { + dom.setAttr(this.idNode, "class", (this.userId.indexOf("@") >= 0) ? "email" : "x-lconn-userid"); + + this.inherited(arguments); + + SemanticTagService.loadSemanticTagService(); }, - /** - * Return summary element to be included in post data for this ATOM entry. - * - * @method createSummary - * @returns {String} - */ - createSummary : function() { - var summary = this.getSummary(); - if (summary) { - return stringUtil.transform(SummaryTmpl, { "summary" : summary }); - } - return ""; - }, + renderError: function(el, error) { + var ediv = domConstruct.create("div", { + "class": this.errorClass, + role: "alert", + tabIndex: 0 + }, el, "only"); + dom.setText(ediv, error.message); + } - /** - * Return contributor element to be included in post data for this ATOM entry. - * - * @method createContributor - * @returns {String} - */ - createContributor : function() { - var contributor = this.getContributor(); - if (contributor) { - var value = ""; - var email = contributor.email || ((this.getEmail) ? this.getEmail() : null); - if (email) { - value += stringUtil.transform(EmailTmpl, { "email" : email }); - } - var userid = contributor.userid || ((this.getUserid) ? this.getUserid() : null); - if (userid) { - value += stringUtil.transform(UseridTmpl, { "userid" : userid }); - } - if (value.length > 0) { - value = stringUtil.transform(ContributorTmpl, { "contributor" : value }); - } - return value; - } - return ""; + }); + + return profileVcardInline; +}); +}, +'sbt/connections/controls/activities/nls/ActivityGridRenderer':function(){ +/* + * © 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. + */ + +// NLS_CHARSET=UTF-8 +define({ + root: { + updatedBy: "Updated by", + modified: "Last Updated", + dueDate: "Due Date: ", + name: "Name", + feed : "Feed for these Activities", + tags:"Tags: " + } +}); +}, +'sbt/authenticator/OAuth':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK. + * Definition of the authentication mechanism for OAuth 1.0. + */ +define(['../declare','../lang', '../util'], function(declare, lang, util) { + + /** + * OAuth 1.0 authentication. + * + * This class triggers the authentication for a service. + */ + return declare(null, { + + url: "", + loginUi: "", // mainWindow, dialog or popup + + constructor: function(args){ + lang.mixin(this, args || {}); + }, + + /** + * Method that authenticates the current user + */ + authenticate: function(options) { + var self = this; + require(["sbt/config"], function(config) { + var mode = options.loginUi || config.Properties["loginUi"] || this.loginUi; + var width = config.Properties["login.oauth.width"] || 800; + var height = config.Properties["login.oauth.height"] || 450; + if(mode=="popup") { + return self._authPopup(options, self.url, width, height); + } else if(mode=="dialog") { + return self._authDialog(options, self.url, width, height); + } else { + return self._authMainWindow(options, self.url); + } + }); + }, + + _authMainWindow: function(options, sbtUrl) { + var url = sbtUrl + "?oaredirect="+encodeURIComponent(window.location.href); + newwindow=window.location.href = url; + return true; + + }, + + _authPopup: function(options, sbtUrl, width, height) { + require(["sbt/config"], function(config){ + config.callback = options.callback; + var url = sbtUrl + "?loginUi=popup"; + + var windowQueryMap = { + height: height, + width: width + }; + var windowQuery = util.createQuery(windowQueryMap, ","); + newwindow = window.open(url,'Authentication',windowQuery); + return true; + }); + }, + + _authDialog: function(options, sbtUrl, width, height) { + require(["sbt/_bridge/ui/OAuthDialog"], function(dialog) { + dialog.show(sbtUrl, width, height); + }); + return true; + } + }); +}); +}, +'sbt/smartcloud/controls/profiles/ProfileAction':function(){ +/* + * © 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. + */ + +/** + * @module sbt.smartcloud.controls.profiles.ProfileAction + */ +define([ "../../../declare", "../../../controls/grid/GridAction", "dojo/string" ], + function(declare, GridAction, string) { + + /** + * @class ProfileAction + * @namespace sbt.smartcloud.controls.profiles + */ + var ProfileAction = declare(GridAction, { + + /**Strings used in the actions */ + nls: { + tooltip: "Go to ${name}" }, - /** - * Return tags elements to be included in post data for this ATOM entry. - * - * @method createTags - * @returns {String} - */ - createTags : function() { - if (this.getTags && this.getTags()) { - var value = ""; - var tags = this.getTags(); - for (var tag in tags) { - value += stringUtil.transform(CategoryTmpl, { "tag" : tags[tag] }); - } - return value; - } - return ""; + /**ProfileAction Constructor function + * @method constructor + * */ + constructor: function() { }, /** - * Return extra entry data to be included in post data for this ATOM entry. - * - * @method createEntryData - * @returns {String} + * Handles displaying a tooltip for an item + * For profiles, the tooltip by default will be a business card + * So nothing is done in this function + * @method getTooltip + * @param item The element that will use the tooltip */ - createEntryData : function() { - return ""; + getTooltip: function(item) { + + //for default the semantic tag service will pop up the business card + //so do nothing here + }, /** - * return namespaces for this ATOM entry. - * - * @method createNamespaces + * The execute function is called from the handle click function + * For Profiles by default the business card functionality is used + * which works from the Semantic tag service so nothing is done here. + * @method execute + * @param item The item which fired the event + * @param opts + * @param event The event */ - createNamespaces : function() { - var namespaceData = ""; - var namespaces = this.dataHandler ? this.dataHandler.namespaces : this.namespaces; - for (prefix in namespaces) { - if (prefix != "a") { // ATOM automatically included - namespaceData += (namespaceData.length > 0) ? " " : ""; - namespaceData += "xmlns:"+prefix+"=\"" + namespaces[prefix] + "\""; - } - } - return namespaceData; + execute: function(item, opts, event) { + + //for default the semantic tag service will pop up the business card + //so do nothing here } }); - - return AtomEntity; -}); + return ProfileAction; +}); }, -'url:sbt/controls/grid/templates/GridSorter.html':"
    \r\n\t
      \r\n\t\t
    • ${nls.sortBy}
    • \r\n\t\t${sortAnchors}\r\n\t
    \r\n
    \r\n", -'sbt/Jsonpath':function(){ +'sbt/smartcloud/SmartcloudConstants':function(){ /* - * © Copyright IBM Corp. 2012 + * © Copyright IBM Corp. 2012,2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15886,216 +10928,84 @@ define([ "../declare", "../lang", "../stringUtil", "./BaseConstants", "./BaseEnt */ /** - * Social Business Toolkit SDK - * JSONPath 0.8.0 - XPath for JSON - * Would be replaced with JsonPath version of Github + * Social Business Toolkit SDK. Definition of constants for IBM Connections. + * + * @module sbt.connections.ConnectionsConstants */ -define(['./declare'],function(declare){ - return function(obj, expr, arg) - { - var P = { - resultType: arg && arg.resultType || "VALUE", - result: [], - normalize: function(expr) { - var subx = []; - return expr.replace(/[\['](\??\(.*?\))[\]']/g, function($0,$1){return "[#"+(subx.push($1)-1)+"]";}) - .replace(/'?\.'?|\['?/g, ";") - .replace(/;;;|;;/g, ";..;") - .replace(/;$|'?\]|'$/g, "") - .replace(/#([0-9]+)/g, function($0,$1){return subx[$1];}); - }, - asPath: function(path) { - var x = path.split(";"), p = "$"; - for (var i=1,n=x.length; i\r\n \r\n \"${name}\"\r\n \r\n\r\n", -'url:sbt/smartcloud/controls/profiles/templates/ColleagueItemFull.html':"\r\n \t\r\n \r\n \"${name}\r\n \r\n \r\n \r\n ${name}\r\n \r\n\r\n", -'url:sbt/smartcloud/controls/profiles/templates/ViewAll.html':"\r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n ${viewAllTitle}\r\n \r\n
    "}}); -define(["../../../declare", - "../BaseGridRenderer", - "../../../text!./templates/ColleagueItem.html", - "../../../stringUtil", - "../../../lang", - "../../../dom", - "./nls/ColleagueGridRenderer", - "../../../text!./templates/ColleagueItemFull.html", - "../../../text!./templates/ViewAll.html"], - -function(declare, BaseGridRenderer, ColleagueItemTemplate, stringUtil, lang, dom, nls, colleagueItemFullTemplate, viewAllTemplate){ - - var ColleagueGridRenderer = declare(BaseGridRenderer, { - - _nls: nls, - - containerClass: "lotusChunk", - - /** The template used to construct a photo url */ - contactImageUrl: "{baseUrl}/contacts/img/photos/{photo}", - - /** The template used to construct a no photo url*/ - noContactImageUrl: "{baseUrl}/contacts/img/noContactImage.gif", - - /**The table row template*/ - template: ColleagueItemTemplate, - - fullTemplate: colleagueItemFullTemplate, - - viewAllTemplate: viewAllTemplate, - - /**The HTML template to show paging */ - pagerTemplate : null, +'sbt/connections/controls/forums/BackAction':function(){ +/* + * © 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. + */ + +define([ "../../../declare", "../../../controls/grid/GridAction","../../../i18n!./nls/ForumGridRenderer"], + function(declare, GridAction, nls) { + + /** + * @class BackAction + * @namespace sbt.connections.controls.forum + * @module sbt.connections.controls.forum.BackAction + */ + var BackAction = declare(GridAction, { - /**The HTML template to show sorting options*/ - sortTemplate : null, - - /**The HTML template for sort Anchors*/ - sortAnchor : null, - - /** - * The constructor function + + /**ForumAction Constructor function * @method constructor - * @param args - */ + * */ constructor: function(args) { + }, - /** - * @param grid - * @param item - * @param i - * @param items - * @returns {String} - */ - photoUrl: function(grid, item, i, items) { - var ep = grid.store.getEndpoint(); - if (!ep) return null; - - var photos = item.getValue("photos"); - if (photos && lang.isArray(photos) && photos.length > 1) { - return stringUtil.replace(this.contactImageUrl, { baseUrl : ep.baseUrl , photo : photos[1] }); - }else{ - return stringUtil.replace(this.noContactImageUrl, { baseUrl : ep.baseUrl }); - } + showForums: function(item, grid, event){ + var options = { + start: grid.data.start, count: grid.pageSize + }; + grid.getForums(options); }, - - render: function(grid, el, items, data) { - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - var size = items.length; - if (size === 0) { - this.renderEmpty(grid, el); - } - else { - var container = this.renderContainer(grid, el, items, data); - for (var i=0; i\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n\r\n", -'url:sbt/connections/controls/profiles/templates/TagListRow.html':"
  • \r\n\t${term}\r\n\t${frequency}\r\n
  • \r\n", -'sbt/controls/grid/GridAction':function(){ +'url:sbt/connections/controls/vcard/templates/CommunityVCard.html':"\r\n ${name}\r\n ${uuid}\r\n ${selectedWidgetId}\r\n", +'sbt/controls/panel/_ProfilePanel':function(){ /* * © Copyright IBM Corp. 2013 * @@ -16113,61 +11023,241 @@ function(declare, BaseGridRenderer, ColleagueItemTemplate, stringUtil, lang, dom */ /** - * @module sbt.controls.grid.GridAction + * @module sbt.controls.panel._ProfilePanel */ -define(["../../declare"], function(declare) { +define(["../../declare", "../../lang", "../../dom", "../../widget/_TemplatedWidget"], + function(declare, lang, dom, _TemplatedWidget) { /** - * @class sbt.controls.grid.GridAction - * @namespace sbt.controls.grid + * @module sbt.controls.panel._ProfilePanel */ - var GridAction = declare(null, { - - /** - * Grid Action Constructor function - * @constructor - */ - constructor: function() { - }, - - /** - * Gets the string to be displayed as an elements tooltip - * @method getTooltip - * @param item the HTML element - * @returns {String} contains the text for the tooltip - */ - getTooltip: function(item) { - return "sbt.controls.GridAction No tooltip specified"; - }, - - /** - * Default action for the grid - * @method execute - * @param item The element that fired the event - * @param opts - * @param event the Event, for example onClick - */ - execute: function(item, opts, event) { - dojo.stopEvent(event); - }, - - /** - * Action to view the user's profile in connections. - * When the user clicks on a link to a person's profile - * the HREF will have the URL and redirect the user to the person's - * profile, if this action needs to be changed it can be overridden using this function - *@method viewUserProfile - */ - viewUserProfile: function(){ - //do nothing by default - } + var _ProfilePanel = declare([ _TemplatedWidget ], { + + templateString: "
    Loading profile...
    ", + template: null, + + profile: null, + + errorClass: null, + + constructor: function(args) { + lang.mixin(this, args); + + if (this.templateId) { + this.template = this._getTemplate(this.templateId); + } + }, + + postMixInProperties: function() { + }, + + postCreate: function() { + this.inherited(arguments); + + if (this.email || this.userid) { + this.getProfile(this.email || this.userid); + } else { + this.getMyProfile(); + } + }, + + getMyProfile: function() { + }, + + getProfile: function(id) { + }, + + showProfile: function(profile) { + this.profile = profile || this.profile; + if (!this.profile) { + this._displayError(new Error("Invalid profile")); + return; + } + + try { + var el = this.domNode; + while (el.childNodes[0]) { + dom.destroy(el.childNodes[0]); + } + + var node; + if (lang.isString(this.template)) { + var domStr = this._substituteItems(this.template, this.profile); + node = dom.toDom(domStr, el.ownerDocument); + } else { + node = this.template.cloneNode(true); + } + el.appendChild(node); + } catch (error) { + this._displayError(error); + } + }, + + getThumbnailAlt: function() { + return this.profile.getName() || ""; + }, + + // Internals + + _substituteItems : function(template, profile) { + var self = this; + return this._substitute(template, profile, function(value,key) { + if (typeof value == "undefined") { + // check the self for the property + value = lang.getObject(key, false, self); + } + + if (typeof value == 'function') { + // invoke function to return the value + try { + value = value.apply(profile); + } catch (ex) { + try { + value = value.apply(self, [profile]); + } catch (ex1) { + value = "ERROR:" + key + " " + ex1; + } + } + } + + if (typeof value == "undefined" || value == null) { + return ""; + } + + return value; + }, this); + }, + + _displayError: function(error) { + var el = this.domNode; + while (el.childNodes[0]) { + dom.destroy(el.childNodes[0]); + } + var ediv = dom.create("div", { + "class": this.errorClass, + innerHTML: error, + role: "alert", + tabIndex: 0 + }, el, "only"); + }, + + _getTemplate: function(domId) { + var domNode = dom.byId(domId); + return domNode ? domNode.innerHTML : "Unable to load template: "+domId+""; + } }); - return GridAction; + return _ProfilePanel; }); }, -'sbt/connections/BlogConstants':function(){ +'url:sbt/connections/controls/search/templates/DefaultSummary.html':"
    \r\n \r\n ${summaryIcon}\r\n \r\n \r\n ${communityParent}\r\n ${parentageMeta}\r\n \r\n ${summaryTypeLabel}  \r\n \r\n ${resultSummary}  \r\n
    \r\n\r\n${resultComment}", +'sbt/validate':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK - JS Validation Utilities + * @module sbt.validate + */ +define([ "./log", "./stringUtil", "sbt/i18n!sbt/nls/validate","./util" ], + function(log, stringUtil, nls, util) { + var errorCode = 400; + + return { + + /** + * Validates Input to be not null and of expected Type + * @param {String} [className] class which called this utility + * @param {String} [methodName] method which called this utility + * @param {String} [fieldName] Name of Field which is being validated + * @param {Object} [object] object to be validated + * @param {String} [expectedType] expected type of the object + * @param {Object} [args] Arguments containing callbacks + * @param {Function} [args.error] The error parameter is a callback function that is only invoked when an error occurs. This allows to write + * logic when an error occurs. The parameter passed to the error function is a JavaScript Error object indicating what the failure was. From the + * error object. one can access the javascript library error object, the status code and the error message. + * @param {Function} [args.handle = null] This callback function is called regardless of whether the call to update the file completes or fails. + * The parameter passed to this callback is the FileEntry object (or error object). From the error object. one can get access to the javascript + * library error object, the status code and the error message. + * @static + * @method _validateInputTypeAndNotify + */ + _validateInputTypeAndNotify : function(className, methodName, fieldName, object, expectedType, args) { + if (!object || (typeof object == "object" && object.declaredClass && object.declaredClass != expectedType) + || (typeof object == "object" && !object.declaredClass && typeof object != expectedType) + || (typeof object != "object" && typeof object != expectedType)) { + var message; + if (!object) { + message = stringUtil.substitute(nls.validate_nullObject, [ className, methodName, + fieldName, expectedType ]); + } else { + var actualType; + if (typeof object == "object" && object.declaredClass) { + actualType = object.declaredClass; + } else { + actualType = typeof object; + } + message = stringUtil.substitute(nls.validate_expectedType, [ className, methodName, + actualType, expectedType, fieldName ]); + } + util.notifyError({ + code : errorCode, + message : message + }, args); + return false; + } + return true; + + }, + /** + * Validates Input to be not null and of expected Type + * @param {String} [className] class which called this utility + * @param {String} [methodName] method which called this utility + * @param {Object} [fieldNames] List of Names of Fields which are being validated + * @param {Object} [objects] List of objects to be validated + * @param {Object} [expectedTypes] List of expected types of the objects + * @param {Object} [args] Arguments containing callbacks + * @param {Function} [args.error] The error parameter is a callback function that is only invoked when an error occurs. This allows to write + * logic when an error occurs. The parameter passed to the error function is a JavaScript Error object indicating what the failure was. From the + * error object. one can access the javascript library error object, the status code and the error message. + * @param {Function} [args.handle = null] This callback function is called regardless of whether the call to update the file completes or fails. + * The parameter passed to this callback is the FileEntry object (or error object). From the error object. one can get access to the javascript + * library error object, the status code and the error message. + * @static + * @method _validateInputTypeAndNotify + */ + _validateInputTypesAndNotify : function(className, methodName, fieldNames, objects, expectedTypes, args) { + for ( var counter in objects) { + var object = objects[counter]; + var expectedType = expectedTypes[counter]; + var fieldName = fieldNames[counter]; + if (!(this._validateInputTypeAndNotify(className, methodName, fieldName, object, expectedType, args))) { + return false; + } + } + return true; + + } + }; + }); + +}, +'url:sbt/connections/controls/forums/templates/TopicHeader.html':"\r\n\t\r\n\t${nls.topics}\r\n\t${nls.replies}\r\n\t\r\n\t${nls.latestPost}\r\n", +'sbt/controls/grid/Grid':function(){ /* * © Copyright IBM Corp. 2013 * @@ -16185,999 +11275,690 @@ define(["../../declare"], function(declare) { */ /** - * Social Business Toolkit SDK. Definition of constants for BlogService. * - * @module sbt.connections.BlogConstants */ -define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { +define([ "../../declare", "../../lang", "../../itemFactory", "../../stringUtil", "../../widget/grid/_Grid", "../../util"], + function(declare, lang, itemFactory, stringUtil, _Grid, util) { + + /** + * @class grid + * @namespace sbt.controls.grid + * @module sbt.controls.grid.Grid + */ + var Grid = declare([ _Grid ], { - return lang.mixin({}, conn, { - /** - * XPath expressions used when parsing a Connections Blogs ATOM feed - * - * @property BlogFeedXPath - * @type Object - * @for sbt.connections.BlogService + * Data associated with this Grid + */ + data: null, + + /** + * The renderer associated with the grid */ - BlogFeedXPath : conn.ConnectionsFeedXPath, + renderer: null, - RecommendersFeedXpath : { - entries : "/a:feed/a:entry", - totalResults : "/a:feed/os:totalResults" - }, + /** + * Encode all of the data coming from the connections server + * as HTML entities, to prevent XSS attacks + */ + encodeHtml: true, /** - * Namespaces to be used when reading the Blogs ATOM entry or feed + * The number of grid rows displayed per page */ - BlogNamespaces : { - a : "http://www.w3.org/2005/Atom", - app : "http://www.w3.org/2007/app", - snx : "http://www.ibm.com/xmlns/prod/sn" - }, + pageSize: 10, /** - * XPath expressions to be used when reading a Blog - * - * @property BlogXPath - * @type Object - * @for sbt.connections.BlogService + * Flag to hide the pager */ - BlogXPath : lang.mixin({}, conn.AtomEntryXPath, { - blogUuid : "a:id", - handle : "snx:handle", - timezone : "snx:timezone", - rank : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", - categoryupdates : "a:category[@term='updates']", - categoryfaq : "a:category[@term='faq']", - categorywith : "a:category[@term='with']", - categoryshared : "a:category[@term='shared']", - communityUuid : "snx:communityUuid", - containerUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/container']/@href", - containerType : "snx:containertype", - categoryFlags : "a:link[@scheme='http://www.ibm.com/xmlns/prod/sn/flags']/@term", - summary : "a:summary[@type='html']" - }), + hidePager: false, /** - * XPath expressions to be used when reading a Blog Post - * - * @property BlogPostXPath - * @type Object - * @for sbt.connections.BlogService + * Flag to hide the sorter */ - BlogPostXPath : lang.mixin({}, conn.AtomEntryXPath, { - postUuid : "a:id", - replies : "a:link[@rel='replies']/@href", - recommendationsUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/recommendations']/@href", - rankRecommendations : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", - rankComment : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/comment']", - rankHit : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/hit']", - repliesUrl : "a:link[@rel='replies']/@href", - sourceId : "a:source/a:id", - sourceTitle : "a:source/a:title ", - sourceLink : "a:source/a:link[@rel='self']/@href", - sourceLinkAlternate : "a:source/a:link[@rel='alternate']/@href", - sourceUpdated : "a:source/a:updated", - sourceCategory : "a:source/a:link[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", - blogHandle : "blogHandle", - summary : "a:summary[@type='html']" - }), + hideSorter: false, /** - * XPath expressions to be used when reading a Blog Post Comment - * - * @property CommentXPath - * @type Object - * @for sbt.connections.BlogService + * flag to hide the footer */ - CommentXPath : lang.mixin({}, conn.AtomEntryXPath, { - commentUuid : "a:id", - commentUrl : "a:link[@rel='self']/@href", - recommendationsUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/recommendations']/@href", - trackbacktitle : "snx:trackbacktitle", - replyTo : "thr:in-reply-to/@ref", - replyToSource : "thr:in-reply-to/@source", - rankRecommendations : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", - sourceId : "a:source/a:id", - sourceTitle : "a:source/a:title ", - sourceLink : "a:source/a:link[@rel='self']/@href", - sourceLinkAlternate : "a:source/a:link[@rel='alternate']/@href", - blogHandle : "blogHandle", - blogPostUuid : "blogPostUuid" - }), + hideFooter: false, /** - * XPath expressions to be used when reading a Blog Post Recommenders feed - * - * @property RecommendersXPath - * @type Object - * @for sbt.connections.BlogService + * FilterTag, is used for sorting and paging, as to only sort as filtered set of results */ - RecommendersXPath : lang.mixin({}, conn.AtomEntryXPath, { - recommenderUuid : "a:id", - category : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term" - }), + filterTag: "", + + /** + * Selected rows are the rows of the grid that have been selected by checking a check box + */ + selectedRows: null, + + /* + * TODO remove this? + */ + _strings: {}, + + /* + * Arguments for the associated data store + */ + _storeArgs: null, + + /* + * Regular expression used to remove // from url's + */ + _regExp: new RegExp("/{2}"), + + /* + * Array of selection listeners + */ + _selListeners: [], /** - * page Page number. Specifies the page to be returned. The default value is 1, which returns the first page. - * ps Page size. Specify the number of entries to return per page. - * search Well-formed full text search query. Performs a text search on community titles and descriptions. - * since Includes in the resulting feed all communities updated after a specified date. Specify the date using a date-time value that conforms to RFC3339. Use an upper case "T" to separate the date and time, and an uppercase "Z" in the absence of a numeric time zone offset. For example: 2009-01-04T20:32:31.171Z. - * sortBy Specifies what value to use as the basis for organizing the entries returned in the feed. The options are: - * modified © Sorts the results by last modified date. - * commented - Sorts the entries by the number of comments or replies an item has received. - * popularity - Sorts the entries by how popular the item is. - * recommended - Sorts the entries by the number of times the item was recommended. - * title - Sorts the entries alphabetically by title. The title used is the text that is displayed in the element of each entry in the feed. - * sortOrder Specifies the order in which to sort the results. The options are: - * asc - Sorts the results in ascending order. - * desc - Sorts the results in descending order. - * communityUuid Returns community blog and community ideation blog in the specified community. - * ps Page size. Specify the number of entries to return per page. - * blogType Returns only specific Blogs type: - * blog - regular blogs and community blogs - * communityblog - community blogs only - * communityideationblog - community ideation blogs only - * tags Returns blog entries with the specified tags. Separate multiple tags with a plus sign (+). + * Empty context root map, can be overridden by subclasses of Grid. Represents Connections context roots. */ + contextRootMap: {}, /** - * A feed of all blogs. - * - * Get the Blogs feed to see a list of all blogs - * - * Supports: page, ps, sortBy, sortOrder, search, since, communityUuid, blogType, sortField, tag - * - * @property AtomBlogsAll - * @type String - * @for sbt.connections.BlogService + * Constructor method for the grid. + * Creates a default store and renderer, if none have been already created + * @method constructor + * @param args */ - AtomBlogsAll : "/${blogs}/{blogHomepageHandle}/feed/blogs/atom", + constructor: function(args) { + lang.mixin(this, args); + + this.selectedRows = []; + + if (!this.store) { + if (args && args.storeArgs) { + this._storeArgs = lang.mixin({}, args.storeArgs); + this._storeArgs.endpoint = this.endpoint; + this.store = this.createDefaultStore(args.storeArgs); + } else if (this.options) { + this._storeArgs = lang.mixin({}, this.options[this.defaultOption].storeArgs); + this._storeArgs.endpoint = this.endpoint; + if (args && args.type && this.options.hasOwnProperty(args.type)) { + lang.mixin(this._storeArgs, this.options[args.type].storeArgs); + } + } + this.store = this.createDefaultStore(this._storeArgs); + } + + if (!this.renderer) { + if (args && args.rendererArgs) { + this.renderer = this.createDefaultRenderer(args.rendererArgs,this); + } else if (this.options) { + var rendererArgs = this.options[this.defaultOption].rendererArgs; + if (args && args.type && this.options.hasOwnProperty(args.type)) { + rendererArgs = this.options[args.type].rendererArgs; + } + + this.renderer = this.createDefaultRenderer(rendererArgs,this); + } + } + }, /** - * A feed of my blogs. - * - * Get the Blogs feed to see a list of Blogs created by logged in user - * - * Supports: page, ps, sortBy, sortOrder, search, since, communityUuid, blogType, sortField, tag + * Create the store to be used with this Grid. * - * @property AtomBlogsMy - * @type String - * @for sbt.connections.BlogService + * @method - createDefaultStore + * @param args - the arguments to pass to the atom store, such as URL and attributes + * @returns - an atom store instance */ - AtomBlogsMy : "/${blogs}/{blogHomepageHandle}/api/blogs", + createDefaultStore: function(args) { + var store = this._createDefaultStore(args); + var url = store.getUrl(); + if (url) { + url = this.buildUrl(url, args, store.getEndpoint()); + } + store.setUrl(url); + + return store; + }, /** - * A blog instance. + * Allow Grid to build the complete URL before it is passed to the store. * - * @property AtomBlogInstance - * @type String - * @for sbt.connections.BlogService + * @method buildUrl + * @param url base url + * @param args arguments that will be passed to the store + * @param endpoint The endpoint, needed to verify if custom service mappings are present. + * @returns Built url */ - AtomBlogInstance : "/${blogs}/{blogHomepageHandle}/api/blogs/{blogUuid}", - + buildUrl: function(url, args, endpoint) { + var params = {}; + if (this.query) { + params = lang.mixin(params, this.query); + } + return this.constructUrl(url, params, this.getUrlParams(), endpoint); + }, + /** - * A blog post entry. + * Create the renderer to be used with this Grid. * - * @property AtomBlogPostInstance - * @type String - * @for sbt.connections.BlogService + * @method - createDefaultRenderer + * @param args */ - AtomBlogPostInstance : "/${blogs}/{blogHomepageHandle}/api/entries/{postUuid}", + createDefaultRenderer: function(args) { + }, /** - * A feed of all blogs posts. - * - * Get the Blogs posts feed to see a list of posts from all Blogs - * - * Supports: page, ps, sortBy, sortOrder, search, since - * - * @property AtomEntriesAll - * @type String - * @for sbt.connections.BlogService + * Post create function is called after grid has been created. + * @method - postCreate */ - AtomEntriesAll : "/${blogs}/{blogHomepageHandle}/feed/entries/atom", + postCreate: function() { + this.inherited(arguments); + + if (this.renderer && this.store) { + this.renderer.renderLoading(this, this.gridNode); + } + + if (this.updateOnCreate) { + this.created = true; + this.update(); + } + }, /** - * A feed of a blog's posts. - * - * Get the Blog posts feed to see a list of posts from a Blog - * - * Supports: page, ps, sortBy, sortOrder, search, since - * - * @property AtomBlogEntries - * @type String - * @for sbt.connections.BlogService + * Refresh the grid + * @method - refresh */ - AtomBlogEntries : "/${blogs}/{blogHandle}/feed/entries/atom", - + refresh: function() { + if (this.data) { + if (this.store) { + this.update(null); + } else { + this.update(); + } + } + + this.selectedRows = []; + }, + /** - * A feed of a blog's comments. - * - * Get the Blog Comments feed to see a list of comments from a blog post - * - * Supports: page, ps, sortBy, sortOrder, search, since - * - * @property AtomBlogComments - * @type String - * @for sbt.connections.BlogService + * Update the grid + * @method - update */ - AtomBlogComments : "/${blogs}/{blogHandle}/feed/comments/atom", + update: function(data) { + this.selectedRows = []; + + if (arguments.length > 0) { + this.data = data; + } + if (this.data) { + this.renderer.render(this, this.gridNode, this.data.items, this.data); + this.onUpdate(this.data); + } else if (this.store) { + if (this._activeSortAnchor && this._activeSortIsDesc !== undefined) { + this._doQuery(this.store, { start : 0, count : this.pageSize, sort: [{ attribute : this._activeSortAnchor.sortParameter, descending : this._activeSortIsDesc }] }); + } else { + this._doQuery(this.store, { start : 0, count : this.pageSize }); + } + + } else { + this.renderer.renderEmpty(this, this.gridNode, this.data); + this.onUpdate(this.data); + } + }, /** - * A feed of a blog's comments. - * - * Get the Blog Comments feed to see a list of comments from all blog post - * - * Supports: page, ps, sortBy, sortOrder, search, since - * - * @property AtomBlogCommentsAll - * @type String - * @for sbt.connections.BlogService + * @method onUpdate + * @param data */ - AtomBlogCommentsAll : "/${blogs}/{blogHomepageHandle}/feed/comments/atom", + onUpdate: function(data) { + }, + + /** + * @method getSortInfo + */ + getSortInfo: function() { + }, + + /** + * Go back to the previous page + * @method - prevPage + * @param el - The element that fired the event, typically an anchor + * @param data - the data associated with element + * @param ev - the event, for example onClick + */ + prevPage: function(el, data, ev) { + this._stopEvent(ev); + + if (this.store) { + + //if sorting + if(this._activeSortAnchor){ + var options = { + start : 0, count : this.pageSize, + sort: [{ attribute: this._activeSortAnchor.sortParameter }] + }; + + if(this._activeSortIsDesc !== undefined){ + options.sort[0].descending = this._activeSortIsDesc; + } + }else{ + var options = { + start : 0, count : this.pageSize + }; + } + if (this.data) { + options.start = Math.max(0, this.data.start - options.count); + } + + if(this.filterTag != "" && this.filterTag != null){ + options.tag = this.filterTag; + } + + this._doQuery(this.store, options); + } + }, /** - * A feed of featured blogs. - * - * Get the featured blogs feed to find the blogs that have had the most activity across - * all of the blogs hosted by the Blogs application in the past two weeks. - * - * Supports: page, ps, sortBy, sortOrder, search, since + * Helper method to display 10 items per page * - * @property AtomBlogsFeatured - * @type String - * @for sbt.connections.BlogService + * @method show10ItemsPerPage + * @param el + * @param data + * @param event */ - AtomBlogsFeatured : "/${blogs}/{blogHomepageHandle}/feed/featuredblogs/atom", - + show10ItemsPerPage: function(el, data, ev) { + this.showItemsPerPage(el, data, ev, 10); + }, + /** - * A feed of featured blogs posts. - * - * Get the featured posts feed to find the blog posts that have had the most activity across - * all of the blogs hosted by the Blogs application within the past two weeks - * - * Supports: page, ps, sortBy, sortOrder, search, since + * Helper method to display 25 items per page * - * @property AtomBlogsPostsFeatured - * @type String - * @for sbt.connections.BlogService + * @method show25ItemsPerPage + * @param el + * @param data + * @param event */ - AtomBlogsPostsFeatured : "/${blogs}/{blogHomepageHandle}/feed/featured/atom", + show25ItemsPerPage: function(el, data, ev) { + this.showItemsPerPage(el, data, ev, 25); + }, /** - * A feed of featured blogs posts. - * - * Get a feed that includes all of the recommended blog posts - * in all of the blogs hosted by the Blogs application. - * - * Supports: page, ps, sortBy, sortOrder, search, since + * Helper method to display 50 items per page * - * @property AtomBlogsPostsRecommended - * @type String - * @for sbt.connections.BlogService + * @method show50ItemsPerPage + * @param el + * @param data + * @param event */ - AtomBlogsPostsRecommended : "/${blogs}/{blogHomepageHandle}/feed/recommended/atom", + show50ItemsPerPage: function(el, data, ev) { + this.showItemsPerPage(el, data, ev, 50); + }, /** - * A feed of blogs tags. - * - * Get a feed that includes all of the tags - * in all of the blogs hosted by the Blogs application. + * Helper method to display 100 items per page * - * @property AtomBlogsTags - * @type String - * @for sbt.connections.BlogService + * @method show100ItemsPerPage + * @param el + * @param data + * @param event */ - AtomBlogsTags : "/${blogs}/{blogHomepageHandle}/feed/tags/atom", - + show100ItemsPerPage: function(el, data, ev) { + this.showItemsPerPage(el, data, ev, 100); + }, + /** - * A feed of blog tags. - * - * Get a feed that includes all of the tags - * in a perticular Blog. - * - * @property AtomBlogTags - * @type String - * @for sbt.connections.BlogService + * Displays the feed for the content that is currently shown. + * @method - viewFeed + * @param el - The element that fired the event, typically an anchor + * @param data - the data associated with element + * @param ev - the event, for example onClick */ - AtomBlogTags : "/${blogs}/{blogHandle}/feed/tags/atom", + viewFeed: function(el, data, ev) { + var endpoint = this.store.getEndpoint(); + var proxy = endpoint.proxy; + var baseUrl = endpoint.baseUrl; + var proxyPath = endpoint.proxyPath; + var url = proxy.rewriteUrl(baseUrl, this.store.getUrl(), proxyPath); + window.open(url, "_new"); + }, /** - * Create a Blog. - * - * @property AtomBlogCreate - * @type String - * @for sbt.connections.BlogService + * Show "count" items per page + * @method - showItemsPerPage + * @param el - The element that fired the event, typically an anchor + * @param data - the data associated with element + * @param ev - the event, for example onClick + * @param count - the number of items to display per page */ - AtomBlogCreate : "/${blogs}/{blogHomepageHandle}/api/blogs", + showItemsPerPage: function(el, data, ev, count) { + this._stopEvent(ev); + if (this.store) { + this.pageSize = count; + this.update(null); + } + }, + /** - * Edit or remove a Blog. - * - * @property AtomBlogEditDelete - * @type String - * @for sbt.connections.BlogService + * Move forward to the next page of grid rows + * @method - nextPage + * @param el - The element that fired the event, typically an anchor + * @param data - the data associated with element + * @param ev - the event, for example onClick */ - AtomBlogEditDelete : "/${blogs}/{blogHomepageHandle}/api/blogs/{blogUuid}", + nextPage: function(el, data, ev) { + this._stopEvent(ev); + + if (this.store) { + //if there is sorting available + if(this._activeSortAnchor){ + var options = { + start : 0, count : this.pageSize , + sort: [{ attribute: this._activeSortAnchor.sortParameter }] + }; + if(this._activeSortAnchor !== undefined){ + options.sort[0].descending = this._activeSortIsDesc; + } + } else { + var options = { + start : 0, count : this.pageSize + }; + } + if (this.data) { + options.start = this.data.start + options.count; + options.count = this.pageSize; + options.total = this.data.totalCount; + } + if(this.filterTag != "" && this.filterTag != null){ + options.tag = this.filterTag; + } + this._doQuery(this.store, options); + } + }, + /** - * Create, Edit or remove a Blog Post. - * - * @property AtomBlogPostCreate - * @type String - * @for sbt.connections.BlogService + * Called when the user clicks a checkbox + * The row gets added or removed to an array, + * to retrieve the array call getSelected + * @method handleCheckBox */ - AtomBlogPostCreate : "/${blogs}/{blogHandle}/api/entries", + handleCheckBox: function (el, data, ev) { + // keep track of current selection + if (el.checked) { + this.selectedRows.push(data); + } else if (!el.checked) { + var rows = this.getSelected(); + for(var i=0;i<rows.length;i++){ + if(rows[i].data == data){ + //selected row + this.selectedRows.splice(i,1); + } + } + } + + // notify selection listeners + for (var i=0; i<this._selListeners.length; i++) { + try { + var selection = this.selectedRows.slice(); + this._selListeners[i].selectionChanged(selection, this); + } catch (error) { + } + } + }, /** - * Edit or remove a Blog Post. + * If the grid rows have checkboxes , get a list of the rows which are currently selected + * (That have a checked checkbox) + * @method - getSelected * - * @property AtomBlogPostEditDelete - * @type String - * @for sbt.connections.BlogService */ - AtomBlogPostEditDelete : "/${blogs}/{blogHandle}/api/entries/{postUuid}", + getSelected: function() { + var items = []; + if (this.selectedRows) { + for (var i=0; i<this.selectedRows.length; i++) { + var item = { + data: this.selectedRows[i] + }; + items.push(item); + } + } + return items; + }, + /** - * Create, Edit or remove a Blog Comment. - * - * @property AtomBlogCommentCreate - * @type String - * @for sbt.connections.BlogService + * @method addSelectionListener + * @param listener */ - AtomBlogCommentCreate : "/${blogs}/{blogHandle}/api/entrycomments/{postUuid}", + addSelectionListener : function(listener) { + this._selListeners.push(listener); + }, /** - * Edit or remove a Blog Comment. - * - * @property AtomBlogCommentEditRemove - * @type String - * @for sbt.connections.BlogService - */ - AtomBlogCommentEditRemove : "/${blogs}/{blogHandle}/api/comments/{commentUuid}", + * @method removeSelectionListener + * @param listener + */ + removeSelectionListener : function(listener) { + this._selListeners.pop(listener); + }, - /** - * Recommend or Unrecommend a Blog Post. - * - * @property AtomRecommendBlogPost - * @type String - * @for sbt.connections.BlogService - */ - AtomRecommendBlogPost : "/${blogs}/{blogHandle}/api/recommend/entries/{postUuid}", + refreshSelectionListeners: function(){ + // notify selection listeners + for (var i=0; i<this._selListeners.length; i++) { + try { + var selection = this.selectedRows.slice(); + this._selListeners[i].selectionChanged(selection, this); + } catch (error) { + } + } + }, /** - * Get list of voted Ideas by user. + * Add an item using the specified Document * - * @property AtomVotedIdeas - * @type String - * @for sbt.connections.IdeationBlogService - */ - AtomVotedIdeas : "/${blogs}/{blogHomepageHandle}/feed/myvotes/atom", + * @method addItem + * @param document + */ + addItems: function(document) { + if (!this.data) { + this.data = { items: [], start: 0, end: 0, count: 0, totalCount: 0 }; + } + var attributes = this._storeArgs.attributes; + var items = itemFactory.createItems(document, attributes, this); + this.data.items = this.data.items.concat(items); + this.data.totalCount += this.data.items.length; + this.data.end = this.data.count = this.data.totalCount; + }, /** - * Get list of comments to the specified blog entry. + * Insert the specified item into the grid at the specified index. * - * @property AtomBlogEntryComments - * @type String - * @for sbt.connections.BlogService + * TODO This is here so that we can insert the local user grid at the start of the items array, mainly. + * The args like email are not available at the start. So try to see if the user can be inserted to the start of some asrray before it goes to get the different profiles. + * @param e */ - AtomBlogEntryComments : "/${blogs}/{blogHandle}/feed/entrycomments/{entryAnchor}/atom" - }); -}); -}, -'sbt/util':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ - -/** - * @module sbt.util - */ -define(['./lang','sbt/i18n!sbt/nls/util','./log','./stringUtil','./pathUtil'],function(lang, nls, log, stringUtil, pathUtil) { - var errorCode = 400; - function _notifyError(error, args){ - if (args && (args.error || args.handle)) { - if (args.error) { - try { - args.error(error); - } catch (error1) { - log.error(nls.notifyError_catchError, error1); - } - } - if (args.handle) { - try { - args.handle(error); - } catch (error2) { - log.error(nls.notifyError_catchError, error2); - } - } - } else { - log.error(nls.notifyError_console, error.code, error.message); - } - } - return { - notifyError: _notifyError, - isEmptyObject: function(obj){ - var isEmpty = true; - for( var key in obj ){ - if(obj.hasOwnProperty(key)){ - isEmpty = false; - break; - } + insertItem: function(document, index) { + if(!this.data){ + console.log("Data is not yet present, adding to beginning."); + this.data = { items: [], start: 0, end: 0, count: 0, totalCount: 0 }; + index = 0; } - return isEmpty; + var attributes = this._storeArgs.attributes; + var items = itemFactory.createItems(document, attributes, this); + this.data.items.splice(index, 0, items[0]); + this.data.totalCount = this.data.items.length; + this.data.end = this.data.count = this.data.totalCount; }, - checkObjectClass: function(object, className, message, args){ - if(object.declaredClass != className){ - if(args){ - _notifyError({code:errorCode,message:message},args); - }else{ - log(message); - } - return false; - }else{ - return true; - } - }, - checkNullValue: function(object, message, args){ - if(!object){ - if(args){ - _notifyError({code:errorCode,message:message},args); - }else{ - log(message); - } - return false; - }else{ - return true; - } - }, - minVersion: function(required, used) { - var reqParts = required.split('.'); - var usedParts = used.split('.'); - - for (var i = 0; i < reqParts.length; ++i) { - if (usedParts.length == i) { - return false; - } - - if (reqParts[i] == usedParts[i]) { - continue; - } - else if (reqParts[i] > usedParts[i]) { - return false; - } - else { - return true; - } - } - - if (reqParts.length != usedParts.length) { - return true; - } - - return true; - }, - getAllResponseHeaders: function(xhr) { - var headers = {}; - try { - var headersStr = xhr.getAllResponseHeaders(); - if (headersStr) { - var headersStrs = headersStr.split('\n'); - for (var i=0; i<headersStrs.length; i++) { - var index = headersStrs[i].indexOf(':'); - var key = lang.trim(headersStrs[i].substring(0, index)); - var value = lang.trim(headersStrs[i].substring(index+1)); - if (key.length > 0) { - headers[key] = value; - } - } - } - } catch(ex) { - console.log(ex); - } - return headers; + + /** + * @method encodeImageUrl + * @param url + */ + encodeImageUrl: function(url) { + var ep = this.store.getEndpoint(); + return ep.proxy.rewriteUrl(ep.baseUrl, url, ep.proxyPath); }, /** - * Takes an object mapping query names to values, and formats them into a query string separated by the delimiter. - * e.g. - * createQuery({height: 100, width: 200}, ",") - * - * returns "height=100,width=200" - * - * @method createQuery - * - * @param {Object} queryMap An object mapping query names to values, e.g. {height:100,width:200...} - * @param {String} delimiter The string to delimit the queries + * Return the auth type to be used + * @returns {String} */ - createQuery: function(queryMap, delimiter){ - if(!queryMap){ - return null; - } - var delim = delimiter; - if(!delim){ - delim = ","; - } - var pairs = []; - for(var name in queryMap){ - var value = queryMap[name]; - pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(value)); - } - return pairs.join(delim); - }, - - /** - * Takes a query string and returns an equivalent object mapping. - * e.g. - * splitQuery("height=100,width=200", ",") - * - * returns {height: 100, width: 200} - * - * @method splitQuery - * - * @param {String} query A query string, e.g. "height=100,width=200" - * @param {String} delimiter The string which delimits the queries + getAuthType: function() { + return ""; + }, + + /** + * Return the url parameters to be used + * @returns {Object} */ - splitQuery: function(query, delimiter){ - var i; - var result = {}; - var part; - var parts; - var length; - - query = query.replace("?", ""); - parts = query.split(delimiter); - length = parts.length; - - for (i = 0; i < length; i++) { - if(!parts[i]){ - continue; - } - part = parts[i].split('='); - result[part[0]] = part[1]; + getUrlParams: function() { + return { authType : this.getAuthType() }; + }, + + /** + * Construct a url using the specified parameters + * @method constructUrl + * @param url + * @param params + * @param urlParams + * @param endpoint An endpoint which may contain custom service mappings. + * @returns + */ + constructUrl : function(url,params,urlParams, endpoint) { + if (!url) { + throw new Error("Grid.constructUrl: Invalid argument, url is undefined or null."); } - - return result; - }, - - /** - * Returns the JavaScript Library and version used - * @returns {String} JavaScript Library with version - */ - getJavaScriptLibrary : function(){ - var jsLib = "Unknown"; - if(window.dojo) { - if(dojo.version) { - jsLib = "Dojo "+dojo.version; - } - } else if(define && define.amd && define.amd.vendor && define.amd.vendor === "dojotoolkit.org") { - require(["dojo/_base/kernel"], function(kernel){ - jsLib = "Dojo AMD "+kernel.version; - }); - } else if(window.jQuery) { - jsLib = "JQuery "+jQuery.fn.jquery; - } - return jsLib; - }, - - /** - * Return san absolute version of the specified url - * @param {String} URL to convert - * @returns {String} Absolute version of the url - */ - makeAbsoluteUrl : function(url) { - if (stringUtil.startsWith(url, "http")) { - return url; - } - var loc = window.location; - var baseUrl = loc.protocol+'//'+loc.hostname+(loc.port ? ':'+loc.port: ''); - return pathUtil.concat(baseUrl, url); - } - }; -}); -}, -'url:sbt/connections/controls/files/templates/FolderRow.html':"<tr style=\"cursor: pointer;\" class=\"lotusFirst\">\r\n <td style=\"width: 100%;\" class=\"lotusFirstCell\">\r\n <h4 class=\"lotusBreakWord\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${title}\" href=\"${folderUrl}\"> \r\n ${title} \r\n </a>\r\n </h4>\r\n <div class=\"lotusMeta\" role=\"list\">\r\n <span role=\"listitem\"> \r\n <span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t\t<a aria-label=\"${nls.ariaVcard}\" href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" class=\"fn url\">${authorName}</a>\r\n \t\t\t\t\t\t<span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${authorUserId}</span>\r\n\t\t\t\t\t</span>\r\n\t\t\t\t\t ${_nls.created} ${createdLabel} | ${itemCount} ${_nls.files}\r\n </span>\r\n </div>\r\n </td>\r\n <td style=\"padding-right: 20px;\">\r\n <a class=\"lconnPinnedToggle _folderPinned\" href=\"#\" topic=\"lconn/files/folders/myfavorites/toggle\" role=\"button\"\r\n title=\"${nls.pin}\" aria-label=\"${nls.pin}\"\r\n uid=\"${uid}\">\r\n <img src=\"images/blank.gif\"\r\n alt=\"\" class=\"lconnSprite lconnSprite-iconPinned16-off\"\r\n style=\"margin-top: 1px;\">\r\n <span class=\"lotusAltText\">${_nls.pin}</span>\r\n </a>\r\n </td>\r\n <td style=\"padding-right: 30px;\" class=\"lotusNowrap\" >\r\n <a href=\"${folderUrl}\" aria-label=\"${shareLabel}\">\r\n <img src=\"images/blank.gif\"\r\n class=\"lconnSprite lconnSprite-icon${visibilityLabel}16\"\r\n alt=\"\" title=\"${shareLabel}\"\r\n style=\"margin-top: 1px;\">\r\n <span class=\"lotusAltText\">${shareLabel}</span></a></td>\r\n \r\n</tr>", -'sbt/connections/controls/search/SearchBoxRenderer':function(){ -require({cache:{ -'url:sbt/connections/controls/search/templates/SearchBoxTemplate.html':"<span class=\"lotusTitleBar2\">\r\n\t<span style=\"max-width:100%; padding:0px 0px 0px 0px;\" class=\"lotusWrapper\">\r\n\t\t<span style=\"border-bottom: none;\"class=\"lotusInner\">\r\n\t\t\t<div style=\"position:relative; margin-top:0px; top:0px;\" class=\"lotusSearch\" >\r\n\t\t\t\t\t<table cellspacing=\"0\" role=\"presentation\" class=\"lotusLayout\">\r\n\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<div class=\"lotusHidden\">${nls.refine}</div>\r\n\t\t\t\t\t\t\t\t\t<div>\r\n\t\t\t\t\t\t\t\t\t\t<a data-dojo-attach-event=\"onclick: handleClick\" class=\"lotusScope\" href=\"javascript:;\">\r\n\t\t\t\t\t\t\t\t\t\t\t<img src=\"images/blank.gif?etag=20120919.054848\"\r\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"${nls.allConnectionsIcon}\" class=\"lotusIcon lconnSprite lconnSprite-iconConnections16\">\r\n\t\t\t\t\t\t\t\t\t\t\t<span id=\"searchAppType\">${nls.allConnections}</span>\r\n\t\t\t\t\t\t\t\t\t\t\t<span role=\"presentation\" class=\"lotusAltText\">â–¼</span>\r\n\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span><label for=\"input\" style=\"display:none;\">text</label>\r\n\t\t\t\t\t\t\t\t\t\t<input id=\"input\" type=\"text\" data-dojo-attach-event=\"onkeyup: suggest, blur: setSearchQuery\" class=\"lotusText lotusInactive\" />\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span class=\"lotusBtnImg\"> \r\n\t\t\t\t\t\t\t\t\t\t<input data-dojo-attach-event=\"click: search\" class=\"lotusSearchButton\" type=\"image\" title=\"${nls.search}\" alt=\"${nls.search}\"\r\n\t\t\t\t\t\t\t\t\t\t\tsrc=\"images/blank.gif?etag=20120919.054848\"> \r\n\t\t\t\t\t\t\t\t\t\t<a class=\"lotusAltText\" alt=\"${nls.search}\" href=\"javascript:;\">${nls.search}</a>\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t</span>\r\n\t</span>\r\n</span>", -'url:sbt/connections/controls/search/templates/SearchSuggestTemplate.html':"<span class=\"lotusTitleBar2\">\r\n\t<span style=\"max-width:100%; padding:0px 0px 0px 0px;\" class=\"lotusWrapper\">\r\n\t\t<span style=\"border-bottom: none;\"class=\"lotusInner\">\r\n\t\t\t<div style=\"position:relative; margin-top:0px; top:0px;\" class=\"lotusSearch\" >\r\n\t\t\t\t\t<table cellspacing=\"0\" role=\"presentation\" class=\"lotusLayout\">\r\n\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t<div class=\"lotusHidden\">${nls.refine}</div>\r\n\t\t\t\t\t\t\t\t\t<div>\r\n\t\t\t\t\t\t\t\t\t\t<a data-dojo-attach-event=\"onclick: handleClick\" class=\"lotusScope\" href=\"javascript:;\">\r\n\t\t\t\t\t\t\t\t\t\t\t<img src=\"images/blank.gif?etag=20120919.054848\"\r\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"${nls.allConnectionsIcon}\" class=\"lotusIcon lconnSprite lconnSprite-iconConnections16\">\r\n\t\t\t\t\t\t\t\t\t\t\t<span>${nls.allConnections}</span>\r\n\t\t\t\t\t\t\t\t\t\t\t<span role=\"presentation\" class=\"lotusAltText\">â–¼</span>\r\n\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span ><label for=\"com.ibm.sbt.search.input\" style=\"display:none;\">text</label>\r\n\t\t\t\t\t\t\t\t\t\t<input id=\"com.ibm.sbt.search.input\" type=\"text\" data-dojo-attach-event=\"onkeyup: suggest, blur: setSearchQuery\" class=\"lotusText lotusInactive\" />\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span class=\"lotusBtnImg\"> \r\n\t\t\t\t\t\t\t\t\t\t<input data-dojo-attach-event=\"click: search\" class=\"lotusSearchButton\" type=\"image\" title=\"${nls.search}\" alt=\"${nls.search}\"\r\n\t\t\t\t\t\t\t\t\t\t\tsrc=\"images/blank.gif?etag=20120919.054848\"> \r\n\t\t\t\t\t\t\t\t\t\t<a class=\"lotusAltText\" alt=\"${nls.search}\" href=\"javascript:;\">${nls.search}</a>\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\r\n\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t</span>\r\n\t</span>\r\n</span>", -'url:sbt/connections/controls/search/templates/PopUpTemplate.html':"<table role=\"presentation\" tabindex=\"0\"\r\n\tdata-dojo-attach-event=\"blur: handleBlur, onkeypress: onKeyPress\"\r\n\tclass=\"dijit dijitMenu dijitReset dijitMenuTable lotusNavMenu lconnSearchScope dijitMenuActive\"\r\n\tstyle=\"position:fixed;\">\r\n\t<tbody tabindex=\"0\" class=\"dijitReset\">\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onmouseenter: displayHighlight, onmouseleave: removeHighlight, onclick: setSelectedApplication\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem lotusAlignLeft\">\r\n\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconConnections16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.allConnections}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onmouseenter: displayHighlight, onmouseleave: removeHighlight, onclick: setSelectedApplication\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconStatusUpdate16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.statusUpdates}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconActivities16\" />\r\n\t\t\t</td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.activities}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconBlogs16\" /></td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.blogs}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconBookmarks16\" />\r\n\t\t\t</td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.bookmarks}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconCommunities16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.communities}</td>\r\n\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconFiles16\" /></td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.files}</td>\r\n\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconForums16\" /></td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.forums}</td>\r\n\t\t</tr>\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconProfiles16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.profiles}</td>\r\n\r\n\t\t</tr>\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem dijitMenuItemSelected\">\r\n\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconWikis16\" /></td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.wikis}</td>\r\n\t\t</tr>\r\n\r\n\t</tbody>\r\n</table>", -'url:sbt/connections/controls/search/templates/SuggestPopUpTemplate.html':"<table style=\"border-radius:0px; list-style:none; cursor: pointer; width: 190px; position:absolute; z-index:100; background-color:#EEEEEE; left:13em; \" role=\"presentation\">\r\n</table>\r\n", -'url:sbt/connections/controls/search/templates/MemberListItemTemplate.html':"<span class=\"lotusFilters\">\r\n\t<a class=\"lotusFilter\" href=\"javascript:;\" data-dojo-attach-event=\"click: closeMemberItem\" >\r\n\t\t<span>${memberName}</span>\r\n\t\t<span class=\"lotusClose\">X</span>\r\n\t</a>  \r\n</span>", -'url:sbt/connections/controls/search/templates/MemberListTemplate.html':"<div style=\"padding-top: 15px;\" class=\"lotusHeader\"></div>", -'url:sbt/connections/controls/search/templates/SingleApplicationSearch.html':"<span style=\"position:relative\">\r\n\t<span>\r\n\t\t<span>\r\n\t\t\t<div>\r\n\t\t\t\t\t<table>\r\n\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t<tr>\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span><label style=\"display:none;\">text</label>\r\n\t\t\t\t\t\t\t\t\t\t<input style=\"width: 350px; height:2em;\" type=\"text\" data-dojo-attach-event=\"onkeyup: suggest,blur: setSearchQuery\" />\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t</span>\r\n\t</span>\r\n</span>", -'url:sbt/connections/controls/search/templates/SingleSearchPopUp.html':"<ul style=\"z-index:10000 !important; width:345px !important;list-style-type: none !important; padding-left:5px; !important\" class=\"dijitReset dijitMenu lotusui30dojo\" role=\"presentation\">\r\n \r\n </ul>"}}); -/* - * © 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. - */ - -define(["../../../declare", - "../../../lang", - "../../../text!./templates/SearchBoxTemplate.html", - "../../../text!./templates/SearchSuggestTemplate.html", - "../../../text!./templates/PopUpTemplate.html", - "../../../text!./templates/SuggestPopUpTemplate.html", - "../../../i18n!./nls/SearchBoxRenderer", - "../../../text!./templates/MemberListItemTemplate.html", - "../../../text!./templates/MemberListTemplate.html", - "../../../text!./templates/SingleApplicationSearch.html", - "../../../text!./templates/SingleSearchPopUp.html"], - function(declare,lang, template, SuggestTemplate, PopUpTemplate, SuggestionPopUp ,nls, - MemberListItemTemplate, MemberListTemplate, SingleApplicationSearch, SingleSearchPopUp){ - /** - * @class SearchBoxRenderer - * @namespace sbt.connections.controls.search - * @module sbt.connections.controls.search.SearchBoxRenderer - */ - var SearchBoxRenderer = declare(null,{ - - nls: null, - - _appsPopUp: null, - - _appsMemberListItem: null, - - _appsMemberList: null, - - _suggestionPopUp: null, - - _suggestionContainer: null, - - /** - * SearchBoxRenderer class constructor function - * @method constructor - * @param args - */ - constructor: function(args){ - this.nls = nls; - }, - - /** - * Converts the HTML pop up template into a DOM node. - * Creates a Div element and uses the template as the div's inner HTML - * @method getDomeNode - * @returns The Search Box Dom Node - */ - getDomNode: function(SearchBox){ - - var htmlTemplate = ""; - - if(SearchBox.predefinedSearch){ - var domStr = this._substituteItems(SingleApplicationSearch, this); - SingleApplicationSearch = domStr; - htmlTemplate = SingleApplicationSearch; - }else{ - var domStr = this._substituteItems(template, this); - template = domStr; - htmlTemplate = template; - } - - var div = this._convertToDomNode(htmlTemplate); - - this._suggestionContainer = document.createElement("span"); - div.appendChild(this._suggestionContainer); - - var temp = div.getElementsByTagName("input"); - var input = temp[0]; - SearchBox._searchInput = input; - - return div; - }, - - /** - * Converts the HTML pop up template into a DOM node. - * Creates a div and sets it's inner html to be the pop up template - * @method getPopUpNode - * @returns the applications list pop up DOM Node - */ - getPopUpNode: function(){ - - var domstr = this._substituteItems(PopUpTemplate, this); - PopUpTemplate = domstr; - - var div = this._convertToDomNode(PopUpTemplate); - return div; - }, - - /** - * Converts the HTML member list item template into a DOM node. - * Creates a div and sets it's inner html to be the member list item template - * @method getMemberListItemNode - * @param memberName The name to display - * @returns the applications list pop up DOM Node - */ - getMemberListItemNode: function(memberName){ - var domstr = this._substituteItems(MemberListItemTemplate, this); - domstr = this._substituteMemberName(domstr, memberName); - - var obj = this._convertToDomNode(domstr); - - return obj; - }, - - /** - * Converts the HTML member list template into a DOM node. - * Creates a div and sets it's inner html to be the member list template - * @method getMemberListItemNode - * @returns the applications list pop up DOM Node - */ - getMemberListNode: function(){ - - var domstr = this._substituteItems(MemberListTemplate, this); - MemberListTemplate = domstr; - - var div = this._convertToDomNode(MemberListTemplate); - return div; - }, - - /** - * Attaches events to the template - * @method render - * @param searchBox - * @param el - * @param data - */ - render: function(searchBox, el, data) { - searchBox.templateString = template; - this._doAttachEvents(searchBox,el,data); - }, - - /** - * renders the applications lists pop up - * @method renderPopUp - * @param searchBox The SearchBox class - * @param el The searchBox Element - */ - renderPopUp: function(searchBox,el){ - - if(!this._appsPopUp){ - this._appsPopUp = this.getPopUpNode(); - this._doAttachEvents(searchBox,this._appsPopUp,{}); - } - - el.appendChild(this._appsPopUp); - this._appsPopUp.focus(); - return this._appsPopUp; - }, - - /** - * renders a member list item - * @method renderMemberListItem - * @param searchBox the SearchBox class - * @param memberName The member name to display - * @param memberId The member's profile id - this acts as a unique identifier (needed when, for example, - * creating a new community) - */ - renderMemberListItem: function(searchBox, memberName, memberId){ - // Get node - this._appsMemberListItem = this.getMemberListItemNode(memberName); - - // Create member object for storage - var newMember = new Object(); - newMember.html = this._appsMemberListItem.innerHTML; - newMember.id = memberId; - newMember.name = memberName; - // Make sure that the member hasn't already been selected - for (var i = 0; i < searchBox.members.length; i++) { - var member = searchBox.members[i]; - if (member.html == newMember.html) { - return; - } - } - - // Add it to the list - this._appsMemberList.appendChild(this._appsMemberListItem); - - // Attach event listeners - this._doAttachEvents(searchBox,this._appsMemberListItem,{}); - - // Keep track of the added member - searchBox.members.push(newMember); - - return this._appsMemberListItem; - }, - - /** - * renders the member list - * @method renderMemberList - * @param el HTML Element / DOM Node - */ - renderMemberList: function(el){ - - if(!this._appsMemberList){ - // Generate the DOM object representing the member list - this._appsMemberList = this.getMemberListNode(); - } - - // Append the list to the parent - el.appendChild(this._appsMemberList); - - // Request focus - this._appsMemberList.focus(); - - return this._appsMemberList; - }, - - - /** - * Renders the suggestions that appear under the search box. - * @method renderSuggestionPopUp - * @param searchBox The searchBox class - * @param el The SearchBox DOM node / HTML element - * @returns The search suggestion pop up as a DOM Node - */ - renderSuggestionPopUp: function(searchBox,el){ - - if(!this._suggestionPopUp){ - if(searchBox.predefinedSearch){ - this._suggestionPopUp= this._convertToDomNode(SingleSearchPopUp); - }else{ - this._suggestionPopUp= this._convertToDomNode(SuggestionPopUp); - } - - } - this._suggestionContainer.appendChild(this._suggestionPopUp); - return this._suggestionContainer.firstChild; - }, - - /** - * Removes the applications pop up - * @method removePopUp - * @param searchBoxElement The searchBox HTML Element - * @param popUp The DOM node that represents the popup that displays the list of applications on connections - */ - removePopUp: function(searchBoxElement,popUp){ - searchBoxElement.removeChild(popUp); - }, - - /** - * remove the list of suggestions that appeas when searching - * @method removeSuggestionPopUp - * @param searchBoxElement The DOM Node that represents the search box - * @param popUpElement the DOM node pop up - */ - removeSuggestionPopUp: function(searchBoxElement,popUpElement){ - this._suggestionContainer.removeChild(popUpElement); - }, - - /** - * Changes the Text displayed in the "currently selected" application text field - * @method changeSelectedApplication - * @param selectedApplication The name of the application to display - * @param el The table row element - */ - changeSelectedApplication: function(selectedApplication, trImgIcon){ - var element = document.getElementById("searchAppType"); - if(element.textContent == nls.selectedApplication){ + + if(endpoint){ + lang.mixin(this.contextRootMap, endpoint.serviceMappings); - //change the text showing the selected application - element.textContent = selectedApplication; - nls.selectedApplication = selectedApplication; + if(this.contextRootMap){ + url = stringUtil.transform(url, this.contextRootMap, function(value, key){ + if(!value){ + return key; + } + else{ + return value; + } + }, this); + } + } + + if (urlParams) { + url = stringUtil.replace(url, urlParams); + if (url.indexOf("//") != -1) { + // handle empty values + url = url.replace(this._regExp, "/"); + } } - }, - - /* - * Converts a HTML String to a DOM Node, - * @method _convertToDomNode - * @param template the html string to be converted to a DOM node - * @returns A DOM Node - */ - _convertToDomNode: function(template){ - var div = null; - if(typeof template =="string"){ - var wrapper= document.createElement('div'); - wrapper.innerHTML= template; - wrapper.tabIndex = 0; - div= wrapper; - } - return div.firstChild; - }, - - /* - * Override _substitureItems as there are only NLS strings to be substituted - * no XPath values, functions etc. - * @param template - * @param renderer - * @returns - */ - _substituteItems: function(template,renderer){ - var text = template; - if(text.indexOf("${nls.") != -1){ - var nls = renderer.nls; - - var startIndex = text.indexOf("${nls."); - var endIndex = text.indexOf("}",startIndex); - - var nlsIndex = text.substring(startIndex+6,endIndex); - var stringToReplace = text.substring(startIndex,endIndex+1); - - var replacingString = nls[nlsIndex]; - - text = text.replace(stringToReplace,replacingString); - - //if there are more strings to substitute keep substituting - if(text.indexOf("${nls.") != -1){ - return this._substituteItems(text,renderer); - } - } - //if no more strings to substitute return the final string - return text; - }, - - /* - * Override _substituteMemberName as there are only NLS strings to be substituted - * no XPath values, functions etc. This function substitutes the member name in the template - * with the actual member item name. - * @method _substituteMemberName - * @param template - * @param renderer - * @returns - */ - _substituteMemberName: function(template,memberName){ - return template.replace("${memberName}", memberName); - }, - - /* - * connects events to event handlers - */ - _doAttachEvents: function(searchBox, el, data) { - var nodes = (el.all || el.getElementsByTagName("*")); - for (var i in nodes) { - var attachEvent = (nodes[i].getAttribute) ? nodes[i].getAttribute("data-dojo-attach-event") : null; - if (attachEvent) { - nodes[i].removeAttribute("data-dojo-attach-event"); - var event, events = attachEvent.split(/\s*,\s*/); - while((event = events.shift())) { - if (event) { - var func = null; - if (event.indexOf(":") != -1) { - var eventFunc = event.split(":"); - event = lang.trim(eventFunc[0]); - func = lang.trim(eventFunc[1]); - } else { - event = lang.trim(event); - } - if (!func) { - func = event; - } - var callback = searchBox._hitch(searchBox, searchBox[func], nodes[i], data); - searchBox._connect(nodes[i], event, callback); + if (params) { + for (param in params) { + if (params[param]) { + if (url.indexOf("?") == -1) { + url += "?"; + } else if (url.indexOf("&") != (url.length - 1)) { + url += "&"; } + url += param + "=" + encodeURIComponent(params[param]); } } } - } - }); - - return SearchBoxRenderer; + return url; + }, + + // Internals + + /* + * Sort the contents + */ + _sort: function(index, defaultOrder, el, data, ev) { + this._stopEvent(ev); + var options = { + start: data.start, count: this.pageSize, + sort: [{ attribute: index }] + }; + + if(this.filterTag != "" && this.filterTag != null){ + options.tag = this.filterTag; + } + + if(this._activeSortAnchor === this._sortInfo[index]) { + this._activeSortIsDesc = !this._activeSortIsDesc; // Flip sort order + } + else { // Change active sort to anchor clicked and its default order + this._activeSortAnchor = this._sortInfo[index]; + this._activeSortIsDesc = defaultOrder; + } + options.sort[0].descending = this._activeSortIsDesc; + + this._doQuery(this.store, options); + + }, + + /* + * Filter the contents + */ + _filter: function(args, data){ + var options = { + start: 0, count: this.pageSize, + sort: [{ attribute: this._activeSortAnchor.sortParameter }] + }; + options.sort[0].descending = this._activeSortIsDesc; + + var query = {}; + if(args.tag){ + query.tag = args.tag; + this.filterTag = args.tag; + } + + this._doQuery(this.store, options,query); + }, + + /* + * Display the specified error message + */ + _updateWithError: function(e) { + console.error(e.message); + this.renderer.renderError(this, this.domNode, e.message); + } + }); + + return Grid; }); + }, -'sbt/controls/grid/GridRenderer':function(){ +'sbt/nls/loginForm':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK - Default resource bundle for validate module. + */ + + +define({ + root: ({ + username:"User name :", + password:"Password :", + authentication_dialog_title: "Authentication", + login_ok: "Log in", + login_cancel: "Cancel", + wrong_creds_message:"Wrong Credentials" + }) + +}); +}, +'sbt/connections/controls/vcard/ProfileVCard':function(){ +require({cache:{ +'url:sbt/connections/controls/vcard/templates/ProfileVCard.html':"<span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n <a href=\"javascript:void(0);\" class=\"fn url\">${userName}</a>\r\n <span dojoAttachPoint=\"idNode\" class=\"\" style=\"display: none;\">${userId}</span>\r\n</span>"}}); /* * © Copyright IBM Corp. 2013 * @@ -17197,835 +11978,891 @@ define(["../../../declare", /** * */ -define([ "../../declare", "../../dom", "../../lang"], - function(declare, dom, lang) { +define(["../../../declare", + "../../../dom", + "../../../widget/_TemplatedWidget", + "../../../lang", + "../../../connections/controls/vcard/SemanticTagService", + "../../../text!./templates/ProfileVCard.html"], + function(declare, dom, _TemplatedWidget, lang, SemanticTagService, template) { /** - * @module sbt.controls.grid.GridRenderer - * @class GridRenderer - * @namespace sbt.controls.grid + * @class sbt.controls.vcard.connections.ProfileVCard */ - var GridRenderer = declare(null, { + var profileVCard = declare([ _TemplatedWidget ], { + /** - * Strings used in the grid + * The html template of the vcard. + * + * @property configUtil + * @type String */ - nls: null, - - /** - * CSS class to be used for tables - see ConnectionsGridRenderer - */ - tableClass: null, - emptyClass: null, - errorClass: null, - loadingClass: null, - loadingImgClass: null, - grid: null, + templateString: template, + /** + * Whether or not to encode HTML. + * + * @property encodeHtml + * @type Boolean + * @default true + */ + encodeHtml: true, + /** + * The href of the vcard link. By default clicking the link does nothing. + * + * @property href + * @type String + * @default "javascript:void(0);" + */ + href: "javascript:void(0);", /** - * Constructor function - * @method - constructor + * The person's name to be displayed with this vcard. + * + * @property userName + * @type String + * @default "" */ - constructor: function(args,grid) { - - this.grid = grid; - lang.mixin(this, args); - - }, + userName: "", /** - * Function to render the Paging , sorting and the table - * @method - render - * @param grid - the grid - * @param el - the grid DOM node - * @param items - the items in the grid row, for example icon, displayName,email etc. - * @param data - the data associated with the grid row + * The connections profile id. This is the sole determinant of which vcard will be displayed. + * + * @property userId + * @type String + * @default "" */ - render: function(grid, el, items, data) { - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - if(!grid.theme || grid.theme == "oneui"){ - dom.addClass(el,"lotusui30"); - dom.addClass(el,"lotusui30_body"); - } - var size = items.length; - if (size === 0) { - this.renderEmpty(grid, el); - } - else { - this.renderPager(grid, el, items, data); - this.renderSorter(grid, el, data); - var container = null; - if (!this.containerType || this.containerType == "table") { - container = this.renderTable(grid, el, items, data); - } else { - container = this.renderList(grid, el, this.containerType, ""); - } - for (var i=0; i<items.length; i++) { - this.renderItem(grid, container, data, items[i], i, items); - } - this.renderFooter(grid, el, items, data); - } - }, + userId: "", /** - * Checks if a pagerTemplate exists ,if so, the HTML template is converted to - * a DOM node, and attached to the body. - * @method - renderPager - * @param grid - the grid - * @param el - the current element - * @param items - the items in the current element - * @param data - the data associated with the current element + * A url flag specifying whether or not connections should include the css when loading the Semantic Tag Service. + * @property inclCss + * @type Boolean + * @default false */ - renderPager : function(grid,el,items,data) { - if(!grid.hidePager){ - var node; - if(grid.theme == "bootstrap"){ - if (lang.isString(this.bootstrapPagerTemplate)) { - var domStr = this._substituteItems(this.bootstrapPagerTemplate, grid, this, items, data); - node = dom.toDom(domStr, el.ownerDocument); - } else { - node = this.bootstrapPagerTemplate.cloneNode(true); - } - el.appendChild(node); - }else {//use oneui by default - if (lang.isString(this.pagerTemplate)) { - var domStr = this._substituteItems(this.pagerTemplate, grid, this, items, data); - node = dom.toDom(domStr, el.ownerDocument); - } else { - node = this.pagerTemplate.cloneNode(true); - } - el.appendChild(node); - - } - - grid._doAttachEvents(el, data); - grid._doAttachPoints(el,grid); - } - - }, + inclCss: false, /** - * Checks if a footerTemplate exists ,if so, the HTML template is converted to - * a DOM node, and attached to the body. - * @method - renderFooter - * @param grid - the grid - * @param el - the current element - * @param items - the items in the current element - * @param data - the data associated with the current element + * A url flag specifying whether or not connections should include dojo when loading the Semantic Tag Service. + * + * Careful. + * + * @property inclDojo + * @type Boolean + * @default false */ - renderFooter : function(grid,el,items,data) { - if(!grid.hideFooter){ - var node; - if(grid.theme == "bootstrap"){ - if (lang.isString(this.bootstrapFooterTemplate)) { - var domStr = this._substituteItems(this.bootstrapFooterTemplate, grid, this, items, data); - node = dom.toDom(domStr, el.ownerDocument); - } else { - node = this.bootstrapFooterTemplate.cloneNode(true); - } - el.appendChild(node); - }else { - if (lang.isString(this.footerTemplate)) { - var domStr = this._substituteItems(this.footerTemplate, grid, this, items, data); - node = dom.toDom(domStr, el.ownerDocument); - } else { - node = this.footerTemplate.cloneNode(true); - } - el.appendChild(node); - } - - grid._doAttachEvents(el, data); - grid._doAttachPoints(el,grid); - - } - - }, + inclDojo: false, /** - * Converts an HTML sortTemplate to a DOM node and attaches it - * @method - renderSorter - * @param grid - the Grid - * @param el - the current element - * @param data - the data associated with the current element + * The class of the html error element. + * + * @property errorClass + * @type String + * @default "" */ - renderSorter : function(grid,el,data) { - if(!grid.hideSorter){ - var sortInfo = grid.getSortInfo(); - if (grid.theme == "bootstrap"){ - if (sortInfo) { - var node; - if (lang.isString(this.bootstrapSortTemplate)) { - var domStr = this._substituteItems(this.bootstrapSortTemplate, grid, this, sortInfo); - node = dom.toDom(domStr, el.ownerDocument); - } else { - node = this.bootstrapSortTemplate.cloneNode(true); - } - el.appendChild(node); - } - }else{ - if (sortInfo) { - var node; - if (lang.isString(this.sortTemplate)) { - var domStr = this._substituteItems(this.sortTemplate, grid, this, sortInfo); - node = dom.toDom(domStr, el.ownerDocument); - } else { - node = this.sortTemplate.cloneNode(true); - } - el.appendChild(node); - } - } - - grid._doAttachEvents(el, data); - grid._doAttachPoints(el,grid); - } - - }, + errorClass: "", - /*** - * Creates a table and table body, Attaches the table body to the - * table, and returns the table body - * @method - renderTable - * @param grid - the grid - * @param el - the current element - * @param items - all of the items in the current row - * @param data - the data associated with the current row - * @returns - A table body element, that is attached to a table + /** + * @property endpointName + * @type String + * @default "" */ - renderTable: function(grid, el, items, data) { - var table = dom.create("table", { - "class": this.tableClass, - border:"0", - cellspacing:"0", - cellpadding:"0", - role:"presentation" - }, el); - var tbody = dom.create("tbody", null, table); - return tbody; - }, + endpointName: "connections", - /*** - * Creates a list. + /** * - * @method - renderList - * @param grid - the grid - * @param el - the current element - * @param listType - the type of list to render: ul or ol - * @param listClass - the class for the list - * @param data - the data associated with the current row - * @returns - A list element (either ul or ol) + * @param args */ - renderList: function(grid, el, listType, listClass) { - var ol = dom.create(listType, { - role:"presentation", - "class":listClass - }, el); - return ol; + constructor: function(args) { + lang.mixin(args); }, /** - * Creates a DIV and attaches it to the current element - * Then creates the loading image and attaches it to the DIV - * @method - renderLoading - * @param grid - The grid - * @param el - The Current Element + * @method postCreate */ - renderLoading: function(grid, el) { - var div = dom.create("div", { - "class": this.loadingClass - }, el, "only"); - dom.setText(div,this.nls.loading); - - var img = dom.create("img", { - "class": this.loadingImgClass, - src: grid._blankGif, - role: "presentation" - }, div, "first"); + postCreate: function() { + dom.setAttr(this.idNode, "class", (this.userId.indexOf("@") >= 0) ? "email" : "x-lconn-userid"); + + this.inherited(arguments); + SemanticTagService.loadSemanticTagService({ + endpoint: this.endpointName, + inclDojo: this.inclDojo, + inclCss: this.inclCss + }); }, /** - * Creates a Div, with a different CSS class, to display a grid that has no results - * @method - renderEmpty - * @param - grid - The Grid - * @param - el - The Current Element + * @method renderError + * @param el + * @param error */ - renderEmpty: function(grid, el) { - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - var ediv = dom.create("div", { - "class": this.emptyClass, - role: "document", - tabIndex: 0 - }, el, "only"); - dom.setText(ediv,this.nls.empty); - }, + renderError: function(el, error) { + var ediv = domConstruct.create("div", { + "class": this.errorClass, + role: "alert", + tabIndex: 0 + }, el, "only"); + dom.setText(ediv, error.message); + } - /**Creates a div to display a grid that has returned an error - * @method - renderError - * @param - grid - The Grid - * @param - el - The Current Element - * @param - error - The error message to be displayed*/ - renderError: function(grid, el, error) { - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - var ediv = dom.create("div", { - "class": this.errorClass, - role: "alert", - tabIndex: 0 - }, el, "only"); - - dom.setText(ediv, error); - }, + }); + + return profileVCard; +}); +}, +'sbt/connections/controls/files/FileGrid':function(){ +/* + * © 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. + */ + +/** + * + */ +define( + [ "../../../declare", "../../../lang", "../../../dom", + "../../../stringUtil", "../../../config", + "../../../store/parameter", "../../../controls/grid/Grid", + "./FileGridRenderer", "./FileAction", + "../../../connections/controls/vcard/SemanticTagService", + "../../../connections/FileService", + "../../../connections/FileConstants" ], +function(declare, lang, dom, stringUtil, sbt, parameter, Grid, + FileGridRenderer, FileAction, SemanticTagService, FileService, + FileConstants) { + + var sortVals = { + name : "title", + updated : "modified", + downloads : "downloaded", + comments : "commented", + likes : "recommended", + files : "itemCount", + created : "created", + modified : "modified" + }; + + var ParamSchema = { + pageNumber : parameter.oneBasedInteger("page"), + pageSize : parameter.oneBasedInteger("ps"), + sortBy : parameter.sortField("sortBy", sortVals), + sortOrder : parameter.sortOrder("sortOrder") + }; + + /** + * @class FileGrid + * @namespace sbt.connections.controls.files + * @module sbt.connections.controls.files.FileGrid + */ + var FileGrid = declare( + Grid, + { + + gridSortType : "", + fileService : null, + + /** + * Options determine which type of file grid will be + * created + */ + options : { + "myFiles" : { + storeArgs : { + url : FileConstants.AtomFilesMy, + attributes : FileConstants.FileXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "file" + } + }, + "publicFiles" : { + storeArgs : { + url : FileConstants.AtomFilesPublic, + attributes : FileConstants.FileXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "file" + } + }, + "myPinnedFiles" : { + storeArgs : { + url : FileConstants.AtomFilesMyPinned, + attributes : FileConstants.FileXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "file" + } + }, + "myFolders" : { + storeArgs : { + url : FileConstants.AtomFoldersMy, + attributes : FileConstants.FolderXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "folder" + } + }, + "publicFolders" : { + storeArgs : { + url : FileConstants.AtomFoldersPublic, + attributes : FileConstants.FolderXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "folder" + } + }, + "myPinnedFolders" : { + storeArgs : { + url : FileConstants.AtomGetPinnedFolders, + attributes : FileConstants.FolderXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "folder" + } + }, + "activeFolders" : { + storeArgs : { + url : FileConstants.AtomFoldersActive, + attributes : FileConstants.FolderXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "folder" + } + }, + "recycledFiles" : { + storeArgs : { + url : FileConstants.AtomFilesRecycled, + attributes : FileConstants.FileXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "recycledFile" + } + }, + "myFileComments" : { + storeArgs : { + url : FileConstants.AtomFileCommentsMy, + attributes : FileConstants.CommentXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "comment" + } + }, + "fileShares" : { + storeArgs : { + url : FileConstants.AtomFilesShared, + attributes : FileConstants.FileXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "file" + } + }, + "communityFiles" : { + storeArgs : { + url : FileConstants.AtomGetAllCommunityFiles, + attributes : FileConstants.FileXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "file" + } + }, + "filesSharedByMe" : { + storeArgs : { + url : FileConstants.AtomFilesShared, + attributes : FileConstants.FileXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "file" + } + }, + "filesSharedWithMe" : { + storeArgs : { + url : FileConstants.AtomFilesShared, + attributes : FileConstants.FileXPath, + paramSchema : ParamSchema + }, + rendererArgs : { + type : "file" + } + } - /** - * Returns the paging results, - How many pages of results there are - * @method - pagingResults - * @return - A String for paging - for example "0 - 5 Of 5" - */ - pagingResults : function(grid,renderer,items,data) { - return grid._substitute(renderer.nls.pagingResults, data); - }, - - /**If the user is on the first page of results, they cannot click - * to go back a page, this function hides the back link - * @method - hidePreviousLink - * @return - A String used as a CSS style - */ - hidePreviousLink : function(grid,renderer,items,data) { - return (data.start > 1) ? "" : "display: none;"; - }, - - /**Hides the back page label - * @method - hidePreviousLabel - * @return - A String used as a CSS style - */ - hidePreviousLabel : function(grid,renderer,items,data) { - return (data.start == 0) ? "" : "display: none;"; - }, - - /**If there is only one page of results the user cannot move forward - * to the next page, this function hides the next link - * @method - hideNextLink - * @return - A String used as CSS style - */ - hideNextLink : function(grid,renderer,items,data) { - return (data.start + data.count < data.totalCount) ? "" : "display: none;"; - }, - - /** - * If there is only one page of results the user cannot move forward - * to the next page, this function hides the next label - * @method - hideNextLabel - * @return - A String used as CSS style - */ - hideNextLabel : function(grid,renderer,items,data) { - return (data.start + data.count >= data.totalCount) ? "" : "display: none;"; - }, - - /** - * A sort anchor is what the grid is sorted against. - * For example sort by name, date etc. This function returns a string of HTML links - * @method - sortAnchors - * @param grid - the grid - * @param renderer - the associated renderer - * @param items - items contains a list of sort anchors, which will be substituted into the html - * @returns {String} - a HTML string consisting of the various sort anchors - */ - sortAnchors : function(grid,renderer,items) { - if (items.list == undefined || items.list.length == 0) { - return ""; - } else { - var sortStr = ""; - for ( var i = 0; i < items.list.length; i++) { - if(grid.theme == "bootstrap"){ - sortStr += this._substituteItem(this.bootstrapSortAnchor, grid, items.list[i], i, items); - }else{ - sortStr += this._substituteItem(this.sortAnchor, grid, items.list[i], i, items); - } - - } - return sortStr; - } - }, + }, - /** - * @method sortItemClass - * @param grid - * @param item - * @param i - * @param items - * @returns - */ - sortItemClass : function(grid,item,i,items) { - return (i === 0 ? this.firstClass : ""); - }, - - /** - * Sets the CSS class for the sort anchor which is currently being used - * Also sets CSS classes for whether the results are ascending or descending - * @method - sortAnchorClass - * @param grid - The Grid - * @param item - the current sort anchor - for example "name" - * @param i - the number of the grid row - * @param items - all of the sort anchors - * @returns - A CSS class - */ - sortAnchorClass : function(grid,item,i,items) { - if(item !== items.active.anchor) { - return ""; - } - - if(items.active.isDesc) { - return this.descendingSortClass; - } - else { - return this.ascendingSortClass; - } - }, - - /** - * Converts the HTML template into a dom node and attaches it. - * @method - rendeItem - * @param grid - the grid - * @param el - the current element - * @param data - the data for the current row, ie name, last updated etc - * @param item - the current item and its associated data - * @param i - the number of the grid row - * @param items - All of the elements & data for each row - */ - renderItem : function(grid,el,data,item,i,items) { - if (this.template) { - var node; - if (lang.isString(this.template)) { - var domStr = this._substituteItem(this.template, grid, item, i, items); - node = dom.toDom(domStr, el.ownerDocument); - } else { - node = this.template.cloneNode(true); - } - el.appendChild(node); - - grid._doAttachEvents(el, item); - grid._doAttachPoints(el,grid); - } - }, + contextRootMap : { + files : "files" + }, - // Internals + /** + * The default grid, if no options are selected + */ + defaultOption : "publicFiles", - /* - * Does substitution of ${foo} type properties in template string - */ - _substituteItem : function(template,grid,item,i,items) { - var self = this; - return grid._substitute(template, item, function(value,key) { - if (typeof value == "undefined") { - // check the renderer for the property - value = lang.getObject(key, false, self); - } + /** + * FileAction defines the default actions for files, + * which can be overridden + */ + fileAction : null, - if (typeof value == 'function') { - // invoke function to return the value - try { - value = value.apply(self, [grid, item, i, items]); - } catch (ex) { - value = "ERROR:" + key + " " + ex; - } - } - - if (typeof value == "undefined" && typeof item.getValue == 'function') { - // invoke function to return the value - try { - value = item.getValue(key); - } catch (ex) { - value = "ERROR:" + key + " " + ex; - } - } + /** + * Constructor function + * + * @method constructor + */ + constructor : function(args) { + + this.fileAction = new FileAction(this), + + this.fileService = new FileService(args); + + /** + * gridSortType is used to determine what sorting + * anchors should be used, for example folders have + * different sort anchors than files, file comments + * have no anchors etc + */ + if (args.type == "fileShares" + || args.type == "library" + || args.type == "pinnedFiles") { + gridSortType = "file"; + } else if (args.type == "fileComments" + || args.type == "recycledFiles") { + gridSortType = ""; + } else if (args.type == "publicFiles") { + gridSortType = "publicFiles"; + } else { + gridSortType = "folder"; + } - if (typeof value == "undefined" || value == null) { - return ""; - } + var nls = this.renderer.nls; + this._sortInfo = { + name : { + title : nls.name, + sortMethod : "sortByName", + sortParameter : "name" + }, + updated : { + title : nls.updated, + sortMethod : "sortByLastUpdated", + sortParameter : "updated" + }, + downloads : { + title : nls.downloads, + sortMethod : "sortByDownloads", + sortParameter : "downloads" + }, + comments : { + title : nls.comments, + sortMethod : "sortByComments", + sortParameter : "comments" + }, + likes : { + title : nls.likes, + sortMethod : "sortByLikes", + sortParameter : "likes" + }, + created : { + title : nls.created, + sortMethod : "sortByCreatedDate", + sortParameter : "created" + }, + files : { + title : nls.files, + sortMethod : "sortByNumberOfFiles", + sortParameter : "files" + } + }; - return value; - }, this); - }, + if (args.type == "publicFiles") { + this._activeSortAnchor = this._sortInfo.created; + this._activeSortIsDesc = false; + } else if (args.type == "folders") { + this._activeSortAnchor = this._sortInfo.name; + this._activeSortIsDesc = true; + } else { + this._activeSortAnchor = this._sortInfo.updated; + this._activeSortIsDesc = true; + } + + if (args && args.pinFile) { + this.renderer.pinFiles = args.pinFile; + } + + }, + + /** + * Override buildUrl to add direction, userId and fileId + * + * @method buildUrl + * @param url + * base url + * @param args + * arguments that will be passed to the store + * @param endpoint + * An endpoint which may contain custom + * service mappings. + * @returns Built url + */ + buildUrl : function(url, args, endpoint) { + var params = { + format : this.format + }; + + if (this.query) { + params = lang.mixin(params, this.query); + } + if (this.direction) { + params = lang.mixin(params, { + direction : this.direction + }); + } + if(this.type == "filesSharedWithMe"){ + params = lang.mixin(params, { + direction : "inbound" + }); + }else if (this.type == "filesSharedByMe"){ + params = lang.mixin(params, { + direction : "outbound" + }); + } + + return this.constructUrl(url, params, this + .getUrlParams(), endpoint); + }, + + /** + * Return the url parameters to be used + * + * @returns {Object} + */ + getUrlParams : function() { + var params = { + authType : this.getAuthType() + }; + + if (this.userId) { + params = lang.mixin(params, { + userId : this.userId + }); + } + if (this.documentId) { + params = lang.mixin(params, { + documentId : this.documentId + }); + } + + if(this.communityId){ + params = lang.mixin(params, { + communityId : this.communityId + }); + } + + return params; + }, + + /** + * Instantiates a FileGridRenderer + * + * @method createDefaultRenderer + * @param args + * @returns {FileGridRenderer} + */ + createDefaultRenderer : function(args) { + return new FileGridRenderer(args,this); + }, + + /** + * Called after the grid is created The + * semanticTagService is loaded, which is responsible + * for displaying business card functionality. + * + * @method postCreate + */ + postCreate : function() { + this.inherited(arguments); + if(this.displayBusinessCard){ + SemanticTagService.loadSemanticTagService(); + } + }, + + /** + * Event handler for onClick events + * + * @method handleClick + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + handleClick : function(el, data, ev) { + if (this.fileAction) { + this._stopEvent(ev); + + this.fileAction.execute(data, { + grid : this.grid + }, ev); + } + }, + + /** + * @method getSortInfo + * @returns A List of Strings,that describe how the grid + * can be sorted + */ + getSortInfo : function() { + if (gridSortType == "file") { + + return { + active : { + anchor : this._activeSortAnchor, + isDesc : this._activeSortIsDesc + }, + list : [ this._sortInfo.name, + this._sortInfo.updated, + this._sortInfo.downloads, + this._sortInfo.comments, + this._sortInfo.likes ] + }; + } else if (gridSortType == "folder") { + return { + active : { + anchor : this._activeSortAnchor, + isDesc : this._activeSortIsDesc + }, + list : [ this._sortInfo.name, + this._sortInfo.updated, + this._sortInfo.created, + this._sortInfo.files ] + }; + } else if (gridSortType == "publicFiles") { + return { + active : { + anchor : this._activeSortAnchor, + isDesc : this._activeSortIsDesc + }, + list : [ this._sortInfo.created, + this._sortInfo.downloads, + this._sortInfo.comments, + this._sortInfo.likes ] + }; + } + }, + + /** + * Sort the grid rows by name + * + * @method sortByName + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + sortByName : function(el, data, ev) { + this._sort("name", true, el, data, ev); + }, + + /** + * Sort the grid rows by last modified date + * + * @method sortByLastUpdated + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + sortByLastUpdated : function(el, data, ev) { + this._sort("updated", true, el, data, ev); + }, - _substituteItems : function(template,grid,renderer,items,data) { - var self = this; - return grid._substitute(template, renderer, function(value,key) { - if (typeof value == "undefined") { - // check the renderer for the property - value = lang.getObject(key, false, self); - } + /** + * Sort the grid rows by the amount of times a file has + * been downloaded. + * + * @method sortByDownloads + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + sortByDownloads : function(el, data, ev) { + this._sort("downloads", true, el, data, ev); + }, - if (typeof value == 'function') { - // invoke function to return the value - try { - value = value.apply(self, [grid, renderer, items, data]); - } catch (ex) { - value = "ERROR:" + key + " " + ex; - } - } + /** + * Sort the grid rows by the amount of comments a file + * has. + * + * @method sortByComments + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + sortByComments : function(el, data, ev) { + this._sort("comments", true, el, data, ev); + }, - if (typeof value == "undefined" || value == null) { - return ""; - } + /** + * Sort the grid rows by the number of "likes" that a + * file has. + * + * @method sortByLikes + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + sortByLikes : function(el, data, ev) { + this._sort("likes", true, el, data, ev); + }, - return value; - }, this); - }, - - getProfileUrl: function(grid,id){ - var endpoint = grid.store.getEndpoint(); - var profileURL = "/${profiles}/html/profileView.do?userid="+id; - profileURL = grid.constructUrl(profileURL,{},{},endpoint); - profileURL = endpoint.baseUrl+profileURL; - return profileURL; - } - - }); - - return GridRenderer; -}); -}, -'sbt/connections/BlogPost':function(){ -/* - * © Copyright IBM Corp. 2012, 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. - */ + /** + * Sort the grid rows by when the files were first + * created + * + * @method sortByCreatedDate + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + sortByCreatedDate : function(el, data, ev) { + this._sort("created", true, el, data, ev); + }, -/** - * - * @module sbt.connections.BlogPost - * @author Rajmeet Bal - */ -define(["../declare", "../lang", "../base/AtomEntity", "./BlogConstants", "../base/XmlDataHandler" ], - function(declare, lang, AtomEntity, consts, XmlDataHandler) { + /** + * Sorts the grid, based on the number of files + * contained in each folder. This is for grids that + * display folders. + * + * @method sortByNumberOfFiles + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + sortByNumberOfFiles : function(el, data, ev) { + this._sort("files", true, el, data, ev); + }, - /** - * BlogPost class represents a post for a Blogs feed returned by the - * Connections REST API. - * - * @class BlogPost - * @namespace sbt.connections - */ - var BlogPost = declare(AtomEntity, { + /** + * Event handler to show and hide the more options in + * the files grid + * + * @method showMore + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + showMore : function(el, data, ev) { + /** TODO to be implemented in iteration 9 */ + }, - xpath : consts.BlogPostXPath, - namespaces : consts.BlogPostNamespaces, - - /** - * Construct a Blog Post. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, + /** + * @method onUpdate This is called after the grid is + * updated In this implementation, a list of + * pinned files is received from the server then + * all of the pin file links, are retrieved by + * class name, then if the file is a pinned + * file, its css class will be changed to + * reflect this NOTE: this function will only + * execute, if file pin functionality is passed + * as an argument to the grid + */ + onUpdate : function() { - /** - * Return the value of IBM Connections blog post ID - * entry document. - * - * @deprecated Use getPostUuid instead. - * @method getBlogPostUuid - * @return {String} ID of the blog post - */ - getBlogPostUuid : function() { - var postUuidPrefix = "urn:lsid:ibm.com:blogs:entry-"; - var postUuid = this.getAsString("postUuid"); - if(postUuid && postUuid.indexOf(postUuidPrefix) != -1){ - postUuid = postUuid.substring(postUuidPrefix.length, postUuid.length); - } - return postUuid; - }, + if (this.renderer.pinFiles) { - /** - * Sets id of IBM Connections blog post Id. - * - * @deprecated Use setPostUuid instead - * @method setBlogPostUuid - * @param {String} BlogPostUuid of the blog post - */ - setBlogPostUuid : function(postUuid) { - return this.setAsString("postUuid", postUuid); - }, - - /** - * Return the value of IBM Connections blog post ID. - * - * @method getPostUuid - * @return {String} Unique id of the blog post - */ - getPostUuid : function() { - var postUuidPrefix = "urn:lsid:ibm.com:blogs:entry-"; - var postUuid = this.getAsString("postUuid"); - if(postUuid && postUuid.indexOf(postUuidPrefix) != -1){ - postUuid = postUuid.substring(postUuidPrefix.length, postUuid.length); - } - return postUuid; - }, + // Get all of the pin file img tags, we do this + // by classname + var pinElements = document + .getElementsByClassName(this.renderer.unPinnedClass); + // ids will hold the ID of each element, the id + // of the element is the uuid of the file. + var ids = []; + // set the Ids into the ids array + for ( var x = 0; x < pinElements.length; x++) { + ids[x] = pinElements[x].id; + } - /** - * Sets id of IBM Connections blog post Id. - * - * @method setPostUuid - * @param {String} Unique id of the blog post - */ - setPostUuid : function(postUuid) { - return this.setAsString("postUuid", postUuid); - }, - - /** - * Return the entry anchor for this blog post. - * - * @method getEntryAnchor - * @return {String} Entry anchor for this blog post - */ - getEntryAnchor : function() { - var entry = this.dataHandler.getData(); - if (entry) { - var base = entry.getAttribute("xml:base"); - if (base) { - var n = base.lastIndexOf("/"); - return base.substring(n+1); - } - } - }, - - /** - * Return the bloghandle of the blog post. - * - * @method getBlogHandle - * @return {String} Blog handle of the blog post - */ - getBlogHandle : function() { - var blogHandle = this.getAsString("blogHandle"); - if(blogHandle){ - return blogHandle; - } - var blogEntryUrlAlternate = this.getAsString("alternateUrl"); - blogHandle = this.service._extractBlogHandle(blogEntryUrlAlternate); - return blogHandle; - }, + // create an args object containing these three + // vars to hitch. + var pinClass = this.renderer.pinnedClass; + var unPinnedClass = this.renderer.unPinnedClass + var renderer = this.renderer; + var args = { + pinClass : pinClass, + unPinnedClass : unPinnedClass, + ids : ids, + renderer : renderer + }; - /** - * Sets blog handle of IBM Connections blog post. - * - * @method setBlogHandle - * @param {String} blogHandle of the blog post's blog - */ - setBlogHandle : function(blogHandle) { - return this.setAsString("blogHandle", blogHandle); - }, - - /** - * Return the value of IBM Connections blog post replies URL from blog ATOM - * entry document. - * - * @method getRepliesUrl - * @return {String} Blog replies URL for the blog post - */ - getRepliesUrl : function() { - return this.getAsString("replies"); - }, + // we use the array of ids, and not the array of + // elements + // because as we remove a class from an element, + // the array of elements will dynamically reduce + this + ._hitch( + args, + this.fileService + .getPinnedFiles() + .then( + function(files) { + for ( var k = 0; k < args.ids.length; k++) { + for ( var i = 0; i < files.length; i++) { + if (args.ids[k] == files[i] + .getId()) { + args.renderer + ._removeClass( + args.ids[k], + args.unPinnedClass); + args.renderer + ._addClass( + args.ids[k], + args.pinClass); + } + } + } + }, + function(error) { + console + .log("error getting pinned files"); + })); - /** - * Return tags of IBM Connections blog post - * document. - * - * @method getTags - * @return {Object} Array of tags of the blog post - */ - getTags : function() { - return this.getAsArray("tags"); - }, + } + }, - /** - * Set new tags to be associated with this IBM Connections blog post. - * - * @method setTags - * @param {Object} Array of tags to be added to the blog post - */ + /** + * This function pins(favourites) a file, It will send a + * request to the server using the file service API, And + * when the request returns successfully, the css clas + * of the link will be change to reflect that the file + * is now pinned. If the file is already pinned, it will + * remove the pin from the file. + * + * @method doPinFile + * @param el + * The element that fired the event + * @param data + * The data associated with this table row + * @param ev + * The event, onclick + */ + doPinFile : function(el, data, ev) { + var uuid = ""; + if (data.getValue("uid")) { + uuid = data.getValue("uid"); + } - setTags : function(tags) { - return this.setAsArray("tags", tags); - }, - - /** - * Return the replies url of the ATOM entry document. - * - * @method getRepliesUrl - * @return {String} Replies url - */ - getRepliesUrl : function() { - return this.getAsString("repliesUrl"); - }, - - /** - * Return the last updated dateRecommendations URL of the IBM Connections blog post from - * blog ATOM entry document. - * - * @method getRecommendationsURL - * @return {String} Recommendations URL of the Blog Post - */ - getRecommendationsURL : function() { - return this.getAsString("recommendationsUrl"); - }, - - /** - * Return the Recommendations count of the IBM Connections blog post from - * blog ATOM entry document. - * - * @method getRecommendationsCount - * @return {String} Last updated date of the Blog post - */ - getRecommendationsCount : function() { - return this.getAsNumber("rankRecommendations"); - }, - - /** - * Return the comment count of the IBM Connections blog post from - * blog ATOM entry document. - * - * @method getCommentCount - * @return {String} Last updated date of the Blog post - */ - getCommentCount : function() { - return this.getAsNumber("rankComment"); - }, - - /** - * Return the hit count of the IBM Connections blog post from - * blog ATOM entry document. - * - * @method getHitCount - * @return {String} Last updated date of the Blog post - */ - getHitCount : function() { - return this.getAsNumber("rankHit"); - }, + // create an args object containing these three vars + // to hitch. + var pinClass = this.renderer.pinnedClass; + var unPinnedClass = this.renderer.unPinnedClass; + var renderer = this.renderer; + var args = { + pinClass : pinClass, + unPinnedClass : unPinnedClass, + el : el, + renderer : renderer + }; - /** - * Gets an source of IBM Connections Blog post. - * - * @method getSource - * @return {Object} Source of the blog post - */ - getSource : function() { - return this.getAsObject([ "sourceId", "sourceTitle", "sourceLink", "sourceLinkAlternate", "sourceUpdated", "sourceCategory" ]); - }, + if (el.firstElementChild.className == this.renderer.unPinnedClass) { + this + ._hitch( + args, + this.fileService + .pinFile(uuid) + .then( + function( + response) { + args.renderer + ._removeClass( + args.el.firstElementChild, + args.unPinnedClass); + args.renderer + ._addClass( + args.el.firstElementChild, + args.pinClass); - /** - * Loads the blog post object with the atom entry associated with the - * blog post. By default, a network call is made to load the atom entry - * document in the blog post object. - * - * @method load - * @param {Object} [args] Argument object - */ - load : function(args) { - // detect a bad request by validating required arguments - var blogPostUuid = this.getBlogPostUuid(); - var promise = this.service._validateBlogUuid(blogPostUuid); - if (promise) { - return promise; - } + }, + function( + response) { + console + .log("Error pinning file"); + })); + } else if (el.firstElementChild.className == this.renderer.pinnedClass) { + this + ._hitch( + args, + this.fileService + .unpinFile(uuid) + .then( + function(data) { + args.renderer + ._removeClass( + args.el.firstElementChild, + args.pinClass); + args.renderer + ._addClass( + args.el.firstElementChild, + args.unPinnedClass); + }, + function(error) { + console + .log("error removing pin from file"); + })); + } - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - self.setDataHandler(new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BlogPostXPath - })); - return self; - } - }; + } - var requestArgs = lang.mixin({}, args || {}); - var options = { - handleAs : "text", - query : requestArgs - }; - var url = null; - url = this.service.constructUrl(consts.AtomBlogPostInstance, null, { - blogHomepageHandle : this.service.handle, - postUuid : blogPostUuid - }); - return this.service.getEntity(url, options, blogPostUuid, callbacks); - }, + // Internals - /** - * Remove this blog post - * - * @method remove - * @param {Object} [args] Argument object - */ - remove : function(args) { - return this.service.deletePost(this.getBlogPostUuid(), args); - }, + }); - /** - * Update this blog post - * - * @method update - * @param {Object} [args] Argument object - */ - update : function(args) { - return this.service.updatePost(this, args); - }, - - /** - * Save this blog post - * - * @method save - * @param {Object} [args] Argument object - */ - save : function(args) { - if (this.getBlogPostUuid()) { - return this.service.updatePost(this, args); - } else { - return this.service.createPost(this, args); - } - }, - - /** - * Return comments associated with this blog post. - * - * @method getComments - * @param {Object} [args] Argument object - */ - getComments : function(args) { - var blogHandle = this.getBlogHandle(); - var entryAnchor = this.getEntryAnchor(); - return this.service.getEntryComments(blogHandle, entryAnchor, args); - } - }); - return BlogPost; + return FileGrid; }); - }, -'sbt/connections/controls/bookmarks/BookmarkGridRenderer':function(){ -require({cache:{ -'url:sbt/connections/controls/bookmarks/templates/BookmarkRow.html':"<tr class=\"lotusFirst\">\r\n\t<td class=\"lotusFirstCell iconFirstWidth iconWidth\">\r\n\t\t<div class=\"iconsComponentsGray16 iconsComponentsGray16-BookmarksGray16\">\r\n\t\t</div>\r\n\t</td>\r\n\t\r\n\t<td width=\"100%\">\r\n\t <h4>\r\n\t\t\t<a href=\"\" data-dojo-attach-event=\"onclick: handleClick\" title=\"${tooltip}\">${title}</a>\r\n\t\t</h4>\r\n\t\t\r\n\t\t<div class=\"lotusMeta\" role=\"list\">\r\n\t\t\t<a title=\"${authorName}\" href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\">${authorName}</a>\r\n\r\n\t\t\t<span aria-hidden=\"true\" role=\"img\" alt=\"Image divider\" class=\"lotusDivider\">|</span> <span\r\n\t\t\t\tclass=\"Date localizedDone\" \r\n\t\t\t\ttitle=\"${updated}\">${updatedDate}</span>\r\n\r\n\r\n\t\t\t<span style=\"${displayTags}\" aria-hidden=\"true\" alt=\"Image divider\" role=\"img\" class=\"lotusDivider\">|</span> <span\r\n\t\t\t\trole=\"listitem\"> <span role=\"list\" class=\"lotusTags\">\r\n\t\t\t\t${tagsLabel} <span role=\"listitem\"> \r\n\t\t\t\t\t${tagsAnchors}</span>\r\n\r\n\t\t\t</span>\r\n\t\t\t</span>\r\n\r\n\t\t</div>\r\n\t\t</td>\r\n</tr>", -'url:sbt/connections/controls/bookmarks/templates/BootstrapBookmarkRow.html':"<tr>\t\r\n\t<td width=\"100%\">\r\n\t\t\r\n\t <h4><span class=\"icon-bookmark\" ></span>\r\n\t\t\t<a href=\"\" data-dojo-attach-event=\"onclick: handleClick\" title=\"${tooltip}\">${title}</a>\r\n\t\t</h4>\r\n\t\t\t\t\r\n\t</td>\r\n</tr>", -'url:sbt/connections/controls/bookmarks/templates/TagAnchor.html':"<a class=\"tagLink\" title=\"${nls.filterByTag}\" href=\"javascript: void(0);\" data-dojo-attach-event=\"onclick: filterByTag\">${tagName}</a>", -'url:sbt/connections/controls/bookmarks/templates/BookmarkListItem.html':"<li>\r\n\t<h4><a href=\"\" data-dojo-attach-event=\"onclick: handleClick\" title=\"${tooltip}\">${title}</a></h4>\r\n</li>"}}); - /* +'sbt/connections/controls/files/nls/FileGridRenderer':function(){ +/* * © Copyright IBM Corp. 2013 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18041,153 +12878,39 @@ require({cache:{ * permissions and limitations under the License. */ -define(["../../../declare", "../../../i18n", - "../../../connections/controls/ConnectionsGridRenderer", - "../../../text!../../../connections/controls/bookmarks/templates/BookmarkRow.html", - "../../../text!../../../connections/controls/bookmarks/templates/BootstrapBookmarkRow.html", - "../../../text!../../../connections/controls/bookmarks/templates/TagAnchor.html", - "../../../i18n!../../../connections/controls/bookmarks/nls/BookmarkGridRenderer", - "../../../lang", - "../../../text!../../../connections/controls/bookmarks/templates/BookmarkListItem.html"], - function(declare, i18n, ConnectionsGridRenderer, BookmarkRow,BootstrapBookmarkRow, - TagAnchor, nls, lang, BookmarkListItem) { - - /** - * @class BookmarkGridRenderer - * @namespace sbt.connections.controls.bookmarks - * @module sbt.connections.controls.bookmarks.BookmarkGridRenderer - * */ - var BookmarkGridRenderer = declare(ConnectionsGridRenderer,{ - - _nls: nls, - - /** - * The Constructor function - * @method constructor - * @param args - */ - constructor: function(args,grid){ - if(grid.theme == "bootstrap"){ - this.template = BootstrapBookmarkRow; - }else{ - if (args && args.containerType) { - if(args.containerType == "ol" || args.containerType == "ul"){ - this.template = BookmarkListItem; - }else if(args.containerType == "table"){ - this.template = BookmarkRow; - } - }else{ - this.template = BookmarkRow; - } - - } - - this.tagAnchorTemplate = TagAnchor; - }, - - /** - * Displays a tooltip by calling the getTooltip function in the bookmarkAction. - * @method tooltip - * @param grid The Grid element - * @param item the element to display the tooltip - * @param i the number of the current row - * @param items all of the items in the grid row - * @returns A String used as a tooltip - */ - tooltip: function(grid, item, i, items) { - return grid.bookmarkAction.getTooltip(item); - - }, - - /** - * Gets the last updated date in human readable format. - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i the number of the current grid row - * @param items an object array containing the data for all of the grid rows - * @returns The date when the community was last updates - */ - updatedDate: function(grid, item, i, items) { - return i18n.getSearchUpdatedLabel((item.getValue("updated"))); - }, - - /** - * Returns a CSS style based on if a community has tags. - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i The number of the current row - * @param items an object array containing the data for all of the grid rows - * @returns {String} - */ - displayTags: function(grid, item, i, items) { - var tags = item.getValue("tags"); - if (tags.length == 0) { - return "display: none"; - } else { - return ""; - } - }, - - /** - * Get the tag label, if a community has no tags and empty string is returned - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i The number of the current row - * @param items an object array containing the data for all of the grid rows - * @returns an array of strings, that are tags for a community - */ - tagsLabel: function(grid, item, i, items) { - var tags = item.getValue("tags"); - if (tags.length == 0) { - return ""; - } else { - return this._nls.tags; - } - }, - /** - * Substitutes tag labels(Strings) from the nls file into the tag - * Anchor template which creates a tag links, and displays these tags on the page - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i The number of the current row - * @param items an object array containing the data for all of the grid rows - * @returns {String} - */ - tagsAnchors: function(grid, item, i, items) { - var tags = item.getValue("tags"); - if (tags == undefined) { - return ""; - } else { - var tagsStr=""; - if (lang.isArray(tags)) { - for (var i=0; i<tags.length; i++) { - tagsStr += grid._substitute(this.tagAnchorTemplate, { tagName : tags[i] }); - if (i+1 < tags.length) { - tagsStr += ", "; - } - } - } else if (lang.isString(tags)) { - tagsStr = grid._substitute(this.tagAnchorTemplate, { tagName : tags }); - } - return tagsStr; - } - }, - - getUserProfileHref: function(grid,item,i,items){ - return this.getProfileUrl(grid,item.getValue("authorId")); - } - - }); - - - - return BookmarkGridRenderer; +// NLS_CHARSET=UTF-8 +define({ + root: { + updatedBy : "Updated by", + name: "Name", + updated: "Updated", + downloads: "Downloads", + comments: "Comments", + likes: "Likes", + noLikes: "No one likes this", + oneLike: "1 person likes this", + nLikes: "{recommendationCount} people like this", + downloads: "Downloads", + download: "Download", + more: "More", + created: "Created", + pin: "Pin This Item", + commented: "Commented", + _delete: "Delete", + edit: "Edit", + files:"Files", + ariaCheckbox: "checkbox", + ariaVcard: "ariaCheckbox", + feed : "Feed for these Files", + allActions: "All actions for this file" + } }); + }, -'url:sbt/connections/controls/communities/templates/TagAnchor.html':"<a class=\"tagLink\" title=\"${nls.filterByTag}\" href=\"javascript: void(0);\" data-dojo-attach-event=\"onclick: filterByTag\">${tagName}</a>", -'sbt/smartcloud/controls/profiles/ProfileGrid':function(){ +'url:sbt/connections/controls/forums/templates/ReplyRow.html':"<tr uuid=\"${uid}\" class=\" normalTopic \">\r\n\t<td style=\"width: 20px; height: 30px\" class=\"lotusFirstCell\">\r\n\t\t<div style=\"margin-top: 2px;\" class=\"lconnSprite lconnSprite-iconComment16\"></div>\r\n </td>\r\n\t<td>\r\n\t\t<h4 style=\"max-width: 300px\">\r\n\t\t\t${content}\r\n\t\t</h4>\r\n\t</td>\r\n\t<td style=\"width: 12em\" class=\"lotusMeta\" >\r\n\t${title}\r\n\t</td>\r\n\t<td></td>\r\n\t<td class=\"lotusMeta\"><span class=\"lotusRight\"><a href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" >${authorName}</a></span></td>\r\n\t\r\n\t<td class=\"lotusMeta lotusLastCell lotusNowrap\"><span\r\n\t\tclass=\"formatDate\">${getDateLabel}</span></td>\r\n</tr>", +'sbt/authenticator/Basic':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18201,348 +12924,153 @@ define(["../../../declare", "../../../i18n", * implied. See the License for the specific language governing * permissions and limitations under the License. */ - /** + * Social Business Toolkit SDK. + * Definition of an authentication mechanism. + */ +define(["../declare", "../lang", "../util", "../i18n!../nls/loginForm"],function(declare, lang, util, loginForm) { +/** + * Proxy basic authentication. * - * @module sbt.smartcloud.controls.profiles.ProfileGrid + * This class triggers the authentication for a service. */ -define([ "../../../declare", - "../../../lang", - "../../../config", - "../../../controls/grid/Grid", - "./ProfileGridRenderer", - "./ProfileAction", - "../../../store/parameter", - "../../ProfileConstants", - "../../CommunityConstants"], - function(declare, lang, sbt, Grid, ProfileGridRenderer, ProfileAction, parameter, ProfileConstants,CommunityConstants) { - - var ProfileXPath = { - id : "o:person/o:id", - entry : "/o:response/o:entry", - uid : "o:person/o:id", - name : "o:person/o:displayName", - email : "o:person/o:emailAddress", - title : "o:person/o:jobtitle", - profileUrl : "o:person/o:profileUrl", - orgName : "o:person/o:org/o:name", - address : "o:person/o:address", - phoneNumbers : "o:person/o:phoneNumbers/o:phone", - photos : "o:person/o:photos/o:value" - }; - - var FeedXPath = { - "entry" : "/o:response/o:entry", - "entries" : "/o:response/o:entry", - "totalResults" : "/o:response/o:totalResults", - "startIndex" : "/o:response/o:startIndex", - "itemsPerPage" : "/o:response/o:itemsPerPage" - }; +return declare(null, { + loginUi: "", + loginPage: "/sbt/authenticator/templates/login.html", + dialogLoginPage:"authenticator/templates/loginDialog.html", + url: "", + actionUrl: "", - var Namespaces = { - o : "http://ns.opensocial.org/2008/opensocial" - }; + /** + * Constructor, necessary so that this.url is not empty. + * It may also mixin loginUi, loginPage or dialogLoginPage if they are present in sbt.properties. + */ + constructor: function(args){ + lang.mixin(this, args || {}); + }, - var ParamSchema = { - startIndex : parameter.zeroBasedInteger("startIndex"), - pageSize : parameter.oneBasedInteger("count") - }; + /** + * Method that authenticate the current user . + * + * This is a working version. But this is work in progress with following todos + * + * todos: + * Internationalization + */ + authenticate: function(options) { + var self = this; + require(['sbt/config'], function(config){ + var mode = options.loginUi || config.Properties["loginUi"] || self.loginUi; + var loginPage = options.loginPage || config.Properties["loginPage"] || self.loginPage; + var dialogLoginPage = options.dialogLoginPage || config.Properties["dialogLoginPage"] || self.dialogLoginPage; + if(mode=="popup") { + self._authPopup(options, loginPage, config, self.url); + } else if(mode=="dialog") { + self._authDialog(options, dialogLoginPage, config); + } else { + self._authMainWindow(options, loginPage, self.url); + } + }); + + return true; + }, - /** - * @class ProfileGrid - * @namespace sbt.connections.controls.profiles - */ - var ProfileGrid = declare(Grid, { - - /** - * @param options, This is a list of all - * the different types of profile grids available. - * Depending on which one is selected specific arguments will be given to - * the atom store and grid renderer. - */ - options : { - "contacts" : { - storeArgs : { - url : ProfileConstants.GetMyContacts, - attributes : ProfileXPath, - paramSchema : ParamSchema, - feedXPath : FeedXPath, - namespaces : Namespaces - }, - rendererArgs : { - type : "contacts" - } - }, - "friends" : { - storeArgs : { - url : ProfileConstants.GetMyConnections, - attributes : ProfileXPath, - paramSchema : ParamSchema, - feedXPath : FeedXPath, - namespaces : Namespaces - }, - rendererArgs : { - type : "friends" - } - }, - "communityMembers" : { - storeArgs : { - url : CommunityConstants.AtomCommunityMembers, - attributes : CommunityConstants.MemberXPath, - paramSchema : ParamSchema, - feedXPath : CommunityConstants.CommunityFeedXPath, - namespaces: CommunityConstants.CommunityNamespaces - }, - rendererArgs : { - type : "communityMembers" - } + _authDialog: function(options, dialogLoginPage, sbtConfig) { + var self = this; + require(["sbt/_bridge/ui/BasicAuth_Dialog", "sbt/dom"], function(dialog, dom) { + if(options.cancel){ + sbtConfig.cancel = options.cancel; } - }, - - /** - * Endpoint to use, default is 'smartcloud' - */ - endpoint: "smartcloud", - - /** - * A profile action, defines default behaviour for when - * items in the grid are clicked on or hovered on, - * it is possible to override these actions - */ - profileAction: new ProfileAction(), - - /** - * This is the default grid that will be created if no - * arguments are given. - */ - defaultOption: "contacts", - - /** - * Constructor function - * @method constructor - */ - constructor: function(args){ - }, - - buildUrl: function(url, args, endpoint){ - var params; - if (this.communityUuid) { - params = {communityUuid: this.communityUuid}; - } - - return this.constructUrl(url, params, {},endpoint); - }, - - /** - * Creates a renderer for the grid.The renderer is responsible for - * loading the grid's HTML content. - * @method createDefaultRenderer - * @param args sets the template the renderer will use, by checking args.type, but for - * profile grids this will always be "profile" - * @returns an instance of a profile gird renderer. - */ - createDefaultRenderer : function(args) { - return new ProfileGridRenderer(args); - }, - - postCreate: function(){ - this.inherited(arguments); - if(this.type === "communityMembers"){ - if(!arguments.communityUuid){ - this._updateWithError({message:this.renderer._nls.communityIdError}); + + options.actionUrl = self._computeActionURL(options); + + dialog.show(options, dialogLoginPage); + dom.setText('wrongCredsMessage', loginForm.wrong_creds_message); + dom.setText('basicLoginFormUsername', loginForm.username); + dom.setText('basicLoginFormPassword', loginForm.password); + dom.setAttr(dom.byId('basicLoginFormOK'), "value", loginForm.login_ok); + dom.setAttr(dom.byId('basicLoginFormCancel'), "value", loginForm.login_cancel); + }); + return true; + }, - } - } - }, - - /** - * In the grid HTML an element can have an event attached - * using dojo-attach-event="onClick: handleClick". - * This method is the handler for the onclick event. - * @method handleClick - * @param el the element that fired the event - * @param data all of the items from the current row of the grid. - * @param ev the event - */ - handleClick: function(el, data, ev) { - if (this.profileAction) { - console.log(data); - this.stopEvent(ev); - - this.profileAction.execute(data, { grid : this.grid }, ev); - } - }, - - // Internals - - /* - * Override to change count if needed - */ - _doQuery: function(store, options) { - // OpenSocial API doesn't like requests for more than is available - if (options && options.total) { - options.count = Math.min(options.count, options.total - options.start); - } - - this.inherited(arguments); + _authPopup: function(options, loginPage, sbtConfig, sbtUrl) { + var actionURL = this._computeActionURL(options); + var urlParamsMap = { + actionURL: actionURL, + redirectURL: 'empty', + loginUi: 'popup', + showWrongCredsMessage: 'false' + }; + var urlParams = util.createQuery(urlParamsMap, "&"); + var url = sbtUrl+loginPage + '?' + urlParams; + + var windowParamsMap = { + width: window.screen.availWidth / 2, + height: window.screen.availHeight / 2, + left: window.screen.availWidth / 4, + top: window.screen.availHeight / 4, + menubar: 0, + toolbar: 0, + status: 0, + location: 0, + scrollbars: 1, + resizable: 1 + }; + var windowParams = util.createQuery(windowParamsMap, ","); + var loginWindow = window.open(url,'Authentication', windowParams); + if(options.callback){ + sbtConfig.callback = options.callback; + loginWindow.callback = options.callback; + } + if(options.cancel){ + sbtConfig.cancel = options.cancel; + loginWindow.cancel = options.cancel; } + globalLoginFormStrings = loginForm; + globalEndpointAlias = options.name; + loginWindow.focus(); - }); - - return ProfileGrid; + return true; + }, + + _authMainWindow: function(options, loginPage, sbtUrl) { + var actionURL = this._computeActionURL(options); + var urlParamsMap = { + actionURL: actionURL, + redirectURL: document.URL, + loginUi: 'mainWindow', + showWrongCredsMessage: 'false', + username: loginForm.username, + password: loginForm.password, + login_ok: loginForm.login_ok, + login_cancel: loginForm.login_cancel, + wrong_creds_message: loginForm.wrong_creds_message + }; + + var urlParams = util.createQuery(urlParamsMap, "&"); + var url = sbtUrl+loginPage + '?' + urlParams; + window.location.href = url; + + return true; + }, + + _computeActionURL: function(options) { + if (!this.actionUrl) { + var proxy = options.proxy.proxyUrl; + return proxy.substring(0,proxy.lastIndexOf("/"))+"/basicAuth/"+options.proxyPath+"/JSApp"; + } + return this.actionUrl; + } + +} +); }); -}, -'url:sbt/smartcloud/controls/profiles/templates/ViewAll.html':"<table width=\"100%\" style=\"margin-top: 5px;\">\r\n <tbody>\r\n <tr>\r\n <td style=\"text-align: ${countAlign}; vertical-align: ${verticalAlign}; width: 100%;\">\r\n <span>\r\n <a class=\"lotusAction\" href=\"javascript:void(0);\" data-dojo-attach-event=\"onclick: handleViewAll\">${viewAllTitle}</a>\r\n </span>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>", -'sbt/connections/controls/search/nls/SearchGridRenderer':function(){ -/* - * © 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. - */ -// NLS_CHARSET=UTF-8 -define({ - root: { - name: "Name", - updated: "Updated", - downloads: "Downloads", - likes: "Likes", - loading : "Loading...", - previous : "Previous", - previousPage : "Previous Page", - next : "Next", - nextPage : "Next Page", - pagingResults : "${start} - ${count} of ${totalCount}", - updatedBy : "Updated by", - sortByRelevance : "Relevance", - sortByDate: "Date", - feed : "Feed for these search results", - - - /** - * Search specific Misc - */ - empty : "No results were found for that search", - summary : "Search Results", - emptyString: "", - ltr: "ltr", - help: "Help", - tags: "Tags:", - tagsMore: "and {0} more", - noDescription: "No description or summary for this result.", - members: "members", - people: "People", - feed: "feed", - commentOn: "Comment on: ", - comments: "comments", - comment: "Comment:", - oneComment: "1 comment", - entry: "Entry: ", - topic: "Topic:", - - /** - * Activity-Related - */ - activities: "Activities", - activitiesTitle: "Activities", - activity: "Activity: ", - activityComment: "Comment:", - activityToDo:"To Do:", - activityEntry: "Activity:", - activityBookmark: "Bookmark:", - activitySection: "Section:", - fromAnActivity: "Activity", - - /** - * Blog-Related - */ - blog: "Blog: ", - blogs: "Blogs", - blogEntry: "Blog: ", - blogComment: "Comment:", - idea: "Idea: ", - ideaComment: "Comment: ", - ideationBlog: "Ideation Blog: ", - fromABlog: "Blog", - fromAnIdeationBlog: "Ideation Blog", - - /** - * Bookmark-Related - */ - bookmarks: "Bookmarks", - bookmark: "Bookmark: ", - bookmarksTitle: "Bookmarks", - - /** - * Calendar-Related - */ - calendar: "Calendar: ", - calendars: "Calendars", - eventIsAllDay: "All day", - eventRepeats: "Repeats", - eventDateOn: "On: ", - - /** - * CommunityRelated - */ - communities: "Communities", - community: "Community: ", - communitiesTitle: "Communities", - fromACommunity: "Community", - - /** - * File-Related - */ - file: "File: ", - files: "Files", - - /** - * Forum-Related - */ - forum: "Forum: ", - forums: "Forums", - forumTopic: "Topic:", - forumCategory: "Category:", - fromAForum: "Forum", - - /** - * Profile-Related - */ - profile: "Profile: ", - profiles: "Profiles", - inactiveLabel: "(inactive)", - - /** - * StatusUpdate-Related - */ - statusUpdate: "Status Update: ", - statusUpdates: "Status updates", - fromAStatusUpdate: "Status Update", - - /** - * Wiki-Related - */ - wiki: "Wiki: ", - wikis: "Wikis", - wikiType: "Wiki: ", - wikiFile: "File: ", - wikiPage: "Page: ", - fromAWiki: "Wiki" - } -}); - }, -'sbt/Cache':function(){ +'url:sbt/connections/controls/profiles/templates/TagListHeader.html':"<div class=\"lotusChunk\">\r\n\t<h3>${tagHeader}</h3>\r\n</div>", +'url:sbt/connections/controls/bootstrap/templates/FileRow.html':"<tr class=\"lotusFirst\">\r\n <td class=\"lotusFirstCell\" width=\"32\" title=\"${title}\">\r\n <input value=\"${title}\" name=\"${title}\" aria-label=\"${nls.ariaCheckbox}\" data-dojo-attach-event=\"onclick: handleCheckBox\" type=\"checkbox\" class=\"lotusCheckbox\">\r\n </td>\r\n <td class=lotusNowrap>\r\n <a title=\"Download ${title}\" href=\"${downloadUrl}\" class=\"lconnDownloadable lconnDownloadableIcon\">\r\n <img alt=\"\" src=\"images/blank.gif\" class=\"lconn-ftype32 lconn-ftype32-${ftype}\"><span class=\"lotusAltText\" title=\"\">${_nls.download}</span>\r\n </a>\r\n </td>\r\n <td style=\"width: 100%;\">\r\n <h4 class=\"lotusBreakWord lotusLeft\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${tooltip}\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a> \r\n </h4>\r\n <div class=\"lotusMeta lotusClear\">\r\n <ul class=\"lotusInlinelist\">\r\n <li class=\"lotusFirst\" title=\"\">\r\n <span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t\t<a aria-label=\"${nls.ariaVcard}\" href=\"javascript:void(0);\" class=\"fn url\">${authorName}</a>\r\n \t\t\t\t\t\t<span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${authorUid}</span>\r\n\t\t\t\t\t</span>\r\n ${_nls.created} ${createdLabel}\r\n </li>\r\n <li>\r\n ${hitCount} ${_nls.downloads}\r\n </li>\r\n <li>\r\n ${commentCount} ${_nls.comments}\r\n </li>\r\n </ul>\r\n </div>\r\n </td>\r\n \r\n \r\n\r\n</tr>\r\n\r\n", +'sbt/smartcloud/Subscriber':function(){ /* * © Copyright IBM Corp. 2012 * @@ -18558,97 +13086,444 @@ define({ * implied. See the License for the specific language governing * permissions and limitations under the License. */ - /** - * The cache implements the Least Recently Used (LRU)Algorithm by doubly linked list. Every node has 4 variables - key, value, next and previous. - * The key stores the key of the node and value stores the actual data for the key. The next and previous variables point to the - * next and previous nodes in the cache. - * The cache has a head variable pointing to the top cache node and a tail variable pointing to the last cache node. - * - * Head -> A ---> B ---> C ---> D <-- Tail - * <--- <--- <--- - * - * Suppose the cache has 4 entries and its max size limit is 4 (the cache is full right now). The structure of the cache would be as described by figure above. - * The entries are listed as per their order of recent access. - * So when a new entry E is added to the cache, the new order of the cache entries would be EABC. D would be deleted from the cache. + * Social Business Toolkit SDK. * - * @module sbt.Cache + * @author Vimal Dhupar + * Definition of a Subscriber Helper for getting the Subscriber ID for a SmartCloud User. */ -define(['./declare'],function(declare) { - var Cache = declare(null, { - constructor: function(max) { - this.limit = max;// This is the maximum limit of the cache. - this._cache = {};//Variable to hold the items in the cache. - this.head = null;// Pointer to the head of the cache - this.tail = null;// Pointer to the tail of the cache - this.count = 0;// Counter for number of items in the cache +define([ "../declare", "../Endpoint" ], function(declare, Endpoint) { + /** + * Subscriber Helper Class for getting the Subscriber ID for a SmartCloud User. + * @class Subscriber + * @namespace sbt.smartcloud + */ + var Subscriber = declare(null, { + + endpoint : null, + + /** + * @constructor + * @param endpoint + * @param callback + */ + constructor : function(endpoint, callback) { + this.endpoint = endpoint; + if (callback) + this.load(callback); }, - get: function _cg(key) { //Retrieves a cached item. - var k = this._cache[key]; - if(k){//Item found in the cache. Move the accessed node to the top of the cache. - if(this.head == k){return k.value;} // the node is already at the top, no need to shift, just return the value. - else{// shift the node to the top and return the value - if(k.prev)k.prev.next = k.next; - if(k.next){k.next.prev = k.prev;} else {this.tail=k.prev;} - k.next = this.head; - this.head.prev = k; - k.prev = null; - this.head = k; + + /** + * Load method is responsible for making the network call to fetch the user identity + * @method load + * @param callback + */ + load : function(callback) { + var _self = this; + this.endpoint.xhrGet({ + serviceUrl : "/manage/oauth/getUserIdentity", + loginUi : this.endpoint.loginUi, + handleAs : "json", + load : function(response) { + callback(_self, response); + }, + error : function(error) { + callback(_self, null); + console.log("Error fetching feed for getUserIdentity"); } - return k.value; - } - return null; // the node is not in the cache - }, - put: function _cp(key,value) {// puts a node in the cache if the node is not present in the cache. The node is put at the top of the cache. - if(this._cache[key])//remove the asked node - {this.remove(key); this.count --;} - - var k = this._cache[key] ={key:key, value:value}; - if(this.count==this.limit) //if the cache is full, remove the last node - {this.remove(this.tail.key);this.count --;} - //add the asked node to the top of the list. - k.next = this.head; - if(k.next)k.next.prev = k;else this.tail = k; - this.head = k; - k.prev = null; - this.count ++; - }, - remove: function _cr(key) {//removes a node from the cache and updates the next and prev attributes of the surrounding nodes. - var k = this._cache[key]; - if(k){ - if(k.next)k.next.prev = k.prev;else this.tail = k.prev; - if(k.prev)k.prev.next = k.next; else this.head = k.next; - k.next = k.prev = null; - delete this._cache[key]; - this.count -- ; - } - + }); }, /** - * Function that browse the content of the cache and call a call back method for each entry. - * - * @param callback the callback method to invoke for each entry + * Method to get the Subscriber Id of the user. + * @method getSubscriberId + * @param response + * @returns */ - browse: function(callback) { - if(callback) { - for(var i in this._cache) { - var e = this._cache[i]; - var r = callback(e.key,e.value); - if(r) { - return r; - } - } - return null; + getSubscriberId : function(response) { + if (response && response.subscriberid) { + return response.subscriberid; } return null; } }); + return Subscriber; +}); +}, +'sbt/entities':function(){ +// The entities class from dojox/html/entities. +define(["./lang"], function(lang) { + // Entity characters for HTML, represented as an array of + // character code, entity name (minus & and ; wrapping. + // The function wrapper is to fix global leaking with the build tools. + var dhe = {}; + + var _applyEncodingMap = function(str, map){ + // summary: + // Private internal function for performing encoding of entity characters. + // tags: + // private + + // Check to see if we have genned and cached a regexp for this map yet + // If we have, use it, if not, gen it, cache, then use. + var mapper, regexp; + if(map._encCache && + map._encCache.regexp && + map._encCache.mapper && + map.length == map._encCache.length){ + mapper = map._encCache.mapper; + regexp = map._encCache.regexp; + }else{ + mapper = {}; + regexp = ["["]; + var i; + for(i = 0; i < map.length; i++){ + mapper[map[i][0]] = "&" + map[i][1] + ";"; + regexp.push(map[i][0]); + } + regexp.push("]"); + regexp = new RegExp(regexp.join(""), "g"); + map._encCache = { + mapper: mapper, + regexp: regexp, + length: map.length + }; + } + str = str.replace(regexp, function(c){ + return mapper[c]; + }); + return str; + }; + + var _applyDecodingMap = function(str, map){ + // summary: + // Private internal function for performing decoding of entity characters. + // tags: + // private + var mapper, regexp; + if(map._decCache && + map._decCache.regexp && + map._decCache.mapper && + map.length == map._decCache.length){ + mapper = map._decCache.mapper; + regexp = map._decCache.regexp; + }else{ + mapper = {}; + regexp = ["("]; + var i; + for(i = 0; i < map.length; i++){ + var e = "&" + map[i][1] + ";"; + if(i){regexp.push("|");} + mapper[e] = map[i][0]; + regexp.push(e); + } + regexp.push(")"); + regexp = new RegExp(regexp.join(""), "g"); + map._decCache = { + mapper: mapper, + regexp: regexp, + length: map.length + }; + } + str = str.replace(regexp, function(c){ + return mapper[c]; + }); + return str; + }; + + dhe.html = [ + ["\u0026","amp"], ["\u0022","quot"],["\u003C","lt"], ["\u003E","gt"], + ["\u00A0","nbsp"] + ]; + + // Entity characters for Latin characters and similar, represented as an array of + // character code, entity name (minus & and ; wrapping. + dhe.latin = [ + ["\u00A1","iexcl"],["\u00A2","cent"],["\u00A3","pound"],["\u20AC","euro"], + ["\u00A4","curren"],["\u00A5","yen"],["\u00A6","brvbar"],["\u00A7","sect"], + ["\u00A8","uml"],["\u00A9","copy"],["\u00AA","ordf"],["\u00AB","laquo"], + ["\u00AC","not"],["\u00AD","shy"],["\u00AE","reg"],["\u00AF","macr"], + ["\u00B0","deg"],["\u00B1","plusmn"],["\u00B2","sup2"],["\u00B3","sup3"], + ["\u00B4","acute"],["\u00B5","micro"],["\u00B6","para"],["\u00B7","middot"], + ["\u00B8","cedil"],["\u00B9","sup1"],["\u00BA","ordm"],["\u00BB","raquo"], + ["\u00BC","frac14"],["\u00BD","frac12"],["\u00BE","frac34"],["\u00BF","iquest"], + ["\u00C0","Agrave"],["\u00C1","Aacute"],["\u00C2","Acirc"],["\u00C3","Atilde"], + ["\u00C4","Auml"],["\u00C5","Aring"],["\u00C6","AElig"],["\u00C7","Ccedil"], + ["\u00C8","Egrave"],["\u00C9","Eacute"],["\u00CA","Ecirc"],["\u00CB","Euml"], + ["\u00CC","Igrave"],["\u00CD","Iacute"],["\u00CE","Icirc"],["\u00CF","Iuml"], + ["\u00D0","ETH"],["\u00D1","Ntilde"],["\u00D2","Ograve"],["\u00D3","Oacute"], + ["\u00D4","Ocirc"],["\u00D5","Otilde"],["\u00D6","Ouml"],["\u00D7","times"], + ["\u00D8","Oslash"],["\u00D9","Ugrave"],["\u00DA","Uacute"],["\u00DB","Ucirc"], + ["\u00DC","Uuml"],["\u00DD","Yacute"],["\u00DE","THORN"],["\u00DF","szlig"], + ["\u00E0","agrave"],["\u00E1","aacute"],["\u00E2","acirc"],["\u00E3","atilde"], + ["\u00E4","auml"],["\u00E5","aring"],["\u00E6","aelig"],["\u00E7","ccedil"], + ["\u00E8","egrave"],["\u00E9","eacute"],["\u00EA","ecirc"],["\u00EB","euml"], + ["\u00EC","igrave"],["\u00ED","iacute"],["\u00EE","icirc"],["\u00EF","iuml"], + ["\u00F0","eth"],["\u00F1","ntilde"],["\u00F2","ograve"],["\u00F3","oacute"], + ["\u00F4","ocirc"],["\u00F5","otilde"],["\u00F6","ouml"],["\u00F7","divide"], + ["\u00F8","oslash"],["\u00F9","ugrave"],["\u00FA","uacute"],["\u00FB","ucirc"], + ["\u00FC","uuml"],["\u00FD","yacute"],["\u00FE","thorn"],["\u00FF","yuml"], + ["\u0192","fnof"],["\u0391","Alpha"],["\u0392","Beta"],["\u0393","Gamma"], + ["\u0394","Delta"],["\u0395","Epsilon"],["\u0396","Zeta"],["\u0397","Eta"], + ["\u0398","Theta"], ["\u0399","Iota"],["\u039A","Kappa"],["\u039B","Lambda"], + ["\u039C","Mu"],["\u039D","Nu"],["\u039E","Xi"],["\u039F","Omicron"], + ["\u03A0","Pi"],["\u03A1","Rho"],["\u03A3","Sigma"],["\u03A4","Tau"], + ["\u03A5","Upsilon"],["\u03A6","Phi"],["\u03A7","Chi"],["\u03A8","Psi"], + ["\u03A9","Omega"],["\u03B1","alpha"],["\u03B2","beta"],["\u03B3","gamma"], + ["\u03B4","delta"],["\u03B5","epsilon"],["\u03B6","zeta"],["\u03B7","eta"], + ["\u03B8","theta"],["\u03B9","iota"],["\u03BA","kappa"],["\u03BB","lambda"], + ["\u03BC","mu"],["\u03BD","nu"],["\u03BE","xi"],["\u03BF","omicron"], + ["\u03C0","pi"],["\u03C1","rho"],["\u03C2","sigmaf"],["\u03C3","sigma"], + ["\u03C4","tau"],["\u03C5","upsilon"],["\u03C6","phi"],["\u03C7","chi"], + ["\u03C8","psi"],["\u03C9","omega"],["\u03D1","thetasym"],["\u03D2","upsih"], + ["\u03D6","piv"],["\u2022","bull"],["\u2026","hellip"],["\u2032","prime"], + ["\u2033","Prime"],["\u203E","oline"],["\u2044","frasl"],["\u2118","weierp"], + ["\u2111","image"],["\u211C","real"],["\u2122","trade"],["\u2135","alefsym"], + ["\u2190","larr"],["\u2191","uarr"],["\u2192","rarr"],["\u2193","darr"], + ["\u2194","harr"],["\u21B5","crarr"],["\u21D0","lArr"],["\u21D1","uArr"], + ["\u21D2","rArr"],["\u21D3","dArr"],["\u21D4","hArr"],["\u2200","forall"], + ["\u2202","part"],["\u2203","exist"],["\u2205","empty"],["\u2207","nabla"], + ["\u2208","isin"],["\u2209","notin"],["\u220B","ni"],["\u220F","prod"], + ["\u2211","sum"],["\u2212","minus"],["\u2217","lowast"],["\u221A","radic"], + ["\u221D","prop"],["\u221E","infin"],["\u2220","ang"],["\u2227","and"], + ["\u2228","or"],["\u2229","cap"],["\u222A","cup"],["\u222B","int"], + ["\u2234","there4"],["\u223C","sim"],["\u2245","cong"],["\u2248","asymp"], + ["\u2260","ne"],["\u2261","equiv"],["\u2264","le"],["\u2265","ge"], + ["\u2282","sub"],["\u2283","sup"],["\u2284","nsub"],["\u2286","sube"], + ["\u2287","supe"],["\u2295","oplus"],["\u2297","otimes"],["\u22A5","perp"], + ["\u22C5","sdot"],["\u2308","lceil"],["\u2309","rceil"],["\u230A","lfloor"], + ["\u230B","rfloor"],["\u2329","lang"],["\u232A","rang"],["\u25CA","loz"], + ["\u2660","spades"],["\u2663","clubs"],["\u2665","hearts"],["\u2666","diams"], + ["\u0152","Elig"],["\u0153","oelig"],["\u0160","Scaron"],["\u0161","scaron"], + ["\u0178","Yuml"],["\u02C6","circ"],["\u02DC","tilde"],["\u2002","ensp"], + ["\u2003","emsp"],["\u2009","thinsp"],["\u200C","zwnj"],["\u200D","zwj"], + ["\u200E","lrm"],["\u200F","rlm"],["\u2013","ndash"],["\u2014","mdash"], + ["\u2018","lsquo"],["\u2019","rsquo"],["\u201A","sbquo"],["\u201C","ldquo"], + ["\u201D","rdquo"],["\u201E","bdquo"],["\u2020","dagger"],["\u2021","Dagger"], + ["\u2030","permil"],["\u2039","lsaquo"],["\u203A","rsaquo"] + ]; + + dhe.encode = function(str/*string*/, m /*array?*/){ + // summary: + // Function to obtain an entity encoding for a specified character + // str: + // The string to process for possible entity encoding. + // m: + // An optional list of character to entity name mappings (array of + // arrays). If not provided, it uses the and Latin entities as the + // set to map and escape. + // tags: + // public + if(str){ + if(!m){ + // Apply the basic mappings. HTML should always come first when decoding + // as well. + str = _applyEncodingMap(str, dhe.html); + str = _applyEncodingMap(str, dhe.latin); + + }else{ + str = _applyEncodingMap(str, m); + } + } + return str; + }; + + dhe.decode = function(str/*string*/, m /*array?*/){ + // summary: + // Function to obtain an entity encoding for a specified character + // str: + // The string to process for possible entity encoding to decode. + // m: + // An optional list of character to entity name mappings (array of + // arrays). If not provided, it uses the HTML and Latin entities as the + // set to map and decode. + // tags: + // public + if(str){ + if(!m){ + // Apply the basic mappings. HTML should always come first when decoding + // as well. + str = _applyDecodingMap(str, dhe.html); + str = _applyDecodingMap(str, dhe.latin); + + }else{ + str = _applyDecodingMap(str, m); + } + } + return str; + }; + return dhe; +}); - return Cache; + +}, +'sbt/connections/controls/WidgetWrapper':function(){ +require({cache:{ +'url:sbt/connections/controls/templates/WidgetFrame.html':"<iframe width=\"99%\" height=\"99%\" style=\"border-style: none;\" dojoAttachPoint=\"iframeNode\">\r\n</iframe>"}}); +/* + * © 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. + */ +/** + * + */ +define(["../../declare", "../../config", "../../lang", "../../widget/_TemplatedWidget", "../../stringUtil", "../../json", + "../../text!./templates/WidgetFrame.html", "../../i18n!sbt/connections/controls/nls/WidgetWrapper" ], + function(declare, config, lang, _TemplatedWidget, stringUtil, JSON, frameTemplate, nls) { + + /** + * Base class for wrapped widgets. + * This class manages population of an iframe with a template which should be provided by subclasses. + * + * @class sbt.controls.WidgetWrapper + */ + var WidgetWrapper = declare([ _TemplatedWidget ], { + /** + * The templateString from dijit's _TemplatedMixin. Set it to be our iframe Template. + * + * @property templateString + * @type String + * @default frameTemplate + */ + templateString: frameTemplate, + + /** + * The url of our default frame content. In this case, a simple loading page. + * + * @property frameContent + * @type String + * @default "/sbt/connections/controls/templates/LoadingPage.html" + */ + frameContent: "/sbt/connections/controls/templates/LoadingPage.html", + + /** + * The attach point for the iframe. This is specified in the frameTemplate. + * + * @property iframeNode + * @type Object + * @default null + */ + iframeNode: null, + + /** + * The endpoint we will authenticate before it is used by the underlying widget. + * @property endpoint + * @type Object + * @default null + */ + _endpoint: null, + + /** + * Constructor function. + * + * @method constructor + * @param {Object} args + * @param {String} [args.endpoint] If this is provided it will look for an endpoint with this name which will be used throughout the widget. + * Otherwise it will default to the "connections" endpoint. + */ + constructor: function(args){ + var endpointName = args.endpoint || "connections"; + var ep = config.findEndpoint(endpointName); + this._endpoint = ep; + }, + + /** + * After the widget is created but BEFORE it is added to the dom. + * @method postCreate + */ + postCreate: function() { + this.inherited(arguments); + + if (this.frameContent) { + this.iframeNode.src = config.Properties.sbtUrl + this.frameContent; + } + }, + + /** + * Get an object with the transformations to be performed on the template. Subclasses should override this to provide values for any substitution variables in their templates. + * + * @method getTemplateReplacements + * @returns {Object} + */ + getTemplateReplacements: function(){ + return {}; + }, + + /** + * @method getEndpoint + * @returns {Object} + */ + getEndpoint: function(){ + return this._endpoint; + }, + + /** + * @method setEndpoint + */ + setEndpoint: function(endpoint){ + this._endpoint = endpoint; + }, + + /** + * After the widget has been created AND added to the dom. + * + * When instantiating programmatically, this method should ALWAYS be called explicitly after creation. + * + * @method startup + */ + startup: function() { + this.inherited(arguments); + if (this.frameContent) { + var iframe = (this.iframeNode.contentWindow || this.iframeNode.contentDocument); + if (iframe.document){ + iframe = iframe.document; + } + if(this.defaultTemplate){ + + this.defaultTemplate = stringUtil.transform(this.defaultTemplate, this.getTemplateReplacements(), function(value, key){ + if(!value){ + return "${" + key + "}"; + } + else{ + return value; + } + }); + this.defaultTemplate = stringUtil.transform(this.defaultTemplate, this._endpoint.serviceMappings, function(value, key){ + if(!value){ + return key; + } + else{ + return value; + } + }); + } + else{ + this.defaultTemplate = nls.unsupportedBrowser; + } + + iframe.open(); + iframe.write(this.defaultTemplate); + iframe.close(); + } + } + + }); + + return WidgetWrapper; }); }, -'sbt/connections/SearchConstants':function(){ +'sbt/connections/FollowConstants':function(){ /* * © Copyright IBM Corp. 2013 * @@ -18666,165 +13541,277 @@ define(['./declare'],function(declare) { */ /** * Social Business Toolkit SDK. - * Definition of constants for SearchService. + * Definition of constants for FollowService. */ define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { return lang.mixin(conn, { + /** + * Activities Source + * + * @property ActivitiesSource + * @type String + * @for sbt.connections.FollowedResource + */ + ActivitiesSource : "activities", + /** - * Namespaces to be used when reading the Search ATOM feed + * Activity Resource Type + * + * @property ActivityResourceType + * @type String + * @for sbt.connections.FollowedResource */ - SearchNamespaces : { - a : "http://www.w3.org/2005/Atom", - ibmsc : "http://www.ibm.com/search/content/2010", - opensearch : "http://a9.com/-/spec/opensearch/1.1/", - relevance : "http://a9.com/-/opensearch/extensions/relevance/1.0/", - snx : "http://www.ibm.com/xmlns/prod/sn", - spelling : "http://a9.com/-/opensearch/extensions/spelling/1.0/" - }, + ActivityResourceType : "activity", /** - * XPath expressions used when parsing a Connections Search ATOM feed + * Blogs Source + * + * @property BlogsSource + * @type String + * @for sbt.connections.FollowedResource */ - SearchFeedXPath : conn.ConnectionsFeedXPath, + BlogsSource : "blogs", + + /** + * Blog Resource Type + * + * @property BlogResourceType + * @type String + * @for sbt.connections.FollowedResource + */ + BlogResourceType : "blog", + + /** + * Communities Source + * + * @property CommunitiesSource + * @type String + * @for sbt.connections.FollowedResource + */ + CommunitiesSource : "communities", /** - * XPath expressions used when parsing a Connections Search facets feed - * that only contains a single facet + * Community Resource Type + * + * @property CommunitiesResourceType + * @type String + * @for sbt.connections.FollowedResource */ - SingleFacetXPath : { - // used by getEntitiesDataArray - entries : "/a:feed/ibmsc:facets/ibmsc:facet[@id='{facet.id}']/ibmsc:facetValue" - // used by getSummary - //totalResults : "", - //startIndex : "", - //itemsPerPage : "" - }, + CommunitiesResourceType : "community", + + /** + * Files Source + * + * @property FilesSource + * @type String + * @for sbt.connections.FollowedResource + */ + FilesSource : "files", /** - * XPath expressions used when parsing a Connections Search facet + * File Resource Type + * + * @property FileResourceType + * @type String + * @for sbt.connections.FollowedResource */ - FacetValueXPath : { - // used by getEntityData - entry : "/ibmsc:facetValue", - // used by getEntityId - uid : "@id", - // used by getters - id : "@id", - label : "@label", - weight : "@weight" - }, + FileResourceType : "file", + + /** + * FileFolder Resource Type + * + * @property FileFolderResourceType + * @type String + * @for sbt.connections.FollowedResource + */ + FileFolderResourceType : "file_folder", + + /** + * Forums Source + * + * @property ForumsSource + * @type String + * @for sbt.connections.FollowedResource + */ + ForumsSource : "forums", /** - * XPath expressions to be used when reading a scope + * Forum Resource Type + * + * @property ForumResourceType + * @type String + * @for sbt.connections.FollowedResource */ - ScopeXPath : lang.mixin({}, conn.AtomEntryXPath, { - link : "link" - }), + ForumResourceType : "forum", /** - * XPath expressions to be used when reading a search result + * ForumTopic Resource Type + * + * @property ForumTopicResourceType + * @type String + * @for sbt.connections.FollowedResource */ - SearchXPath : lang.mixin({}, conn.AtomEntryXPath, { - rank : "snx:rank", - relevance : "relevance:score", - type : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", - application : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/component']/@term", - applicationCount : "count(a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/component']/@term)", - primaryComponent : "a:category[ibmsc:field[@id='primaryComponent']]/@term", - tags : "a:category[not(@scheme)]/@term", - commentCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/comment']", - resultLink : "a:link[not(@rel)]/@href", - bookmarkLink : "ibmsc:field[@id='dogearURL']", - eventStartDate : "ibmsc:field[@id='eventStartDate']", - authorJobTitle : "a:content/xhtml:div/xhtml:span/xhtml:div[@class='title']", - authorJobLocation : "a:content/xhtml:div/xhtml:span/xhtml:div[@class='location']", - authorCount : "count(a:contributor)", - contributorCount : "count(a:author)", - tagCount : "count(a:category[not(@scheme)])", - highlightField : "ibmsc:field[@id='highlight']", - fileExtension : "ibmsc:field[@id='fileExtension']", - memberCount : "snx:membercount", - communityUuid : "snx:communityUuid", - containerType : "ibmsc:field[@id='container_type']", - communityParentLink : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/container' and @type='text/html']/@href", - parentageMetaID : "ibmsc:field[contains(@id, 'ID')]/@id", - parentageMetaURL : "ibmsc:field[contains(@id, 'URL')]", - parentageMetaURLID : "ibmsc:field[contains(@id, 'URL')]/@id", - objectRefDisplayName : "ibmsc:field[@id='FIELD_OBJECT_REF_DISPLAY_NAME']", - objectRefUrl : "ibmsc:field[@id='FIELD_OBJECT_REF_URL']", - accessControl : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/accesscontrolled']/@term", - commentsSummary : "ibmsc:field[@id='commentsSummary']" - }), + ForumTopicResourceType : "forum_topic", - /** - * Returns the set of supported values that can be passed to the "scope" parameter of the Search API. - * Scopes relating to Connections applications that have not been installed will not be returned. + /** + * Profile Source + * + * @property ProfilesSource + * @type String + * @for sbt.connections.FollowedResource */ - AtomScopes : "/${search}/atom/scopes", + ProfilesSource : "profiles", + + /** + * Profile Resource Type + * + * @property ProfilesResourceType + * @type String + * @for sbt.connections.FollowedResource + */ + + ProfilesResourceType : "profile", /** - * API call for searching IBM Connections to find content that, for example, contains a specific text - * string in its title or content, or is tagged with a specific tag. + * Wikis Source + * + * @property WikisSource + * @type String + * @for sbt.connections.FollowedResource */ - AtomSearch : "/${search}/atom/search", + WikisSource : "wikis", + + /** + * Wiki Resource Type + * + * @property WikiResourceType + * @type String + * @for sbt.connections.FollowedResource + */ + WikiResourceType : "wiki", /** - * API call for searching IBM Connections to find content that, for example, contains a specific text - * string in its title or content, or is tagged with a specific tag. + * WikiPage Resource Type + * + * @property WikiPageResourceType + * @type String + * @for sbt.connections.FollowedResource */ - AtomMySearch : "/${search}/atom/mysearch", + WikiPageResourceType : "wiki_page", - /** - * These API's are all deprecated + /** + * Tags Source + * + * @property TagsSource + * @type String + * @for sbt.connections.FollowedResource + */ + TagsSource : "tags", + + /** + * Tag Resource Type + * + * @property TagResourceType + * @type String + * @for sbt.connections.FollowedResource + */ + TagResourceType : "tag", + + + /** + * Get the followed resources feed + * + * @method getFollowedResources + * @param {String} source String specifying the resource. Options are: + * + * activities + * blogs + * communities + * files + * forums + * profiles + * wikis + * tags + * + * @param {String} resourceType String representing the resource type. Options are: + * + * If source=activities + * activity + * + * If source=blogs + * blog + * + * If source=communities + * community + * + * If source=files + * file + * file_folder + * + * + * If source=forums + * forum + * forum_topic + * + * + * If source=profiles + * profile + * + * If source=wikis + * wiki + * wiki_page + * + * + * If source=tags + * tag + * + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of members of a + * community. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + FollowedResourceFeedXPath : conn.ConnectionsFeedXPath, + + /** + * XPath expressions to be used when reading a followed resource entry + */ + FollowedResourceXPath : lang.mixin({}, conn.AtomEntryXPath, { + followedResourceUuid : "a:id", + categoryType : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", + source : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/source']/@term", + resourceType : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-type']/@term", + resourceId : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-id']/@term", + relatedUrl : "a:link[@rel='related']/@href" + }), + + /** + * XPath expressions to be used when reading a followed resource entry + */ + OneFollowedResourceXPath : lang.mixin({}, conn.AtomEntryXPath, { + entry : "/a:feed/a:entry", + followedResourceUuid : "a:id", + categoryType : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", + source : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/source']/@term", + resourceType : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-type']/@term", + resourceId : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/resource-id']/@term", + relatedUrl : "a:link[@rel='related']/@href" + }), + + /** + * Get, follow or stop following a resource. */ - publicSearch : "/${search}/atom/search/results", - mySearch : "/${search}/atom/mysearch/results", - peopleSearch : "/${search}/atom/search/facets/people", - myPeopleSearch : "/${search}/atom/mysearch/facets/people", - tagsSearch : "/${search}/atom/search/facets/tags", - myTagsSearch : "/${search}/atom/mysearch/facets/tags", - dateSearch : "/${search}/atom/search/facets/date", - myDateSearch : "/${search}/atom/mysearch/facets/date", - sourceSearch : "/${search}/atom/search/facets/source", - mySourceSearch : "/${search}/atom/mysearch/facets/source" + AtomFollowAPI : "/{service}/follow/atom/resources", - + /** + * Get, follow or stop following a resource. + */ + AtomStopFollowAPI : "/{service}/follow/atom/resources/{resourceId}" }); }); }, -'sbt/IWidget':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ - -/** - * Social Business Toolkit SDK - iWidget specific helpers. - */ -define([],function() { - -sbt.getUserPref = function(ns,name) { - -}; - -}); -}, -'sbt/smartcloud/controls/profiles/ProfilePanel':function(){ -require({cache:{ -'url:sbt/smartcloud/controls/profiles/templates/ProfilePanel.html':"<div class=\"lotusColLeft\">\r\n\t<div class=\"lotusSection\">\r\n\t\t<div class=\"\">\r\n\t\t\t<img src=\"${getThumbnailUrl}\" alt=\"${getThumbnailAlt}\" class=\"lldbd-personImg\">\r\n\t\t</div>\r\n\t\t<div class=\"lotusChunk lldbd-chunk\">\r\n\t\t\t<div class=\"lldbd-personInfo\">\r\n\t\t\t\t<a class=\"lldbd-personInfoLink\" href=\"${getProfileUrl}\">${getDisplayName}</a>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"lldbd-personInfo\">\r\n\t\t\t\t<span class=\"lldbd-personInfoLink lldbd-personInfoOrgLink\">${getAbout}</span>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</div>\r\n</div>"}}); +'sbt/store/parameter':function(){ /* * © Copyright IBM Corp. 2013 * @@ -18842,89 +13829,98 @@ require({cache:{ */ /** - * @module sbt.connections.controls.profiles.ProfilePanel + * */ -define(["../../../declare", "../../../lang", "../../../config", - "../../../smartcloud/ProfileService", - "../../../controls/panel/_ProfilePanel", - "../../../text!sbt/smartcloud/controls/profiles/templates/ProfilePanel.html"], - function(declare, lang, config, ProfileService, _ProfilePanel, PanelTmpl) { - - var getUserIdentity = "/manage/oauth/getUserIdentity"; - - /** - * @module sbt.connections.controls.profiles.ProfilePanel - */ - var ProfilePanel = declare([ _ProfilePanel ], { - - template: PanelTmpl, - profileService: null, - - constructor: function(args) { +define(["../stringUtil", "../config"], function(stringUtil, config) { + var Formatter = { + defaultFormat: function(param, val) { + return param.key + "=" + val; }, - - getMyProfile: function() { - var path = getUserIdentity; - - if (this.userid) { - this.getProfile(this.userid); - } else { - var self = this; - var endpoint = this._getEndpoint(); - endpoint.request(path, { handleAs : "json", preventCache : true }).then( - function(response) { - var userid = response.subscriberid; - self.getProfile(userid); - }, - function(error) { - self._displayError(error); - } - ); - } + sortField: function(vals) { + return function(param, val) { + var v = vals[val] || ""; + return param.key + "=" + v; + }; }, - getProfile: function(id) { - var self = this; - var promise = this._getProfileService().getProfile(id); - promise.then( - function(profile) { - self.profile = profile; - self.showProfile(); - }, - function(error) { - self.profile = null; - self._displayError(error); - } - ); + ascSortOrderBoolean: function(param, val) { + var v = (val === "asc") ? true : false; + return param.key + "=" + v; }, - // Internals - - _getProfileService: function() { - if (!this.profileService) { - this.profileService = new ProfileService(this._getEndpointName()); - } - return this.profileService; + sortOrder: function(param,val){ + return param.key + "=" + val; }, - _getEndpoint: function() { - return config.findEndpoint(this._getEndpointName()); + oneBasedInteger: function(param, val) { + var v = Math.floor(val); + if(v < 1) { + v = 1; + } + return param.key + "=" + v; }, - _getEndpointName: function() { - return this.endpoint || "smartcloud"; + zeroBaseInteger: function(param, val) { + var v = Math.floor(val); + if(v < 0) { + v = 0; + } + return param.key + "=" + v; } - - }); + + }; - return ProfilePanel; + + var Parameter = function(args) { + var self = this; + this.key = args.key; + var formatFunc = args.format || Formatter.defaultFormat; + this.format = function(val) { + return formatFunc(self, val); + }; + }; + + + return { + defaultFormat: function (key){ + return new Parameter({key: key, format: Formatter.defaultFormat}); + }, + + sortField: function(key, sortVals){ + return new Parameter({key: key, format: Formatter.sortField(sortVals)}); + }, + + sortOrder: function(key){ + return new Parameter({key: key, format: Formatter.sortOrder}); + }, + + booleanSortOrder: function (key){ + return new Parameter({key: key, format: Formatter.ascSortOrderBoolean}); + }, + + /** + * + * @param key + * @returns + */ + zeroBasedInteger : function(key) { + return new Parameter({ key: key, format: Formatter.zeroBasedInteger }); + }, + + /** + * + * @param key + * @returns + */ + oneBasedInteger : function(key) { + return new Parameter({ key: key, format: Formatter.oneBasedInteger }); + } + }; }); + }, -'sbt/controls/grid/bootstrap/GridRendererMixin':function(){ -require({cache:{ -'url:sbt/controls/grid/bootstrap/templates/GridPager.html':"<div class=\"\" dojoAttachPoint=\"pagingHeader\">\r\n\t<ul class=\"pager\">\r\n\t\t<li>\r\n\t\t\t<a style=\"${hidePreviousLink}\" title=\"${nls.previousPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: prevPage\">${nls.previous}</a>\r\n\t\t\t<span style=\"${hidePreviousLabel}\">${nls.previous}</span>\r\n\t\t</li>\r\n\t\t<li>\r\n\t\t\t<span>${pagingResults}</span>\r\n\t\t</li>\r\n\t\t<li>\r\n\t\t\t<a style=\"${hideNextLink}\" title=\"${nls.nextPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: nextPage\">${nls.next}</a>\r\n\t\t\t<span style=\"${hideNextLabel}\">${nls.next}</span>\r\n\t\t</li>\r\n\t</ul>\r\n\t<div>\r\n\t\t<div dojoAttachPoint=\"catCenterPagingTop\"></div>\r\n\t</div>\r\n</div>\r\n\r\n\r\n", -'url:sbt/controls/grid/bootstrap/templates/GridSorter.html':"<div class=\"navbar\">\r\n\t<div class=\"navbar-inner\">\r\n\t\t<a class=\"brand\" href=\"#\">${nls.sortBy}</a>\r\n\t\t<ul class=\"nav\">\r\n\t\t\t${sortAnchors}\r\n\t\t</ul>\r\n\t</div>\r\n</div>", -'url:sbt/controls/grid/bootstrap/templates/SortAnchor.html':"<li>\r\n\t<a href=\"javascript:\" data-dojo-attach-event=\"onclick: ${sortMethod}\" class=\"\"><i class=\"${sortAnchorClass}\"></i> ${title}</a>\r\n</li>"}}); +'url:sbt/connections/controls/profiles/templates/SharedConnectionsRow.html':"<tr class=\"lotusFirst\">\r\n\t<td class=\"lotusLastCell\">\r\n\t\t<h3>Connections Shared By Frank Adams & Amy Blanks</h3>\r\n\t\t<h4 class=\"lotusTitle\">\r\n\t\t\t<a href=\"javascript:;\">${sharedColleagueName}</a>\r\n\t\t</h4>\r\n\t\t\r\n\t\t<p>${sharedColleagueEmail}</p>\r\n\t</td>\r\n\r\n</tr>", +'sbt/Promise':function(){ /* * © Copyright IBM Corp. 2013 * @@ -18942,223 +13938,182 @@ require({cache:{ */ /** + * Social Business Toolkit SDK. * + * @module sbt.Promise */ -define([ "../../../text!./templates/GridPager.html", - "../../../text!./templates/GridSorter.html", - "../../../text!./templates/SortAnchor.html" ], - function(GridPager, GridSorter, SortAnchor) { +define(["./declare","./log"], function(declare,log) { /** - * @module sbt.controls.grid.bootstrap.GridRendererMixin - */ - return { - tableClass : "table table-striped table-bordered", - emptyClass : "label label-info", - errorClass : "label label-warning", - loadingClass : "label label-info", - loadingImgClass : "icon-refresh", - firstClass : "", - defaultSortClass : "icon-arrow-down", - ascendingSortClass : "icon-arrow-up", - descendingSortClass : "icon-arrow-down", - pagerTemplate : GridPager, - sortTemplate : GridSorter, - sortAnchor : SortAnchor - }; - -}); -}, -'sbt/xsl':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. + * Promise class + * + * @class Promise + * @namespace sbt + */ + var Promise = declare(null, { + + // private + _isRejected : false, + _isFulfilled : false, + _isCanceled : false, + _deferreds : null, + response : null, + error : null, + + /* + * Constructor for the promise. + */ + constructor: function(response) { + if (response) { + if (response instanceof Error) { + this.rejected(response); + } else { + this.fulfilled(response); + } + } else { + this._deferreds = []; + } + }, + + /* + * Add new callbacks to the promise. + */ + then: function(fulfilledHandler, errorHandler) { + var promise = new Promise(); + if (this._isFulfilled) { + this._fulfilled(fulfilledHandler, errorHandler, promise, this.data); + } else if (this._isRejected) { + this._rejected(errorHandler, promise, this.error); + } else { + this._deferreds.push([ fulfilledHandler, errorHandler, promise ]); + } + return promise; + }, - * Social Business Toolkit SDK - XSL utilities. - * Borrowed from the Connections source code, for now - */ + /* + * Inform the deferred it may cancel its asynchronous operation. + */ + cancel: function(reason, strict) { + this._isCanceled = true; + }, -/** - * @module sbt.xsl - */ -define(['./Cache','./xml','./lang'],function(cache,sbtml,lang) { - return { - - /** - * Transform an XML document using an XSL stylesheet. - * The XML document can be either a string or an actual DOM document. In case of a - * string, if it starts with "http", then the string is read from the URL. Then, it - * is parsed to a DOM document. - * The XSL must be a string - */ - xsltTransform: function(xml,xsl) { - if(!xml) return null; - - // Resolve the XML if it is a URL - if(lang.isString(xml)) { - xml = sbtml.parse(sbt.cache.get(xml)); - } - - // Resolve the XSL if it is a URL - if(!xsl) return lang.clone(xml); - xsl = sbt.cache.get(xsl); - - // Run the transformation - if(window.ActiveXObject) { - return xml.transformNode(xsl); - } else if(document.implementation && document.implementation.createDocument) { - var xslt = new XSLTProcessor(); - xslt.importStyleSheet(xsl); - return xslt.transformToFragment(xml,document); - } - - // No XSLT engine is available, just return the document as is - return lang.clone(xml); - } - }; -}); -}, -'sbt/widget/grid/_Grid':function(){ -require({cache:{ -'url:sbt/controls/grid/templates/Grid.html':"<div dojoAttachPoint=\"gridNode\" role=\"main\"></div>\r\n"}}); -/* - * © Copyright IBM Corp. 2014 - * - * 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. - */ + /* + * Checks whether the promise has been resolved. + */ + isResolved: function() { + return this._isRejected || this._isFulfilled; + }, -/** - * - */ -define([ "../../declare", "../../store/AtomStore", "dojo/_base/lang", "dojo/_base/Deferred", - "../../widget/_TemplatedWidget", "../../text!../../controls/grid/templates/Grid.html"], - function(declare, AtomStore, lang, Deferred, _TemplatedWidget, GridTemplate) { + /* + * Checks whether the promise has been rejected. + */ + isRejected: function() { + return this._isRejected; + }, - /* - * @module sbt._bridge.grid._Grid - */ - var _Grid = declare([ _TemplatedWidget ], { + /* + * Checks whether the promise has been resolved or rejected. + */ + isFulfilled: function() { + return this._isFulfilled; + }, - templateString: GridTemplate, - /* - * Creates an instance of an atom store. + * Checks whether the promise has been canceled. */ - _createDefaultStore: function(args) { - return new AtomStore(args); - }, + isCanceled: function() { + return this._isCanceled; + }, + + /* + * Called if the promise has been fulfilled + */ + fulfilled : function(data) { + if (this._isCanceled) { + return; + } + + this._isFulfilled = true; + this.data = data; + + if (this._deferreds) { + while (this._deferreds.length > 0) { + var deferred = this._deferreds.shift(); + var fulfilledHandler = deferred[0]; + var errorHandler = deferred[1]; + var promise = deferred[2]; + this._fulfilled(fulfilledHandler, errorHandler, promise, data); + } + } + }, - /* - * Retrieves the data from the Atom Store + /* + * Call if the promise has been rejected */ - _doQuery: function(store, options, query) { - query = query || {}; - var self = this; - var errCallback = lang.hitch(this, this._updateWithError); - var results = store.query(query, options); + rejected : function(error) { + if (this._canceled) { + return; + } - Deferred.when(results.total, function(totalCount) { - Deferred.when(results, function(items) { - self.data = { - items : items, - start : options.start, - end : options.start + items.length, - count : items.length, - totalCount : totalCount, - response : results.response - }; - try { - self.renderer.render(self, self.gridNode, items, self.data); - self.onUpdate(self.data); - } catch (error) { - self.renderer.renderError(self, self.gridNode, error); - } - return results; - }, errCallback); - }, errCallback); - } - - }); - - return _Grid; -}); -}, -'sbt/connections/controls/forums/BackAction':function(){ -/* - * © 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. - */ - -define([ "../../../declare", "../../../controls/grid/GridAction","../../../i18n!./nls/ForumGridRenderer"], - function(declare, GridAction, nls) { - - /** - * @class BackAction - * @namespace sbt.connections.controls.forum - * @module sbt.connections.controls.forum.BackAction - */ - var BackAction = declare(GridAction, { - - - /**ForumAction Constructor function - * @method constructor - * */ - constructor: function(args) { - + this._isRejected = true; + this.error = error; + + if (this._deferreds) { + while (this._deferreds.length > 0) { + var deferred = this._deferreds.shift(); + var errorHandler = deferred[1]; + var promise = deferred[2]; + this._rejected(errorHandler, promise, error); + } + } + }, + + _fulfilled : function(fulfilledHandler, errorHandler, promise, data) { + if (fulfilledHandler) { + try { + var retval = fulfilledHandler(data); + if (retval instanceof Promise) { + retval.then( + function(data) { + promise.fulfilled(data); + }, + function(error) { + promise.rejected(error); + } + ); + } else { + promise.fulfilled(retval); + } + } catch (error) { + promise.rejected(error); + } + } else { + promise.fulfilled(data); + } }, - showForums: function(item, grid, event){ - var options = { - start: grid.data.start, count: grid.pageSize - }; - grid.getForums(options); - }, - showTopics: function(item, grid, event){ - var options = { - start: grid.data.start, count: grid.pageSize - }; - grid.getTopics("",options); + _rejected : function(errorHandler, promise, error) { + if (errorHandler) { + try { + var retval = errorHandler(error); + if (!retval) { + // stop propogating errors + promise.rejected(retval); + } + } catch (error1) { + promise.rejected(error1); + } + } else { + promise.rejected(error); + } } - - }); - - return BackAction; + + }); + return Promise; }); }, -'url:sbt/connections/controls/profiles/templates/ViewAll.html':"<table width=\"100%\" style=\"margin-top: 5px;\">\r\n <tbody>\r\n <tr>\r\n <td style=\"text-align: ${countAlign}; vertical-align: ${verticalAlign}; width: 100%;\">\r\n <span>\r\n <a class=\"lotusAction\" href=\"javascript:void(0);\" data-dojo-attach-event=\"onclick: handleViewAll\">${viewAllTitle}</a>\r\n </span>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>", -'sbt/connections/ForumService':function(){ +'url:sbt/smartcloud/controls/profiles/templates/ProfileRow.html':"<tr class=\"${rowClass}\">\r\n\t<td align=\"center\" style=\"width: 40px; padding-top: 5px;\">\r\n\t\t<input id=\"${uid}\" name=\"${uid}\" value=\"${uid}\" data-dojo-attach-event=\"onclick: handleCheckBox\" type=\"checkbox\" aria-label=\"${name}\"></input>\r\n\t</td>\r\n\t<td style=\"width: 70px\" class=\"lotusFirstCell\">\r\n\t\t<img width=\"55\" height=\"55\" src=\"${photoUrl}\" alt=\"\" class=\"photo\">\r\n\t</td>\r\n\t<td style=\"width: 40%\">\r\n\t\t<h1>\r\n\t\t\t<span class=\"vcard lotusBreakWord\"> \r\n\t\t\t\t<span class=\"fn\" semtag_refcnt=\"1\" semtag_live_id=\"1\" semtag_hover_idx=\"1\" id=\"semtag_live_1\">\r\n\t\t\t\t\t<a href=\"${profileUrl}\" id=\"\">${name}</a>\r\n\t\t\t\t</span>\r\n\t\t\t\t<!-- \r\n\t\t\t\t<a class=\"menu_drop_icon\" href=\"javascript:void()\" title=\"Business card for ${name}\">\r\n\t\t\t\t\t<span class=\"lotusAltText\">â–¼</span>\r\n\t\t\t\t</a> \r\n\t\t\t\t<span style=\"display: none;\" class=\"uid\">${uid}</span>\r\n\t\t\t\t -->\r\n\t\t\t</span>\r\n\t\t</h1>\r\n\t\t<div>\r\n\t\t\t<div class=\"llnowrap\">\r\n\t\t\t\t<span>${title}</span>\r\n\t\t\t\t<a href=\"/contacts/orgprofiles/partnerPage/${uid}\">${orgName}</a>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"lotusBreakWord\">${address}</div>\r\n\t\t</div>\r\n\t</td>\r\n\t<td style=\"width: 30%\" class=\"llCntConnection\">\r\n\t\t<span class=\"lotusConfirm lotusMeta connections llConnectionStatus\">\r\n\t\t\t<strong>Network Contact</strong>\r\n\t\t</span>\r\n\t</td>\r\n\t<td style=\"width: 30%\" class=\"lotusLastCell\">\r\n\t\t<div>\r\n\t\t\t<label>Primary telephone</label> <strong>${primaryTelephone}</strong>\r\n\t\t</div>\r\n\t\t<div>\r\n\t\t\t<label>Primary email</label> \r\n\t\t\t<strong><a href=\"mailto:${email}\">${email}</a></strong>\r\n\t\t</div>\r\n\t</td>\r\n</tr>\r\n", +'sbt/connections/controls/communities/CommunityMembersAction':function(){ /* * © Copyright IBM Corp. 2013 * @@ -19176,6057 +14131,6374 @@ define([ "../../../declare", "../../../controls/grid/GridAction","../../../i18n! */ /** - * The Forums application of IBM© Connections enables a team to discuss issues that are pertinent to their work. - * The Forums API allows application programs to create new forums, and to read and modify existing forums. * - * @module sbt.connections.ForumService */ -define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./ForumConstants", "./ConnectionsService", "../base/AtomEntity", "../base/XmlDataHandler" ], - function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler) { - - var CategoryForum = "<category scheme=\"http://www.ibm.com/xmlns/prod/sn/type\" term=\"forum-forum\"></category>"; - var CategoryTopic = "<category scheme=\"http://www.ibm.com/xmlns/prod/sn/type\" term=\"forum-topic\"></category>"; - var CategoryReply = "<category scheme=\"http://www.ibm.com/xmlns/prod/sn/type\" term=\"forum-reply\"></category>"; - var CategoryRecommendation = "<category scheme=\"http://www.ibm.com/xmlns/prod/sn/type\" term=\"recommendation\"></category>"; - - var CommunityTmpl = "<snx:communityUuid xmlns:snx=\"http://www.ibm.com/xmlns/prod/sn\">${getCommunityUuid}</snx:communityUuid>"; - var TopicTmpl = "<thr:in-reply-to xmlns:thr=\"http://purl.org/syndication/thread/1.0\" ref=\"urn:lsid:ibm.com:forum:${getForumUuid}\" type=\"application/atom+xml\" href=\"\"></thr:in-reply-to>"; - var ReplyTmpl = "<thr:in-reply-to xmlns:thr=\"http://purl.org/syndication/thread/1.0\" ref=\"urn:lsid:ibm.com:forum:${getTopicUuid}\" type=\"application/atom+xml\" href=\"\"></thr:in-reply-to>"; - var FlagTmpl = "<category scheme=\"http://www.ibm.com/xmlns/prod/sn/flags\" term=\"${flag}\"></category>"; - - /** - * Forum class represents an entry from a Forums feed returned by the - * Connections REST API. - * - * @class Forum - * @namespace sbt.connections - */ - var Forum = declare(AtomEntity, { - - xpath : consts.ForumXPath, - contentType : "html", - categoryScheme : CategoryForum, - - /** - * Construct a Forum entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, +define( + [ "../../../declare", "../../../controls/grid/GridAction", + "sbt/connections/CommunityService", + "sbt/connections/CommunityConstants" ], - /** - * Return extra entry data to be included in post data for this entity. - * - * @returns {String} - */ - createEntryData : function() { - if (!this.getCommunityUuid()) { - return ""; - } - var transformer = function(value,key) { - return value; - }; - var postData = stringUtil.transform(CommunityTmpl, this, transformer, this); - return stringUtil.trim(postData); - }, + function(declare, GridAction, CommunityService, CommunityConstants) { - /** - * Return the value of id from Forum ATOM - * entry document. - * - * @method getForumUuid - * @return {String} ID of the Forum - */ - getForumUuid : function() { - var uid = this.getAsString("forumUuid"); - return extractForumUuid(uid); - }, + /** + * @class ProfileAction + * @namespace sbt.connections.controls.communities + * @module sbt.connections.controls.communities.CommunityMembersAction + */ + var CommunityMembersAction = declare( + GridAction, + { - /** - * Sets id of IBM Connections forum. - * - * @method setForumUuid - * @param {String} forumUuid Id of the forum - */ - setForumUuid : function(forumUuid) { - return this.setAsString("forumUuid", forumUuid); - }, + /** Strings used in the actions */ + nls : { + tooltip : "Go to ${name}" + }, - /** - * Return the value of communityUuid from Forum ATOM - * entry document. - * - * @method getCommunityUuid - * @return {String} Uuid of the Community - */ - getCommunityUuid : function() { - return this.getAsString("communityUuid"); - }, + /** + * ProfileAction Constructor function + * + * @method constructor + */ + constructor : function() { + }, - /** - * Sets communityUuid of IBM Connections forum. - * - * @method setCommunityUuid - * @param {String} communityUuid Community Uuid of the forum - */ - setCommunityUuid : function(communityUuid) { - return this.setAsString("communityUuid", communityUuid); - }, + /** + * Handles displaying a tooltip for an item For + * profiles, the tooltip by default will be a business + * card So nothing is done in this function + * + * @method getTooltip + * @param item + * The element that will use the tooltip + */ + getTooltip : function(item) { + return item.getValue("title"); + }, - /** - * Return the moderation of the IBM Connections forum from - * forum ATOM entry document. - * - * @method getModeration - * @return {String} Moderation of the forum - */ - getModeration : function() { - return this.getAsDate("moderation"); - }, - - /** - * Return the thread count of the IBM Connections forum from - * forum ATOM entry document. - * - * @method getThreadCount - * @return {Number} Thread count of the forum - */ - getThreadCount : function() { - return this.getAsNumber("threadCount"); - }, - - /** - * Return the url of the IBM Connections forum from - * forum ATOM entry document. - * - * @method getForumUrl - * @return {String} Url of the forum - */ - getForumUrl : function() { - return this.getAlternateUrl(); - }, - - /** - * Get a list for forum topics that includes the topics in the specified forum. - * - * @method getTopics - * @param {Object} args - */ - getTopics : function(args) { - return this.service.getTopics(this.getForumUuid(), args); - }, + /** + * The execute function is called from the handle click + * function For Profiles by default the business card + * functionality is used which works from the Semantic + * tag service so nothing is done here. + * + * @method execute + * @param item + * The item which fired the event + * @param opts + * @param event + * The event + */ + execute : function(item, grid, event) { + var url = grid.renderer.getProfileUrl(grid,item.getValue("id")); + window.open(url); + }, - /** - * Return an array containing the tags for this forum. - * - * @method getTags - * @return {Array} - */ - getTags : function() { - return this.getAsArray("tags"); - }, - - /** - * Return an array containing the tags for this forum. - * - * @method setTags - * @param {Array} - */ - setTags : function(tags) { - return this.setAsArray("tags", tags); - }, - - /** - * Loads the forum object with the atom entry associated with the - * forum. By default, a network call is made to load the atom entry - * document in the forum object. - * - * @method load - * @param {Object} [args] Argument object - */ - load : function(args) { - // detect a bad request by validating required arguments - var forumUuid = this.getForumUuid(); - var promise = this.service._validateForumUuid(forumUuid); - if (promise) { - return promise; - } + /** + * The removeMember function is called from the + * removeMember function and removes members from the + * community specified by currentCommunity + * + * @method removeMember + * @param grid + * The grid to update after the member has + * been removed. + * @param communityService + * The community service instance used to + * remove the member. + * @param currentCommunity + * The ID of the community from which to + * remove the member. + * @param data + * The data row from which the event was + * fired. + */ + removeMember : function(grid, currentCommunity, data) { + _removeMember(grid, currentCommunity, data); + }, + + /** + * Updates a community member. + * + * @method updateMember + * @param grid + * The grid to update. + * @param el + * the element that fired the event + * @param data + * all of the items from the current row of + * the grid. + * @param ev + * the event + * @param grid + * The grid to update after the member has + * been removed. + * + * @param communityUuid + * The ID of the community from which to + * remove the member. + * @param data + * The data row from which the event was + * fired. + */ + updateMember : function(grid, el, data, ev, communityUuid) { + var communityService = new CommunityService(); + var rbOwnerId = "rbOwner" + data.uid; + var rbOwner = document.getElementById(rbOwnerId); + communityService.getMembers(communityUuid).then( + function(members) { + for ( var i = 0; i < members.length; i++) { + var member = members[i]; + if (member.getUserid() == data.uid) { + if (rbOwner.checked) { + member.setRole(CommunityConstants.Owner); + } else { + member.setRole(CommunityConstants.Member); + } - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - self.setData(data); - return self; - } - }; + // Update community + var promise = communityService.updateMember( + communityUuid, member); + + promise.then(function(data) { + grid.update(null); + }, function(error) { + console.log(error); + }); + break; + } + } + }, function(error) { + console.log(error); + }); + }, + + /** + * Closes the edit form. + * + * @method removeMember + * @param grid + * The grid to update. + * @param el + * the element that fired the event + * @param data + * all of the items from the current row of + * the grid. + * @param ev + * the event + * @param grid + * The grid to update after the member has + * been removed. + * @param data + * The data row from which the event was + * fired. + */ + closeEditForm : function(grid, el, data, ev) { + var id = "editTable" + data.uid; + document.getElementById(id).style.display = "none"; + }, + + /** + * Opens the edit form. + * + * @method openEditForm + * @param data + * The data row from which the event was + * fired. + */ + openEditForm : function(data) { + var id = "editTable" + data.uid; + document.getElementById(id).style.display = "block"; + }, + - var requestArgs = lang.mixin({ - forumUuid : forumUuid - }, args || {}); - var options = { - handleAs : "text", - query : requestArgs - }; - - return this.service.getEntity(consts.AtomForum, options, forumUuid, callbacks); - }, + /** + * Removes a community member. + * + * @method removeMember + * @param grid + * The grid to update. + * @param el + * the element that fired the event + * @param data + * all of the items from the current row of + * the grid. + * @param ev + * the event + * @param grid + * The grid to update after the member has + * been removed. + * + * @param communityUuid + * The ID of the community from which to + * remove the member. + * @param data + * The data row from which the event was + * fired. + */ + removeMember : function(grid, el, data, ev, communityUuid) { + var communityService = new CommunityService(); - /** - * Remove this forum - * - * @method remove - * @param {Object} [args] Argument object - */ - remove : function(args) { - return this.service.deleteForum(this.getForumUuid(), args); - }, + communityService.getMembers(currentCommunity).then( + function(members) { + for (var i = 0; i < members.length; i++) { + var member = members[i]; + if (member.getUserid() == data.uid) { + // Remove member + communityService.getCommunity(currentCommunity).then( + function(community) { + community.removeMember(member.getUserid(), {}).then( + function(memberId) { + grid.update(null); + el.parentNode.removeChild(container); + }, + function(error) { + console.log(error); + }); + }, + function(error) { + console.log(error); + }); + break; + } + } + }, function(error) { + console.log(error); + }); + } + }); + return CommunityMembersAction; + }); - /** - * Update this forum - * - * @method update - * @param {Object} [args] Argument object - */ - update : function(args) { - return this.service.updateForum(this, args); - }, - - /** - * Save this forum - * - * @method save - * @param {Object} [args] Argument object - */ - save : function(args) { - if (this.getForumUuid()) { - return this.service.updateForum(this, args); - } else { - return this.service.createForum(this, args); - } - } - - }); - - /** - * ForumTopic class represents an entry for a forums topic feed returned by the - * Connections REST API. - * - * @class ForumTopic - * @namespace sbt.connections - */ - var ForumTopic = declare(AtomEntity, { +}, +'sbt/connections/WikiConstants':function(){ +/* + * © 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. + */ +/** + * Social Business Toolkit SDK. + * Definition of constants for WikiService. + */ +define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - xpath : consts.ForumTopicXPath, - contentType : "html", - categoryScheme : CategoryTopic, + /** + * XPath expressions to be used when reading a wiki or wiki page entry + */ + var BaseWikiXPath = lang.mixin({ + uuid : "td:uuid", + label : "td:label", + permissions : "td:permissions", + tags : "a:category[not(@scheme)]/@term", + modifierName : "td:modifier/a:name", + modifierEmail : "td:modifier/a:email", + modifierUserid : "td:modifier/snx:userid", + modifierUserState : "td:modifier/snx:userState", + created : "td:created", + modified : "td:modified", + member : "ca:member", + memberId : "ca:member/@ca:id", + memberType : "ca:member/@ca:type", + memberRole : "ca:member/@ca:role" + }, conn.AtomEntryXPath); + + return lang.mixin(conn, { /** - * Construct a ForumTopic entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Return extra entry data to be included in post data for this entity. - * - * @returns {String} + * XPath expressions used when parsing a Connections Wiki ATOM feed */ - createEntryData : function() { - var entryData = ""; - if (this.isPinned()) { - entryData += stringUtil.transform(FlagTmpl, this, function(v,k) { return consts.FlagPinned; }, this); - } - if (this.isLocked()) { - entryData += stringUtil.transform(FlagTmpl, this, function(v,k) { return consts.FlagLocked; }, this); - } - if (this.isQuestion()) { - entryData += stringUtil.transform(FlagTmpl, this, function(v,k) { return consts.FlagQuestion; }, this); - } - return stringUtil.trim(entryData); - }, + WikiFeedXPath : conn.ConnectionsFeedXPath, /** - * Return the value of id from Forum Topic ATOM - * entry document. - * - * @method getTopicUuid - * @return {String} ID of the Forum Topic + * XPath expressions to be used when reading a wiki entry */ - getTopicUuid : function() { - var uid = this.getAsString("topicUuid"); - return extractForumUuid(uid); - }, - + WikiXPath : lang.mixin({ + communityUuid : "snx:communityUuid", + themeName : "td:themeName", + librarySize : "td:librarySize", + libraryQuota : "td:libraryQuota", + totalRemovedSize : "td:totalRemovedSize" + }, BaseWikiXPath, conn.AtomEntryXPath), + /** - * Sets id of IBM Connections Forum Topic. - * - * @method setTopicUuid - * @param {String} topicUuid Id of the forum topic + * XPath expressions to be used when reading a wiki page entry */ - setTopicUuid : function(topicUuid) { - return this.setAsString("topicUuid", topicUuid); - }, - - getTopicTitle: function(){ - return this.getAsString("topicTitle"); - }, + WikiPageXPath : lang.mixin({ + lastAccessed : "td:lastAccessed", + versionUuid : "td:versionUuid", + versionLabel : "td:versionLabel", + propagation : "td:propagation", + totalMediaSize : "td:totalMediaSize", + recommendations : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", + comment : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/comment']", + hit : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/hit']", + anonymous_hit : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/anonymous_hit']", + share : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/share']", + collections : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/collections']", + attachments : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/attachments']", + versions : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/versions']" + }, BaseWikiXPath, conn.AtomEntryXPath), - setTopicTitle: function(title){ - return this.setAsString("topicTitle", title); - }, - - /** - * Return the value of IBM Connections forum ID from forum ATOM - * entry document. - * - * @method getForumUuid - * @return {String} Forum ID of the forum + /** + * This returns a feed of wikis to which the authenticated user has access. */ - getForumUuid : function() { - var uid = this.getAsString("forumUuid"); - return extractForumUuid(uid); - }, - - /** - * Sets id of IBM Connections forum. - * - * @method setForumUuid - * @param {String} forumUuid Id of the forum + WikisAll : "/{wikis}/{authType}/api/wikis/feed", + + /** + * This returns a feed of wikis to which everyone who can log into the Wikis application has access. */ - setForumUuid : function(forumUuid) { - return this.setAsString("forumUuid", forumUuid); - }, - - /** - * Return the value of communityUuid from Forum ATOM - * entry document. - * - * @method getCommunityUuid - * @return {String} Uuid of the Community + WikisPublic : "/{wikis}/{authType}/api/wikis/public", + + /** + * This returns a feed of wikis of which the authenticated user is a member. */ - getCommunityUuid : function() { - return this.getAsString("communityUuid"); - }, - - /** - * Sets communityUuid of IBM Connections forum. - * - * @method setCommunityUuid - * @param {String} communityUuid Community Uuid of the forum - * @return {ForumTopic} + WikisMy : "/{wikis}/{authType}/api/mywikis/feed", + + /** + * This returns a feed of wikis to which everyone who can log into the Wikis application has access. */ - setCommunityUuid : function(communityUuid) { - return this.setAsString("communityUuid", communityUuid); - }, - - /** - * Return the url of the IBM Connections forum from - * forum ATOM entry document. - * - * @method getTopicUrl - * @return {String} Url of the forum + WikisMostCommented : "/{wikis}/{authType}/anonymous/api/wikis/mostcommented", + + /** + * This returns a feed of wikis to which everyone who can log into the Wikis application has access. */ - getTopicUrl : function() { - return this.getAsString("alternateUrl"); - }, - - /** - * Return the permissions of the IBM Connections forum topic from - * forum ATOM entry document. - * - * @method getPermisisons - * @return {String} Permissions of the forum topic + WikisMostRecommended : "/{wikis}/{authType}/api/wikis/mostrecommended", + + /** + * This returns a feed of wikis to which everyone who can log into the Wikis application has access. */ - getPermisisons : function() { - return this.getAsString("permissions"); - }, - - /** - * True if you want the topic to be added to the top of the forum thread. - * - * @method isPinned - * @return {Boolean} + WikisMostVisited : "/{wikis}/{authType}/api/wikis/mostvisited", + + /** + * This returns a feed of the pages in a given wiki. */ - isPinned : function() { - var terms = this.getAsArray("categoryTerm"); - var pinned = consts.FlagPinned; - - if(lang.isArray(terms)){ - for(var i=0;i<terms.length;i++){ - if(terms[i].indexOf(pinned) != -1){ - return true; - } - } - }else if(lang.isString(terms)){ - if(terms.indexOf(pinned) != -1){ - return true; - } - }else{ - return false; - } - }, + WikiPages : "/{wikis}/{authType}/anonymous/api/wiki/{wikiLabel}/feed", - /** - * Set to true if you want the topic to be added to the top of the forum thread. - * - * @method setPinned - * @param pinned - * @return {ForumTopic} + /** + * Get a feed that lists all of the pages in a specific wiki that have been added or edited by the authenticated user. */ - setPinned : function(pinned) { - var terms = this.getAsArray("categoryTerm"); - if(pinned){ - if(terms){ - terms.push(consts.setPinned); - }else{ - this.setAsArray("categoryTerm",consts.setPinned ); - } - - }else{ - if(terms){ - var pinned = consts.FlagPinned; - for(var i=0;i<terms.length;i++){ - if(terms[i].indexOf(pinned) !=-1){ - terms.splice(i,1); - } - } - this.setAsArray("categoryTerm",terms); - } - - } - - }, + WikiMyPages : "/{wikis}/{authType}/api/wiki/{wikiLabel}/mypages", - /** - * If true, indicates that the topic is locked. - * - * @method isLocked - * @return {Boolean} + /** + * This returns a feed that lists the pages that have been deleted from wikis and are currently stored in the trash. */ - isLocked : function() { - var terms = this.getAsArray("categoryTerm"); - var locked = consts.FlagLocked; - - if(lang.isArray(terms)){ - for(var i=0;i<terms.length;i++){ - if(terms[i].indexOf(locked) !=-1){ - return true; - } - } - }else if(lang.isString(terms)){ - if(terms.indexOf(locked) !=-1){ - return true; - } - }else{ - return false; - } - - }, + WikiRecycleBin : "/{wikis}/{authType}/anonymous/api/wiki/{wikiLabelOrId}/recyclebin/feed", /** - * Set to true, indicates that the topic is locked. - * - * @method isLocked - * @param located - * @return {ForumTopic} + * Retrieve an Atom document of a wiki. */ - setLocked : function(locked) { - var terms = this.getAsArray("categoryTerm"); - if(locked){ - if(terms){ - terms.push(consts.setLocked); - }else{ - this.setAsArray("categoryTerm",consts.setLocked); - } - - }else{ - if(terms){ - var locked = consts.FlagLocked; - for(var i=0;i<terms.length;i++){ - if(terms[i].indexOf(locked) !=-1){ - terms.splice(i,1); - } - } - this.setAsArray("categoryTerm",terms); - } - - } - }, + WikiEntry : "/{wikis}/{authType}/api/wiki/{wikiLabel}/entry", /** - * If true, indicates that the topic is a question. - * - * @method isQuestion - * @return {Boolean} + * Returns a wiki page after authenticating the request. */ - isQuestion : function() { - var terms = this.getAsArray("categoryTerm"); - var question = consts.FlagQuestion; - - if(lang.isArray(terms)){ - for(var i=0;i<terms.length;i++){ - if(terms[i].indexOf(question) != -1){ - return true; - } - } - }else if(lang.isString(terms)){ - if(terms.indexOf(question) != -1){ - return true; - } - }else{ - return false; - } - }, + WikiPageEntry : "/{wikis}/{authType}/api/wiki/{wikiLabel}/page/{pageLabel}/entry", /** - * Set to true, indicates that the topic is a question. - * - * @method setQuestion - * @param question - * @return {Boolean} + * Post to this feed to create a wiki page. */ - setQuestion : function(question) { - var terms = this.getAsArray("categoryTerm"); - if(question){ - if(terms){ - terms.push(consts.markAsQuestion); - }else{ - this.setAsArray("categoryTerm",consts.markAsQuestion); - } - - }else{ - var questionFlag = consts.FlagQuestion; - if(terms){ - for(var i=0;i<terms.length;i++){ - if(terms[i].indexOf(questionFlag) !=-1){ - terms.splice(i,1); - } - } - - this.setAsArray("categoryTerm",terms); - } - - } - }, + WikiFeed : "/{wikis}/{authType}/api/wiki/{wikiLabel}/feed" + }); +}); +}, +'sbt/base/AtomEntity':function(){ +/* + * © 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. + */ + +/** + * AtomEntity class represents an entry from an IBM Connections ATOM feed. + * + * @module sbt.base.AtomEntity + */ +define([ "../declare", "../lang", "../stringUtil", "./BaseConstants", "./BaseEntity", "./XmlDataHandler" ], + function(declare,lang,stringUtil,BaseConstants,BaseEntity,XmlDataHandler) { + + var EntryTmpl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<entry xmlns=\"http://www.w3.org/2005/Atom\" ${createNamespaces}>" + + "${categoryScheme}${createTitle}${createContent}${createSummary}${createContributor}${createTags}${createEntryData}" + + "</entry>"; + var TitleTmpl = "<title type=\"text\">${title}"; + var ContentTmpl = "${content}"; + var SummaryTmpl = "${summary}"; + var ContributorTmpl = "${contributor}"; + var EmailTmpl = "${email}"; + var UseridTmpl = "${userid}"; + var CategoryTmpl = ""; + + /** + * AtomEntity class represents an entry from an IBM Connections ATOM feed. + * + * @class AtomEntity + * @namespace sbt.base + */ + var AtomEntity = declare(BaseEntity, { + + contentType : "html", + categoryScheme : null, + /** - * If true, indicates that the topic is a question that has been answered. + * Construct an AtomEntity. * - * @method isAnswered - * @return {Boolean} + * @constructor + * @param args */ - isAnswered : function() { - return this.getAsBoolean("answered"); + constructor : function(args) { + if (args.data) { + // create XML data handler + this.dataHandler = this.createDataHandler( + args.service, args.data || null, args.response || null, + args.namespaces || this.namespaces || BaseConstants.Namespaces, + args.xpath || this.xpath || BaseConstants.AtomEntryXPath + ); + } else { + this.service = args.service || this.service; + this.namespaces = args.namespaces || this.namespaces || BaseConstants.Namespaces; + this.xpath = args.xpath || this.xpath || BaseConstants.AtomEntryXPath; + } }, /** - * If true, this forum topic has not been recommended by the current user. + * Create the DataHandler for this entity. * - * @method isNotRecommendedByCurrentUser - * @returns {Boolean} + * @method createDataHandler */ - isNotRecommendedByCurrentUser : function() { - return this.getAsBoolean("notRecommendedByCurrentUser"); + createDataHandler : function(service, data, response, namespaces, xpath) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : namespaces, + xpath : xpath + }); }, /** - * Return an array containing the tags for this forum topic. + * Called to set the entity data after the entity + * was loaded. This will cause the existing fields to be cleared. * - * @method getTags - * @return {Array} + * @param data */ - getTags : function() { - return this.getAsArray("tags"); + setData : function(data, response) { + // create XML data handler + this.dataHandler = this.createDataHandler( + this.service, + data, response || null, + this.namespaces || BaseConstants.Namespaces, + this.xpath || BaseConstants.AtomEntryXPath + ); + + this.inherited(arguments); }, - + /** - * Return an array containing the tags for this forum topic. + * Return the value of id from ATOM entry document. * - * @method setTags - * @param {Array} + * @method getId + * @return {String} ID of the ATOM entry */ - setTags : function(tags) { - return this.setAsArray("tags", tags); + getId : function() { + return this.getAsString("id"); }, - + /** - * Return the recommendations url of the forum topic. + * Return the value of title from ATOM entry document. * - * @method getRecommendationsUrl - * @return {String} Recommendations url + * @method getTitle + * @return {String} ATOM entry title */ - getRecommendationsUrl : function() { - return this.getAsString("recommendationsUrl"); + getTitle : function() { + return this.getAsString("title"); }, /** - * Get a list for forum recommendations that includes the recommendations for this forum topic. + * Sets title of ATOM entry. * - * @method getRecommendations + * @method setTitle + * @param {String} title ATOM entry title */ - getRecommendations : function(args) { - return this.service.getForumRecommendations(this.getTopicUuid(), args); + setTitle : function(title) { + return this.setAsString("title", title); }, /** - * Get a list for forum replies that includes the replies for this forum topic. + * Return the value of summary from ATOM entry document. * - * @method getReplies + * @method getSummary + * @return {String} ATOM entry summary */ - getReplies : function(args) { - return this.service.getForumTopicReplies(this.getTopicUuid(), args); + getSummary : function() { + return this.getAsString("summary"); }, - + /** - * To like this topic in a stand-alone forum, create forum recommendation to the forum topic resources. + * Sets summary of ATOM entry. * - * @method deleteRecommendation - * @param args + * @method setSummary + * @param {String} title ATOM entry summary */ - createRecommendation : function(args) { - return this.service.createForumRecommendation(this.getTopicUuid(), args); + setSummary : function(summary) { + return this.setAsString("summary", summary); }, /** - * Delete a recommendation of this topic in the forum. - * Only the user who have already recommended the post can delete it's own recommendation. + * Return the content from ATOM entry document. * - * @method deleteRecommendation - * @param args + * @method getContent + * @return {Object} Content */ - deleteRecommendation : function(args) { - return this.service.deleteForumRecommendation(this.getTopicUuid(), args); + getContent : function() { + return this.getAsString("content"); }, - + /** - * Loads the forum topic object with the atom entry associated with the - * forum topic. By default, a network call is made to load the atom entry - * document in the forum topic object. + * Sets content of ATOM entry. * - * @method load - * @param {Object} [args] Argument object + * @method setContent + * @param {String} content */ - load : function(args) { - // detect a bad request by validating required arguments - var topicUuid = this.getTopicUuid(); - var promise = this.service._validateTopicUuid(topicUuid); - if (promise) { - return promise; - } - - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - self.setData(data); - return self; - } - }; - - var requestArgs = lang.mixin({ - topicUuid : topicUuid - }, args || {}); - var options = { - handleAs : "text", - query : requestArgs - }; - - return this.service.getEntity(consts.AtomTopic, options, topicUuid, callbacks); + setContent : function(content) { + return this.setAsString("content", content); }, /** - * Remove this forum topic + * Return array of category terms from ATOM entry document. * - * @method remove - * @param {Object} [args] Argument object + * @method getCategoryTerms + * @return {Object} Array of categories of the ATOM entry */ - remove : function(args) { - return this.service.deleteForumTopic(this.getTopicUuid(), args); + getCategoryTerms : function() { + return this.getAsArray("categoryTerm"); }, /** - * Update this forum topic + * Set new category terms to be associated with this ATOM entry document. * - * @method update - * @param {Object} [args] Argument object + * @method setCategories + * @param {Object} Array of categories to be added to the ATOM entry */ - update : function(args) { - return this.service.updateForumTopic(this, args); + + setCategoryTerms : function(categoryTerms) { + return this.setAsArray("categoryTerm", categoryTerms); }, - + /** - * Save this forum topic + * Gets an author of the ATOM entry * - * @method save - * @param {Object} [args] Argument object + * @method getAuthor + * @return {Object} author Author of the ATOM entry */ - save : function(args) { - if (this.getTopicUuid()) { - return this.service.updateForumTopic(this, args); - } else { - return this.service.createForumTopic(this, args); - } - } - - }); - - /** - * ForumReply class represents an entry for a forums reply feed returned by the - * Connections REST API. - * - * @class ForumReply - * @namespace sbt.connections - */ - var ForumReply = declare(AtomEntity, { + getAuthor : function() { + return this.getAsObject( + [ "authorUserid", "authorName", "authorEmail", "authorUserState" ], + [ "userid", "name", "email", "userState" ]); + }, - xpath : consts.ForumReplyXPath, - contentType : "html", - categoryScheme : CategoryReply, - /** - * Construct a ForumReply entity. + * Gets a contributor of the ATOM entry * - * @constructor - * @param args + * @method getContributor + * @return {Object} contributor Contributor of the ATOM entry */ - constructor : function(args) { + getContributor : function() { + return this.getAsObject( + [ "contributorUserid", "contributorName", "contributorEmail", "contributorUserState" ], + [ "userid", "name", "email", "userState" ]); }, /** - * Return extra entry data to be included in post data for this entity. + * Sets the contributor of the ATOM entry * - * @returns {String} + * @method setContributor + * @return {Object} contributor Contributor of the ATOM entry */ - createEntryData : function() { - if (!this.getTopicUuid()) { - return ""; - } - var entryData = ""; - if (this.isAnswer()) { - entryData += stringUtil.transform(FlagTmpl, this, function(v,k) { return consts.FlagAnswer; }, this); - } - entryData += stringUtil.transform(ReplyTmpl, this, function(v,k) { return v; }, this); - return stringUtil.trim(entryData); + setContributor : function(contributor) { + return this.setAsObject(contributor); }, - + /** - * Return the value of id from Forum Reply ATOM - * entry document. + * Return the published date of the ATOM entry document. * - * @method getReplyUuid - * @return {String} ID of the Forum Reply + * @method getPublished + * @return {Date} Published date of the entry */ - getReplyUuid : function() { - var uid = this.getAsString("replyUuid"); - return extractForumUuid(uid); + getPublished : function() { + return this.getAsDate("published"); }, /** - * Sets id of IBM Connections Forum Reply. + * Return the last updated date of the ATOM entry document. * - * @method setReplyUuid - * @param {String} replyUuid Id of the forum reply + * @method getUpdated + * @return {Date} Last updated date of the entry */ - setReplyUuid : function(replyUuid) { - return this.setAsString("replyUuid", replyUuid); + getUpdated : function() { + return this.getAsDate("updated"); }, - + /** - * Return the value of IBM Connections topic ID from forum ATOM - * entry document. + * Return the alternate url of the ATOM entry document. * - * @method getTopicUuid - * @return {String} ID of the forum reply + * @method getAlternateUrl + * @return {String} Alternate url */ - getTopicUuid : function() { - var uid = this.getAsString("topicUuid"); - return extractForumUuid(uid); + getAlternateUrl : function() { + return this.getAsString("alternateUrl"); }, - + /** - * Sets id of IBM Connections forum reply. + * Return the self url of the ATOM entry document. * - * @method setTopicUuid - * @param {String} topicUuid Id of the forum topic + * @method getSelfUrl + * @return {String} Self url */ - setTopicUuid : function(topicUuid) { - return this.setAsString("topicUuid", topicUuid); + getSelfUrl : function() { + return this.getAsString("selfUrl"); }, /** - * Return the value of id of the post that this is a repy to. + * Return the edit url of the ATOM entry document. * - * @method getReplyToPostUuid - * @returns {String} postUuid Id of the forum post + * @method getEditUrl + * @return {String} Edit url */ - getReplyToPostUuid : function() { - var uid = this.getAsString("replyTo"); - return extractForumUuid(uid); + getEditUrl : function() { + return this.getAsString("editUrl"); }, /** - * Sets the value of id of the post that this is a repy to. + * Create ATOM entry XML * - * @method setReplyToPostUuid - * @param {String} postUuid Id of the forum post + * @method createPostData + * @returns */ - setReplyToPostUuid : function(postUuid) { - return this.setAsString("replyTo", postUuid); + createPostData : function() { + var postData = stringUtil.transform(EntryTmpl, this, function(v,k) { return v; }, this); + return stringUtil.trim(postData); }, - + /** - * Return the url of the IBM Connections Forum Reply reply from - * forum ATOM entry document. + * Return title element to be included in post data for this ATOM entry. * - * @method getReplyUrl - * @return {String} Url of the forum + * @method createTitle + * @returns {String} */ - getReplyUrl : function() { - return this.getAlternateUrl(); + createTitle : function() { + var title = this.getTitle(); + if (title) { + return stringUtil.transform(TitleTmpl, { "title" : stringUtil.htmlEntity(title) }); + } + return ""; }, - + /** - * Return the permissions of the IBM Connections Forum Reply from - * forum ATOM entry document. + * Return content element to be included in post data for this ATOM entry. * - * @method getPermisisons - * @return {String} Permissions of the Forum Reply + * @method createContent + * @returns {String} */ - getPermisisons : function() { - return this.getAsString("permissions"); + createContent : function() { + var content = this.getContent(); + if (content) { + if (this.contentType == "html") { + content = (content && lang.isString(content)) ? stringUtil.htmlEntity(content) : content; + } + return stringUtil.transform(ContentTmpl, { "contentType" : this.contentType, "content" : content }); + } + return ""; }, /** - * If true, indicates that the reply is an accepted answer. + * Return summary element to be included in post data for this ATOM entry. * - * @method isAnswered - * @return {Boolean} + * @method createSummary + * @returns {String} */ - isAnswer : function() { - return this.getAsBoolean("answer"); + createSummary : function() { + var summary = this.getSummary(); + if (summary) { + return stringUtil.transform(SummaryTmpl, { "summary" : summary }); + } + return ""; }, /** - * Set to true, indicates that the reply is an accepted answer. + * Return contributor element to be included in post data for this ATOM entry. * - * @method setAnswer - * @param answer - * @return {Boolean} + * @method createContributor + * @returns {String} */ - setAnswer : function(answer) { - return this.setAsBoolean("answer", answer); + createContributor : function() { + var contributor = this.getContributor(); + if (contributor) { + var value = ""; + var email = contributor.email || ((this.getEmail) ? this.getEmail() : null); + if (email) { + value += stringUtil.transform(EmailTmpl, { "email" : email }); + } + var userid = contributor.userid || ((this.getUserid) ? this.getUserid() : null); + if (userid) { + value += stringUtil.transform(UseridTmpl, { "userid" : userid }); + } + if (value.length > 0) { + value = stringUtil.transform(ContributorTmpl, { "contributor" : value }); + } + return value; + } + return ""; }, /** - * If true, this forum reply has not been recommended by the current user. + * Return tags elements to be included in post data for this ATOM entry. * - * @method isNotRecommendedByCurrentUser - * @returns {Boolean} + * @method createTags + * @returns {String} */ - isNotRecommendedByCurrentUser : function() { - return this.getAsBoolean("notRecommendedByCurrentUser"); + createTags : function() { + if (this.getTags && this.getTags()) { + var value = ""; + var tags = this.getTags(); + for (var tag in tags) { + value += stringUtil.transform(CategoryTmpl, { "tag" : tags[tag] }); + } + return value; + } + return ""; }, /** - * Return the recommendations url of the forum reply. + * Return extra entry data to be included in post data for this ATOM entry. * - * @method getRecommendationsUrl - * @return {String} Recommendations url + * @method createEntryData + * @returns {String} */ - getRecommendationsUrl : function() { - return this.getAsString("recommendationsUrl"); + createEntryData : function() { + return ""; }, + + /** + * return namespaces for this ATOM entry. + * + * @method createNamespaces + */ + createNamespaces : function() { + var namespaceData = ""; + var namespaces = this.dataHandler ? this.dataHandler.namespaces : this.namespaces; + for (prefix in namespaces) { + if (prefix != "a") { // ATOM automatically included + namespaceData += (namespaceData.length > 0) ? " " : ""; + namespaceData += "xmlns:"+prefix+"=\"" + namespaces[prefix] + "\""; + } + } + return namespaceData; + } + + }); + + return AtomEntity; +}); + +}, +'url:sbt/connections/controls/profiles/templates/ProfilePanel.html':"
    \r\n\t
    \r\n\t\t
    \r\n\t\t\t\"${getThumbnailAlt}\"\r\n\t\t
    \r\n\t
    \r\n\t\r\n\t
    \r\n\t\t\r\n\t\t\t\r\n\t\t\t${getName}\r\n\t\t\t\r\n\t\t\t${getUserid}\r\n\t\t\r\n\t
    \r\n\t\r\n\t
    \r\n\t\t ${getJobTitle}
    \r\n\t\t${getTelephoneNumber}
    \r\n\t\t${getEmail}
    \r\n\t
    \r\n
    ", +'sbt/main':function(){ +/* +* © Copyright IBM Corp. 2012 +* +* 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. +*/ + +/** +* @module sbt.main +*/ +define([ + 'sbt/Cache', + 'sbt/DebugTransport', + 'sbt/Endpoint', + 'sbt/ErrorTransport', + 'sbt/Gadget', + 'sbt/GadgetTransport', + 'sbt/IWidget', + 'sbt/Jsonpath', + 'sbt/MockTransport', + 'sbt/Portlet', + 'sbt/Promise', + 'sbt/Proxy', + 'sbt/_config', + 'sbt/compat', + 'sbt/config', + 'sbt/declare', + 'sbt/defer', + 'sbt/dom', + 'sbt/emailService', + 'sbt/i18n', + 'sbt/itemFactory', + 'sbt/json', + 'sbt/lang', + 'sbt/log', + 'sbt/pathUtil', + 'sbt/ready', + 'sbt/stringUtil', + 'sbt/text', + 'sbt/url', + 'sbt/util', + 'sbt/validate', + 'sbt/xml', + 'sbt/xpath', + 'sbt/xsl', + 'sbt/WPSProxy', + 'sbt/authenticator/Basic', + 'sbt/authenticator/GadgetOAuth', + 'sbt/authenticator/OAuth', + 'sbt/authenticator/SSO', + 'sbt/base/AtomEntity', + 'sbt/base/BaseConstants', + 'sbt/base/BaseEntity', + 'sbt/base/BaseService', + 'sbt/base/DataHandler', + 'sbt/base/JsonDataHandler', + 'sbt/base/VCardDataHandler', + 'sbt/base/XmlDataHandler', + 'sbt/base/core', + 'sbt/connections/ActivityConstants', + 'sbt/connections/ActivityService', + 'sbt/connections/ActivityStreamConstants', + 'sbt/connections/ActivityStreamService', + 'sbt/connections/BlogConstants', + 'sbt/connections/BlogService', + 'sbt/connections/BookmarkConstants', + 'sbt/connections/BookmarkService', + 'sbt/connections/CommunityConstants', + 'sbt/connections/CommunityService', + 'sbt/connections/ConnectionsConstants', + 'sbt/connections/ConnectionsService', + 'sbt/connections/FileConstants', + 'sbt/connections/FileService', + 'sbt/connections/FollowConstants', + 'sbt/connections/FollowService', + 'sbt/connections/ForumConstants', + 'sbt/connections/ForumService', + 'sbt/connections/ProfileAdminService', + 'sbt/connections/ProfileConstants', + 'sbt/connections/ProfileService', + 'sbt/connections/SearchConstants', + 'sbt/connections/SearchService', + 'sbt/connections/Tag', + 'sbt/connections/WikiConstants', + 'sbt/connections/WikiService', + 'sbt/data/AtomReadStore', + 'sbt/nls/Endpoint', + 'sbt/nls/ErrorTransport', + 'sbt/nls/loginForm', + 'sbt/nls/messageSSO', + 'sbt/nls/util', + 'sbt/nls/validate', + 'sbt/smartcloud/CommunityConstants', + 'sbt/smartcloud/ProfileConstants', + 'sbt/smartcloud/ProfileService', + 'sbt/smartcloud/SmartcloudConstants', + 'sbt/smartcloud/Subscriber', + 'sbt/store/AtomStore', + 'sbt/store/parameter', + 'sbt/authenticator/nls/SSO', + 'sbt/authenticator/templates/ConnectionsLogin.html', + 'sbt/authenticator/templates/ConnectionsLoginDialog.html', + 'sbt/authenticator/templates/Message.html', + 'sbt/authenticator/templates/MessageDialogSSO.html', + 'sbt/authenticator/templates/MessageSSO.html', + 'sbt/authenticator/templates/login.html', + 'sbt/authenticator/templates/login', + 'sbt/authenticator/templates/loginDialog.html', + 'sbt/authenticator/templates/messageSSO', + 'sbt/connections/nls/CommunityService', + 'sbt/connections/nls/ConnectionsService', + 'sbt/connections/nls/ProfileService' +],function() { + return; +}); + +}, +'sbt/connections/controls/communities/nls/CommunityGridRenderer':function(){ +/* + * © 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. + */ + +// NLS_CHARSET=UTF-8 +define({ + root: { + summary : "Public Communities", + filterByTag : "Click to filter by tag", + updatedBy : "Updated by ", + person : "1 person", + people : "{memberCount} people", + tags : "Tags: ", + date: "Date", + popularity: "Popularity", + name: "Name", + ariaVcard: "Press Control And Enter For Business Card", + feed : "Feed for these Communities", + restricted : "Restricted", + moderated: "Moderated" + } +}); + +}, +'url:sbt/controls/grid/bootstrap/templates/SortAnchor.html':"
  • \r\n\t ${title}\r\n
  • ", +'url:sbt/controls/grid/bootstrap/templates/GridFooter.html':"
    \r\n
    \r\n\t\r\n\t\tShow:\r\n\t\t\r\n\t\t\t10\r\n\t\t|\r\n\t\t\r\n\t\t\t25\r\n\t\t|\r\n\t\t\r\n\t\t\t50\r\n\t\t|\r\n\t\t\r\n\t\t\t100\r\n\t\t ${nls.items}\r\n\t\r\n
    \r\n
    \r\n\t${nls.feed}\r\n
    \r\n
    ", +'sbt/connections/FileConstants':function(){ +/* + * © Copyright IBM Corp. 2012,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. + */ +/** + * Social Business Toolkit SDK. Definition of constants for FileService. + */ +define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { + return lang.mixin({ + /** - * Get a list for forum recommendations that includes the recommendations for this forum reply. - * - * @method getRecommendations + * XPath expressions used when parsing a Connections Files ATOM feed */ - getRecommendations : function(args) { - return this.service.getForumRecommendations(this.getReplyUuid(), args); - }, + FileFeedXPath : conn.ConnectionsFeedXPath, /** - * Get a list for forum replies that includes the replies for this forum reply. - * - * @method getReplies + * XPath expressions used when parsing a Connections Comments ATOM feed */ - getReplies : function(args) { - return this.service.getForumReplyReplies(this.getReplyUuid(), args); - }, - + CommentFeedXPath : conn.ConnectionsFeedXPath, + /** - * To like this reply in a stand-alone forum, create forum recommendation to the forum reply resources. - * - * @method deleteRecommendation - * @param args + * XPath expressions to be used when reading a File Entry */ - createRecommendation : function(args) { - return this.service.createForumRecommendation(this.getReplyUuid(), args); + FileXPath : { + // used by getEntityData + entry : "/a:entry", + id : "a:id", + // used by getEntityId + uid : "td:uuid", + label : "td:label", + selfUrl : "a:link[@rel='self']/@href", + alternateUrl : "a:link[@rel='alternate']/@href", + downloadUrl : "a:link[@rel='enclosure']/@href", + type : "a:link[@rel='enclosure']/@type", + length : "a:link[@rel='enclosure']/@length", + editLink : "a:link[@rel='edit']/@href", + editMediaLink : "a:link[@rel='edit-media']/@href", + thumbnailUrl : "a:link[@rel='thumbnail']/@href", + commentsUrl : "a:link[@rel='replies']/@href", + fileSize : "td:totalMediaSize", + content : "a:content[@type='html']", + shareCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/share']", + + authorName : "a:author/a:name", + authorUserId : "a:author/snx:userid", + authorEmail : "a:author/a:email", + authorUserState : "a:author/snx:userState", + + title: "a:title", + published : "a:published", + updated : "a:updated", + created: "td:created", + modified: "td:modified", + lastAccessed : "td:lastAccessed", + + modifierName : "td:modifier/td:name", + modifierUserId : "td:modifier/snx:userid", + modifierEmail : "td:modifier/td:email", + modifierUserState : "td:modifier/snx:userState", + + visibility : "td:visibility", + libraryId : "td:libraryId", + libraryType : "td:libraryType", + versionUuid : "td:versionUuid", + versionLabel : "td:versionLabel", + propagation : "td:propagation", + recommendationsCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", + commentsCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/comment']", + sharesCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/share']", + foldersCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/collections']", + attachmentsCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/attachments']", + versionsCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/versions']", + referencesCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/references']", + totalMediaSize : "td:totalMediaSize", + summary : "a:summary", + contentUrl : "a:content/@src", + contentType : "a:content/@type", + objectTypeId : "td:objectTypeId", + lock : "td:lock/@type", + acls : "td:permissions", + hitCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/hit']", + anonymousHitCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/anonymous_hit']", + tags : "a:category[not(@scheme)]/@term", + category : "a:category/@label" }, /** - * Delete a recommendation of this reply in the forum. - * Only the user who have already recommended the post can delete it's own recommendation. - * - * @method deleteRecommendation - * @param args + * XPath expression for parsing folder informartion from the File ATOM Feed. */ - deleteRecommendation : function(args) { - return this.service.deleteForumRecommendation(this.getReplyUuid(), args); + FolderXPath : { + id : "id", + uid : "td:uuid", + title : "a:title", + label : "td:label", + folderUrl : "a:link[@rel='alternate']/@href", + logoUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/logo']/@href", + tags : "a:category/@term", + summary : "a:summary[@type='text']", + content : "a:content[@type='html']", + visibility : "td:visibility", + notification : "td:notification", + versionUuid : "td:versionUuid", + versionLabel : "td:versionLabel", + documentVersionUuid : "td:documentVersionUuid", + documentVersionLabel : "td:documentVersionLabel", + itemCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/item']", + shareCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/user']", + groupShareCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/group']", + modified : "td:modified", + created : "td:created", + updated : "a:updated", + authorName : "a:author/a:name", + authorUserId : "a:author/snx:userid", + authorEmail : "a:author/a:email", + content : "a:content[@type='text']", + modifierName : "a:modifier/a:name", + modifierId : "a:modifier/snx:userid", + modifierEmail : "a:modifier/a:email" }, /** - * Loads the forum reply object with the atom entry associated with the - * forum reply. By default, a network call is made to load the atom entry - * document in the forum reply object. - * - * @method load - * @param {Object} [args] Argument object - */ - load : function(args) { - // detect a bad request by validating required arguments - var replyUuid = this.getReplyUuid(); - var promise = this.service._validateReplyUuid(replyUuid); - if (promise) { - return promise; - } - - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - self.setData(data); - return self; - } - }; - - var requestArgs = lang.mixin({ - replyUuid : replyUuid - }, args || {}); - var options = { - handleAs : "text", - query : requestArgs - }; - - return this.service.getEntity(consts.AtomReply, options, replyUuid, callbacks); - }, - - /** - * Remove this forum reply - * - * @method remove - * @param {Object} [args] Argument object + * XPath expressions to be used when reading a Comment */ - remove : function(args) { - return this.service.deleteForumReply(this.getReplyUuid(), args); - }, + CommentXPath : { + entry : "a:entry", + id : "a:id", + uid : "td:uuid", + title : "a:title", + content : "a:content[@type='text']", + created : "td:created", + modified : "td:modified", + versionLabel : "td:versionLabel", + updated : "a:updated", + published : "a:published", + modifierName : "td:modifier/td:name", + modifierUserId : "td:modifier/snx:userid", + modifierEmail : "td:modifier/td:email", + modifierUserState : "td:modifier/snx:userState", + authorName : "a:author/a:name", + authorUserId : "a:author/snx:userid", + authorEmail : "a:author/a:email", + authorUserState : "a:author/snx:userState", + language : "td:language", + deleteWithRecord : "td:deleteWithRecord" + }, + + /** + * XPath expressions used for parsing information on shared files and folders. + */ + SharesXPath : { + id : "id", + uuid : "td:uuid", + title : "a:title", + summary : "a:summary[@type='text']", + sharedResourceType : "td:sharedResourceType", // always set to document, but will add the attribute anyway + sharePermission : "td:sharePermission", + sharedWhat : "td:sharedWhat", + sharedWithName : "a:sharedWith/a:name", + sharedWithId : "a:sharedWith/snx:userid", + sharedWithEmail : "a:sharedWith/a:email", + documentOwner : "td:documentOwner", + updated : "a:updated", + published : "a:published", + authorName : "a:author/a:name", + authorUid : "a:author/snx:userid", + authorEmail : "a:author/a:email" + }, + + /** + * XPath expressions used for parsing information on user library. + */ + LibraryXPath : { + entry : "a:feed", + id : "a:id", + uuid : "td:uuid", + librarySize : "td:librarySize", + totalRemovedSize : "td:totalRemovedSize", + libraryQuota : "td:libraryQuota", + totalResults : "opensearch:totalResults" + }, + + /** + * Get a Feed for a File + */ + AtomFileInstance : "${files}/basic/api/myuserlibrary/document/{documentId}/entry", + + /** + * + */ + AtomFileInstancePublic : "${files}/basic/anonymous/api/library/{libraryId}/document/{documentId}/entry", /** - * Update this forum reply + * A feed of files of which the authenticated user owns. * - * @method update - * @param {Object} [args] Argument object + * Get the My Files feed to see a list of the files which the authenticated owns. + * Supports: acls , includePath , includeQuota , includeTags , page , ps , shared , sI , since , sortBy , sortOrder , tag , visibility */ - update : function(args) { - return this.service.updateForumReply(this, args); - }, + AtomFilesMy : "/${files}/basic/api/myuserlibrary/feed", /** - * Save this forum reply + * A feed of files with are shared by or with the authenticated user. * - * @method save - * @param {Object} [args] Argument object + * Get the My Files feed to see a list of the files which the authenticated owns. + * Supports: direction (default inbound : with me, outbound : by me), acls , includePath , includeQuota , includeTags , page , ps , shared , sI , since , sortBy , sortOrder , tag , visibility */ - save : function(args) { - if (this.getReplyUuid()) { - return this.service.updateForumReply(this, args); - } else { - return this.service.createForumReply(this, args); - } - } - - }); - - /** - * ForumMember class represents an entry for a forums member feed returned by the - * Connections REST API. - * - * @class ForumMember - * @namespace sbt.connections - */ - var ForumMember = declare(AtomEntity, { - - categoryScheme : null, - + AtomFilesShared : "/${files}/basic/api/documents/shared/feed", + /** - * Construct a Forum Tag entity. - * - * @constructor - * @param args + * Get a feed that lists all public files. + * + * Supports: acls , includePath , includeQuota , includeTags , page , ps , shared , sI , since , sortBy , sortOrder , tag , visibility */ - constructor : function(args) { - } - - }); - - /** - * ForumRecommendation class represents an entry for a forums recommendation feed returned by the - * Connections REST API. - * - * @class ForumTag - * @namespace sbt.connections - */ - var ForumRecommendation = declare(AtomEntity, { - - xpath : consts.ForumRecommendationXPath, - contentType : "text", - categoryScheme : CategoryRecommendation, - + AtomFilesPublic : "/${files}/basic/anonymous/api/documents/feed?visibility=public", + /** - * Construct a Forum Tag entity. - * - * @constructor - * @param args + * Get feed of recycled files */ - constructor : function(args) { - }, - + AtomFilesRecycled : "/${files}/basic/api/myuserlibrary/view/recyclebin/feed", + /** - * Return the value of title from ATOM entry document. - * - * @method getTitle - * @return {String} ATOM entry title + * Get a feed that lists your folders + * + * Supports: access(editor or manager), creator, page, ps, shared, sharedWithMe, sI, sortBy, sortOrder, title, visibility */ - getTitle : function() { - return this.getAsString("title") || "liked"; - }, - - /** - * Return the value of IBM Connections recommendation ID from recommendation ATOM - * entry document. - * - * @method getRecommendationUuid - * @return {String} ID of the recommendation topic - */ - getRecommendationUuid : function() { - var uid = this.getAsString("id"); - return extractForumUuid(uid); - }, - + AtomFoldersMy : "/${files}/basic/api/collections/feed", + /** - * Return the value of IBM Connections post ID from recommendation ATOM - * entry document. - * - * @method getPostUuid - * @return {String} ID of the forum post + * Feed of public folders */ - getPostUuid : function() { - var postUuid = this.getAsString("postUuid"); - return this.service.getUrlParameter(postUuid, "postUuid") || postUuid; - }, + AtomFoldersPublic : "/${files}/basic/anonymous/api/collections/feed", /** - * Set the value of IBM Connections post ID from recommendation ATOM - * entry document. - * - * @method setPostUuid - * @return {String} ID of the forum post + * Feed of folders you recently added files to */ - setPostUuid : function(postUuid) { - return this.setAsString("postUuid", postUuid); - } - - }); - - /** - * ForumTag class represents an entry for a forums tag feed returned by the - * Connections REST API. - * - * @class ForumTag - * @namespace sbt.connections - */ - var ForumTag = declare(AtomEntity, { - - categoryScheme : null, - + AtomFoldersActive : "/${files}/basic/api/collections/addedto/feed", + /** - * Construct a Forum Tag entity. - * - * @constructor - * @param args + * A feed of comments associated with all public files. Do not authenticate this request. + * + * Supports: acls, category Note: This parameter is required., commentId, identifier, page, ps, sI, sortBy, sortOrder */ - constructor : function(args) { - } - - }); - - /* - * Method used to extract the forum uuid for an id string. - */ - var extractForumUuid = function(uid) { - if (uid && uid.indexOf("urn:lsid:ibm.com:forum:") == 0) { - return uid.substring("urn:lsid:ibm.com:forum:".length); - } else { - return uid; - } - }; - - /* - * Callbacks used when reading a feed that contains forum entries. - */ - var ForumFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.ForumsFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new Forum({ - service : service, - data : data - }); - } - }; - - /* - * Callbacks used when reading a feed that contains forum topic entries. - */ - var ForumTopicFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.ForumsFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new ForumTopic({ - service : service, - data : data - }); - } - }; - - /* - * Callbacks used when reading a feed that contains forum topic reply entries. - */ - var ForumReplyFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.ForumsFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new ForumReply({ - service : service, - data : data - }); - } - }; - - /* - * Callbacks used when reading a feed that contains forum recommendation entries. - */ - var ForumRecommendationFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.ForumsFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new ForumRecommendation({ - service : service, - data : data - }); - } - }; - - - /** - * ForumsService class. - * - * @class ForumsService - * @namespace sbt.connections - */ - var ForumService = declare(ConnectionsService, { - - contextRootMap: { - forums: "forums" - }, - - serviceName : "forums", + AtomFileCommentsPublic : "/${files}/basic/anonymous/api/userlibrary/{userId}/document/{documentId}/feed?category=comment", /** - * Constructor for ForumsService - * - * @constructor - * @param args + * A feed of comments associated with files to which you have access. You must authenticate this request. + * + * Supports: acls, category Note: This parameter is required., commentId, identifier, page, ps, sI, sortBy, sortOrder */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } - }, + AtomFileCommentsMy : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/feed?category=comment", /** - * Create a Forum object with the specified data. + * Adds a comment to the specified file. * - * @method newForum - * @param {Object} args Object containing the fields for the - * new Forum + * Supports : identifier - Indicates how the document is identified in the {document-id} variable segment of the web address. By default, look up is performed with the expectation that the URL contains the value from the element of a File Atom entry. Specify "label" if the URL instead contains the value from the element of a File Atom entry. */ - newForum : function(args) { - return this._toForum(args); - }, + AtomAddCommentToFile : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/feed", /** - * Create a ForumTopic object with the specified data. + * Adds a comment to the specified file for logged in user. * - * @method newForumTopic - * @param {Object} args Object containing the fields for the - * new ForumTopic + * Supports : identifier - Indicates how the document is identified in the {document-id} variable segment of the web address. By default, look up is performed with the expectation that the URL contains the value from the element of a File Atom entry. Specify "label" if the URL instead contains the value from the element of a File Atom entry. */ - newForumTopic : function(args) { - return this._toForumTopic(args); - }, + AtomAddCommentToMyFile : "/${files}/basic/api/myuserlibrary/document/{documentId}/feed", /** - * Create a ForumReply object with the specified data. + * Update the Atom document representation of the metadata for a file from logged in user's library. * - * @method newForumReply - * @param {Object} args Object containing the fields for the - * new ForumReply + * supports : + * propagate Indicates if users that are shared with can share this document. The default value is true. + * sendEmail Indicates if an email notification is sent when sharing with the specified user. The default value is true. */ - newForumReply : function(args) { - return this._toForumReply(args); - }, + AtomUpdateFileMetadata : "/${files}/basic/api/myuserlibrary/document/{documentId}/entry", /** - * Get a feed that includes forums created by the authenticated user or associated with communities to which the user belongs. + * Get pinned files from my my favorites feed. * - * @method getMyForums - * @param args */ - getMyForums: function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomForumsMy, options, ForumFeedCallbacks); - }, + AtomFilesMyPinned : "/${files}/basic/api/myfavorites/documents/feed", /** - * Get a feed that includes the topics that the authenticated user created in stand-alone forums and in forums associated - * with communities to which the user belongs. + * Add a file to my favorites feed of logged in user * - * @method getMyTopics - * @param requestArgs */ - getMyTopics: function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - return this.getEntities(consts.AtomTopicsMy, options, ForumTopicFeedCallbacks); - }, + AtomPinFile : "/${files}/basic/api/myfavorites/documents/feed", /** - * Get a feed that includes all stand-alone and forum forums created in the enterprise. - * - * @method getAllForums - * @param requestArgs + * Add file of list of files to folder */ - getAllForums: function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - return this.getEntities(consts.AtomForums, options, ForumFeedCallbacks); - }, + AtomAddFilesToFolder : "/${files}/basic/api/collection/{collectionId}/feed", /** - * Get a feed that includes all stand-alone and forum forums created in the enterprise. - * - * @method getPublicForums - * @param args + * Delete a file and the Atom document representation of its associated metadata from logged in user's collection. */ - getPublicForums: function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomForumsPublic, options, ForumFeedCallbacks); - }, + AtomDeleteFile : "/${files}/basic/api/myuserlibrary/document/{documentId}/entry", /** - * Get a list for forum topics that includes the topics in the specified forum. - * - * @method getForumTopics - * @param forumUuid - * @param args - * @returns + * Lock or unlock a file */ - getForumTopics: function(forumUuid, args) { - var promise = this._validateForumUuid(forumUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ forumUuid : forumUuid }, args || {}); - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - return this.getEntities(consts.AtomTopics, options, ForumTopicFeedCallbacks); - }, + AtomLockUnlockFile : "/${files}/basic/api/document/{documentId}/lock", /** - * Get a list for forum topics that includes the topics in the specified community. - * - * @method getCommunityForumTopics - * @param forumUuid - * @param args - * @returns + * Add the document to collections specified by atom entry or feed. */ - getCommunityForumTopics: function(communityUuid, args) { - var promise = this._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ communityUuid : communityUuid }, args || {}); - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - return this.getEntities(consts.AtomTopics, options, ForumTopicFeedCallbacks); - }, + AtomAddFileToFolders : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/feed", /** - * Get a list for forum recommendations that includes the recommendations in the specified post. - * - * @method getForumRecommendations - * @param postUuid - * @param args - * @returns + * Add the document of logged in user to collections specified by atom entry or feed. + */ + AtomAddMyFileToFolders : "/${files}/basic/api/myuserlibrary/document/{documentId}/feed", + + /** + * Create a file folder programmatically. */ - getForumRecommendations: function(postUuid, args) { - var promise = this._validatePostUuid(postUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ postUuid : postUuid }, args || {}); - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - return this.getEntities(consts.AtomRecommendationEntries, options, ForumRecommendationFeedCallbacks); - }, + AtomCreateFolder : "/${files}/basic/api/collections/feed", /** - * Get a list for forum replies that includes the replies in the specified topic. - * - * @method getForumTopicReplies - * @param topicUuid - * @param args - * @returns + * Delete all files from recycle bin of specified user */ - getForumTopicReplies: function(topicUuid, args) { - var promise = this._validateTopicUuid(topicUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ topicUuid : topicUuid }, args || {}); - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - return this.getEntities(consts.AtomReplies, options, ForumReplyFeedCallbacks); - }, + AtomDeleteAllFilesFromRecyclebBin : "/${files}/basic/api/userlibrary/{userId}/view/recyclebin/feed", /** - * Get a list for forum replies that includes the replies in the specified reply. - * - * @method getForumReplyReplies - * @param replyUuid - * @param args - * @returns + * Delete all files from recycle bin of logged in user */ - getForumReplyReplies: function(replyUuid, args) { - var promise = this._validateReplyUuid(replyUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ replyUuid : replyUuid }, args || {}); - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - return this.getEntities(consts.AtomReplies, options, ForumReplyFeedCallbacks); - }, + AtomDeleteMyFilesFromRecyclebBin : "/${files}/basic/api/myuserlibrary/view/recyclebin/feed", /** - * Get a list for forum replies that includes the replies in the specified post. - * The post uuid must be specified in the args as either: - * { topicUuid : "" } or { replyUuid : "" } - * - * @method getForumReplies - * @param topicUuid - * @param args - * @returns + * Delete All Versions of a File */ - getForumReplies: function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args - }; - - return this.getEntities(consts.AtomReplies, options, ForumReplyFeedCallbacks); - }, + AtomDeleteAllVersionsOfAFile : "/${files}/basic/api/myuserlibrary/document/{documentId}/feed", /** - * Retrieve a list of all forum entries, add communityUuid to the requestArgs object to get the forums related to a specific community. - * - * @method getForums - * @param {Object} requestArgs Object containing the query arguments to be - * sent (defined in IBM Connections Communities REST API) + * Delete a Comment for a File */ - getForums : function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; - - return this.getEntities(consts.AtomForums, options, ForumFeedCallbacks); - }, - + AtomDeleteComment : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/comment/{commentId}/entry", + /** - * Retrieve a forum entry, use the edit link for the forum entry - * which can be found in the my communities feed. - * - * @method getForum - * @param {String } forumUuid - * @param {Object} args Object containing the query arguments to be - * sent (defined in IBM Connections Communities REST API) + * Delete a comment on file for logged in user */ - getForum : function(forumUuid, args) { - var forum = new Forum({ - service : this, - _fields : { forumUuid : forumUuid } - }); - return forum.load(args); - }, + AtomDeleteMyComment : "/${files}/basic/api/myuserlibrary/document/{documentId}/comment/{commentId}/entry", /** - * Create a forum by sending an Atom entry document containing the - * new forum to the My Forums resource. - * - * @method createForum - * @param {Object} forum Forum object which denotes the forum to be created. - * @param {Object} [args] Argument object + * Purge a file from Recycle Bin */ - createForum : function(forumOrJson,args) { - var forum = this._toForum(forumOrJson); - var promise = this._validateForum(forum, false, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - forum.setData(data); - var forumUuid = this.getLocationParameter(response, "forumUuid"); - forum.setForumUuid(forumUuid); - return forum; - }; - - var options = { - method : "POST", - query : args || {}, - headers : consts.AtomXmlHeaders, - data : forum.createPostData() - }; - - return this.updateEntity(consts.AtomForumsMy, options, callbacks, args); - }, - + AtomDeleteFileFromRecycleBin : "/${files}/basic/api/userlibrary/{userId}/view/recyclebin/{documentId}/entry", + /** - * Update a forum by sending a replacement forum entry document in Atom format - * to the existing forum's edit web address. - * All existing forum entry information will be replaced with the new data. To avoid - * deleting all existing data, retrieve any data you want to retain first, and send it back - * with this request. For example, if you want to add a new tag to a forum entry, retrieve - * the existing tags, and send them all back with the new tag in the update request. - * - * @method updateForum - * @param {Object} forum Forum object - * @param {Object} [args] Argument object + * Purge a file from REcycle Bin for Logged in user */ - updateForum : function(forumOrJson,args) { - var forum = this._toForum(forumOrJson); - var promise = this._validateForum(forum, true, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - // preserve the forumUuid - var forumUuid = forum.getForumUuid(); - forum.setData(data); - forum.setForumUuid(forumUuid); - return forum; - }; - - var requestArgs = lang.mixin({ - forumUuid : forum.getForumUuid() - }, args || {}); - - var options = { - method : "PUT", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : forum.createPostData() - }; - - return this.updateEntity(consts.AtomForum, options, callbacks, args); - }, - + AtomDeleteMyFileFromRecycleBin : "/${files}/basic/api/myuserlibrary/view/recyclebin/{documentId}/entry", + /** - * Delete a forum, use the HTTP DELETE method. - * Only the owner of a forum can delete it. Deleted communities cannot be restored - * - * @method deleteForum - * @param {String/Object} forum id of the forum or the forum object (of the forum to be deleted) - * @param {Object} [args] Argument object + * Remove a file Share */ - deleteForum : function(forumUuid,args) { - var promise = this._validateForumUuid(forumUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ - forumUuid : forumUuid - }, args || {}); - - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - - return this.deleteEntity(consts.AtomForum, options, forumUuid); - }, + AtomDeleteFileShare : "/${files}/basic/api/shares/feed", /** - * Retrieve a forum topic entry, use the edit link for the forum topic entry - * which can be found in the My Forums feed. - * - * @method getForumTopic - * @param {String } topicUuid - * @param {Object} args Object containing the query arguments to be - * sent (defined in IBM Connections Communities REST API) + * Delete a Folder */ - getForumTopic : function(topicUuid, args) { - var forumTopic = new ForumTopic({ - service : this, - _fields : { topicUuid : topicUuid } - }); - return forumTopic.load(args); - }, - + AtomDeleteFolder : "/${files}/basic/api/collection/{collectionId}/entry", + /** - * Create a forum topc by sending an Atom entry document containing the - * new forum to the forum replies resource. - * - * @method createForumTopic - * @param {Object} forumTopic Forum topic object which denotes the forum topic to be created. - * @param {Object} [args] Argument object + * Get Files for a user */ - createForumTopic : function(topicOrJson,args) { - var forumTopic = this._toForumTopic(topicOrJson); - var promise = this._validateForumTopic(forumTopic, false, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - var topicUuid = this.getLocationParameter(response, "topicUuid"); - forumTopic.setTopicUuid(topicUuid); - forumTopic.setData(data); - return forumTopic; - }; - - var requestArgs = lang.mixin({ - forumUuid : forumTopic.getForumUuid() - }, args || {}); - - var options = { - method : "POST", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : forumTopic.createPostData() - }; - - return this.updateEntity(consts.AtomTopics, options, callbacks, args); - }, - + AtomGetAllUsersFiles : "/${files}/basic/anonymous/api/userlibrary/{userId}/feed", + /** - * Update a forum topic by sending a replacement forum entry document in Atom format - * to the existing forum topic's edit web address. - * All existing forum entry information will be replaced with the new data. To avoid - * deleting all existing data, retrieve any data you want to retain first, and send it back - * with this request. For example, if you want to add a new tag to a forum entry, retrieve - * the existing tags, and send them all back with the new tag in the update request. - * - * @method updateForumTopic - * @param {Object} topicOrJson Forum topic object - * @param {Object} [args] Argument object + * Get a comment for a file */ - updateForumTopic : function(topicOrJson,args) { - var forumTopic = this._toForumTopic(topicOrJson); - var promise = this._validateForumTopic(forumTopic, true, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - // preserve the topicUuid - var topicUuid = forumTopic.getTopicUuid(); - forumTopic.setData(data); - forumTopic.setTopicUuid(topicUuid); - return forumTopic; - }; - - var requestArgs = lang.mixin({ - topicUuid : forumTopic.getTopicUuid() - }, args || {}); - - var options = { - method : "PUT", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : forumTopic.createPostData() - }; - - return this.updateEntity(consts.AtomTopic, options, callbacks, args); - }, - + AtomGetFileComment : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/comment/{commentId}/entry", + /** - * Delete a forum topic, use the HTTP DELETE method. - * Only the owner of a forum topic can delete it. Deleted forum topics cannot be restored - * - * @method deleteForumTopic - * @param {String/Object} id of the forum topic to be deleted - * @param {Object} [args] Argument object + * Get a comment for a File for logged in user */ - deleteForumTopic : function(topicUuid,args) { - var promise = this._validateTopicUuid(topicUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ - topicUuid : topicUuid - }, args || {}); - - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - - return this.deleteEntity(consts.AtomTopic, options, topicUuid); - }, + AtomGetMyFileComment : "/${files}/basic/api/myuserlibrary/document/{documentId}/comment/{commentId}/entry", /** - * Retrieve a forum reply entry, use the edit link for the forum reply entry - * which can be found in the my communities feed. - * - * @method getForumReply - * @param {String } replyUuid - * @param {Object} args Object containing the query arguments to be - * sent (defined in IBM Connections Communities REST API) + * Get File from Recycle Bin + */ + AtomGetFileFromRecycleBin : "/${files}/basic/api/userlibrary/{userId}/view/recyclebin/{documentId}/entry", + + /** + * Get Files Awaiting Approval + */ + AtomGetFilesAwaitingApproval : "/${files}/basic/api/approval/documents", + + /** + * Get File Shares */ - getForumReply : function(replyUuid, args) { - var forumReply = new ForumReply({ - service : this, - _fields : { replyUuid : replyUuid } - }); - return forumReply.load(args); - }, - + AtomGetFileShares : "/${files}/basic/api/documents/shared/feed", + /** - * Create a forum reply by sending an Atom entry document containing the - * new forum reply to the My Communities resource. - * - * @method createForumReply - * @param {Object} reply ForumReply object which denotes the forum to be created. - * @param {Object} [args] Argument object + * Get All Files in a Folder */ - createForumReply : function(replyOrJson,args) { - var forumReply = this._toForumReply(replyOrJson); - var promise = this._validateForumReply(forumReply, false, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - var replyUuid = this.getLocationParameter(response, "replyUuid"); - forumReply.setReplyUuid(replyUuid); - forumReply.setData(data); - return forumReply; - }; - - var options = { - method : "POST", - query : args || { topicUuid : forumReply.getTopicUuid() }, - headers : consts.AtomXmlHeaders, - data : forumReply.createPostData() - }; - - return this.updateEntity(consts.AtomReplies, options, callbacks, args); - }, - + AtomGetFilesInFolder : "/${files}/basic/api/collection/{collectionId}/feed", + /** - * Update a forum by sending a replacement forum entry document in Atom format - * to the existing forum's edit web address. - * All existing forum entry information will be replaced with the new data. To avoid - * deleting all existing data, retrieve any data you want to retain first, and send it back - * with this request. For example, if you want to add a new tag to a forum entry, retrieve - * the existing tags, and send them all back with the new tag in the update request. - * - * @method updateForumReply - * @param {Object} replyOrJson Forum reply object - * @param {Object} [args] Argument object + * Get Files in Recycle Bin of logged in user */ - updateForumReply : function(replyOrJson,args) { - var forumReply = this._toForumReply(replyOrJson); - var promise = this._validateForumReply(forumReply, true, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - // preserve the replyUuid - var replyUuid = forumReply.getReplyUuid(); - forumReply.setData(data); - forumReply.setReplyUuid(replyUuid); - return forumReply; - }; - - var requestArgs = lang.mixin({ - replyUuid : forumReply.getReplyUuid() - }, args || {}); - - var options = { - method : "PUT", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : forumReply.createPostData() - }; - - return this.updateEntity(consts.AtomReply, options, callbacks, args); - }, - + AtomGetFilesInMyRecycleBin : "/${files}/basic/api/myuserlibrary/view/recyclebin/feed", + /** - * Delete a forum reply, use the HTTP DELETE method. - * Only the owner of a forum reply can delete it. Deleted forum replies cannot be restored - * - * @method deleteForumReply - * @param {String/Object} Id of the forum reply to be deleted - * @param {Object} [args] Argument object + * Get file with given version */ - deleteForumReply : function(replyUuid,args) { - var promise = this._validateReplyUuid(replyUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ - replyUuid : replyUuid - }, args || {}); - - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - - return this.deleteEntity(consts.AtomReply, options, replyUuid); - }, - + AtomGetFileWithGivenVersion : "/${files}/basic/api/myuserlibrary/document/{documentId}/version/{versionId}/entry", + /** - * Retrieve complete information about recommendations to a post(topic/reply) in a stand-alone forum. - * - * @method getForumRecommendation - * @param postUuid - * @param args + * Get a folder */ - getForumRecommendation : function(postUuid, args) { - var forumRecommendation = new ForumRecommendation({ - service : this, - _fields : { postUuid : postUuid } - }); - return forumRecommendation.load(args); - }, + AtomGetFolder : "/${files}/basic/api/collection/{collectionId}/entry", /** - * To like a post(topic/reply) in a stand-alone forum, create forum recommendation to the forum topic/reply resources. - * - * @method createForumRecommendation - * @param recommendationOrJson - * @param args + * Get Folder with Recenty Added Files */ - createForumRecommendation : function(recommendationOrJson, args) { - var forumRecommendation = this._toForumRecommendation(recommendationOrJson); - var promise = this._validateForumRecommendation(forumRecommendation, false, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - forumRecommendation.setData(data); - return forumRecommendation; - }; - - var options = { - method : "POST", - query : args || { postUuid : forumRecommendation.getPostUuid() }, - headers : consts.AtomXmlHeaders, - data : forumRecommendation.createPostData() - }; - - return this.updateEntity(consts.AtomRecommendationEntries, options, callbacks, args); - }, + AtomGetFoldersWithRecentlyAddedFiles : "/${files}/basic/api/collections/addedto/feed", /** - * Delete a recommendation of a post(topic or reply) in a forum. - * Only the user who have already recommended the post can delete it's own recommendation. - * - * @method deleteForumRecommendation - * @param postUuid - * @param args + * Get Pinned Folders */ - deleteForumRecommendation : function(postUuid, args) { - var promise = this._validatePostUuid(postUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ - postUuid : postUuid - }, args || {}); - - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - - return this.deleteEntity(consts.AtomRecommendationEntries, options, postUuid); - }, - - // - // Internals - // + AtomGetPinnedFolders : "/${files}/basic/api/myfavorites/collections/feed", - /* - * Validate a forum and return a Promise if invalid. + /** + * Get Public Folders */ - _validateForum : function(forum,checkUuid) { - if (!forum || !forum.getTitle()) { - return this.createBadRequestPromise("Invalid argument, forum with title must be specified."); - } - if (checkUuid && !forum.getForumUuid()) { - return this.createBadRequestPromise("Invalid argument, forum with UUID must be specified."); - } - }, + AtomGetPublicFolders : "/${files}/basic/anonymous/api/collections/feed", - /* - * Validate a forum topic and return a Promise if invalid. + /** + * Pin/unpin a Folder */ - _validateForumTopic : function(forumTopic,checkUuid) { - if (!forumTopic || !forumTopic.getTitle()) { - return this.createBadRequestPromise("Invalid argument, forum topic with title must be specified."); - } - if (checkUuid && !forumTopic.getTopicUuid()) { - return this.createBadRequestPromise("Invalid argument, forum topic with UUID must be specified."); - } - }, + AtomPinFolder : "/${files}/basic/api/myfavorites/collections/feed", - /* - * Validate a forum reply and return a Promise if invalid. + /** + * Remove File from Folder */ - _validateForumReply : function(forumReply,checkUuid) { - if (!forumReply || !forumReply.getTitle()) { - return this.createBadRequestPromise("Invalid argument, forum reply with title must be specified."); - } - if (checkUuid && !forumReply.getReplyUuid()) { - return this.createBadRequestPromise("Invalid argument, forum reply with UUID must be specified."); - } - }, + AtomRemoveFileFromFolder : "/${files}/basic/api/collection/{collectionId}/feed", - /* - * Validate a forum recommendation and return a Promise if invalid. + /** + * Restore File from Recycle Bin */ - _validateForumRecommendation : function(forumRecommendation,checkUuid) { - if (!forumRecommendation || !forumRecommendation.getPostUuid()) { - return this.createBadRequestPromise("Invalid argument, forum recommendation with postUuid must be specified."); - } - if (checkUuid && !forumRecommendation.getRecommendationUuid()) { - return this.createBadRequestPromise("Invalid argument, forum recommendation with UUID must be specified."); - } - }, + AtomRestoreFileFromRecycleBin : "/${files}/basic/api/userlibrary/{userId}/view/recyclebin/{documentId}/entry", - /* - * Validate a forum UUID, and return a Promise if invalid. + /** + * Share File with Community or communities */ - _validateForumUuid : function(forumUuid) { - if (!forumUuid || forumUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected forumUuid."); - } - }, + AtomShareFileWithCommunities : "/${files}/basic/api/myuserlibrary/document/{documentId}/feed", - /* - * Validate a community UUID, and return a Promise if invalid. + /** + * Update a Comment + */ + AtomUpdateComment : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/comment/{commentId}/entry", + + /** + * Update comment of logged in user */ - _validateCommunityUuid : function(communityUuid) { - if (!communityUuid || communityUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected communityUuid."); - } - }, + AtomUpdateMyComment : "/${files}/basic/api/myuserlibrary/document/{documentId}/comment/{commentId}/entry", - /* - * Validate a post UUID, and return a Promise if invalid. + /** + * Add Comment To Community File */ - _validatePostUuid : function(postUuid) { - if (!postUuid || postUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected postUuid."); - } - }, + AtomAddCommentToCommunityFile : "/${files}/basic/api/communitylibrary/{communityId}/document/{documentId}/feed", - /* - * Validate a topic UUID, and return a Promise if invalid. + /** + * Get All Community Files, Shows only files with with a libraryType of communityFiles + * TODO This should be renamed */ - _validateTopicUuid : function(topicUuid) { - if (!topicUuid || topicUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected topicUuid."); - } - }, + AtomGetAllFilesInCommunity : "/${files}/basic/api/communitylibrary/{communityId}/feed", - /* - * Validate a reply UUID, and return a Promise if invalid. + /** + * Get all files in a community, Shows public, private, communityFiles etc. */ - _validateReplyUuid : function(replyUuid) { - if (!replyUuid || replyUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected replyUuid."); - } - }, + AtomGetAllCommunityFiles : "/${files}/basic/api/communitycollection/{communityId}/feed", - /* - * Return a Forum instance from Forum or JSON or String. Throws - * an error if the argument was neither. + /** + * Get Community File */ - _toForum : function(forumOrJsonOrString) { - if (forumOrJsonOrString instanceof Forum) { - return forumOrJsonOrString; - } else { - if (lang.isString(forumOrJsonOrString)) { - forumOrJsonOrString = { - forumUuid : forumOrJsonOrString - }; - } - return new Forum({ - service : this, - _fields : lang.mixin({}, forumOrJsonOrString) - }); - } - }, - - /* - * Return a ForumTopic instance from Forum or JSON or String. Throws - * an error if the argument was neither. + AtomGetCommunityFile : "/${files}/basic/api/communitylibrary/{communityId}/document/{documentId}/entry", + + /** + * Update metadata of community File */ - _toForumTopic : function(topicOrJsonOrString) { - if (topicOrJsonOrString instanceof ForumTopic) { - return topicOrJsonOrString; - } else { - if (lang.isString(topicOrJsonOrString)) { - topicOrJsonOrString = { - forumTopicUuid : topicOrJsonOrString - }; - } - return new ForumTopic({ - service : this, - _fields : lang.mixin({}, topicOrJsonOrString) - }); - } - }, + AtomUpdateCommunityFileMetadata : "/${files}/basic/api/library/{libraryId}/document/{documentId}/entry" + }, conn); +}); +}, +'sbt/connections/ActivityService':function(){ +/* + * © 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. + */ + +/** + * The Activities application of IBM© Connections enables a team to collect, organize, share, and reuse work related to a project goal. The Activities API + * allows application programs to create new activities, and to read and modify existing activities. + * + * @module sbt.connections.ActivityService + */ +define( + [ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./ActivityConstants", "./ConnectionsService", "../base/AtomEntity", + "../base/BaseEntity", "../base/XmlDataHandler", "../xml" ], + function(declare, config, lang, stringUtil, Promise, consts, ConnectionsService, AtomEntity, BaseEntity, XmlDataHandler, xml) { + + var ActivityCategory = ""; + var PositionTmpl = "${getPosition}"; + var CommunityTmpl = "${getCommunityUuid}" + + ""; + var CompletedTmpl = ""; + var TemplateTmpl = ""; + var DueDateTmpl = "${getDueDate}"; + var InReplytoTmpl = ""; + var FieldTmpl = "${getText}${getPerson}${getDate}${getLink}${getFile}"; + var TextFieldTmpl = "${summary}"; + var PersonFieldTmpl = "${personName} {email} ${userId}"; + var LinkFieldTmpl = ""; + var DateFieldTmpl = "${date}"; + var IconTmpl = "${getIconUrl}"; + var AssignedToTmpl = "${getAssignedToEmail}"; + var RoleTmpl = "${getRole}"; + var MemberCategory = ""; + var ActivityIdTmpl = "${getActivityUuid}"; + var ActivityNodeIdTmpl = "urn:lsid:ibm.com:oa:${getActivityNodeUuid}"; + + var extractId = function(id, token) { + //decode uri component returns "null" for null input + if(id) id = decodeURIComponent(id); // to make sure the Id doesnt contain encoded characters + if (id) { + var index = id.indexOf(token); + if (index != -1) { + var len = token.length; + id = id.substring(index + len); + } + } + return id; + }; + + var transformer = function(value, key) { + if (value) { + return value; + } + }; + + /** + * Field class represents a Field in an Activity Node. + * + * @class Field + * @namespace sbt.connections + */ + var Field = declare(null, { + name : null, + fid : null, + position : null, + type : null, + + /** + * Returns Field Name + * @method getName + * @returns {String} field name + */ + getName : function() { + return this.name; + }, + + /** + * Sets Field Name + * @method setName + * @param {String} field name + */ + setName : function(newName) { + this.name = newName; + }, + + /** + * Returns Field ID + * @method getFid + * @returns {String} field ID + */ + getFid : function() { + return this.fid; + }, + + /** + * Returns Field Position + * @method getPosition + * @returns {String} field position + */ + getPosition : function() { + return this.position; + }, + + /** + * Returns Field Type + * @method getType + * @returns {String} field type + */ + getType : function() { + return this.type; + } + }); + + /** + * TextField class represents a Text Field in an Activity Node. + * + * @class TextField + * @namespace sbt.connections + */ + var TextField = declare(Field, { + summary : null, + + /** + * Returns Field Summary + * @method getSummary + * @returns {String} field summary + */ + getSummary : function() { + return this.summary; + }, + + /** + * Sets Field Summary + * @method setSummary + * @param {String} field summary + */ + setSummary : function(newSumamry) { + this.summary = newSummary; + } + + }); + + /** + * DateField class represents a Date Field in an Activity Node. + * + * @class DateField + * @namespace sbt.connections + */ + var DateField = declare(Field, { + date : null, + + /** + * Returns Field Date + * @method getDate + * @returns {Date} field date + */ + getDate : function() { + return this.date; + }, + /** + * Sets Field Date + * @method setDate + * @param {Date} field date + */ + setDate : function(newDate) { + this.date = newDate; + } - /* - * Return a Forum instance from ForumReply or JSON or String. Throws - * an error if the argument was neither. - */ - _toForumReply : function(replyOrJsonOrString) { - if (replyOrJsonOrString instanceof ForumReply) { - return replyOrJsonOrString; - } else { - if (lang.isString(replyOrJsonOrString)) { - replyOrJsonOrString = { - forumReplyUuid : replyOrJsonOrString - }; - } - return new ForumReply({ - service : this, - _fields : lang.mixin({}, replyOrJsonOrString) - }); - } - }, - - /* - * Return a ForumRecommendation instance from ForumRecommendation, ForumTopic, - * ForumReply or JSON or String. Throws an error if the argument was neither. - */ - _toForumRecommendation : function(entityOrJsonOrString) { - if (entityOrJsonOrString instanceof ForumRecommendation) { - return entityOrJsonOrString; - } else { - if (lang.isString(entityOrJsonOrString)) { - entityOrJsonOrString = { - postUuid : entityOrJsonOrString - }; - } - if (entityOrJsonOrString instanceof ForumTopic) { - entityOrJsonOrString = { - postUuid : entityOrJsonOrString.getTopicUuid() - }; - } - if (entityOrJsonOrString instanceof ForumReply) { - entityOrJsonOrString = { - postUuid : entityOrJsonOrString.getReplyUuid() - }; - } - return new ForumRecommendation({ - service : this, - _fields : lang.mixin({}, entityOrJsonOrString) - }); - } - } - - }); - return ForumService; -}); + }); -}, -'sbt/main':function(){ -/* -* © Copyright IBM Corp. 2012 -* -* 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. -*/ + /** + * LinkField class represents a Link Field in an Activity Node. + * + * @class LinkField + * @namespace sbt.connections + */ + var LinkField = declare(Field, { + url : null, + title : null, + /** + * Returns Link Field URL + * @method getUrl + * @returns {String} field Url + */ + getUrl : function() { + return this.url; + }, + /** + * Sets Link Field URL + * @method setUrl + * @param {String} field Url + */ + setUrl : function(newUrl) { + this.url = newUrl; + }, + /** + * Returns Link Field Title + * @method getTitle + * @returns {String} field Title + */ + getTitle : function() { + return this.title; + }, + /** + * Sets Link Field Title + * @method setTitle + * @param {String} field Title + */ + setTitle : function(title) { + this.title = title; + } -/** -* @module sbt.main -*/ -define([ - 'sbt/Cache', - 'sbt/DebugTransport', - 'sbt/Endpoint', - 'sbt/ErrorTransport', - 'sbt/Gadget', - 'sbt/GadgetTransport', - 'sbt/IWidget', - 'sbt/Jsonpath', - 'sbt/MockTransport', - 'sbt/Portlet', - 'sbt/Promise', - 'sbt/Proxy', - 'sbt/_config', - 'sbt/compat', - 'sbt/config', - 'sbt/declare', - 'sbt/defer', - 'sbt/dom', - 'sbt/emailService', - 'sbt/i18n', - 'sbt/itemFactory', - 'sbt/json', - 'sbt/lang', - 'sbt/log', - 'sbt/pathUtil', - 'sbt/ready', - 'sbt/stringUtil', - 'sbt/text', - 'sbt/url', - 'sbt/util', - 'sbt/validate', - 'sbt/xml', - 'sbt/xpath', - 'sbt/xsl', - 'sbt/WPSProxy', - 'sbt/authenticator/Basic', - 'sbt/authenticator/GadgetOAuth', - 'sbt/authenticator/OAuth', - 'sbt/authenticator/SSO', - 'sbt/base/AtomEntity', - 'sbt/base/BaseConstants', - 'sbt/base/BaseEntity', - 'sbt/base/BaseService', - 'sbt/base/DataHandler', - 'sbt/base/JsonDataHandler', - 'sbt/base/VCardDataHandler', - 'sbt/base/XmlDataHandler', - 'sbt/base/core', - 'sbt/connections/ActivityConstants', - 'sbt/connections/ActivityService', - 'sbt/connections/ActivityStreamConstants', - 'sbt/connections/ActivityStreamService', - 'sbt/connections/BlogConstants', - 'sbt/connections/BlogService', - 'sbt/connections/BookmarkConstants', - 'sbt/connections/BookmarkService', - 'sbt/connections/CommunityConstants', - 'sbt/connections/CommunityService', - 'sbt/connections/ConnectionsConstants', - 'sbt/connections/ConnectionsService', - 'sbt/connections/FileConstants', - 'sbt/connections/FileService', - 'sbt/connections/FollowConstants', - 'sbt/connections/FollowService', - 'sbt/connections/ForumConstants', - 'sbt/connections/ForumService', - 'sbt/connections/ProfileAdminService', - 'sbt/connections/ProfileConstants', - 'sbt/connections/ProfileService', - 'sbt/connections/SearchConstants', - 'sbt/connections/SearchService', - 'sbt/connections/Tag', - 'sbt/connections/WikiConstants', - 'sbt/connections/WikiService', - 'sbt/data/AtomReadStore', - 'sbt/nls/Endpoint', - 'sbt/nls/ErrorTransport', - 'sbt/nls/loginForm', - 'sbt/nls/messageSSO', - 'sbt/nls/util', - 'sbt/nls/validate', - 'sbt/smartcloud/CommunityConstants', - 'sbt/smartcloud/ProfileConstants', - 'sbt/smartcloud/ProfileService', - 'sbt/smartcloud/SmartcloudConstants', - 'sbt/smartcloud/Subscriber', - 'sbt/store/AtomStore', - 'sbt/store/parameter', - 'sbt/authenticator/nls/SSO', - 'sbt/authenticator/templates/ConnectionsLogin.html', - 'sbt/authenticator/templates/ConnectionsLoginDialog.html', - 'sbt/authenticator/templates/Message.html', - 'sbt/authenticator/templates/MessageDialogSSO.html', - 'sbt/authenticator/templates/MessageSSO.html', - 'sbt/authenticator/templates/login.html', - 'sbt/authenticator/templates/login', - 'sbt/authenticator/templates/loginDialog.html', - 'sbt/authenticator/templates/messageSSO', - 'sbt/connections/nls/CommunityService', - 'sbt/connections/nls/ConnectionsService', - 'sbt/connections/nls/ProfileService' -],function() { - return; -}); + }); -}, -'sbt/entities':function(){ -// The entities class from dojox/html/entities. -define(["./lang"], function(lang) { - // Entity characters for HTML, represented as an array of - // character code, entity name (minus & and ; wrapping. - // The function wrapper is to fix global leaking with the build tools. - var dhe = {}; - - var _applyEncodingMap = function(str, map){ - // summary: - // Private internal function for performing encoding of entity characters. - // tags: - // private - - // Check to see if we have genned and cached a regexp for this map yet - // If we have, use it, if not, gen it, cache, then use. - var mapper, regexp; - if(map._encCache && - map._encCache.regexp && - map._encCache.mapper && - map.length == map._encCache.length){ - mapper = map._encCache.mapper; - regexp = map._encCache.regexp; - }else{ - mapper = {}; - regexp = ["["]; - var i; - for(i = 0; i < map.length; i++){ - mapper[map[i][0]] = "&" + map[i][1] + ";"; - regexp.push(map[i][0]); - } - regexp.push("]"); - regexp = new RegExp(regexp.join(""), "g"); - map._encCache = { - mapper: mapper, - regexp: regexp, - length: map.length - }; - } - str = str.replace(regexp, function(c){ - return mapper[c]; - }); - return str; - }; - - var _applyDecodingMap = function(str, map){ - // summary: - // Private internal function for performing decoding of entity characters. - // tags: - // private - var mapper, regexp; - if(map._decCache && - map._decCache.regexp && - map._decCache.mapper && - map.length == map._decCache.length){ - mapper = map._decCache.mapper; - regexp = map._decCache.regexp; - }else{ - mapper = {}; - regexp = ["("]; - var i; - for(i = 0; i < map.length; i++){ - var e = "&" + map[i][1] + ";"; - if(i){regexp.push("|");} - mapper[e] = map[i][0]; - regexp.push(e); - } - regexp.push(")"); - regexp = new RegExp(regexp.join(""), "g"); - map._decCache = { - mapper: mapper, - regexp: regexp, - length: map.length - }; - } - str = str.replace(regexp, function(c){ - return mapper[c]; - }); - return str; - }; + /** + * FileField class represents a File Field in an Activity Node. + * + * @class FileField + * @namespace sbt.connections + */ + var FileField = declare(Field, { + url : null, + fileType : null, + size : null, + length : null, + /** + * Returns File Field URL + * @method getUrl + * @returns {String} field URL + */ + getUrl : function() { + return this.url; + }, + /** + * Returns File Field File Type + * @method getFileType + * @returns {String} File Type + */ + getFileType : function() { + return this.type; + }, - dhe.html = [ - ["\u0026","amp"], ["\u0022","quot"],["\u003C","lt"], ["\u003E","gt"], - ["\u00A0","nbsp"] - ]; - - // Entity characters for Latin characters and similar, represented as an array of - // character code, entity name (minus & and ; wrapping. - dhe.latin = [ - ["\u00A1","iexcl"],["\u00A2","cent"],["\u00A3","pound"],["\u20AC","euro"], - ["\u00A4","curren"],["\u00A5","yen"],["\u00A6","brvbar"],["\u00A7","sect"], - ["\u00A8","uml"],["\u00A9","copy"],["\u00AA","ordf"],["\u00AB","laquo"], - ["\u00AC","not"],["\u00AD","shy"],["\u00AE","reg"],["\u00AF","macr"], - ["\u00B0","deg"],["\u00B1","plusmn"],["\u00B2","sup2"],["\u00B3","sup3"], - ["\u00B4","acute"],["\u00B5","micro"],["\u00B6","para"],["\u00B7","middot"], - ["\u00B8","cedil"],["\u00B9","sup1"],["\u00BA","ordm"],["\u00BB","raquo"], - ["\u00BC","frac14"],["\u00BD","frac12"],["\u00BE","frac34"],["\u00BF","iquest"], - ["\u00C0","Agrave"],["\u00C1","Aacute"],["\u00C2","Acirc"],["\u00C3","Atilde"], - ["\u00C4","Auml"],["\u00C5","Aring"],["\u00C6","AElig"],["\u00C7","Ccedil"], - ["\u00C8","Egrave"],["\u00C9","Eacute"],["\u00CA","Ecirc"],["\u00CB","Euml"], - ["\u00CC","Igrave"],["\u00CD","Iacute"],["\u00CE","Icirc"],["\u00CF","Iuml"], - ["\u00D0","ETH"],["\u00D1","Ntilde"],["\u00D2","Ograve"],["\u00D3","Oacute"], - ["\u00D4","Ocirc"],["\u00D5","Otilde"],["\u00D6","Ouml"],["\u00D7","times"], - ["\u00D8","Oslash"],["\u00D9","Ugrave"],["\u00DA","Uacute"],["\u00DB","Ucirc"], - ["\u00DC","Uuml"],["\u00DD","Yacute"],["\u00DE","THORN"],["\u00DF","szlig"], - ["\u00E0","agrave"],["\u00E1","aacute"],["\u00E2","acirc"],["\u00E3","atilde"], - ["\u00E4","auml"],["\u00E5","aring"],["\u00E6","aelig"],["\u00E7","ccedil"], - ["\u00E8","egrave"],["\u00E9","eacute"],["\u00EA","ecirc"],["\u00EB","euml"], - ["\u00EC","igrave"],["\u00ED","iacute"],["\u00EE","icirc"],["\u00EF","iuml"], - ["\u00F0","eth"],["\u00F1","ntilde"],["\u00F2","ograve"],["\u00F3","oacute"], - ["\u00F4","ocirc"],["\u00F5","otilde"],["\u00F6","ouml"],["\u00F7","divide"], - ["\u00F8","oslash"],["\u00F9","ugrave"],["\u00FA","uacute"],["\u00FB","ucirc"], - ["\u00FC","uuml"],["\u00FD","yacute"],["\u00FE","thorn"],["\u00FF","yuml"], - ["\u0192","fnof"],["\u0391","Alpha"],["\u0392","Beta"],["\u0393","Gamma"], - ["\u0394","Delta"],["\u0395","Epsilon"],["\u0396","Zeta"],["\u0397","Eta"], - ["\u0398","Theta"], ["\u0399","Iota"],["\u039A","Kappa"],["\u039B","Lambda"], - ["\u039C","Mu"],["\u039D","Nu"],["\u039E","Xi"],["\u039F","Omicron"], - ["\u03A0","Pi"],["\u03A1","Rho"],["\u03A3","Sigma"],["\u03A4","Tau"], - ["\u03A5","Upsilon"],["\u03A6","Phi"],["\u03A7","Chi"],["\u03A8","Psi"], - ["\u03A9","Omega"],["\u03B1","alpha"],["\u03B2","beta"],["\u03B3","gamma"], - ["\u03B4","delta"],["\u03B5","epsilon"],["\u03B6","zeta"],["\u03B7","eta"], - ["\u03B8","theta"],["\u03B9","iota"],["\u03BA","kappa"],["\u03BB","lambda"], - ["\u03BC","mu"],["\u03BD","nu"],["\u03BE","xi"],["\u03BF","omicron"], - ["\u03C0","pi"],["\u03C1","rho"],["\u03C2","sigmaf"],["\u03C3","sigma"], - ["\u03C4","tau"],["\u03C5","upsilon"],["\u03C6","phi"],["\u03C7","chi"], - ["\u03C8","psi"],["\u03C9","omega"],["\u03D1","thetasym"],["\u03D2","upsih"], - ["\u03D6","piv"],["\u2022","bull"],["\u2026","hellip"],["\u2032","prime"], - ["\u2033","Prime"],["\u203E","oline"],["\u2044","frasl"],["\u2118","weierp"], - ["\u2111","image"],["\u211C","real"],["\u2122","trade"],["\u2135","alefsym"], - ["\u2190","larr"],["\u2191","uarr"],["\u2192","rarr"],["\u2193","darr"], - ["\u2194","harr"],["\u21B5","crarr"],["\u21D0","lArr"],["\u21D1","uArr"], - ["\u21D2","rArr"],["\u21D3","dArr"],["\u21D4","hArr"],["\u2200","forall"], - ["\u2202","part"],["\u2203","exist"],["\u2205","empty"],["\u2207","nabla"], - ["\u2208","isin"],["\u2209","notin"],["\u220B","ni"],["\u220F","prod"], - ["\u2211","sum"],["\u2212","minus"],["\u2217","lowast"],["\u221A","radic"], - ["\u221D","prop"],["\u221E","infin"],["\u2220","ang"],["\u2227","and"], - ["\u2228","or"],["\u2229","cap"],["\u222A","cup"],["\u222B","int"], - ["\u2234","there4"],["\u223C","sim"],["\u2245","cong"],["\u2248","asymp"], - ["\u2260","ne"],["\u2261","equiv"],["\u2264","le"],["\u2265","ge"], - ["\u2282","sub"],["\u2283","sup"],["\u2284","nsub"],["\u2286","sube"], - ["\u2287","supe"],["\u2295","oplus"],["\u2297","otimes"],["\u22A5","perp"], - ["\u22C5","sdot"],["\u2308","lceil"],["\u2309","rceil"],["\u230A","lfloor"], - ["\u230B","rfloor"],["\u2329","lang"],["\u232A","rang"],["\u25CA","loz"], - ["\u2660","spades"],["\u2663","clubs"],["\u2665","hearts"],["\u2666","diams"], - ["\u0152","Elig"],["\u0153","oelig"],["\u0160","Scaron"],["\u0161","scaron"], - ["\u0178","Yuml"],["\u02C6","circ"],["\u02DC","tilde"],["\u2002","ensp"], - ["\u2003","emsp"],["\u2009","thinsp"],["\u200C","zwnj"],["\u200D","zwj"], - ["\u200E","lrm"],["\u200F","rlm"],["\u2013","ndash"],["\u2014","mdash"], - ["\u2018","lsquo"],["\u2019","rsquo"],["\u201A","sbquo"],["\u201C","ldquo"], - ["\u201D","rdquo"],["\u201E","bdquo"],["\u2020","dagger"],["\u2021","Dagger"], - ["\u2030","permil"],["\u2039","lsaquo"],["\u203A","rsaquo"] - ]; - - dhe.encode = function(str/*string*/, m /*array?*/){ - // summary: - // Function to obtain an entity encoding for a specified character - // str: - // The string to process for possible entity encoding. - // m: - // An optional list of character to entity name mappings (array of - // arrays). If not provided, it uses the and Latin entities as the - // set to map and escape. - // tags: - // public - if(str){ - if(!m){ - // Apply the basic mappings. HTML should always come first when decoding - // as well. - str = _applyEncodingMap(str, dhe.html); - str = _applyEncodingMap(str, dhe.latin); - - }else{ - str = _applyEncodingMap(str, m); - } - } - return str; - }; - - dhe.decode = function(str/*string*/, m /*array?*/){ - // summary: - // Function to obtain an entity encoding for a specified character - // str: - // The string to process for possible entity encoding to decode. - // m: - // An optional list of character to entity name mappings (array of - // arrays). If not provided, it uses the HTML and Latin entities as the - // set to map and decode. - // tags: - // public - if(str){ - if(!m){ - // Apply the basic mappings. HTML should always come first when decoding - // as well. - str = _applyDecodingMap(str, dhe.html); - str = _applyDecodingMap(str, dhe.latin); - - }else{ - str = _applyDecodingMap(str, m); - } - } - return str; - }; - return dhe; -}); + /** + * Returns File Field File Size + * @method getSize + * @returns {String} File Size + */ + getSize : function() { + return this.size; + }, + /** + * Returns File Field File Length + * @method getLength + * @returns {String} File Length + */ + getLength : function() { + return this.length; + } + }); + + /** + * PersonField class represents a Person Field in an Activity Node. + * + * @class PersonField + * @namespace sbt.connections + */ + var PersonField = declare(Field, { + personName : null, + userId : null, + email : null, + + /** + * Returns Person Name + * @method getPersonName + * @returns {String} Person Name + */ + getPersonName : function() { + return this.personName; + }, + /** + * Sets Person Name + * @method setPersonName + * @param {String} Person Name + */ + setPersonName : function(newName) { + this.personName = newName; + }, + /** + * Returns Person User ID + * @method getUserId + * @returns {String} Person User ID + */ + getUserId : function() { + return this.userId; + }, + /** + * Sets Person User ID + * @method setUserId + * @param {String} Person User ID + */ + setUserId : function(newUserId) { + this.userId = newUserId; + }, + /** + * Returns Person Email + * @method getEmail + * @returns {String} Person Email + */ + getEmail : function() { + return this.email; + }, + /** + * Sets Person Email + * @method setEmail + * @param {String} Person Email + */ + setEmail : function(newEmail) { + this.email = newEmail; + } + }); + /** + * Tag class represents an entry for a Tag feed returned by the Connections REST API. + * + * @class Tag + * @namespace sbt.connections + */ + var Tag = declare(BaseEntity, { + /** + * Construct a Tag entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, -}, -'sbt/connections/nls/ProfileService':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ + /** + * Returns tag term + * @method getTerm + * @returns {String} tag term + */ + getTerm : function() { + return this.getAsString("term"); + }, + /** + * Returns tag frequency + * @method getFrequency + * @returns {String} tag frequency + */ + getFrequency : function() { + return this.getAsString("frequency"); + }, -/** - * Social Business Toolkit SDK - Default resource bundle for ProfileService - */ -define({ - root: ({ - invalid_argument : "Invalid Argument" - }) -}); -}, -'url:sbt/connections/controls/search/templates/CommunityBody.html':"
    \r\n
      \r\n ${communityMembers}\r\n
    • \r\n ${updatedLabel}\r\n
    • \r\n ${tagsList}\r\n
    \r\n\r\n
    \r\n\r\n", -'url:sbt/connections/controls/forums/templates/BootstrapTopicRow.html':"\r\n\t\r\n\t\t\r\n\r\n\t\t\r\n\t\t\t${title}\r\n\t\t\r\n\t\r\n", -'sbt/Promise':function(){ -/* - * © 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. - */ + /** + * Returns tag bin + * @method getBin + * @returns {String} tag bin + */ + getBin : function() { + return this.getAsString("bin"); + } + }); -/** - * Social Business Toolkit SDK. - * - * @module sbt.Promise - */ -define(["./declare","./log"], function(declare,log) { + /** + * Activity class represents an entry for a activities feed returned by the Connections REST API. + * + * @class Activity + * @namespace sbt.connections + */ + var Activity = declare(AtomEntity, { - /** - * Promise class - * - * @class Promise - * @namespace sbt - */ - var Promise = declare(null, { - - // private - _isRejected : false, - _isFulfilled : false, - _isCanceled : false, - _deferreds : null, - response : null, - error : null, - - /* - * Constructor for the promise. - */ - constructor: function(response) { - if (response) { - if (response instanceof Error) { - this.rejected(response); - } else { - this.fulfilled(response); - } - } else { - this._deferreds = []; - } - }, - - /* - * Add new callbacks to the promise. - */ - then: function(fulfilledHandler, errorHandler) { - var promise = new Promise(); - if (this._isFulfilled) { - this._fulfilled(fulfilledHandler, errorHandler, promise, this.data); - } else if (this._isRejected) { - this._rejected(errorHandler, promise, this.error); - } else { - this._deferreds.push([ fulfilledHandler, errorHandler, promise ]); - } - return promise; - }, + xpath : consts.ActivityNodeXPath, + namespaces : consts.ActivityNamespaces, + contentType : "html", + categoryScheme : null, - /* - * Inform the deferred it may cancel its asynchronous operation. - */ - cancel: function(reason, strict) { - this._isCanceled = true; - }, + /** + * Construct an Activity entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, - /* - * Checks whether the promise has been resolved. - */ - isResolved: function() { - return this._isRejected || this._isFulfilled; - }, + /** + * Sets template for category Scheme + */ + setCategoryScheme : function() { + this.categoryScheme = stringUtil.transform(ActivityCategory, this, transformer, this); + }, + - /* - * Checks whether the promise has been rejected. - */ - isRejected: function() { - return this._isRejected; - }, + /** + * Returns the ID + * @method getUuid + * @returns {String} Uuid + */ + getUuid : function() { + var _id = this.id || this._fields.id || this.getId(); + this.id = _id; + this._fields.id = _id; + return _id; + }, - /* - * Checks whether the promise has been resolved or rejected. - */ - isFulfilled: function() { - return this._isFulfilled; - }, + /** + * Return the value of id from result ATOM entry document. + * + * @method getActivityUuid + * @return {String} ID of the activity + */ + getActivityUuid : function() { + return extractId(this.getUuid(), "urn:lsid:ibm.com:oa:"); + }, - /* - * Checks whether the promise has been canceled. - */ - isCanceled: function() { - return this._isCanceled; - }, + /** + * Returns the Author LdapId + * + * @method getAuthorLdapId + * @returns {Stirng} authorLdapId + */ + getAuthorLdapId : function() { + return this.getAsString("authorLdapid"); + }, - /* - * Called if the promise has been fulfilled - */ - fulfilled : function(data) { - if (this._isCanceled) { - return; - } - - this._isFulfilled = true; - this.data = data; - - if (this._deferreds) { - while (this._deferreds.length > 0) { - var deferred = this._deferreds.shift(); - var fulfilledHandler = deferred[0]; - var errorHandler = deferred[1]; - var promise = deferred[2]; - this._fulfilled(fulfilledHandler, errorHandler, promise, data); - } - } - }, - - /* - * Call if the promise has been rejected - */ - rejected : function(error) { - if (this._canceled) { - return; - } - - this._isRejected = true; - this.error = error; - - if (this._deferreds) { - while (this._deferreds.length > 0) { - var deferred = this._deferreds.shift(); - var errorHandler = deferred[1]; - var promise = deferred[2]; - this._rejected(errorHandler, promise, error); - } - } - }, - - _fulfilled : function(fulfilledHandler, errorHandler, promise, data) { - if (fulfilledHandler) { - try { - var retval = fulfilledHandler(data); - if (retval instanceof Promise) { - retval.then( - function(data) { - promise.fulfilled(data); - }, - function(error) { - promise.rejected(error); - } - ); - } else { - promise.fulfilled(retval); - } - } catch (error) { - promise.rejected(error); - } - } else { - promise.fulfilled(data); - } - }, - - _rejected : function(errorHandler, promise, error) { - if (errorHandler) { - try { - var retval = errorHandler(error); - if (!retval) { - // stop propogating errors - promise.rejected(retval); - } - } catch (error1) { - promise.rejected(error1); - } - } else { - promise.rejected(error); - } - } - - }); - return Promise; -}); -}, -'url:sbt/controls/grid/templates/Grid.html':"
    \r\n", -'sbt/connections/controls/ViewAllAction':function(){ -/* - * © 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. - */ + /** + * Returns the contributor LdapId + * + * @method getContributorLdapId + * @returns {Object} contributor + */ + getContributorLdapId : function() { + return this.getAsString("contributorLdapid"); + }, -/** - * @module sbt.connections.controls.ViewAllAction - */ -define([ "../../declare", "../../controls/grid/GridAction" ], - function(declare, GridAction) { + /** + * Returns Activity Node Type + * + * @method getType + * @returns {String} type + */ + getType : function() { + return this.getAsString("type"); + }, - /** - * @class sbt.connections.controls.ViewAllAction - * @namespace sbt.connections.controls - */ - var ViewAllAction = declare(GridAction, { - - /**Strings used in the actions */ - nls: { - tooltip: "View All" - }, - - /**ViewAllAction Constructor function - * @method - constructor - * */ - constructor: function() { - }, - - /** - * Handles displaying a tooltip for an item - * For profiles, the tooltip by default will be a business card - * So nothing is done in this function - * @method - getTooltip - * @param item - The element that will use the tooltip - */ - getTooltip: function(item) { - return "derp"; - }, - - /** - * The execute function is called from the handle click function - * For Profiles by default the business card functionality is used - * which works from the Semantic tag service so nothing is done here. - * @method - execute - * @param item - The item which fired the event - * @param opts - * @param event - The event - */ - execute: function(item, opts, event) { - opts.grid.renderer.hideViewAll = true; - opts.grid.renderer.template = opts.grid.renderer.fullTemplate; - opts.grid.renderer.render(opts.grid, opts.grid.gridNode, item.items, item); - console.log("clicked the view all link"); - } + /** + * Sets Activity Node Type + * @method setType + * @param {String} type + */ + setType : function(type) { + return this.setAsString("type", type); + }, + /** + * Returns Activity Node Priority + * + * @method getPriority + * @returns {String} priority + */ + getPriority : function() { + return this.getAsString("priority"); + }, - }); + /** + * Return tags of IBM Connections activity from activity ATOM entry document. + * + * @method getTags + * @return {Object} Array of tags of the activity + */ + getTags : function() { + return this.getAsArray("tags"); + }, - return ViewAllAction; -}); -}, -'sbt/connections/controls/vcard/SemanticTagService':function(){ -/* - * © 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. - */ + /** + * Set new tags to be associated with this IBM Connections activity. + * + * @method setTags + * @param {Object} Array of tags to be added to the activity + */ + + setTags : function(tags) { + return this.setAsArray("tags", tags); + }, + + /** + * Returns the dueDate Date + * + * @method getDueDate + * @returns {Date} DueDate + */ + getDueDate : function() { + return this.getAsDate("dueDate"); + }, + + /** + * Sets the Due Date of Activity + * @method setDueDate + * @param {Date} dueDate + */ + setDueDate : function(dueDate) { + return this.setAsDate("dueDate", dueDate); + }, + + /** + * Returns Activity Node Members Url + * + * @method getMembersUrl + * @returns {String} membersUrl + */ + getMembersUrl : function() { + return this.getAsString("membersUrl"); + }, + + /** + * Returns Activity Node History Url + * + * @method getHistoryUrl + * @returns {String} historyUrl + */ + getHistoryUrl : function() { + return this.getAsString("historyUrl"); + }, -/** - * - */ + /** + * Returns Activity Node Templates Url + * + * @method getTemplatesUrl + * @returns {String} templatesUrl + */ + getTemplatesUrl : function() { + return this.getAsString("templatesUrl"); + }, -define([ "../../../declare", "../../../Endpoint", "../../../config", "../../../log"], - function(declare, Endpoint, config, log) { + /** + * Returns Activity Position + * + * @method getPosition + * @returns {String} position + */ + getPosition : function() { + return this.getAsString("position"); + }, - - /** - * Configuration Object. - * - * isBidiRTL - Whether or not to enable bidirectional language support. - * - * @property SemTagSvcConfig - * @type Object - */ - var SemTagSvcConfig = { - isBidiRTL: true - }; - - /** - * The class which handles loading of the semantic tag service for connections, this is needed for displaying vcards. - * - * @class sbt.controls.vcard.connections.SemanticTagService - */ - var SemanticTagService = declare(null, { - }); + /** + * Sets Activity Position + * @method setPosition + * @param position + */ + setPosition : function(position) { + return this.setAsString("position", position); + }, - /** - * Load the Semantic tag service to parse any cards on the page. - * - * @param {Object} [options] - * @params {Function} [options.error] - * An optional error callback, to be fired - * in the event of a problem loading the - * SemanticTagService from Connections. - * @params {Boolean} [options.inclCss] - * If true include's the card's css, - * otherwise false. - * @params {String} [options.endpoint] - * The name of the endpoint to be - * used when fetching the - * SemanticTagService. - */ - SemanticTagService.loadSemanticTagService = function(options){ - // Only load the service once. - if (SemTagSvcConfig.loading || SemTagSvcConfig.loaded) { - return; - } - - if (SemTagSvcConfig.error) { - if (errBack) { - errBack(SemTagSvcConfig.error); - } - return; - } - //Set up defaults. - var inclDojo = false; - var inclCss = false; - var isBidiRTL = false; - var endpointName = "connections"; - var errBack = null; - var missingDojoError = function missingDojoError(){ - log.error("SemanticTagService.loadSemanticTagService:" + - " Dojo is not available, set arg inclDojo : true to load Dojo from Connections."); - if(errBack){ - errBack(SemTagSvcConfig.error); - } - return; - }; - - if(options){ - errBack = options.error || errBack; - isBidiRTL = options.isBidiRTL || isBidiRTL; - endpointName = options.endpoint || endpointName; - inclCss = options.inclCss || inclCss; - inclDojo = options.inclDojo || inclDojo; - //we need dojo from somewhere. - if(!dojo){ - if(!options.inclDojo){ - missingDojoError(); - }else{ - inclDojo = true; - } - } - }else{ - if(!dojo){ - missingDojoError(); - } - } - // We'll be loading the card now. - SemTagSvcConfig.loading = true; - var endpoint = config.findEndpoint(endpointName); - var proxy = endpoint.getProxyUrl(); - - window.SemTagSvcConfig = window.SemTagSvcConfig || {}; - window.SemTagSvcConfig.baseUrl = proxy; - window.SemTagSvcConfig.proxyURL = proxy; - - var serviceUrl = "/profiles/ibm_semanticTagServlet/javascript/semanticTagService.js"; - - var locale = "en"; - dojo.config.proxy = proxy; - locale = dojo.config.locale; - - if(inclCss){ - window.SemTagSvcConfig.loadCssFiles = inclCss; - var pathToResources = "connections"; - pathToResources = endpoint.serviceMappings["pathToResources"] || pathToResources; - - window.SemTagSvcConfig.resourcesSvc = endpoint.baseUrl + "/" + pathToResources + "/resources"; //resourcesSvc is used when loading css. - //Load straight from connections so that relative css urls work. - } - - var requestArgs = { - method : "GET", - handleAs : "text", - query : { - 'inclDojo': inclDojo - }, - headers: { - "Accept-Language": locale + ",en;q=0.8" - } - }; - - endpoint.request(serviceUrl, requestArgs).then( - function(semTagScript){ - SemTagSvcConfig.loading = false; - try { - var re = new RegExp(endpoint.baseUrl, "g"); - var _semTagScript = semTagScript.replace(re, proxy); - eval(_semTagScript); - SemTagSvcConfig.loaded = true; - } catch (error) { - SemTagSvcConfig.error = error; - if (errBack) { - errBack(error); - } - } - }, - function(error){ - SemTagSvcConfig.loading = false; - SemTagSvcConfig.error = error; - if (errBack) { - errBack(error); - } - } - ); - }; - - return SemanticTagService; -}); + /** + * Returns Completed Flag for Activity + * @method isCompleted + * @returns {Boolean} completed flag + */ + isCompleted : function() { + return this.getAsBoolean("categoryFlagCompleted"); + }, -}, -'url:sbt/connections/controls/profiles/templates/TagListHeader.html':"
    \r\n\t

    ${tagHeader}

    \r\n
    ", -'sbt/connections/FileService':function(){ -/* - * © 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. - */ + /** + * Set Completed Flag + * @param {Boolean} completed + * @returns + */ + setCompleted : function(completed) { + return this.setAsBoolean("categoryFlagCompleted", completed); + }, -/** - * JavaScript API for IBM Connections File Service. - * - * @module sbt.connections.FileService - */ + /** + * Get Delete Flag + * + * @returns {Boolean} isDelete + */ + isDeleted : function() { + return this.getAsBoolean("categoryFlagDelete"); + }, -define( - [ "../declare", "../lang", "../stringUtil", "../Promise", "./FileConstants", "./ConnectionsService", "../base/BaseEntity", "../base/XmlDataHandler", - "../config", "../util", "../xml" ], - function(declare, lang, stringUtil, Promise, consts, ConnectionsService, BaseEntity, XmlDataHandler, config, util, xml) { + /** + * Gets Teplate Flag + * + * @returns {Boolean} template + */ + isTemplate : function() { + return this.getAsBoolean("categoryFlagTemplate"); + }, - var FolderTmpl = "${getCategory}${getId}${getFolderLabel}${getTitle}${getSummary}${getVisibility}${getVisibilityShare}"; - var FolderLabelTmpl = ""; - var FileVisibilityShareTmpl = " "; - var FileFeedTmpl = "${getEntries}"; - var FileEntryTmpl = "${getCategory}${getId}${getUuid}${getLabel}${getTitle}${getSummary}${getVisibility}${getItem}${getTags}${getNotification}"; - var FileItemEntryTmpl = "${getCategory}${getItem}"; - var FileCommentsTmpl = "${getCategory}${getDeleteComment}${getContent}"; - var FileCategoryTmpl = ""; - var FileContentTmpl = "${content}"; - var FileDeleteCommentTmpl = "${deleteWithRecord}"; - var FileIdTmpl = "${id}"; - var FileUuidTmpl = "${uuid}"; - var FileLabelTmpl = ""; - var FileTitleTmpl = "${title}"; - var FileSummaryTmpl = "${summary}"; - var FileVisibilityTmpl = "${visibility}"; - var FileItemIdTmpl = "${fileId}"; - var TagsTmpl = " "; - var NotificationTmpl = "${notification}"; + /** + * Sets Template Flag + * + * @param {Boolean} templateFlag + */ + setTemplate : function(templateFlag) { + return this.setAsBoolean("categoryFlagTemplate", templateFlag); + }, - /** - * Library class associated with a library. - * - * @class Library - * @namespace sbt.connections - */ - var Library = declare(BaseEntity, { + /** + * Returns Activity Node Depth + * + * @method getDepth + * @returns {String} depth + */ + getDepth : function() { + return this.getAsString("depth"); + }, - /** - * Returned the Library Id - * - * @method getId - * @returns {String} Id - */ - getId : function() { - return this.getAsString("id"); - }, + /** + * Returns Activity Node Permissions + * + * @method getPermissions + * @returns {String} permissions + */ + getPermissions : function() { + return this.getAsString("permissions"); + }, - /** - * Returned the Library Uuid - * - * @method getLibrrayUuid - * @returns {String} Uuid - */ - getLibraryUuid : function() { - return this.getAsString("uuid"); - }, + /** + * Returns Activity Node IconUrl + * + * @method getIconUrl + * @returns {String} iconUrl + */ + getIconUrl : function() { + return this.getAsString("iconUrl"); + }, - /** - * Returned the library size - * - * @method getLibrarySize - * @returns {Number} library size - */ - getLibrarySize : function() { - return this.getAsNumber("librarySize"); - }, + /** + * setIconUrl + * @param iconUrl + */ + setIconUrl : function(iconUrl) { + return this.setAsString("iconUrl", iconUrl); + }, - /** - * Returned the library quota - * - * @method getLibraryQuota - * @returns {Number} library quota - */ - getLibraryQuota : function() { - return this.getAsNumber("libraryQuota"); - }, + /** + * getCommunityUuid + * @method getCommunityUuid + * @returns {String} communityUuid + */ + getCommunityUuid : function() { + return this.getAsString("communityUuid"); + }, - /** - * Returned the total removed size - * - * @method getTotalRemovedSize - * @returns {Number} total removed size - */ - getTotalRemovedSize : function() { - return this.getAsNumber("totalRemovedSize"); - }, + /** + * setCommunityUuid + * @method setCommunityUuid + * @param communityUuid + */ + setCommunityUuid : function(communityUuid) { + return this.setAsString("communityUuid", communityUuid); + }, + /** + * getCommunityUrl + * @method getCommunityUrl + * @returns {String} communityUrl + */ + getCommunityUrl : function() { + return this.getAsString("communityUrl"); + }, - /** - * Returned the total results - * - * @method getTotalResults - * @returns {Number} total results - */ - getTotalResults : function() { - return this.getAsNumber("totalResults"); - } - }); - - /** - * Comment class associated with a file comment. - * - * @class Comment - * @namespace sbt.connections - */ - var Comment = declare(BaseEntity, { + /** + * setCommunityUrl + * @method setCommunityUrl + * @param communityUrl + */ + setCommunityUrl : function(communityUrl) { + return this.setAsString("communityUrl", communityUrl); + }, - /** - * Returned the Comment Id - * - * @method getCommentId - * @returns {String} File Id - */ - getCommentId : function() { - return this.id || this.getAsString("uid"); - }, - /** - * Returns Comment Title - * - * @method getTitle - * @returns {String} title - */ - getTitle : function() { - return this.getAsString("title"); - }, - /** - * Returns the Comment Content - * - * @method getContent - * @returns {String} content - */ - getContent : function() { - return this.getAsString("content"); - }, - /** - * Returns The create Date - * - * @method getCreated - * @returns {Date} create Date - */ - getCreated : function() { - return this.getAsDate("created"); - }, - /** - * Returns The modified Date - * - * @method getModified - * @returns {Date} modified Date - */ - getModified : function() { - return this.getAsDate("modified"); - }, - /** - * Returns the version label - * - * @method getVersionLabel - * @returns {String} version label - */ - getVersionLabel : function() { - return this.getAsString("versionLabel"); - }, - /** - * Returns the updated Date - * - * @method getModified - * @returns {Date} modified Date - */ - getUpdated : function() { - return this.getAsDate("updated"); - }, - /** - * Returns the published Date - * - * @method getPublished - * @returns {Date} modified Date - */ - getPublished : function() { - return this.getAsDate("published"); - }, - /** - * Returns the modifier - * - * @method getModifier - * @returns {Object} modifier - */ - getModifier : function() { - return this.getAsObject([ "modifierName", "modifierUserId", "modifierEmail", "modifierUserState" ]); - }, - /** - * Returns the author - * - * @method getAuthor - * @returns {Object} author - */ - getAuthor : function() { - return this.getAsObject([ "authorName", "authorUserId", "authorEmail", "authorUserState" ]); - }, - /** - * Returns the language - * - * @method getLanguage - * @returns {String} language - */ - getLanguage : function() { - return this.getAsString("language"); - }, - /** - * Returns the flag for delete with record - * - * @method getDeleteWithRecord - * @returns {Boolean} delete with record - */ - getDeleteWithRecord : function() { - return this.getAsBoolean("deleteWithRecord"); - } - }); + /** + * Loads the Activity object with the atom entry associated with the activity. By default, a network call is made to load the atom entry + * document in the activity object. + * + * @method load + */ + load : function() { + var promise = this.service.validateField("activityUuid", this.getActivityUuid()); + if (promise) { + return promise; + } + var requestArgs = { + "activityNodeUuid" : this.getActivityUuid() + }; + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + var self = this; + var callbacks = { + createEntity : function(service, data, response) { + self.setData(data, response); + return self; + } + }; + return this.service.getEntity(consts.AtomActivityNode, options, this.getActivityUuid(), callbacks); + }, - /** - * File class associated with a file. - * - * @class File - * @namespace sbt.connections - */ - var File = declare(BaseEntity, { + /** + * Creates an activity, sends an Atom entry document containing the new activity to the user's My Activities feed. + * + * @method create + * @returns {Object} Activity + */ + create : function() { + return this.service.createActivity(this); + }, - /** - * Returns the file Id - * - * @method getFileId - * @returns {String} file Id - */ - getFileId : function() { - return this.id || this.getAsString("uid") || this._fields.id; - }, - /** - * Returns the label - * - * @method getLabel - * @returns {String} label - */ - getLabel : function() { - return this.getAsString("label"); - }, - /** - * Returns the self URL - * - * @method getSelfUrl - * @returns {String} self URL - */ - getSelfUrl : function() { - return this.getAsString("selfUrl"); - }, - /** - * Returns the alternate URL - * - * @method getAlternateUrl - * @returns {String} alternate URL - */ - getAlternateUrl : function() { - return this.getAsString("alternateUrl"); - }, - /** - * Returns the download URL - * - * @method getDownloadUrl - * @returns {String} download URL - */ - getDownloadUrl : function() { - return config.Properties.serviceUrl + "/files/" + this.service.endpoint.proxyPath + "/" + "connections" + "/" + "DownloadFile" + "/" - + this.getFileId() + "/" + this.getLibraryId(); - ; - }, - /** - * Returns the type - * - * @method getType - * @returns {String} type - */ - getType : function() { - return this.getAsString("type"); - }, - /** - * Returns the Category - * - * @method getCategory - * @returns {String} category - */ - getCategory : function() { - return this.getAsString("category"); - }, - /** - * Returns the size - * - * @method getSize - * @returns {Number} length - */ - getSize : function() { - return this.getAsNumber("length"); - }, - /** - * Returns the Edit Link - * - * @method getEditLink - * @returns {String} edit link - */ - getEditLink : function() { - return this.getAsString("editLink"); - }, - /** - * Returns the Edit Media Link - * - * @method getEditMediaLink - * @returns {String} edit media link - */ - getEditMediaLink : function() { - return this.getAsString("editMediaLink"); - }, - /** - * Returns the Thumbnail URL - * - * @method getThumbnailUrl - * @returns {String} thumbnail URL - */ - getThumbnailUrl : function() { - return this.getAsString("thumbnailUrl"); - }, - /** - * Returns the Comments URL - * - * @method getCommentsUrl - * @returns {String} comments URL - */ - getCommentsUrl : function() { - return this.getAsString("commentsUrl"); - }, - /** - * Returns the author - * - * @method getAuthor - * @returns {Object} author - */ - getAuthor : function() { - return this.getAsObject([ "authorName", "authorUserId", "authorEmail", "authorUserState" ]); - }, - /** - * Returns the Title - * - * @method getTitle - * @returns {String} title - */ - getTitle : function() { - return this.getAsString("title"); - }, - /** - * Returns the published date - * - * @method getPublished - * @returns {Date} published date - */ - getPublished : function() { - return this.getAsDate("published"); - }, - /** - * Returns the updated date - * - * @method getUpdated - * @returns {Date} updated date - */ - getUpdated : function() { - return this.getAsDate("updated"); - }, - /** - * Returns the created date - * - * @method getCreated - * @returns {Date} created date - */ - getCreated : function() { - return this.getAsDate("created"); - }, - /** - * Returns the modified date - * - * @method getModified - * @returns {Date} modified date - */ - getModified : function() { - return this.getAsDate("modified"); - }, - /** - * Returns the last accessed date - * - * @method getLastAccessed - * @returns {Date} last accessed date - */ - getLastAccessed : function() { - return this.getAsDate("lastAccessed"); - }, - /** - * Returns the modifier - * - * @method getModifier - * @returns {Object} modifier - */ - getModifier : function() { - return this.getAsObject([ "modifierName", "modifierUserId", "modifierEmail", "modifierUserState" ]); - }, - /** - * Returns the visibility - * - * @method getVisibility - * @returns {String} visibility - */ - getVisibility : function() { - return this.getAsString("visibility"); - }, - /** - * Returns the library Id - * - * @method getLibraryId - * @returns {String} library Id - */ - getLibraryId : function() { - return this.getAsString("libraryId"); - }, - - /** - * Sets the library Id - * - * @method setLibraryId - * @param libaryId - */ - setLibraryId : function(libraryId) { - return this.setAsString("libraryId", libraryId); - }, - /** - * Returns the library Type - * - * @method getLibraryType - * @returns {String} library Type - */ - getLibraryType : function() { - return this.getAsString("libraryType"); - }, - /** - * Returns the version Id - * - * @method getVersionUuid - * @returns {String} version Id - */ - getVersionUuid : function() { - return this.getAsString("versionUuid"); - }, - /** - * Returns the version label - * - * @method getVersionLabel - * @returns {String} version label - */ - getVersionLabel : function() { - return this.getAsString("versionLabel"); - }, - /** - * Returns the propagation - * - * @method getPropagation - * @returns {String} propagation - */ - getPropagation : function() { - return this.getAsString("propagation"); - }, - /** - * Returns the recommendations Count - * - * @method getRecommendationsCount - * @returns {Number} recommendations Count - */ - getRecommendationsCount : function() { - return this.getAsNumber("recommendationsCount"); - }, - /** - * Returns the comments Count - * - * @method getCommentsCount - * @returns {Number} comments Count - */ - getCommentsCount : function() { - return this.getAsNumber("commentsCount"); - }, - /** - * Returns the shares Count - * - * @method getSharesCount - * @returns {Number} shares Count - */ - getSharesCount : function() { - return this.getAsNumber("sharesCount"); - }, - /** - * Returns the folders Count - * - * @method getFoldersCount - * @returns {Number} folders Count - */ - getFoldersCount : function() { - return this.getAsNumber("foldersCount"); - }, - /** - * Returns the attachments Count - * - * @method getAttachmentsCount - * @returns {Number} attachments Count - */ - getAttachmentsCount : function() { - return this.getAsNumber("attachmentsCount"); - }, - /** - * Returns the versions Count - * - * @method getVersionsCount - * @returns {Number} versions Count - */ - getVersionsCount : function() { - return this.getAsNumber("versionsCount"); - }, - /** - * Returns the references Count - * - * @method getReferencesCount - * @returns {Number} references Count - */ - getReferencesCount : function() { - return this.getAsNumber("referencesCount"); - }, - /** - * Returns the total Media Size - * - * @method getTotalMediaSize - * @returns {Number} total Media Size - */ - getTotalMediaSize : function() { - return this.getAsNumber("totalMediaSize"); - }, - /** - * Returns the Summary - * - * @method getSummary - * @returns {String} Summary - */ - getSummary : function() { - return this.getAsString("summary"); - }, - /** - * Returns the Content URL - * - * @method getContentUrl - * @returns {String} Content URL - */ - getContentUrl : function() { - return this.getAsString("contentUrl"); - }, - /** - * Returns the Content Type - * - * @method getContentType - * @returns {String} Content Type - */ - getContentType : function() { - return this.getAsString("contentType"); - }, - /** - * Returns the objectTypeId - * - * @method getObjectTypeId - * @returns {String} objectTypeId - */ - getObjectTypeId : function() { - return this.getAsString("objectTypeId"); - }, - /** - * Returns the lock state - * - * @method getLockType - * @returns {String} lock state - */ - getLockType : function() { - return this.getAsString("lock"); - }, - /** - * Returns the permission ACLs - * - * @method getAcls - * @returns {String} ACLs - */ - getAcls : function() { - return this.getAsString("acls"); - }, - /** - * Returns the hit count - * - * @method getHitCount - * @returns {Number} hit count - */ - getHitCount : function() { - return this.getAsNumber("hitCount"); - }, - /** - * Returns the anonymous hit count - * - * @method getAnonymousHitCount - * @returns {Number} anonymous hit count - */ - getAnonymousHitCount : function() { - return this.getAsNumber("anonymousHitCount"); - }, - /** - * Returns the tags - * - * @method getTags - * @returns {Array} tags - */ - getTags : function() { - return this.getAsArray("tags"); - }, - /** - * Returns the tags - * - * @method setTags - * @param {Array} tags - */ - setTags : function(tags) { - return this.setAsArray("tags", tags); - }, - /** - * Sets the label - * - * @method setLabel - * @param {String} label - */ - setLabel : function(label) { - return this.setAsString("label", label); - }, - /** - * Sets the summary - * - * @method setSummary - * @param {String} summary - */ - setSummary : function(summary) { - return this.setAsString("summary", summary); - }, - /** - * Sets the visibility - * - * @method setVisibility - * @param {String} visibility - */ - setVisibility : function(visibility) { - return this.setAsString("visibility", visibility); - }, + /** + * updates an activity, send a replacement Atom Entry document containing the modified activity to the existing activity's edit URL + * @method update + * @returns {Object} activity + */ + update : function() { + return this.service.updateActivity(this); + }, + + /** + * Deletes an activity entry, sends an HTTP DELETE method to the edit web address specified for the node. + * + * @method deleteActivity + */ + deleteActivity : function() { + return this.service.deleteActivity(this.getActivityUuid()); + }, + + /** + * Restores a deleted activity, use a HTTP PUT request. This moves the activity from the trash feed to the user's My Activities feed. + * + * @method restore + */ + restore : function() { + return this.service.restoreActivity(this.getActivityUuid()); + }, + + /** + * Adds a member to the access control list of an activity, sends an Atom entry document containing the new member to the access control list + * feed. You can only add one member per post. + * @method addMember + * @param {Object} memberOrJson + */ + addMember : function(memberOrJson) { + return this.service.addMember(this.getActivityUuid(), memberOrJson); + }, - /** - * Sets Indicator whether the currently authenticated user wants to receive notifications as people edit the document. Options are on or off. - * @param {Boolean} notification - * @returns - */ - setNotification : function(notification) { - return this.setAsBoolean("notification", notification ? "on" : "off"); - }, - /** - * Loads the file object with the atom entry associated with the file. By default, a network call is made to load the atom entry document in the - * file object. - * - * @method load - * @param {Object} [args] Argument object - * @param {Boolean} [isPublic] Optinal flag to indicate whether to load public file which does not require authentication - */ - load : function(args, isPublic, url) { - // detect a bad request by validating required arguments - var fileUuid = this.getFileId(); - var promise = this.service.validateField("fileId", fileUuid); - if (promise) { - return promise; - } - if(isPublic) { - promise = this.service.validateField("libraryId", this.getLibraryId()); - if (promise) { - return promise; + /** + * Removes a member from the acl list for an application, use the HTTP DELETE method. + * @method removeMember + * @param {String} memberId + */ + removeMember : function(memberId) { + return this.service.deleteMember(this.getActivityUuid(), memberId); + }, + + /** + * Updates a member in the access control list for an application, sends a replacement member entry document in Atom format to the existing ACL + * node's edit web address. + * @method updateMember + * @param {Object} memberOrJson + */ + updateMember : function(memberOrJson) { + return this.service.updateMember(this.getActivityUuid(), memberOrJson); + }, + + /** + * Retrieves a member from the access control list for a application, use the edit link found in the member entry in the ACL list feed. + * @method getMember + * @param {String} memberId + * @returns {Object} Member + */ + getMember : function(memberId) { + return this.service.getMember(this.getActivityUuid(), memberId); + }, + + /** + * Retrieves activity members from the access control list for a application, use the edit link found in the member entry in the ACL list feed. + * @method getMembers + * @param {Object} [requestArgs] the optional arguments + * @returns {Array} members + */ + getMembers : function(requestArgs) { + return this.service.getMembers(this.getActivityUuid(), requestArgs); + }, + + /** + * Creats an entry in an activity, such as a to-do item or to add a reply to another entry, send an Atom entry document containing the new + * activity node of the appropriate type to the parent activity's node list. + * + * @mehtod createActivityNode + * @param {Object} activityNodeOrJson + * @returns {Object} ActivityNode + */ + createActivityNode : function(activityNodeOrJson) { + return this.service.createActivityNode(this.getActivityUuid(), activityNodeOrJson); + }, + + /** + * Returns the tags for given actiivity + * @method getActivityTags + * @param {Object} [requestArgs] the optional arguments + * @returns {Array} tags + */ + getActivityTags : function(requestArgs) { + return this.service.getActivityTags(this.getActivityUuid(), requestArgs); + }, + /** + * Return contributor element to be included in post data for this ATOM entry. + * + * @method createContributor + * @returns {String} + */ + createContributor : function() { + return ""; + }, + + /** + * Return extra entry data to be included in post data for this ATOM entry. + * + * @method createEntryData + * @returns {String} + */ + createEntryData : function() { + var postData = ""; + if (this.getPosition && this.getPosition()) { + postData += stringUtil.transform(PositionTmpl, this, transformer, this); + } + if (this.getCommunityUuid && this.getCommunityUuid()) { + postData += stringUtil.transform(CommunityTmpl, this, transformer, this); + } + if (this.getActivityUuid && this.getActivityUuid()) { + postData += stringUtil.transform(ActivityIdTmpl, this, transformer, this); + } + if (this.getActivityNodeUuid && this.getActivityNodeUuid()) { + postData += stringUtil.transform(ActivityNodeIdTmpl, this, transformer, this); + } + if (this.isCompleted && this.isCompleted()) { + postData += CompletedTmpl; + } + if (this.getDueDate && this.getDueDate()) { + postData += stringUtil.transform(DueDateTmpl, this, transformer, this); + } + if (this.getInReplyToId && this.getInReplyToId()) { + postData += stringUtil.transform(InReplytoTmpl, this, transformer, this); + } + if (this.getAssignedToUserId && this.getAssignedToUserId()) { + postData += stringUtil.transform(AssignedToTmpl, this, transformer, this); + } + if (this.getIconUrl && this.getIconUrl()) { + postData += stringUtil.transform(IconTmpl, this, transformer, this); + } + if (this.isTemplate && this.isTemplate()) { + postData += TemplateTmpl; + } + + if (this.getFields && this.getFields().length > 0) { + var fields = this.getFields(); + for ( var counter in fields) { + var field = fields[counter]; + var innerXml = ""; + var trans = function(value, key) { + if (field[key]) { + value = xml.encodeXmlEntry(field[key]); + } else if (innerXml != "") { + value = innerXml; + } + return value; + }; + var tmpl = TextFieldTmpl; + if (field.type == "person") { + tmpl = PersonFieldTmpl; + } else if (field.type == "link") { + tmpl = LinkFieldTmpl; + } else if (field.type == "date") { + tmpl = DateFieldTmpl; + } + innerXml = stringUtil.transform(tmpl, this, trans, this); + postData += stringUtil.transform(FieldTmpl, this, trans, this); + } + } + + return postData; } - } + }); + + /** + * Activity Node class represents an entry for a activities Node feed returned by the Connections REST API. + * + * @class ActivityNode + * @namespace sbt.connections + */ + var ActivityNode = declare(Activity, { + /** + * Construct a Result entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, + + /** + * Return the value of id from result ATOM entry document. + * + * @method getActivityNodeUuid + * @return {String} ID of the result + */ + getActivityNodeUuid : function() { + return extractId(this.getUuid(), "urn:lsid:ibm.com:oa:"); + }, + + /** + * Return the value of activity uuid from result ATOM entry document. + * + * @method getActivityUuid + * @return {String} cctivityUuid of the result + */ + getActivityUuid : function() { + return this.getAsString("activityUuid"); + }, + + /** + * + * @param activityUuid + * @returns + */ + setActivityUuid : function(activityUuid) { + return this.setAsString("activityUuid", activityUuid); + }, + + /** + * getInReplyToId + * @returns {String} getInReplyToId + */ + getInReplyToId : function() { + return this.getAsString("inReplyToId"); + }, + + /** + * getInReplyToUrl + * @returns {String} getInReplyToUrl + */ + getInReplyToUrl : function() { + return this.getAsString("inReplyToUrl"); + }, + /** + * + * @param inReplytoId + * @param inReplyToUrl + * @param inReplyToActivity + */ + setInReplyTo : function(inReplyToId, inReplyToUrl) { + var id = "urn:lsid:ibm.com:oa:" + inReplyToId; + var inReplyTo = { + "inReplyToId" : id, + "inReplyToUrl" : inReplyToUrl + }; + + return this.setAsObject(inReplyTo); + }, + + /** + * getAssignedToUserId + * @returns {String} getAssignedToUserId + */ + getAssignedToUserId : function() { + return this.getAsString("assignedToUserId"); + }, + + /** + * getAssignedToName + * @returns {String} getAssignedToName + */ + getAssignedToName : function() { + return this.getAsString("assignedToName"); + }, + + /** + * getAssignedToEmail + * @returns {String} getAssignedToEmail + */ + getAssignedToEmail : function() { + return this.getAsString("assignedToEmail"); + }, + + /** + * Sets Assigned to in fields for creating playload + * @method setAssignedTo + * @param {String} assignedToUserId + * @param {String} assignedToName + * @param {String} assignedToEmail + * @returns + */ + setAssignedTo : function(assignedToUserId, assignedToName, assignedToEmail) { + var assignedTo = { + "assignedToUserId" : assignedToUserId, + "assignedToName" : assignedToName, + "assignedToEmail" : assignedToEmail + }; + return this.setAsObject(assignedTo); + }, + + /** + * returns Text Fields in Activity node feed + * @returns {Array} textFields + */ + getTextFields : function() { + var nodes = this.getAsNodesArray("textFields"); + var textFields = []; + for ( var counter in nodes) { + var node = nodes[counter]; + var textField = new TextField(); + for ( var i = 0; i < node.attributes.length; i++) { + var attr = node.attributes[i]; + var attrName = attr.name; + var attrValue = attr.value; + textField[attrName] = attrValue; + } + var dataHandler = new XmlDataHandler({ + service : this.service, + data : node, + namespaces : consts.Namespaces, + xpath : consts.TextFieldXPath + }); + textField.summary = dataHandler.getAsString("summary"); + textFields.push(textField); + this.addTextField(textField); + } + return textFields; + }, + + /** + * Adds a test field + * @param {Object} textField + * @returns + */ + addTextField : function(textField) { + if (this._fields["fields"]) { + this._fields["fields"].push(textField); + return this; + } else { + return this.setAsArray("fields", [ textField ]); + } + }, + + /** + * returns Date Fields in Activity node feed + * @returns {Array} dateFields + */ + getDateFields : function() { + var nodes = this.getAsNodesArray("dateFields"); + var dateFields = []; + for ( var counter in nodes) { + var node = nodes[counter]; + var dateField = new DateField; + for ( var i = 0; i < node.attributes.length; i++) { + var attr = node.attributes[i]; + var attrName = attr.name; + var attrValue = attr.value; + dateField[attrName] = attrValue; + } + dateField["date"] = new Date(stringUtil.trim(node.textContent)); + dateFields.push(dateField); + this.addDateField(dateField); + } + return dateFields; + }, + + /** + * adds a DateField + * @param {Object} DateField + * @returns + */ + addDateField : function(dateField) { + if (this._fields["fields"]) { + this._fields["fields"].push(dateField); + return this; + } else { + return this.setAsArray("fields", [ dateField ]); + } + }, + + /** + * returns Link Fields in Activity node feed + * @returns {Array} linkFields + */ + getLinkFields : function() { + var nodes = this.getAsNodesArray("linkFields"); + var linkFields = []; + for ( var counter in nodes) { + var node = nodes[counter]; + var linkField = new LinkField; + for ( var i = 0; i < node.attributes.length; i++) { + var attr = node.attributes[i]; + var attrName = attr.name; + var attrValue = attr.value; + linkField[attrName] = attrValue; + } + var dataHandler = new XmlDataHandler({ + service : this.service, + data : node, + namespaces : consts.Namespaces, + xpath : consts.LinkFieldXPath + }); + linkField.url = dataHandler.getAsString("url"); + linkField.title = dataHandler.getAsString("title"); + linkFields.push(linkField); + this.addLinkField(linkField); + } + return linkFields; + }, + + /** + * Adds a LinkField + * @param {Object} LinkField + * @returns + */ + addLinkField : function(linkField) { + if (this._fields["fields"]) { + this._fields["fields"].push(linkField); + return this; + } else { + return this.setAsArray("fields", [ linkField ]); + } + }, + + /** + * returns Person Fields in Activity node feed + * @returns {Array} personFields + */ + getPersonFields : function() { + var nodes = this.getAsNodesArray("personFields"); + var personFields = []; + for ( var counter in nodes) { + var node = nodes[counter]; + var personField = new PersonField; + for ( var i = 0; i < node.attributes.length; i++) { + var attr = node.attributes[i]; + var attrName = attr.name; + var attrValue = attr.value; + personField[attrName] = attrValue; + } + var dataHandler = new XmlDataHandler({ + service : this.service, + data : node, + namespaces : consts.Namespaces, + xpath : consts.PersonFieldXPath + }); + personField.personName = dataHandler.getAsString("name"); + personField.userId = dataHandler.getAsString("userId"); + personField.email = dataHandler.getAsString("email"); + personFields.push(personField); + this.addPersonField(personField); + } + return personFields; + }, + + /** + * adds a person fields to activity node + * @param {Object} PersonField + * @returns + */ + addPersonField : function(personField) { + if (this._fields["fields"]) { + this._fields["fields"].push(personField); + return this; + } else { + return this.setAsArray("fields", [ personField ]); + } + }, + + /** + * returns File Fields in Activity node feed + * @returns {Array} fileFields + */ + getFileFields : function() { + var nodes = this.getAsNodesArray("fileFields"); + var fileFields = []; + for ( var counter in nodes) { + var node = nodes[counter]; + var fileField = new FileField; + for ( var i = 0; i < node.attributes.length; i++) { + var attr = node.attributes[i]; + var attrName = attr.name; + var attrValue = attr.value; + fileField[attrName] = attrValue; + } + var dataHandler = new XmlDataHandler({ + service : this.service, + data : node, + namespaces : consts.Namespaces, + xpath : consts.FileFieldXPath + }); + fileField.url = dataHandler.getAsString("url"); + fileField.size = dataHandler.getAsString("size"); + fileField.type = dataHandler.getAsString("type"); + fileField.length = dataHandler.getAsString("length"); + fileFields.push(fileField); + } + return fileFields; + }, + + /** + * returns all fields in activity nodes feed + * @returns {Array} fields + */ + getFields : function() { + if (this._fields.fields && this._fields.fields.length > 0) { + return this._fields.fields; + } + var fields = []; + var textFields = this.getTextFields(); + var personFields = this.getPersonFields(); + var linkFields = this.getLinkFields(); + var fileFields = this.getFileFields(); + var dateFields = this.getDateFields(); + for ( var counter in textFields) { + var field = textFields[counter]; + feilds.push(field); + } + for ( var counter in personFields) { + var field = personFields[counter]; + feilds.push(field); + } + for ( var counter in linkFields) { + var field = linkFields[counter]; + feilds.push(field); + } + for ( var counter in fileFields) { + var field = fileFields[counter]; + feilds.push(field); + } + for ( var counter in dateFields) { + var field = dateFields[counter]; + feilds.push(field); + } + return fields; + }, - var self = this; - var callbacks = { - createEntity : function(service, data, response) { - self.dataHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.FileXPath - }); - return self; - } - }; + setFields : function(fields) { + this._fields["fields"] = fields; + }, - var requestArgs = lang.mixin({ - fileUuid : fileUuid - }, args || {}); - var options = { - // handleAs : "text", - query : requestArgs - }; + /** + * Loads the ActivityNode object with the atom entry associated with the activity node. By default, a network call is made to load the atom + * entry document in the ActivityNode object. + * + * @method load + */ + load : function() { + var promise = this.service.validateField("activityNodeUuid", this.getActivityNodeUuid()); + if (promise) { + return promise; + } + var requestArgs = { + "activityNodeUuid" : this.getActivityNodeUuid() + }; + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + var self = this; + var callbacks = { + createEntity : function(service, data, response) { + self.setData(data, response); + return self; + } + }; + return this.service.getEntity(consts.AtomActivityNode, options, this.getActivityNodeUuid(), callbacks); + }, + + /** + * Creats an entry in an activity, such as a to-do item or to add a reply to another entry, send an Atom entry document containing the new + * activity node of the appropriate type to the parent activity's node list. + * + * @mehtod create + * @param {String} activityUuid + * @returns {Object} ActivityNode + */ + create : function(activityUuid) { + return this.service.createActivityNode(activityUuid, this); + }, - if (!url) { - if (isPublic) { - url = this.service.constructUrl(consts.AtomFileInstancePublic, null, { - "documentId" : fileUuid, - "libraryId" : this.getLibraryId() - }); - } - else { - url = this.service.constructUrl(consts.AtomFileInstance, null, { - "documentId" : fileUuid - }); - } - } - return this.service.getEntity(url, options, fileUuid, callbacks); - }, - /** - * Save this file - * - * @method save - * @param {Object} [args] Argument object - */ - save : function(args) { - if (this.getFileId()) { - return this.service.updateFileMetadata(this, args); - } - }, - /** - * Adds a comment to the file. - * - * @method addComment - * @param {String} comment the comment to be added - * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - addComment : function(comment, args) { - return this.service.addCommentToFile(this.getAuthor().authorUserId, this.getFileId(), comment, args); - }, - /** - * Pin th file, by sending a POST request to the myfavorites feed. - * - * @method pin - * @param {Object} [args] Argument object. - */ - pin : function(args) { - return this.service.pinFile(this.getFileId(), args); - }, - /** - * Unpin the file, by sending a DELETE request to the myfavorites feed. - * - * @method unPin - * @param {Object} [args] Argument object. - */ - unpin : function(args) { - return this.service.unpinFile(this.getFileId(), args); - }, - /** - * Lock the file - * - * @method lock - * @param {Object} [args] Argument object - */ - lock : function(args) { - return this.service.lockFile(this.getFileId(), args); - }, - /** - * UnLock the file - * - * @method unlock - * @param {Object} [args] Argument object - */ - unlock : function(args) { - return this.service.unlockFile(this.getFileId(), args); - }, - /** - * Deletes the file. - * - * @method remove - * @param {Object} [args] Argument object - */ - remove : function(args) { - return this.service.deleteFile(this.getFileId(), args); - }, - /** - * Update the Atom document representation of the metadata for the file - * - * @method update - * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - update : function(args) { - return this.service.updateFileMetadata(this, args); - }, - /** - * Downloads the file - * - * @method download - */ - download : function() { - return this.service.downloadFile(this.getFileId(), this.getLibraryId()); - } + /** + * updates an activity node entry, sends a replacement Atom entry document containing the modified activity node to the existing activity's edit + * web address. + * @method update + * @returns {Object} activityNode + */ + update : function() { + return this.service.updateActivityNode(this); + }, - }); + /** + * Deletes an activity node entry, sends an HTTP DELETE method to the edit web address specified for the node. + * + * @method deleteActivityNode + */ + deleteActivityNode : function() { + return this.service.deleteActivityNode(this.getActivityNodeUuid()); + }, + /** + * Restores a deleted entry to an activity, sends a HTTP PUT request to the edit web address for the node defined in the trash feed. This moves + * the entry from the trash feed to the user's activity node list. + * + * @method restoreActivityNode + */ + restore : function() { + return this.service.restoreActivityNode(this.getActivityNodeUuid()); + }, + + /** + * Changes certain activity entries from one type to another. + * + *
     
    +				 * The following types of entries can be changed to other types:
    +				 * chat
    +				 * email
    +				 * entry
    +				 * reply
    +				 * todo<
    +				 * 
    + * + * @method changeEntryType + * @param {String} newType + * @returns {Object} ActivityNode + */ + changeEntryType : function(newType) { + this.setType(newType); + return this.service.changeEntryType(this); + }, + + /** + * Moves a standard entry or a to-do entry to a section in an activity, send an updated Atom entry document to the parent activity's node list. + * + * @method moveToSection + * @param {String} sectionId + * @param {String} [newTitle] + * @returns {Object} ActivityNode + */ + moveToSection : function(sectionId, newTitle) { + return this.service.moveEntryToSection(this, sectionId); + } - /** - * Callbacks used when reading a feed that contains File entries. - */ - var FileFeedCallbacks = { - createEntities : function(service, data, response) { - return new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.FileFeedXPath - }); - }, - createEntity : function(service, data, response) { - var entry = null; - if (typeof data == "object") { - entry = data; - } else { - var feedHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.FileXPath - }); - entry = feedHandler.data; - } - var entryHandler = new XmlDataHandler({ - data : entry, - namespaces : consts.Namespaces, - xpath : consts.FileXPath - }); - return new File({ - service : service, - dataHandler : entryHandler }); - } - }; - /** - * Callbacks used when reading a feed that contains File Comment entries. - */ - var CommentCallbacks = { - createEntities : function(service, data, response) { - return new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.CommentFeedXPath - }); - }, - createEntity : function(service, data, response) { - var entry = null; - if (typeof data == "object") { - entry = data; - } else { - var feedHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.CommentXPath - }); - entry = feedHandler.data; - } - var entryHandler = new XmlDataHandler({ - data : entry, - namespaces : consts.Namespaces, - xpath : consts.CommentXPath - }); - return new Comment({ - service : service, - dataHandler : entryHandler - }); - } - }; + /** + * Member class represents an entry for a members feed returned by the Connections REST API. + * + * @class Member + * @namespace sbt.connections + */ + var Member = declare(AtomEntity, { + + xpath : consts.MemberXPath, + namespaces : consts.ActivityNamespaces, + categoryScheme : null, + + /** + * Sets template for category Scheme + */ + setCategoryScheme : function() { + this.categoryScheme = stringUtil.transform(MemberCategory, this, transformer, this); + }, + + /** + * Return the member Id + * + * @method getMemberId + * @return {String} ID of the result + */ + getMemberId : function() { + return extractId(this.getId(), "&memberid="); + }, - /** - * FileService class. - * - * @class FileService - * @namespace sbt.connections - */ - var FileService = declare(ConnectionsService, { + /** + * Get role + * @method getRole + * @returns {String} role + */ + getRole : function() { + return this.getAsString("role"); + }, - contextRootMap : { - files : "files" - }, - - serviceName : "files", + /** + * Set role + * @method setRole + * @param {String} role + * @returns + */ + setRole : function(role) { + return this.setAsString("role", role); + }, + + /** + * getPermissions + * @method getPermissions + * @returns {Array} permissions + */ + getPermissions : function() { + var permissions = this.getAsString("permissions"); + if (permissions) { + return permissions.split(", "); + } + return permissions; + }, + + /** + * getCategory + * @method getCategory + * @returns {String} category + */ + getCategory : function() { + this.getAsString("category"); + }, + + /** + * setCategory + * @method setCategory + * @param {String} category + */ + setCategory : function(category) { + this.setAsString("category", category); + }, + + /** + * get contributor user ID + * @method getUserId + * @returns {String} userId + */ + getUserId : function() { + return this.getContributor().userid; + }, + + /** + * Sets the contributor user ID + * @method setUserId + * @param {String} userId + */ + setUserId : function(userId) { + return this.setAsString("contributorUserid", userId); + }, + + // Overriding the below methods since they are not relevant for Activity Member Entity in Post Data + + /** + * Return title element to be included in post data for this ATOM entry. + * + * @method createTitle + * @returns {String} + */ + createTitle : function() { + return ""; + }, + + + /** + * Return content element to be included in post data for this ATOM entry. + * + * @method createContent + * @returns {String} + */ + createContent : function() { + return ""; + }, + + /** + * Return summary element to be included in post data for this ATOM entry. + * + * @method createSummary + * @returns {String} + */ + createSummary : function() { + return ""; + }, + + // Overriding the above methods since they are not relevant for Activity Member Entity in Post Data + + /** + * Return extra entry data to be included in post data for this entity. + * + * @returns {String} + */ + createEntryData : function() { + var postData = ""; + postData += stringUtil.transform(RoleTmpl, this, transformer, this); + return stringUtil.trim(postData); + }, + + + /** + * Loads the Member object with the atom entry part with the activity. By default, a network call is made to load the atom entry document in the + * Member object. + * + * @method load + * @param {Stirng} activityUuid The Activity ID + */ + load : function(activityUuid) { + + var promise = this.service.validateField("memberId", this.getMemberId()); + if (!promise) { + promise = this.service.validateField("activityUuid", activityUuid); + } + if (promise) { + return promise; + } + var options = { + method : "GET", + handleAs : "text" + }; + + var url = this.service.constructUrl(consts.AtomActivitiesMember, null, { + "activityUuid" : activityUuid, + "memberId" : this.getMemberId() + }); + + var self = this; + var callbacks = { + createEntity : function(service, data, response) { + // This is required because the feed starts from insttead of + var feedHandler = new XmlDataHandler({ + data : data, + namespaces : consts.ActivityNamespaces, + xpath : consts.MemberXPath + }); + var entry = feedHandler.data; + self.setData(entry, response); + return self; + } + }; + + return this.service.getEntity(url, options, this.getMemberId(), callbacks); + }, + /** + * Adds a member to the access control list of an activity, sends an Atom entry document containing the new member to the access control list + * feed. You can only add one member per post. + * @method addToActivity + * @param {String} activityUuid + */ + addToActivity : function(actvitiyUuid) { + return this.service.addMember(actvitiyUuid, this); + }, + + /** + * Removes a member from the acl list for an application, use the HTTP DELETE method. + * @method removeFromActivity + * @param {String} activityUuid + */ + removeFromActivity : function(activityUuid) { + return this.service.deleteMember(activityUuid, this.getMemberId()); + }, - /** - * Constructor for FileService - * - * @constructor - * @param args - */ - constructor : function(args) { - var endpointName = args ? (args.endpoint ? args.endpoint : this.getDefaultEndpointName()) : this.getDefaultEndpointName(); - if (!this.endpoint) { - this.endpoint = config.findEndpoint(endpointName); - } - }, + /** + * Updates a member in the access control list for an application, sends a replacement member entry document in Atom format to the existing ACL + * node's edit web address. + * @method updateInActivity + * @param {String} activityUuid + */ + updateInActivity : function(activityUuid) { + return this.service.updateMember(activityUuid, this); + } - /** - * Returns information about the current users library. - * - */ - getMyLibrary : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : { ps:1, includeQuota:true } || args || {} - }; + }); - var self = this; - var callbacks = { + /* + * Callbacks used when reading a feed that contains Tag entries. + */ + var TagFeedCallbacks = { + createEntities : function(service, data, response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.TagXPath + }); + }, createEntity : function(service, data, response) { var entryHandler = new XmlDataHandler({ + service : service, data : data, namespaces : consts.Namespaces, - xpath : consts.LibraryXPath + xpath : consts.TagXPath }); - return new Library({ - service : self, + return new Tag({ + service : service, dataHandler : entryHandler }); } }; - return this.getEntity(consts.AtomFilesMy, options, "my", callbacks); - }, + /* + * Callbacks used when reading a feed that contains activities entries. + */ + var MemberFeedCallbacks = { + createEntities : function(service, data, response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.ActivitiesFeedXPath + }); + }, + createEntity : function(service, data, response) { + var entry = null; + if (typeof data == "object") { + entry = data; + } else { + var feedHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.MemberXPath + }); + entry = feedHandler.data; + } + var entryHandler = new XmlDataHandler({ + data : entry, + namespaces : consts.Namespaces, + xpath : consts.MemberXPath + }); + return new Member({ + service : service, + dataHandler : entryHandler + }); + } + }; - /** - * Returns a File instance from File or JSON or String. Throws an error if the argument was neither. - * - * @param {Object} fileOrJsonOrString The file Object or json String for File - */ - newFile : function(fileOrJsonOrString) { - if (fileOrJsonOrString instanceof File) { - return fileOrJsonOrString; - } else { - if (lang.isString(fileOrJsonOrString)) { - fileOrJsonOrString = { - id : fileOrJsonOrString - }; + /* + * Callbacks used when reading a feed that contains activities entries. + */ + var ActivityFeedCallbacks = { + createEntities : function(service, data, response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.ActivityNamespaces, + xpath : consts.ActivitiesFeedXPath + }); + }, + createEntity : function(service, data, response) { + return new Activity({ + service : service, + data : data + }); } - return new File({ - service : this, - _fields : lang.mixin({}, fileOrJsonOrString) - }); - } - }, + }; - /** - * Loads File with the ID passed - * - * @method getFile - * @param {String} fileId the Id of the file to be loaded - * @param {Object} [args] Argument object - */ - getFile : function(fileId, args) { - var promise = this.validateField("fileId", fileId); - if (promise) { - return promise; - } - var file = this.newFile({ - id : fileId - }); - return file.load(args); + /* + * Callbacks used when reading a feed that contains activities nodes and activity entries. + */ + var ActivityNodeFeedCallbacks = { + createEntities : function(service, data, response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.ActivityNamespaces, + xpath : consts.ActivitiesFeedXPath + }); + }, + createEntity : function(service, data, response) { + var entry = null; + if (typeof data == "object") { + entry = data; + } else { + var feedHandler = new XmlDataHandler({ + data : data, + namespaces : consts.ActivityNamespaces, + xpath : consts.ActivityNodeXPath + }); + entry = feedHandler.data; + } + return new ActivityNode({ + service : service, + data : entry + }); + } + }; - }, + /** + * ActivityService class which provides wrapper APIs to the Activities application of IBM© Connections which enables a team to collect, organize, + * share, and reuse work related to a project goal. The Activities API allows application programs to create new activities, and to read and modify + * existing activities. + * + * @class ActivityService + * @namespace sbt.connections + */ + var ActivityService = declare(ConnectionsService, { - /** - * Loads Community File - * - * @method getFile - * @param {String} fileId the Id of the file to be loaded - * @param {String} communityId the Id of the community to which it belongs - * @param {Object} [args] Argument object - */ - getCommunityFile : function(fileId, communityId, args) { - var promise = this.validateField("fileId", fileId); - if (!promise) { - promise = this.validateField("communityId", communityId); - } - if (promise) { - return promise; - } - var file = this.newFile({ - id : fileId - }); - var url = this.constructUrl(consts.AtomGetCommunityFile, null, { - communityId : communityId, - documentId : file.getFileId() - }); - return file.load(args, null, url); + contextRootMap : { + activities : "activities" + }, + + serviceName : "activities", - }, - /** - * Get my files from IBM Connections - * - * @method getMyFiles - * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - getMyFiles : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + /** + * Constructor for ActivitiesService + * + * @constructor + * @param args + */ + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } + }, - return this.getEntities(consts.AtomFilesMy, options, this.getFileFeedCallbacks()); - }, + /** + * Get a list of all active activities that match a specific criteria. + * + * @method getMyActivitiesU + * @param {Object} [requestArgs] Optional arguments like ps, page, asc etc. + * @returns {Array} Activity array + */ + getMyActivities : function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; - /** - * Get community files from IBM Connections (community files refer to - * files which the user uploaded to the community. Calling this function - * will not list files that have been shared with this community). - * - * @method getCommunityFiles - * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - getCommunityFiles : function(communityId, args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + return this.getEntities(consts.AtomActivitiesMy, options, ActivityFeedCallbacks); + }, - var url = this.constructUrl(consts.AtomGetAllFilesInCommunity, null, { - communityId : communityId - }); + /** + * Get a list of all active activity nodes that match a specific criteria in an activity. + * + * @method getActivityNodes + * @param {String} activityUuid The Activity I + * @param {Object} [requestArgs] Optional arguments like ps, page, asc etc. + * @returns {Array} ActivityNode array + */ + getActivityNodes : function(activityUuid, requestArgs) { + var args = lang.mixin(requestArgs || {}, { + "nodeUuid" : activityUuid + }); - return this.getEntities(url, options, this.getFileFeedCallbacks()); - }, - /** - * Get files shared with logged in user from IBM Connections - * - * @method getFilesSharedWithMe - * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - getFilesSharedWithMe : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args + }; - var options = { - method : "GET", - handleAs : "text", + return this.getEntities(consts.AtomActivityNodes, options, ActivityNodeFeedCallbacks); + }, - query : lang.mixin({ - direction : "inbound" - }, args ? args : {}) - }; + /** + * Search for content in all of the activities, both completed and active, that matches a specific criteria. + * + * @method getAllActivities + * @param requestArgs + * @returns {Array} Activity array + */ + getAllActivities : function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; - return this.getEntities(consts.AtomFilesShared, options, this.getFileFeedCallbacks()); - }, - /** - * Get files shared by the logged in user from IBM Connections - * - * @method getFilesSharedByMe - * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - getFilesSharedByMe : function(args) { + return this.getEntities(consts.AtomActivitiesEverything, options, ActivityFeedCallbacks); + }, - var options = { - method : "GET", - handleAs : "text", + /** + * Search for a set of completed activities that match a specific criteria. + * + * @method getCompletedActivities + * @param {Object} [requestArgs] The optional arguments + * @returns {Array} Activity array + */ + getCompletedActivities : function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; - query : lang.mixin({ - direction : "outbound" - }, args ? args : {}) - }; + return this.getEntities(consts.AtomActivitiesCompleted, options, ActivityFeedCallbacks); + }, - return this.getEntities(consts.AtomFilesShared, options, this.getFileFeedCallbacks()); - }, - /** - * Get public files from IBM Connections - * - * @method getPublicFiles - * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - getPublicFiles : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {}, - headers : {} - }; + /** + * Retrieve an activity node entry, uses the edit link found in the corresponding activity node in the user's My Activities feed. + * + * @method getActivityNode + * @param {String} activityNodeUuid the ID of Activity Node + * @returns {Object} ActivityNode + */ + getActivityNode : function(activityNodeUuid) { + var promise = this.validateField("activityNodeUuid", activityNodeUuid); + if (promise) { + return promise; + } + var activityNode = this.newActivityNode(activityNodeUuid); + return activityNode.load(); + }, + + /** + * Retrieve an activity entry, uses the edit link found in the corresponding activity node in the user's My Activities feed. + * + * @method getActivity + * @param {String} activityUuid the ID of Activity + * @returns {Object} Activity + */ + getActivity : function(activityUuid) { + var promise = this.validateField("activityUuid", activityUuid); + if (promise) { + return promise; + } + var activity = this.newActivity(activityUuid); + return activity.load(); + }, + + /** + * Creats an entry in an activity, such as a to-do item or to add a reply to another entry, send an Atom entry document containing the new + * activity node of the appropriate type to the parent activity's node list. + * + * @mehtod createActivityNode + * @param {String} activityUuid + * @param {Object} activityNodeOrJson + * @returns {Object} ActivityNode + */ + createActivityNode : function(activityUuid, activityNodeOrJson) { + var promise = this.validateField("activityUuid", activityUuid); + if (!promise) { + promise = this.validateField("activityNodeOrJson", activityNodeOrJson); + } + if (promise) { + return promise; + } + var activityNode = this.newActivityNode(activityNodeOrJson); + activityNode.setActivityUuid(activityUuid); + activityNode.setCategoryScheme(); + var payload = activityNode.createPostData(); + var requestArgs = { + "activityUuid" : activityUuid + }; + + var options = { + method : "POST", + headers : consts.AtomXmlHeaders, + query : requestArgs, + data : payload + }; + + return this.updateEntity(consts.AtomCreateActivityNode, options, ActivityNodeFeedCallbacks); + }, + + /** + * Creates an activity, sends an Atom entry document containing the new activity to the user's My Activities feed. + * + * @method createActivity + * @param {Object} activityOrJson + * @returns {Object} Activity + */ + createActivity : function(activityOrJson) { + var promise = this.validateField("activityOrJson", activityOrJson); + if (promise) { + return promise; + } + var activity = this.newActivity(activityOrJson); + activity.setType(consts.ActivityNodeTypes.Activity); + activity.setCategoryScheme(); + var payload = activity.createPostData(); + + var options = { + method : "POST", + headers : consts.AtomXmlHeaders, + data : payload + }; + + return this.updateEntity(consts.AtomActivitiesMy, options, ActivityFeedCallbacks); + }, + + _validateActivityNode : function(activityNode, checkUuid, checkType) { + if (checkUuid && !activityNode.getActivityNodeUuid()) { + return this.createBadRequestPromise("Invalid argument, activity node with UUID must be specified."); + } + if (checkType && !activityNode.getType()) { + return this.createBadRequestPromise("Invalid argument, activity node with Type must be specified."); + } + }, + + _validateActivity : function(activity, checkUuid) { + if (checkUuid && !activity.getActivityUuid()) { + return this.createBadRequestPromise("Invalid argument, activity with UUID must be specified."); + } + }, + /** + * updates an activity node entry, sends a replacement Atom entry document containing the modified activity node to the existing activity's edit + * web address. + * @method updateActivityNode + * @param {Object} activityNodeOrJson ActivityNode or Json Object with Uuid populated + * @returns {Object} ActivityNode + */ + updateActivityNode : function(activityNodeOrJson) { + var promise = this.validateField("activityNodeOrJson", activityNodeOrJson); + if (promise) { + return promise; + } + var newActivityNode = this.newActivityNode(activityNodeOrJson); + promise = this._validateActivityNode(newActivityNode, true); + if (promise) { + return promise; + } + return this._update(newActivityNode, ActivityNodeFeedCallbacks); + }, + + /** + * Updates an activity, send a replacement Atom Entry document containing the modified activity to the existing activity's edit URL + * @method updateActivity + * @param {Object} activityOrJson Activity or Json Object + * @returns {Object} Activity + */ + updateActivity : function(activityOrJson) { + var promise = this.validateField("activityOrJson", activityOrJson); + if (promise) { + return promise; + } + var newActivity = this.newActivity(activityOrJson); + promise = this._validateActivity(newActivity, true); + if (promise) { + return promise; + } + return this._update(activityOrJson, ActivityFeedCallbacks); + }, - return this.getEntities(consts.AtomFilesPublic, options, this.getFileFeedCallbacks()); - }, - /** - * Get my folders from IBM Connections - * - * @method getMyFolders - * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - getMyFolders : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + _update : function(activityOrActivityNode, callbacks) { + var promise = new Promise(); + var _this = this; + var uuid = extractId(activityOrActivityNode.getUuid()); + var update = function() { + activityOrActivityNode.setCategoryScheme(); + var payload = activityOrActivityNode.createPostData(); + var requestArgs = { + "activityNodeUuid" : uuid + }; + var options = { + method : "PUT", + headers : consts.AtomXmlHeaders, + query : requestArgs, + data : payload + }; + _this.updateEntity(consts.AtomActivityNode, options, callbacks).then(function(node) { + promise.fulfilled(node); + }, function(error) { + promise.rejected(error); + }); + }; + if (activityOrActivityNode.isLoaded()) { + update(); + } else { + var fields = activityOrActivityNode._fields; + activityOrActivityNode.load().then(function() { + activityOrActivityNode._fields = fields; + update(); + }, function(error) { + promise.rejected(error); + }); + } + return promise; + }, + /** + * Changes certain activity entries from one type to another. + * + *
     
    +				 * The following types of entries can be changed to other types:
    +				 * chat
    +				 * email
    +				 * entry
    +				 * reply
    +				 * todo<
    +				 * /pre>
    +				 * 
    +				 * @method changeEntryType
    +				 * @param {Object} activityNodeOrJson ActivityNode or Json object with Uuid and type populated
    +				 * @returns {Object} ActivityNode
    +				 */
    +				changeEntryType : function(activityNodeOrJson) {
    +					var promise = this.validateField("activityNodeOrJson", activityNodeOrJson);
    +					if (promise) {
    +						return promise;
    +					}
    +					var activityNode = this.newActivityNode(activityNodeOrJson);
    +					promise = this._validateActivityNode(activityNode, true, true);
     
    -			return this.getEntities(consts.AtomFoldersMy, options, this.getFileFeedCallbacks());
    -		},
    -		
    -		/**
    -		 * A feed of comments associated with files to which you have access. You must authenticate this request.
    -		 * 
    -		 * @method getMyFileComments
    -		 * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are
    -		 * supported by IBM Connections like ps, sortBy etc.
    -		 */
    -		getMyFileComments : function(userId, fileId, args) {
    +					return this.updateActivityNode(activityNode);
    +				},
     
    -			return this.getFileComments(fileId, userId, false, null, args);
    -		},
    -		/**
    -		 * A feed of comments associated with all public files. Do not authenticate this request.
    -		 * 
    -		 * @method getPublicFileComments
    -		 * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are
    -		 * supported by IBM Connections like ps, sortBy etc.
    -		 */
    -		getPublicFileComments : function(userId, fileId, args) {
    +				/**
    +				 * Moves a standard entry or a to-do entry to a section in an activity, send an updated Atom entry document to the parent activity's node list.
    +				 * 
    +				 * @method moveEntryToSection
    +				 * @param {Object} activityNodeOrJson
    +				 * @param {Object} sectionNodeOrJsonOrId section activityNode or Json Object or Section ID
    +				 * @returns {Object} ActivityNode
    +				 */
    +				moveEntryToSection : function(activityNodeOrJson, sectionNodeOrJsonOrId) {
    +					var _this = this;
    +					var promise = this.validateField("activityNodeOrJson", activityNodeOrJson);
    +					if (!promise) {
    +						promise = this.validateField("sectionNodeOrJsonOrId", sectionNodeOrJsonOrId);
    +					}
    +					if (promise) {
    +						return promise;
    +					}
    +					var activityNode = this.newActivityNode(activityNodeOrJson);
    +					var sectionNode = this.newActivityNode(sectionNodeOrJsonOrId);
    +					promise = new Promise();
    +					var update = function() {
    +						activityNode.setInReplyTo(sectionNode.getActivityNodeUuid(), sectionNode.getSelfUrl());
    +						_this.updateActivityNode(activityNode).then(function(activityNode) {
    +							promise.fulfilled(activityNode);
    +						}, function(error) {
    +							promise.rejected(error);
    +						});
    +					};
    +					if (sectionNode.isLoaded()) {
    +						update();
    +					} else {
    +						sectionNode.load().then(function() {
    +							update();
    +						}, function(error) {
    +							promise.rejected(error);
    +						});
    +					}
    +					return promise;
    +				},
     
    -			return this.getFileComments(fileId, userId, true, null, args);
    -		},
    +				/**
    +				 * Deletes an activity node entry, sends an HTTP DELETE method to the edit web address specified for the node.
    +				 * 
    +				 * @method deleteActivityNode
    +				 * @param {String} activityNodeUuid
    +				 */
    +				deleteActivityNode : function(activityNodeUuid) {
    +					var promise = this.validateField("activityNodeUuid", activityNodeUuid);
    +					if (promise) {
    +						return promise;
    +					}
    +					var requestArgs = {
    +						"activityNodeUuid" : activityNodeUuid
    +					};
    +					var options = {
    +						method : "DELETE",
    +						headers : consts.AtomXmlHeaders,
    +						query : requestArgs
    +					};
     
    -		/**
    -		 * Adds a comment to the specified file.
    -		 * 
    -		 * @method addCommentToFile
    -		 * @param {String} [userId] the userId for the author
    -		 * @param {String} fileId the ID of the file
    -		 * @param {String} comment the comment to be added
    -		 * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are
    -		 * supported by IBM Connections like ps, sortBy etc.
    -		 */
    -		addCommentToFile : function(userId, fileId, comment, url, args) {
    -			var promise = this.validateField("fileId", fileId);
    -			if (!promise) {
    -				promise = this.validateField("comment", comment);
    -			}
    -			if (promise) {
    -				return promise;
    -			}
    -			var options = {
    -				method : "POST",
    -				query : args || {},
    -				headers : consts.AtomXmlHeaders,
    -				data : this._constructPayloadForComment(false, comment)
    -			};
    +					return this.deleteEntity(consts.AtomActivityNode, options, activityNodeUuid);
    +				},
     
    -			if (!url) {
    -				if (!userId) {
    -					url = this.constructUrl(consts.AtomAddCommentToMyFile, null, {
    -						documentId : fileId
    -					});
    -				} else {
    -					url = this.constructUrl(consts.AtomAddCommentToFile, null, {
    -						userId : userId,
    -						documentId : fileId
    -					});
    -				}
    -			}
    -			return this.updateEntity(url, options, this.getCommentFeedCallbacks());
    -		},
    +				/**
    +				 * Deletes an activity entry, sends an HTTP DELETE method to the edit web address specified for the node.
    +				 * 
    +				 * @method deleteActivity
    +				 * @param {String} activityUuid
    +				 */
    +				deleteActivity : function(activityUuid) {
    +					var promise = this.validateField("activityUuid", activityUuid);
    +					if (promise) {
    +						return promise;
    +					}
    +					return this.deleteActivityNode(activityUuid);
    +				},
     
    -		/**
    -		 * Adds a comment to the specified file of logged in user.
    -		 * 
    -		 * @method addCommentToMyFile
    -		 * @param {String} fileId the ID of the file
    -		 * @param {String} comment the comment to be added
    -		 * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are
    -		 * supported by IBM Connections like ps, sortBy etc.
    -		 */
    -		addCommentToMyFile : function(fileId, comment, args) {
    -			return this.addCommentToFile(null, fileId, comment, null, args);
    -		},
    +				/**
    +				 * Restores a deleted activity, use a HTTP PUT request. This moves the activity from the trash feed to the user's My Activities feed.
    +				 * 
    +				 * @method restoreActivity
    +				 * @param {String} activityUuid
    +				 */
    +				restoreActivity : function(activityUuid) {
    +					var promise = this.validateField("activityUuid", activityUuid);
    +					if (promise) {
    +						return promise;
    +					}
    +					var _this = this;
    +					promise = new Promise();
    +					this.getActivityNodeFromTrash(activityUuid).then(function(deleted) {
    +						return deleted;
    +					}).then(function(activity) {
    +						if (!activity.isDeleted()) {
    +							promise.rejected("Activity is not in Trash");
    +						} else {
    +							var requestArgs = {
    +								"activityNodeUuid" : activityUuid
    +							};
    +							activity.setCategoryScheme();
    +							var options = {
    +								method : "PUT",
    +								headers : consts.AtomXmlHeaders,
    +								query : requestArgs,
    +								data : activity.createPostData()							
    +							};
    +							var callbacks = {
    +								createEntity : function(service, data, response) {
    +									return response;
    +								}
    +							};
    +							_this.updateEntity(consts.AtomActivityNodeTrash, options, callbacks).then(function(response) {
    +								promise.fulfilled(response);
    +							}, function(error) {
    +								promise.rejected(error);
    +							});
    +						}
    +					});
    +					return promise;
    +				},
     
    -		/**
    -		 * Method to add comments to a Community file 

    Rest API used : /files/basic/api/communitylibrary//document//feed - * - * @method addCommentToCommunityFile - * @param {String} fileId - * @param {String} comment - * @param {String} communityId - * @param {Object} [args] - * @return {Comment} comment - */ - addCommentToCommunityFile : function(fileId, comment, communityId, args) { - var url = this.constructUrl(consts.AtomAddCommentToCommunityFile, null, { - communityId : communityId, - documentId : fileId - }); - return this.addCommentToFile(null, fileId, comment, url, args); - }, + /** + * Restores a deleted entry to an activity, sends a HTTP PUT request to the edit web address for the node defined in the trash feed. This moves + * the entry from the trash feed to the user's activity node list. + * + * @method restoreActivityNode + * @param {String} activityNodeUuid + */ + restoreActivityNode : function(activityNodeUuid) { + var promise = this.validateField("activityNodeUuid", activityNodeUuid); + if (promise) { + return promise; + } + var _this = this; + var promise = new Promise(); + this.getActivityNodeFromTrash(activityNodeUuid).then(function(deletedNode) { + return deletedNode; + }).then(function(activityNode) { + if (!activityNode.isDeleted()) { + promise.rejected("Activity Node is not in Trash"); + } else { + var requestArgs = { + "activityNodeUuid" : activityNodeUuid + }; + activityNode.setCategoryScheme(); + var options = { + method : "PUT", + headers : consts.AtomXmlHeaders, + query : requestArgs, + data : activityNode.createPostData() + }; + var callbacks = { + createEntity : function(service, data, response) { + return response; + } + }; + _this.updateEntity(consts.AtomActivityNodeTrash, options, callbacks).then(function(response) { + promise.fulfilled(response); + }, function(error) { + promise.rejected(error); + }); + } + }); + return promise; + }, - /** - * Update the Atom document representation of the metadata for a file from logged in user's library. - * - * @method updateFileMetadata - * @param {Object} fileOrJson file or json representing the file to be updated - * @param {Object} [args] Argument object. Object representing various parameters that can be passed. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - updateFileMetadata : function(fileOrJson, url, args) { + /** + * Retrieves and activity node from trash + * + * @method getActivityNodeFromTrash + * @param {String} activityNodeUuid + * @returns {Object} ActivityNode + */ + getActivityNodeFromTrash : function(activityNodeUuid) { + var promise = this.validateField("activityNodeUuid", activityNodeUuid); + if (promise) { + return promise; + } + var requestArgs = { + "activityNodeUuid" : activityNodeUuid + }; + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + return this.getEntity(consts.AtomActivityNodeTrash, options, activityNodeUuid, ActivityNodeFeedCallbacks); + }, - var promise = this.validateField("fileOrJson", fileOrJson); - if (promise) { - return promise; - } + /** + * Returns a ActivityNode instance from ActivityNode or JSON or String. Throws an error if the argument was neither. + * + * @method newActivityNode + * @param {Object} activityNodeOrJsonOrString The ActivityNode Object or json String for ActivityNode + */ + newActivityNode : function(activityNodeOrJsonOrString) { + if (activityNodeOrJsonOrString instanceof ActivityNode || activityNodeOrJsonOrString instanceof Activity) { + return activityNodeOrJsonOrString; + } else { + if (lang.isString(activityNodeOrJsonOrString)) { + activityNodeOrJsonOrString = { + id : activityNodeOrJsonOrString + }; + } + return new ActivityNode({ + service : this, + _fields : lang.mixin({}, activityNodeOrJsonOrString) + }); + } + }, - var file = this.newFile(fileOrJson); - var options = { - method : "PUT", - query : args || {}, - headers : consts.AtomXmlHeaders, - data : this._constructPayload(file._fields, file.getFileId()) - }; + /** + * Gets All activity nodes in trash which match given criteria + * @method getActivityNodesInTrash + * @param {String} activityUuid + * @param {Object} [requestArgs] optional arguments + * @returns {Array} ActivityNode list + */ + getActivityNodesInTrash : function(activityUuid, requestArgs) { - if (!url) { - url = this.constructUrl(consts.AtomUpdateFileMetadata, null, { - documentId : file.getFileId() - }); - } - return this.updateEntity(url, options, this.getFileFeedCallbacks()); - }, + var promise = this.validateField("activityUuid", activityUuid); + if (promise) { + return promise; + } + var args = lang.mixin(requestArgs || {}, { + "activityUuid" : activityUuid + }); + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; - /** - * Method to update Community File's Metadata

    Rest API used : /files/basic/api/library//document//entry

    - * @method updateCommunityFileMetadata - * @param {Object} fileOrJson - * @param {String} libraryId - * @param {Object} [args] - * @return {File} - */ - updateCommunityFileMetadata : function(fileOrJson, communityId, args) { - var promise = this.validateField("fileOrJson", fileOrJson); - if (promise) { - return promise; - } - var file = this.newFile(fileOrJson); - promise = new Promise(); - var _this = this; - var update = function() { - var url = _this.constructUrl(consts.AtomUpdateCommunityFileMetadata, null, { - libraryId : file.getLibraryId(), - documentId : file.getFileId() - }); - _this.updateFileMetadata(file, url, args).then(function(file) { - promise.fulfilled(file); - }, function(error) { - promise.rejected(error); - }); - }; - if (file.isLoaded()) { - update(); - } else { - var url = _this.constructUrl(consts.AtomGetCommunityFile, null, { - communityId : communityId, - documentId : file.getFileId() - }); - file.load(null, null, url).then(function() { - update(); - }, function(error) { - promise.rejected(error); - }); - } - return promise; - }, + return this.getEntities(consts.AtomActivitiesTrash, options, ActivityNodeFeedCallbacks); - /** - * Pin a file, by sending a POST request to the myfavorites feed. - * - * @method pinFile - * @param {String} fileId ID of file which needs to be pinned - * @param {Object} [args] Argument object. - */ - pinFile : function(fileId, args) { + }, - var promise = this.validateField("fileId", fileId); - if (promise) { - return promise; - } - var parameters = args ? lang.mixin({}, args) : {}; - parameters["itemId"] = fileId; + /** + * Returns a Activity instance from Activity or JSON or String. Throws an error if the argument was neither. + * @method newActivity + * @param {Object} activityOrJsonOrString The Activity Object or json String for Activity + */ + newActivity : function(activityOrJsonOrString) { - var options = { - method : "POST", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" + if (activityOrJsonOrString instanceof Activity) { + return activityOrJsonOrString; + } else { + if (lang.isString(activityOrJsonOrString)) { + activityOrJsonOrString = { + id : activityOrJsonOrString + }; + } + return new Activity({ + service : this, + _fields : lang.mixin({}, activityOrJsonOrString) + }); + } }, - query : parameters - }; - var callbacks = { - createEntity : function(service, data, response) { - return "Success"; - } - }; + /** + * Search for a set of to-do items that match a specific criteria. + * + * @method getAllToDos + * @param {Object} [requestArgs] the optional arguments + * @returns {Array} ActivityNode Array + */ + getAllToDos : function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.AtomActivitiesToDos, options, ActivityFeedCallbacks); + }, - return this.updateEntity(consts.AtomPinFile, options, callbacks); + /** + * Search for a set of tags that match a specific criteria. + * @method getAllTags + * @param {Object} [requestArgs] the optional arguments + * @returns {Array} + */ + getAllTags : function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; - }, + return this.getEntities(consts.AtomActivitiesTags, options, TagFeedCallbacks); + }, - /** - * Unpin a file, by sending a DELETE request to the myfavorites feed. - * - * @method unpinFile - * @param {String} fileId ID of file which needs to be unpinned - * @param {Object} [args] Argument object. - */ - unpinFile : function(fileId, args) { - var promise = this.validateField("fileId", fileId); - if (promise) { - return promise; - } + /** + * Search for sctivities in trash which math a specif criteria + * + * @method getActivitiesInTrash + * @param {Object} [requestArgs] the optional arguments + * @returns {Array} activities + */ + getActivitiesInTrash : function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; - var parameters = args ? lang.mixin({}, args) : {}; - parameters["itemId"] = fileId; + return this.getEntities(consts.AtomActivitiesTrash, options, ActivityFeedCallbacks); - var options = { - method : "DELETE", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" }, - query : parameters - }; - return this.deleteEntity(consts.AtomPinFile, options, fileId); + /** + * Returns the tags for given actiivity + * @method getActivityTags + * @param {String} activityUuid + * @param {Object} [requestArgs] the optional arguments + * @returns {Array} tags + */ + getActivityTags : function(activityUuid, requestArgs) { - }, + var promise = this.validateField("activityUuid", activityUuid); + if (promise) { + return promise; + } - /** - * Add a file or files to a folder. - * - * You cannot add a file from your local directory to a folder; the file must already have been uploaded to the Files application. To add a file - * to a folder you must be an editor of the folder. - * - * @method addFilesToFolder - * @param {String} folderId the Id of the folder - * @param {List} fileIds list of file Ids to be added to the folder - * @param {Object} [args] Argument object. - */ - addFilesToFolder : function(fileIds, folderId, args) { + var args = lang.mixin(requestArgs || {}, { + "activityUuid" : activityUuid + }); - var promise = this.validateField("fileIds", fileIds); - if (!promise) { - promise = this.validateField("folderId", folderId); - } + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; - var options = { - method : "POST", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - } - }; - var url = this.constructUrl(consts.AtomAddFilesToFolder, null, { - collectionId : folderId - }); + return this.getEntities(consts.AtomActivitiesTags, options, TagFeedCallbacks); + }, - var separatorChar = "?"; - for ( var counter in fileIds) { - url += separatorChar + "itemId=" + fileIds[counter]; - separatorChar = "&"; - } + /** + * Returns the tags for given actiivity node. + * @method getActivityNodeTags + * @param activityNodeUuid + * @param {Object} [requestArgs] the optional arguments + * @returns {Array} tags + */ + getActivityNodeTags : function(activityNodeUuid, requestArgs) { - var callbacks = { - createEntity : function(service, data, response) { - return "Success"; - } - }; + var promise = this.validateField("activityNodeUuid", activityNodeUuid); + if (promise) { + return promise; + } + var args = lang.mixin(requestArgs || {}, { + "activityNodeUuid" : activityNodeUuid + }); - return this.updateEntity(url, options, callbacks); + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; - }, + return this.getEntities(consts.AtomActivitiesTags, options, TagFeedCallbacks); + }, - /** - * Gets the files pinned by the logged in user. - * - * @method getPinnedFiles - * @param {Object} [args] Argument object for the additional parameters like pageSize etc. - */ - getPinnedFiles : function(args) { + /** + * Retrieves activity members from the access control list for a application, use the edit link found in the member entry in the ACL list feed. + * @method getMembers + * @param {String} activityUuid + * @param {Object} [requestArgs] the optional arguments + * @returns {Array} members + */ + getMembers : function(activityUuid, requestArgs) { + var promise = this.validateField("activityUuid", activityUuid); + if (promise) { + return promise; + } + var args = lang.mixin(requestArgs || {}, { + "activityUuid" : activityUuid + }); - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; - return this.getEntities(consts.AtomFilesMyPinned, options, this.getFileFeedCallbacks()); - }, + return this.getEntities(consts.AtomActivitiesMembers, options, MemberFeedCallbacks); + }, - /** - * Delete a file. - * - * @method deleteFile - * @param {String} fileId Id of the file which needs to be deleted - * @param {Object} [args] Argument object - */ - deleteFile : function(fileId, args) { + _validateMember : function(member, checkId, checkUserIdOrEmail) { + if (checkId && !member.getMemberId()) { + return this.createBadRequestPromise("Invalid argument, member with ID must be specified."); + } + if (checkUserIdOrEmail) { + var id = member.getContributor().userid || member.getContributor().email; + if (!id) { + return this.createBadRequestPromise("Invalid argument, member with User ID or Email must be specified."); + } + } + }, - var promise = this.validateField("fileId", fileId); - if (promise) { - return promise; - } + /** + * Retrieves a member from the access control list for a application, use the edit link found in the member entry in the ACL list feed. + * @method getMember + * @param {String} activityUuid + * @param {String} memberId + * @returns {Object} Member + */ + getMember : function(activityUuid, memberId) { - var options = { - method : "DELETE", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - } - }; - var url = this.constructUrl(consts.AtomDeleteFile, null, { - documentId : fileId - }); + var promise = this.validateField("memberId", memberId); + if (!promise) { + promise = this.validateField("activityUuid", activityUuid); + } + if (promise) { + return promise; + } + var member = this._toMember(memberId); + return member.load(activityUuid); + }, - return this.deleteEntity(url, options, fileId); - }, + /** + * Adds a member to the access control list of an activity, sends an Atom entry document containing the new member to the access control list + * feed. You can only add one member per post. + * @method addMember + * @param {String} activityUuid + * @param {Object} memberOrJson + */ + addMember : function(activityUuid, memberOrJson) { + var promise = this.validateField("memberOrJson", memberOrJson); + if (!promise) { + promise = this.validateField("activityUuid", activityUuid); + } + if (promise) { + return promise; + } + var member = this._toMember(memberOrJson); + promise = this._validateMember(member, false, true); + if (promise) { + return promise; + } + if (!member.getRole()) { + member.setRole("member"); + } + member.setCategoryScheme(); + var payload = member.createPostData(); + var requestArgs = { + "activityUuid" : activityUuid + }; + var options = { + method : "POST", + headers : consts.AtomXmlHeaders, + query : requestArgs, + data : payload + }; + var callbacks = { + createEntity : function(service, data, response) { + return response; + } + }; - /** - * Lock a file - * - * @method lockFile - * @param {String} fileId Id of the file which needs to be locked - * @param {Object} [args] Argument object - */ - lockFile : function(fileId, args) { - var parameters = args ? lang.mixin({}, args) : {}; - parameters["type"] = "HARD"; + return this.updateEntity(consts.AtomActivitiesMembers, options, callbacks); - var options = { - method : "POST", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" }, - query : args || {} - }; - var url = this.constructUrl(consts.AtomLockUnlockFile, parameters, { - documentId : fileId - }); - - var callbacks = { - createEntity : function(service, data, response) { - return "Success"; - } - }; - - return this.updateEntity(url, options, callbacks, args); - }, - /** - * unlock a file - * - * @method lockFile - * @param {String} fileId Id of the file which needs to be unlocked - * @param {Object} [args] Argument object - */ - unlockFile : function(fileId, args) { - var parameters = args ? lang.mixin({}, args) : {}; - parameters["type"] = "NONE"; + /** + * Updates a member in the access control list for an application, sends a replacement member entry document in Atom format to the existing ACL + * node's edit web address. + * @method updateMember + * @param {String} activityUuid + * @param {Object} memberOrJson + */ + updateMember : function(activityUuid, memberOrJson) { + var promise = this.validateField("memberOrJson", memberOrJson); + if (!promise) { + promise = this.validateField("activityUuid", activityUuid); + } + if (promise) { + return promise; + } + var member = this._toMember(memberOrJson); + promise = this._validateMember(member, true, true); + if (promise) { + return promise; + } + member.setCategoryScheme(); + var payload = member.createPostData(); + var requestArgs = { + "activityUuid" : activityUuid, + "memberid" : member.getMemberId() + }; - var options = { - method : "POST", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - }, - query : args || {} - }; - var url = this.constructUrl(consts.AtomLockUnlockFile, parameters, { - documentId : fileId - }); + var options = { + method : "PUT", + headers : consts.AtomXmlHeaders, + query : requestArgs, + data : payload + }; - var callbacks = { - createEntity : function(service, data, response) { - return "Success"; - } - }; + var callbacks = { + createEntity : function(service, data, response) { + return response; + } + }; - return this.updateEntity(url, options, callbacks, args); - }, + return this.updateEntity(consts.AtomActivitiesMembers, options, callbacks); - /** - * Uploads a new file for logged in user. - * - * @method uploadFile - * @param {Object} fileControlOrId The Id of html control or the html control - * @param {Object} [args] The additional parameters for upload - */ - uploadFile : function(fileControlOrId, args) { + }, - var promise = this.validateField("File Control Or Id", fileControlOrId); - if (promise) { - return promise; - } - promise = this.validateHTML5FileSupport(); - if (promise) { - return promise; - } - - var files = null; - if (typeof fileControlOrId == "string") { - var fileControl = document.getElementById(fileControlOrId); - files = fileControl.files; - } else if (typeof fileControlOrId == "object") { - files = fileControlOrId.files; - } else { - return this.createBadRequestPromise("File Control or ID is required"); - } - - if (files.length == 0) { - return this.createBadRequestPromise("No files selected for upload"); - } + /** + * Removes a member from the acl list for an application, use the HTTP DELETE method. + * @method deleteMember + * @param {String} activityUuid + * @param {String} memberId + */ + deleteMember : function(activityUuid, memberId) { + var promise = this.validateField("activityUuid", activityUuid); + if (!promise) { + promise = this.validateField("memberId", memberId); + } + if (promise) { + return promise; + } + var requestArgs = { + "activityUuid" : activityUuid, + "memberid" : memberId + }; + var options = { + method : "DELETE", + headers : consts.AtomXmlHeaders, + query : requestArgs + }; - var file = files[0]; - var data = new FormData(); - data.append("file", file); + return this.deleteEntity(consts.AtomActivitiesMembers, options, memberId); + }, - return this.uploadFileBinary(data, file.name, args); - }, + _toMember : function(memberOrJsonOrString) { + if (memberOrJsonOrString) { + if (memberOrJsonOrString instanceof Member) { + return memberOrJsonOrString; + } + var member = new Member({ + service : this + }); + if (lang.isString(memberOrJsonOrString)) { + memberOrJsonOrString = { + id : memberOrJsonOrString + }; + } + member._fields = lang.mixin({}, memberOrJsonOrString); + if(member._fields.userId) { + member._fields.contributorUserid = member._fields.userId; + } + return member; + } + }, - /** - * Uploads a new file for logged in user. - * - * @method uploadFile - * @param {Object} binaryContent The binary content of the file - * @param {String} filename The name of the file - * @param {Object} [args] The additional parameters of metadata of file for upload like visibility, tag, etc. - */ - uploadFileBinary : function(binaryContent, fileName, args) { + /** + * Returns a Member instance from Member or JSON or String. Throws an error if the argument was neither. + * @method newMember + * @param {Object} memberOrJsonOrString The Member Object or json String for Member + */ + newMember : function(memberOrJsonOrString) { + return this._toMember(memberOrJsonOrString); + } + }); + return ActivityService; + }); - var promise = this.validateField("Binary Content", binaryContent); - if (promise) { - return promise; - } - promise = this.validateField("File Name", fileName); - if (promise) { - return promise; - } - if (util.getJavaScriptLibrary().indexOf("Dojo 1.4.3") != -1) { - return this.createBadRequestPromise("Dojo 1.4.3 is not supported for File upload"); - } - // /files/<>/<>/<>/fileName eg. /files/smartcloud/connections/UploadFile/fileName?args - var url = this.constructUrl(config.Properties.serviceUrl + "/files/" + this.endpoint.proxyPath + "/" + "connections" + "/" + "UploadFile" - + "/" + encodeURIComponent(fileName), args && args.parameters ? args.parameters : {}); - var headers = { - "Content-Type" : false, - "Process-Data" : false // processData = false is reaquired by jquery - }; - var options = { - method : "POST", - headers : headers, - query : args || {}, - data : binaryContent - }; +}, +'sbt/connections/CommunityService':function(){ +/* + * (C) 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. + */ - return this.updateEntity(url, options, this.getFileFeedCallbacks()); - }, +/** + * The Communities API allows application programs to retrieve community information, subscribe to community updates, and create or modify communities. + * + * @module sbt.connections.CommunityService + */ +define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./CommunityConstants", "./ConnectionsService", + "../base/AtomEntity", "../base/XmlDataHandler", "./ForumService", "./BookmarkService", "../pathUtil" ], + function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler,ForumService,BookmarkService,pathUtil) { - /** - * Upload new version of a file. - * - * @method uploadNewVersion - * @param {Object} fileId The ID of the file - * @param {Object} fileControlOrId The Id of html control or the html control - * @param {Object} [args] The additional parameters ffor updating file metadata - */ - uploadNewVersion : function(fileId, fileControlOrId, args) { + var CategoryCommunity = ""; + var CategoryMember = ""; + var CategoryInvite = ""; + var CategoryEvent = ""; + + var IsExternalTmpl = "${isExternal}"; + var parentLinkTmpl = " "; + var CommunityTypeTmpl = "${getCommunityType}"; + var CommunityUuidTmpl = "${getCommunityUuid}instance?communityUuid=${getCommunityUuid} "; + var CommunityThemeTmpl = "${getCommunityTheme}"; + var RoleTmpl = "${getRole}"; + + /* + * CommunityDataHandler class. + */ + var CommunityDataHandler = declare(XmlDataHandler, { + /** + * @method getEntityId + * @returns + */ + getEntityId : function() { + var entityId = stringUtil.trim(this.getAsString("uid")); + return extractCommunityUuid(this.service, entityId); + } + }); + + /** + * Community class represents an entry for a Community feed returned by the + * Connections REST API. + * + * @class Community + * @namespace sbt.connections + */ + var Community = declare(AtomEntity, { - var promise = this.validateField("File Control Or Id", fileControlOrId); - if (!promise) { - promise = this.validateField("File ID", fileId); - } - if (promise) { - return promise; - } - promise = this.validateHTML5FileSupport(); - if (promise) { - return promise; - } - var files = null; - if (typeof fileControlOrId == "string") { - var fileControl = document.getElementById(fileControlOrId); - filePath = fileControl.value; - files = fileControl.files; - } else if (typeof fileControlOrId == "object") { - filePath = fileControlOrId.value; - files = fileControlOrId.files; - } else { - return this.createBadRequestPromise("File Control or ID is required"); - } + xpath : consts.CommunityXPath, + namespaces : consts.CommunityNamespaces, + categoryScheme : CategoryCommunity, + + /** + * Construct a Community entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, - var file = files[0]; - var data = new FormData(); - data.append("file", file); + /** + * Create the DataHandler for this entity. + * + * @method createDataHandler + */ + createDataHandler : function(service, data, response, namespaces, xpath) { + return new CommunityDataHandler({ + service : service, + data : data, + namespaces : namespaces, + xpath : xpath + }); + }, + + /** + * Return extra entry data to be included in post data for this entity. + * + * @returns {String} + */ + createEntryData : function() { + var postData = ""; + var transformer = function(value,key) { + return value; + }; + postData += stringUtil.transform(CommunityTypeTmpl, this, transformer, this); + postData += stringUtil.transform(IsExternalTmpl, this, transformer, this); + if (this.getCommunityUuid()) { + postData += stringUtil.transform(CommunityUuidTmpl, this, transformer, this); + } + if(this.isSubCommunity()){ + postData += stringUtil.transform(parentLinkTmpl, this, transformer, this); + } + if (this.getCommunityTheme()) { + postData += stringUtil.transform(CommunityThemeTmpl, this, transformer, this); + } + return stringUtil.trim(postData); + }, + + /** + * Return the value of IBM Connections community ID from community ATOM + * entry document. + * + * @method getCommunityUuid + * @return {String} Community ID of the community + */ + getCommunityUuid : function() { + var communityUuid = this.getAsString("communityUuid"); + return extractCommunityUuid(this.service, communityUuid); + }, - return this.uploadNewVersionBinary(data, fileId, file.name, args); - }, + /** + * Sets id of IBM Connections community. + * + * @method setCommunityUuid + * @param {String} communityUuid Id of the community + */ + setCommunityUuid : function(communityUuid) { + return this.setAsString("communityUuid", communityUuid); + }, - /** - * Uploads new Version of a File. - * - * @method uploadNewVersionBinary - * @param {Object} binaryContent The binary content of the file - * @param {String} fileId The ID of the file - * @param {Object} [args] The additional parameters for upding file metadata - */ - uploadNewVersionBinary : function(binaryContent, fileId, fileName, args) { + /** + * Return the community type of the IBM Connections community from + * community ATOM entry document. + * + * @method getCommunityType + * @return {String} Type of the Community + */ + getCommunityType : function() { + var type = this.getAsString("communityType"); + if (!type) { + type = consts.Restricted; + } + return type; + }, - var promise = this.validateField("Binary Content", binaryContent); - if (promise) { - return promise; - } - promise = this.validateField("File ID", fileId); - if (promise) { - return promise; - } - promise = this.validateField("File Name", fileName); - if (promise) { - return promise; - } - if (util.getJavaScriptLibrary().indexOf("Dojo 1.4.3") != -1) { - return this.createBadRequestPromise("Dojo 1.4.3 is not supported for File Upload"); - } - // /files/<>/<>/<>/fileId?args eg./files/smartcloud/connections/UpdateFile/fileId/fileName?args - var url = this.constructUrl(config.Properties.serviceUrl + "/files/" + this.endpoint.proxyPath + "/" + "connections" + "/" - + "UploadNewVersion" + "/" + encodeURIComponent(fileId) + "/" + encodeURIComponent(fileName), - args && args.parameters ? args.parameters : {}); - var headers = { - "Content-Type" : false, - "Process-Data" : false // processData = false is reaquired by jquery - }; - var options = { - method : "PUT", - headers : headers, - data : binaryContent - }; - var promise = new Promise(); - var _this = this; + /** + * Set the community type of the IBM Connections community. + * + * @method setCommunityType + * @param {String} Type of the Community + */ + setCommunityType : function(communityType) { + return this.setAsString("communityType", communityType); + }, - this.updateEntity(url, options, this.getFileFeedCallbacks()).then(function(file) { - if (args) { - _this.updateFile(file.getFileId(), args).then(function(updatedFile) { - promise.fulfilled(updatedFile); - }); - } else { - promise.fulfilled(file); - } - }, function(error) { - promise.rejected(error); - }); - return promise; - }, + /** + * Return the community theme of the IBM Connections community from + * community ATOM entry document. + * + * @method getCommunityTheme + * @return {String} Theme of the Community + */ + getCommunityTheme : function() { + return this.getAsString("communityTheme"); + }, - /** - * Updates metadata of a file programatically using a PUT call - * @param [String] fileId the File ID - * @param [Object] args The parameters for update. Supported Input parameters are commentNotification, created, identifier, includePath, - * mediaNotification, modified, recommendation, removeTag, sendNotification, sharePermission, shareSummary, shareWith, tag and visibility - * @returns - */ - updateFile : function(fileId, args) { - var promise = this.validateField("File ID", fileId); - if (promise) { - return promise; - } - var url = this.constructUrl(consts.AtomFileInstance, null, { - documentId : fileId - }); - var separatorChar = "?"; - if (args && args.tags) { - var tags = args.tags.split(","); - for ( var counter in tags) { - url += separatorChar + "tag=" + stringUtil.trim(tags[counter]); - separatorChar = "&"; - } - delete args.tags; - } - if (args && args.removeTags) { - var removeTags = args.removeTags.split(","); - for ( var counter in removeTags) { - url += separatorChar + "removeTag=" + stringUtil.trim(removeTags[counter]); - separatorChar = "&"; - } - delete args.removeTags; - } + /** + * Set the community theme of the IBM Connections community. + * + * @method setCommunityTheme + * @param {String} Theme of the Community + */ + setCommunityTheme : function(communityTheme) { + return this.setAsString("communityTheme", communityTheme); + }, - var options = { - method : "PUT", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - }, - query : args || {} - }; + /** + * Return the external of the IBM Connections community from + * community ATOM entry document. + * + * @method isExternal + * @return {Boolean} External flag of the Community + */ + isExternal : function() { + return this.getAsBoolean("isExternal"); + }, - return this.updateEntity(url, options, this.getFileFeedCallbacks()); - }, + /** + * Set the external flag of the IBM Connections community. + * + * @method setExternal + * @param {Boolean} External flag of the Community + */ + setExternal : function(external) { + return this.setAsBoolean("isExternal", external); + }, + + /** + * function to check if a community is a sub community of another community + * + * @method isSubCommunity + * @return Returns true if this community is a sub community + */ + isSubCommunity : function(){ + var parentUrl = this.getParentCommunityUrl(); + if(parentUrl != null && parentUrl != ""){ + return true; + }else{ + return false; + } + }, + + /** + * If this community is a sub community this function gets the url of the parent community + * else it returns null. + * @method getParentCommunityUrl + * @returns The Url of the parent community if the community is a sub community else returns null + */ + getParentCommunityUrl: function(){ + return this.getAsString("parentCommunityUrl"); + }, - /** - * Downloads a file. - * - * @method downloadFile - * @param {String} fileId The ID of the file - * @param {String} libraryId The library ID of the file - */ - downloadFile : function(fileId, libraryId) { - var url = config.Properties.serviceUrl + "/files/" + this.endpoint.proxyPath + "/" + "connections" + "/" + "DownloadFile" + "/" + fileId - + "/" + libraryId; - window.open(url); - }, + /** + * Return tags of IBM Connections community from community ATOM entry + * document. + * + * @method getTags + * @return {Object} Array of tags of the community + */ + getTags : function() { + return this.getAsArray("tags"); + }, - actOnCommentAwaitingApproval : function(commentId, action, actionReason) { + /** + * Set new tags to be associated with this IBM Connections community. + * + * @method setTags + * @param {Object} Array of tags to be added to the community + */ - }, - actOnFileAwaitingApproval : function(fileId, action, actionReason) { + setTags : function(tags) { + return this.setAsArray("tags", tags); + }, - }, - /** - * Add a file to a folder or list of folders. - * - * You cannot add a file from your local directory to a folder; the file must already have been uploaded to the Files application. To add a file - * to a folder you must be an editor of the folder. - * - * @method addFilesToFolder - * @param {String} fileId the Id of the file - * @param {List} folderIds list of folder Ids - * @param {String} [userId] the userId of the user in case of own file - * @param {Object} [args] Argument object. - */ - addFileToFolders : function(fileId, folderIds, userId, args) { - var promise = this.validateField("fileId", fileId); - if (!promise) { - promise = this.validateField("folderIds", folderIds); - } - if (promise) { - return promise; - } + /** + * Return the value of IBM Connections community URL from community ATOM + * entry document. + * + * @method getCommunityUrl + * @return {String} Community URL of the community + * @deprecated Use getAlternateUrl instead + */ + getCommunityUrl : function() { + return this.getAlternateUrl(); + }, - var url = null; + /** + * Return the value of IBM Connections community Logo URL from community + * ATOM entry document. + * + * @method getLogoUrl + * @return {String} Community Logo URL of the community + */ + getLogoUrl : function() { + return this.getAsString("logoUrl"); + }, - if (!userId) { - url = this.constructUrl(consts.AtomAddMyFileToFolders, null, { - documentId : fileId - }); - } else { - url = this.constructUrl(consts.AtomAddFileToFolders, null, { - userId : userId, - documentId : fileId - }); - } + /** + * Return the member count of the IBM Connections community from + * community ATOM entry document. + * + * @method getMemberCount + * @return {Number} Member count for the Community + */ + getMemberCount : function() { + return this.getAsNumber("memberCount"); + }, - var payload = this._constructPayloadForMultipleEntries(folderIds, "itemId", "collection"); + /** + * Get a list for forum topics that includes the topics in this community. + * + * @method getForumTopics + * @param {Object} args + */ + getForumTopics : function(args) { + return this.service.getForumTopics(this.getCommunityUuid(), args); + }, + + /** + * Create a forum topic by sending an Atom entry document containing the + * new forum to the forum replies resource. + * + * @method createForumTopic + * @param {Object} forumTopic Forum topic object which denotes the forum topic to be created. + * @param {Object} [args] Argument object + */ + createForumTopic : function(communityUuid, topicOrJson, args) { + if(!lang.isString(communityUuid)){ + args = topicOrJson; + topicOrJson = communityUuid; + } + return this.service.createForumTopic(topicOrJson, args); + }, + + /** + * Get sub communities of a community. + * + * @method getSubCommunities + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of members of a + * community. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getSubCommunities : function(args) { + return this.service.getSubCommunities(this.getCommunityUuid(), args); + }, - var options = { - method : "POST", - headers : consts.AtomXmlHeaders, - data : payload - }; + /** + * Get members of this community. + * + * @method getMembers + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of members of a + * community. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getMembers : function(args) { + return this.service.getMembers(this.getCommunityUuid(), args); + }, - var callbacks = { - createEntity : function(service, data, response) { - } - }; + /** + * Add member to a community + * + * @method addMember + * @param {Object} [args] Argument object + * @param {Object} [args.member] Object representing the member to be added + * @param {String} [args.email] Object representing the email of the memeber to be added + * @param {String} [args.id] String representing the id of the member to be added + */ + addMember : function(member,args) { + return this.service.addMember(this.getCommunityUuid(), member, args); + }, - return this.updateEntity(url, options, callbacks); - }, + /** + * Remove member of a community + * + * @method removeMember + * @param {String} Member id of the member + * @param {Object} [args] Argument object + */ + removeMember : function(memberId,args) { + return this.service.removeMember(this.getCommunityUuid(), memberId, args); + }, + + /** + * Loads a member object with the atom entry associated with the + * member of the community. By default, a network call is made to load the atom entry + * document in the member object. + * + * @method getMember + * @param {String} member id of the member. + * @param {Object} [args] Argument object + */ + getMember : function(memberId, args) { + return this.service.getMember(this.getCommunityUuid(), memberId, args); + }, + + /** + * Get a list of the outstanding community invitations for the specified community. + * The currently authenticated user must be an owner of the community. + * + * @method getAllInvites + * @param {Object} [args] + */ + getAllInvites : function(args) { + return this.service.getAllInvites(this.getCommunityUuid(), args); + }, - /** - * Create a new Folder - * - * @method createFolder

    Rest API used : /files/basic/api/collections/feed - * - * @param {String} name name of the folder to be created - * @param {String} [description] description of the folder - * @param {String} [shareWith] If the folder needs to be shared, specify the details in this parameter.
    Pass Coma separated List of id, - * (person/community/group) or role(reader/Contributor/owner) in order - * @return {Object} Folder - */ - createFolder : function(name, description, shareWith) { - var promise = this.validateField("folderName", name); - if (promise) { - return promise; - } - var url = consts.AtomCreateFolder; - var payload = this._constructPayloadFolder(name, description, shareWith, "create"); + /** + * Get the list of community forums. + * + * @method getForums + * @param {Object} [args] Argument object + */ + getForums : function(args) { + var forumService = this.service.getForumService(); + var requestArgs = lang.mixin(args || {}, { communityUuid : this.getCommunityUuid() }); + return forumService.getForums(requestArgs); + }, + + /** + * Loads the community object with the atom entry associated with the + * community. By default, a network call is made to load the atom entry + * document in the community object. + * + * @method load + * @param {Object} [args] Argument object + */ + load : function(args) { + // detect a bad request by validating required arguments + var communityUuid = this.getCommunityUuid(); + var promise = this.service._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } - var options = { - method : "POST", - headers : lang.mixin(consts.AtomXmlHeaders, { - "X-Update-Nonce" : "{X-Update-Nonce}" - }), - data : payload - }; + var self = this; + var callbacks = { + createEntity : function(service, data, response) { + self.setData(data, response); + return self; + } + }; - return this.updateEntity(url, options, this.getFileFeedCallbacks()); + var requestArgs = lang.mixin( + { communityUuid : communityUuid }, + args || {}); + var options = { + handleAs : "text", + query : requestArgs + }; + + return this.service.getEntity(consts.AtomCommunityInstance, options, communityUuid, callbacks); + }, - }, + /** + * Remove this community + * + * @method remove + * @param {Object} [args] Argument object + */ + remove : function(args) { + return this.service.deleteCommunity(this.getCommunityUuid(), args); + }, - /** - * Delete Files From Recycle Bin - * - * @param {String} userId The ID of user - */ - deleteAllFilesFromRecycleBin : function(userId) { + /** + * Update this community + * + * @method remove + * @param {Object} [args] Argument object + */ + update : function(args) { + return this.service.updateCommunity(this, args); + }, + + /** + * Save this community + * + * @method remove + * @param {Object} [args] Argument object + */ + save : function(args) { + if (this.getCommunityUuid()) { + return this.service.updateCommunity(this, args); + } else { + return this.service.createCommunity(this, args); + } + } + + }); - var url = null; + /** + * Member class represents an entry for a Member feed returned by the + * Connections REST API. + * + * @class Member + * @namespace sbt.connections + */ + var Member = declare(AtomEntity, { - if (!userId) { - url = consts.AtomDeleteMyFilesFromRecyclebBin; - } else { - url = this.constructUrl(consts.AtomDeleteAllFilesFromRecyclebBin, null, { - userId : userId - }); - } - var options = { - method : "DELETE" - }; - return this.deleteEntity(url, options, ""); - }, + xpath : consts.MemberXPath, + namespaces : consts.CommunityNamespaces, + categoryScheme : CategoryMember, + + /** + * The UUID of the community associated with this Member + */ + communityUuid : null, - /** - * Delete all Versions of a File before the given version - * - * @param {String} fileId the ID of the file - * @param {String} [versionLabel] The version from which all will be deleted - * @param {Object} [args] additional arguments - */ - deleteAllVersionsOfFile : function(fileId, versionLabel, args) { + /** + * Constructor for Member entity + * + * @constructor + * @param args + */ + constructor : function(args) { + if (!this.getRole()) { + this.setRole(consts.Member); + } + }, - var promise = this.validateField("fileId", fileId); - if (!promise) { - promise = this.validateField("versionLabel", versionLabel); - } - if (promise) { - return promise; - } + /** + * Return extra entry data to be included in post data for this entity. + * + * @returns {String} + */ + createEntryData : function() { + var postData = ""; + var transformer = function(value,key) { + return value; + }; + postData += stringUtil.transform(RoleTmpl, this, transformer, this); + return stringUtil.trim(postData); + }, + + /** + * Return the community UUID. + * + * @method getCommunityUuid + * @return {String} communityUuid + */ + getCommunityUuid : function() { + return this.communityUuid; + }, - var requestArgs = lang.mixin({ - category : "version", - deleteFrom : versionLabel - }, args || {}); + /** + * Return the community member name. + * + * @method getName + * @return {String} Community member name + */ - var options = { - method : "DELETE", - query : requestArgs, - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - } - }; - var url = this.constructUrl(consts.AtomDeleteAllVersionsOfAFile, null, { - documentId : fileId - }); + getName : function() { + return this.getAsString("contributorName"); + }, - return this.deleteEntity(url, options, fileId); - }, + /** + * Set the community member name. + * + * @method setName + * @param {String} Community member name + */ - /** - * Delete a Comment for a file - * - * @param {String} fileId the ID of the file - * @param {String} commentId the ID of comment - * @param {String} [userId] the ID of the user, if not provided logged in user is assumed - * @param {Object} [args] the additional arguments - */ - deleteComment : function(fileId, commentId, userId, args) { - var promise = this.validateField("fileId", fileId); - if (!promise) { - promise = this.validateField("commentId", commentId); - } - if (promise) { - return promise; - } + setName : function(name) { + return this.setAsString("contributorName", name); + }, - var url = null; + /** + * Return the community member userId. + * + * @method getUserid + * @return {String} Community member userId + */ + getUserid : function() { + return this.getAsString("contributorUserid"); + }, - if (userId) { - url = this.constructUrl(consts.AtomDeleteComment, null, { - userId : userId, - documentId : fileId, - commentId : commentId - }); - } else { - url = this.constructUrl(consts.AtomDeleteMyComment, null, { - documentId : fileId, - commentId : commentId - }); - } + /** + * Set the community member userId. + * + * @method getId + * @return {String} Community member userId + */ + setUserid : function(userid) { + return this.setAsString("contributorUserid", userid); + }, - var options = { - method : "DELETE", - query : args || {}, - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - } - }; + /** + * Return the community member email. + * + * @method getName + * @return {String} Community member email + */ + getEmail : function() { + return this.getAsString("contributorEmail"); + }, - return this.deleteEntity(url, options, commentId); - }, + /** + * Return the community member email. + * + * @method getName + * @return {String} Community member email + */ - /** - * Delete File from RecycleBin of a user - * @param {String} fileId the Id of the file - * @param {String} [userId] the Id of the user - * @param {Object} args the additional arguments - * @returns - */ - deleteFileFromRecycleBin : function(fileId, userId, args) { - var promise = this.validateField("fileId", fileId); - if (promise) { - return promise; - } + setEmail : function(email) { + return this.setAsString("contributorEmail", email); + }, - var url = null; + /** + * Return the value of community member role from community member ATOM + * entry document. + * + * @method getRole + * @return {String} Community member role + */ + getRole : function() { + return this.getAsString("role"); + }, - if (userId) { - url = this.constructUrl(consts.AtomDeleteFileFromRecycleBin, null, { - userId : userId, - documentId : fileId - }); - } else { - url = this.constructUrl(consts.AtomDeleteMyFileFromRecycleBin, null, { - documentId : fileId - }); - } + /** + * Sets role of a community member + * + * @method setRole + * @param {String} role Role of the community member. + */ + setRole : function(role) { + return this.setAsString("role", role); + }, + + /** + * Loads the member object with the atom entry associated with the + * member. By default, a network call is made to load the atom entry + * document in the member object. + * + * @method load + * @param {Object} [args] Argument object + */ + load : function(args) { + // detect a bad request by validating required arguments + var communityUuid = this.communityUuid; + var promise = this.service._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } - var options = { - method : "DELETE", - query : args || {}, - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - } - }; + var self = this; + var callbacks = { + createEntity : function(service, data, response) { + self.setData(data, response); + return self; + } + }; - return this.deleteEntity(url, options, fileId); - }, + var requestArgs = { + communityUuid : communityUuid + }; + var memberId = null; + if (this.getUserid()) { + memberId = requestArgs.userid = this.getUserid(); + } else { + memberId = requestArgs.email = this.getEmail(); + } + requestArgs = lang.mixin(requestArgs, args || {}); + var options = { + handleAs : "text", + query : requestArgs + }; - /** - * deletes a File Share - * @param {String} fileId the ID of the file - * @param {String} userId the ID of the user - * @param {Object} args the additional arguments - */ - deleteFileShare : function(fileId, userId, args) { - var promise = this.validateField("fileId", fileId); - if (promise) { - return promise; - } + return this.service.getEntity(consts.AtomCommunityMembers, options, memberId, callbacks); + }, + + /** + * Remove this member from the community. + * + * @method remove + * @param {Object} [args] Argument object + */ + remove : function(args) { + var memberId = this.getUserid() || this.getEmail(); + return this.service.removeMember(this.getCommunityUuid(), memberId, args); + } - var requestArgs = lang.mixin({ - sharedWhat : fileId - }, args || {}); + }); - if (userId) { - requestArgs.sharedWith = userId; - } + /** + * Invite class represents an entry for a Invite feed returned by the + * Connections REST API. + * + * @class Invite + * @namespace sbt.connections + */ + var Invite = declare(AtomEntity, { - var url = consts.AtomDeleteFileShare; + xpath : consts.InviteXPath, + namespaces : consts.CommunityNamespaces, + categoryScheme : CategoryInvite, + + /** + * The UUID of the community associated with this Invite + */ + communityUuid : null, - var options = { - method : "DELETE", - query : requestArgs, - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - } - }; + /** + * The UUID if the invitee associated with this Invite + */ + inviteeUuid : null, - return this.deleteEntity(url, options, fileId); - }, + /** + * Constructor for Invite + * + * @constructor + * @param args + */ + constructor : function(args) { + this.inherited(arguments, [ args ]); + }, - /** - * Deletes a Folder - * @param {String} folderId the ID of the folder - */ - deleteFolder : function(folderId) { - var promise = this.validateField("folderId", folderId); - if (promise) { - return promise; - } + /** + * Return the value of IBM Connections invite ID from invite ATOM + * entry document. + * + * @method getInviteUuid + * @return {String} Invite ID of the invite + */ + getInviteUuid : function() { + var inviteUuid = this.getAsString("inviteUuid"); + return extractInviteUuid(inviteUuid); + }, - var options = { - method : "DELETE", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - } - }; - var url = this.constructUrl(consts.AtomDeleteFFolder, null, { - collectionId : folderId - }); + /** + * Sets id of IBM Connections invite. + * + * @method setInviteUuid + * @param {String} inviteUuid Id of the invite + */ + setInviteUuid : function(inviteUuid) { + return this.setAsString("inviteUuid", inviteUuid); + }, - return this.deleteEntity(url, options, folderId); - }, + /** + * Set the community UUID. + * + * @method setCommunityUuid + * @return {String} communityUuid + */ + setCommunityUuid : function(communityUuid) { + this.communityUuid = communityUuid; + return this; + }, + + /** + * Return the community UUID. + * + * @method getCommunityUuid + * @return {String} communityUuid + */ + getCommunityUuid : function() { + if (!this.communityUuid) { + this.communityUuid = this.service.getUrlParameter(this.getAsString("communityUrl"), "communityUuid"); + } + return this.communityUuid; + }, + + /** + * Set the invitee UUID. + * + * @method setInviteeUuid + * @return {String} inviteeUuid + */ + setInviteeUuid : function(inviteeUuid) { + this.inviteeUuid = inviteeUuid; + return this; + }, + + /** + * Return the value of IBM Connections invitee ID from invite ATOM + * entry document. + * + * @method getInviteeUuid + * @return {String} Invitee ID of the invite + */ + getInviteeUuid : function() { + if (!this.inviteeUuid) { + var inviteUuid = this.getInviteUuid(); + this.inviteeUuid = extractInviteeUuid(inviteUuid, this.getCommunityUuid()); + } + return this.inviteeUuid; + }, - /** - * Get all user Files - * @param {String} userId the ID of the user - * @param {Object} args the addtional arguments - * @returns {Object} Files - */ - getAllUserFiles : function(userId, args) { + /** + * Set the user id of the invitee. + * + * @method setUserid + * @return {String} userid + */ + setUserid : function(userid) { + return this.setAsString("contributorUserid", userid); + }, + + /** + * Return the user id of the invitee. + * + * @method getUserid + * @return {String} userid + */ + getUserid : function() { + return this.getAsString("contributorUserid"); + }, + + /** + * Set the email of the invitee. + * + * @method setEmail + * @return {String} email + */ + setEmail : function(email) { + return this.setAsString("contributorEmail", email); + }, + + /** + * Return the email of the invitee. + * + * @method getEmail + * @return {String} email + */ + getEmail : function() { + return this.getAsString("contributorEmail"); + }, + + /** + * Loads the invite object with the atom entry associated with the + * invite. By default, a network call is made to load the atom entry + * document in the invite object. + * + * @method load + * @param {Object} [args] Argument object + */ + load : function(args) { + // detect a bad request by validating required arguments + var communityUuid = this.getCommunityUuid(); + var promise = this.service._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } + var userid = this.getInviteeUuid(); + promise = this.service._validateUserid(userid); + if (promise) { + return promise; + } - var promise = this.validateField("userId", userId); - if (promise) { - return promise; - } + var self = this; + var callbacks = { + createEntity : function(service, data, response) { + self.setData(data, response); + return self; + } + }; - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + var requestArgs = lang.mixin({ + communityUuid : communityUuid, + userid : userid + }, args || {}); + var options = { + handleAs : "text", + query : requestArgs + }; + + return this.service.getEntity(consts.AtomCommunityInvites, options, communityUuid + "-" + userid, callbacks); + }, - var url = this.constructUrl(consts.AtomGetAllUsersFiles, null, { - userId : userId - }); + /** + * Remove this invite + * + * @method remove + * @param {Object} [args] Argument object + */ + remove : function(args) { + return this.service.removeInvite(this, args); + }, - return this.getEntities(url, options, this.getFileFeedCallbacks()); - }, + /** + * Update this invite + * + * @method remove + * @param {Object} [args] Argument object + */ + update : function(args) { + return this.service.updateInvite(this, args); + }, + + /** + * Save this invite + * + * @method remove + * @param {Object} [args] Argument object + */ + save : function(args) { + if (this.getInviteUuid()) { + return this.service.updateInvite(this, args); + } else { + return this.service.createInvite(this, args); + } + } - /** - * Get file Comments - * @param {String} fileId the ID of the file - * @param {String} [userId] the ID of the user - * @param {Boolean} [isAnnonymousAccess] flag to indicate annonymous access - * @param {String} [commentId] the ID of the comment - * @param {String} [communityId] required in case the file in a community file - * @param {Object} args the additional arguments - * @returns {Array} Comments List - */ - getFileComments : function(fileId, userId, isAnnonymousAccess, commentId, communityId, args) { + }); + + + /** + * Event class represents an entry from an Events feed returned by the Connections REST API. + * + * An Event may repeat and have multiple EventInsts (instances of the event). + * + * e.g. If an event has repeats set so that it happens on 5 different days it has 5 EventInsts, but the Event is still the same. + * + * @class Event + * @namespace sbt.connections + */ + var Event = declare(AtomEntity, { - var promise = this.validateField("fileId", fileId); - if (promise) { - return promise; - } + /** + * Constructor for Event. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, - var url = null; - if(communityId){ - url = this.constructUrl(consts.AtomAddCommentToCommunityFile, null, { - communityId : communityId, - documentId : fileId - }); - } - else if (commentId) { - if (userId) { - url = this.constructUrl(consts.AtomGetFileComment, null, { - userId : userId, - documentId : fileId, - commentId : commentId - }); - } else { - url = this.constructUrl(consts.AtomGetMyFileComment, null, { - documentId : fileId, - commentId : commentId - }); - } - } else { - var promise = this.validateField("userId", userId); - if (promise) { - return promise; - } - if (isAnnonymousAccess) { - url = this.constructUrl(consts.AtomFileCommentsPublic, null, { - userId : userId, - documentId : fileId - }); - } else { - url = this.constructUrl(consts.AtomFileCommentsMy, null, { - userId : userId, - documentId : fileId - }); - } - } + /** + * The Uuid of the event. This is per event rather than per event instance. + * + * e.g. if an event spans multiple days it will have multiple instances, yet each even will have the same Uuid. + * @method getEventUuid + * @return {String} Uuid of the event. + */ + getEventUuid : function(){ + return this.getAsString("eventUuid"); + }, + + /** + * @method getLocation + * @return {String} The location of the event + */ + getLocation : function(){ + return this.getAsString("location"); + }, + + /** + * @method getAllDay + * @return {Boolean} True if event lasts entire day, false otherwise. + */ + getAllDay : function(){ + return this.getAsString("allDay") !== 0; + }, + + /** + * + * @method getSelfLink + * @return {String} Link to the atom representation of this object + */ + getSelfLink : function(){ + return this.getAsString("selfLink"); + }, + + /** + * Gets the source, usually the community it was created in. + * Contains id of source, title and a link to the web representation of the source. + * {id:"", title: "", link:""} + * + * @method getSource + * @return {Object} + */ + getSource : function(){ + return this.getAsObject( + [ "id", "title", "link"], + [ "id", "title", "link"]); + }, + + /** + * Gets the recurrence information of the event. This information is not available in individual event instances. + * + * Recurrence information object consists of: + * frequency - 'daily' or 'weekly' + * interval - Week interval. Value is int between 1 and 5. (e.g. repeats every 2 weeks). null if daily. + * until - The end date of the repeating event. + * allDay - 1 if an all day event, 0 otherwise. + * startDate - Start time of the event + * endDate - End time of the event + * byDay - Days of the week this event occurs, possible values are: SU,MO,TU,WE,TH,FR,SA + * + * @method getRecurrence + * @return {Object} An object containing the above recurrence information of the community event. + */ + getRecurrence : function() { + return this.getAsObject( + [ "frequency", "interval", "until", "allDay", "startDate", "endDate", "byDay" ], + [ "frequency", "interval", "until", "allDay", "startDate", "endDate", "byDay" ]); + }, + + /** + * @method getContainerLink + * @return {String} Link to the container on the web, i.e. the community + */ + getCommunityLink : function(){ + this.getAsString("communityLink"); + }, + + /** + * Return the community UUID. + * + * @method getCommunityUuid + * @return {String} communityUuid + */ + getCommunityUuid : function() { + return this.getAsString("communityUuid"); + } + }); + + /** + * EventInst class represents an entry for an EventInsts feed returned by the Connections REST API. EventInsts all have a parent Event. + * + * @class EventInst + * @namespace sbt.connections + */ + var EventInst = declare(Event, { + /** + * Constructor for Event instance. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, + + /** + * The event instance uuid. This is per event instance, rather than per event. + * e.g. if an event spans multiple days each day will have its own eventInstUuid. + * + * Can be used with the{{#crossLink "CommunityService/getEvent:method"}}{{/crossLink}} method to retrieve event instances. + * @method getEventInstUuid + * @return {String} Uuid of the event instance. + */ + getEventInstUuid : function(){ + return this.getAsString("eventInstUuid"); + }, + + /** + * @method getFollowed + * @return {Boolean} True if the current authenticated user is following this event Instance + */ + getFollowed : function(){ + return this.getAsString("followed"); + }, + + /** + * @method getAttended + * @return {Boolean} True if the current authenticated user is attending this event Instance + */ + getAttended : function(){ + return this.getAsString("attended"); + }, + + /** + * @method getParentEventId + * @return {String} The id of the parent event of this event instance. + */ + getParentEventId : function(){ + return this.getAsString("parentEventId"); + }, + + /** + * @method getParentEventLink + * @return {String} The link to the parent event's atom representation. + */ + getParentEventLink : function(){ + return this.getAsString("parentEventLink"); + }, + + /** + * @method getStartDate + * @return The date the event instance starts + */ + getStartDate : function(){ + return this.getAsString("instStartDate"); + }, + + /** + * @method getEndDate + * @return The date the event instance ends + */ + getEndDate : function(){ + return this.getAsString("instEndDate"); + } + }); - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + /* + * Method used to extract the community uuid for an id url. + */ + var extractCommunityUuid = function(service, uid) { + if (uid && uid.indexOf("http") == 0) { + return service.getUrlParameter(uid, "communityUuid"); + } else { + return uid; + } + }; + + /* + * Method used to extract the invite uuid for an id url. + */ + var extractInviteUuid = function(uid) { + if (uid && uid.indexOf("urn:lsid:ibm.com:communities:invite-") == 0) { + return uid.substring("urn:lsid:ibm.com:communities:invite-".length); + } else { + return uid; + } + }; + + /* + * Method used to extract the invitee uuid for an id url. + */ + var extractInviteeUuid = function(uid, communityUuid) { + if (uid && uid.indexOf(communityUuid) == 0) { + return uid.substring(communityUuid.length + 1); + } else { + return uid; + } + }; + + /* + * Callbacks used when reading a feed that contains Community entries. + */ + var CommunityFeedCallbacks = { + createEntities : function(service,data,response) { + return new CommunityDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommunityFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new Community({ + service : service, + data : data, + response: response + }); + } + }; - return this.getEntities(url, options, this.getCommentFeedCallbacks()); - }, - - /** - * Method to get All comments of a Community File - *

    - * Rest API Used : - * /files/basic/api/communitylibrary//document//feed - *

    - * @method getAllCommunityFileComments - * @param {String} fileId - * @param {String} communityId - * @param {Object} [args] - * @returns {Array} comments - */ - getAllCommunityFileComments : function(fileId, communityId, args) { - - var promise = this.validateField("fileId", fileId); - if(!promise){ - promise = this.validateField("communityId", communityId); - } - if (promise) { - return promise; - } - - return this.getFileComments(fileId, null, null, null, communityId, args); - }, + /* + * Callbacks used when reading a feed that contains Member entries. + */ + var MemberFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommunityFeedXPath + }); + } + }; - /** - * Get Files from recycle bin - * @param {Object} [args] the additional arguments - * @returns {Object} Files - */ - getFileFromRecycleBin : function(fileId, userId, args) { + /* + * Callbacks used when reading a feed that contains Invite entries. + */ + var InviteFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommunityFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new Invite({ + service : service, + data : data, + response: response + }); + } + }; + + /* + * Callbacks used when reading a feed that contains Event entries. + */ + var ConnectionsEventFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommunityFeedXPath + }); + }, + createEntity : function(service,data,response) { + var entryHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.EventXPath + }); + return new Event({ + service : service, + id : entryHandler.getEntityId(), + dataHandler : entryHandler + }); + } + }; + + /* + * Callbacks used when reading a feed that contains EventInst entries. + */ + var ConnectionsEventInstFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommunityFeedXPath + }); + }, + createEntity : function(service,data,response) { + var entryHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.EventXPath + }); + return new EventInst({ + service : service, + id : entryHandler.getEntityId(), + dataHandler : entryHandler + }); + } + }; + + var ConnectionsEventInstCallbacks = { + createEntity : function(service,data,response) { + var entryHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.EventXPath + }); + return new EventInst({ + service : service, + id : entryHandler.getEntityId(), + dataHandler : entryHandler + }); + } + }; + + /* + * Callbacks used when reading an entry that contains a Community. + */ + var CommunityCallbacks = { + createEntity : function(service,data,response) { + return new Community({ + service : service, + data : data, + response: response + }); + } + }; + + /* + * Callbacks used when reading an feed that contains community forum topics. + */ + var ForumTopicFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommunityFeedXPath + }); + }, + createEntity : function(service, data, response) { + var forumService = service.getForumService(); + var forumTopic = forumService.newForumTopic({}); + forumTopic.setData(data, response); + return forumTopic; + } + }; - var promise = this.validateField("fileId", fileId); - if (promise) { - return promise; - } - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = this.constructUrl(consts.AtomGetFileFromRecycleBin, null, { - userId : userId, - documentId : fileId - }); + /** + * CommunityService class. + * + * @class CommunityService + * @namespace sbt.connections + */ + var CommunityService = declare(ConnectionsService, { + + forumService : null, + bookmarkService : null, + + contextRootMap: { + communities: "communities" + }, + + serviceName : "communities", - var callbacks = { - createEntity : function(service, data, response) { - self.dataHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.FileXPath - }); - return self; - } - }; + /** + * Constructor for CommunityService + * + * @constructor + * @param args + */ + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } + }, + + /** + * Return a ForumService instance + * + * @method getForumService + * @returns {ForumService} + */ + getForumService : function() { + if (!this.forumService) { + this.forumService = new ForumService(); + this.forumService.endpoint = this.endpoint; + } + return this.forumService; + }, + + /** + * Return a BookmarkService instance + * + * @method getBookmarkService + * @returns {BookmarkService} + */ + getBookmarkService : function() { + if (!this.bookmarkService) { + this.bookmarkService = new BookmarkService(); + this.bookmarkService.endpoint = this.endpoint; + } + return this.bookmarkService; + }, + + /** + * Get the All Communities feed to see a list of all public communities to which the + * authenticated user has access or pass in parameters to search for communities that + * match a specific criteria. + * + * @method getPublicCommunities + * + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of my communities. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getPublicCommunities : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomCommunitiesAll, options, CommunityFeedCallbacks); + }, - return this.getEntity(url, options, callbacks); - }, + /** + * Get the My Communities feed to see a list of the communities to which the + * authenticated user is a member or pass in parameters to search for a subset + * of those communities that match a specific criteria. + * + * @method getMyCommunities + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of my communities. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getMyCommunities : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomCommunitiesMy, options, CommunityFeedCallbacks); + }, - /** - * Get Files awaiting approval - * @param {Object} [args] the additional arguments - * @returns {Object} Files - */ - getFilesAwaitingApproval : function(args) { + /** + * Retrieve the members feed to view a list of the members who belong + * to a given community. + * + * @method getMembers + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of members of a + * community. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getMembers : function(communityUuid,args) { + var promise = this._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ + communityUuid : communityUuid + }, args || {}); + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + var callbacks = lang.mixin({ + createEntity : function(service,data,response) { + return new Member({ + service : service, + communityUuid : communityUuid, + data : data, + response: response + }); + } + }, MemberFeedCallbacks); + + return this.getEntities(consts.AtomCommunityMembers, options, callbacks); + }, - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + /** + * Retrieve the member entry to view a member who belongs to a given community. + * + * @method getMember + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of members of a + * community. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getMember : function(communityUuid,memberId,args) { + var member = new Member({ + service : this, + communityUuid : communityUuid + }); + + if (this.isEmail(memberId)) { + member.setEmail(memberId); + } else { + member.setUserid(memberId); + } + + return member.load(args); + }, + + /** + * Given the eventUuid, get the instances of that event. + * + * @param eventUuid The uuid of the Event + * @return {Object} Promise which resolves with the array of event Instances. + */ + getEventInsts : function(eventUuid){ + var promise = this._validateEventUuid(eventUuid); + if (promise) { + return promise; + } + + var options = { + method : "GET", + handleAs : "text", + query : { + eventUuid : eventUuid, + mode : "list" + } + }; + + return this.getEntities(consts.AtomCommunityEvents, options, ConnectionsEventInstFeedCallbacks); + }, + + /* + * here since getCommunityEvents and getCommunityEventInsts use the same logic. + */ + _getCommunityEvents : function(communityUuid, startDate, endDate, args, callbacks){ + var promise = this._validateCommunityUuid(communityUuid) || this._validateDateTimes(startDate, endDate); + if (promise) { + return promise; + } + var requiredArgs = { + calendarUuid : communityUuid + }; + if(startDate){ + lang.mixin(requiredArgs, { + startDate : startDate + }); + } + if(endDate){ + lang.mixin(requiredArgs, { + endDate : endDate + }); + } + + args = lang.mixin(args, requiredArgs); + + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomCommunityEvents, options, callbacks); + }, + + /** + * Get the Event instances for a community. See {{#crossLink "CommunityConstants/AtomCommunityEvents:attribute"}}{{/crossLink}} for a complete listing of parameters. + * + * These results do not include all details of the event instance, such as the full description. A summary is available in that case. UseEventInst.getFullEvent to get the full details. + * + * @param communityId The uuid of the Community. + * @param startDate Include events that end after this date. + * @param endDate Include events that end before this date. + * @param args url parameters. + * + * @return {Object} Promise which resolves with the array of event instances. + */ + getCommunityEventInsts : function(communityUuid, startDate, endDate, args){ + return this._getCommunityEvents(communityUuid, startDate, endDate, args, ConnectionsEventInstFeedCallbacks); + }, + + /** + * Get the events of a community. Each event can have multiple event instances. + * + * @method getCommunityEvents + * @return {Object} Promise which resolves with the array of event instances. + */ + getCommunityEvents : function(communityUuid, startDate, endDate, args){ + return this._getCommunityEvents(communityUuid, startDate, endDate, lang.mixin(args, {type: "event"}), ConnectionsEventFeedCallbacks); + }, + + /** + * Used to get the event Inst with the given eventInstUuid. + * + * This will include all details of the event, including its content. + * + * @param eventInstUuid - The id of the event, also used as an identifier when caching the response + * @returns + */ + getEventInst : function(eventInstUuid){ + var options = { + method : "GET", + handleAs : "text", + query : { + eventInstUuid: eventInstUuid + } + }; + + return this.getEntity(consts.AtomCommunityEvents, options, eventInstUuid, ConnectionsEventInstCallbacks); + }, + + /** + * Get a list of the outstanding community invitations of the currently authenticated + * user or provide parameters to search for a subset of those invitations. + * + * @method getMyInvites + * @param {Object} [args] + */ + getMyInvites : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomCommunityInvitesMy, options, InviteFeedCallbacks); + }, - return this.getEntities(consts.AtomGetFilesAwaitingApproval, options, this.getFileFeedCallbacks()); - }, + /** + * Get a list of the outstanding community invitations for the specified community. + * The currently authenticated user must be an owner of the community. + * + * @method getAllInvites + * @param communityUuid + * @param {Object} [args] + */ + getAllInvites : function(communityUuid, args) { + var promise = this._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } - /** - * Get File Shares - * @param {Object} [args] the additional arguments - * @returns {Object} Files - */ - getFileShares : function(args) { + var requestArgs = lang.mixin({ + communityUuid : communityUuid + }, args || {}); + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + return this.getEntities(consts.AtomCommunityInvites, options, InviteFeedCallbacks); + }, - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + /** + * Get a list of subcommunities associated with a community. + * + * @method getSubCommunities + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of members of a + * community. The parameters must be exactly as they are + * supported by IBM Connections like ps, sortBy etc. + */ + getSubCommunities : function(communityUuid,args) { + var promise = this._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ + communityUuid : communityUuid + }, args || {}); + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + return this.getEntities(consts.AtomCommunitySubCommunities, options, CommunityFeedCallbacks); + }, - return this.getEntities(consts.AtomGetFileShares, options, this.getFileFeedCallbacks()); - }, + /** + * Get a list for forum topics for the specified community. + * + * @method getForumTopics + * @param communityUuid + * @param args + * @returns + */ + getForumTopics: function(communityUuid, args) { + return this.getForumService().getCommunityForumTopics(communityUuid, args); + }, + + /** + * Create a Community object with the specified data. + * + * @method newCommunity + * @param {Object} args Object containing the fields for the + * new Community + */ + newCommunity : function(args) { + return this._toCommunity(args); + }, + + /** + * Create a Member object with the specified data. + * + * @method newMember + * @param {Object} args Object containing the fields for the + * new Member + */ + newMember : function(args) { + return this._toMember(args); + }, + + /** + * Create a Invite object with the specified data. + * + * @method newInvite + * @param {String} communityUuid + * @param {Object} args Object containing the fields for the + * new Invite + */ + newInvite : function(communityUuid,args) { + return this._toInvite(communityUuid,args); + }, + + /** + * Retrieve a community entry, use the edit link for the community entry + * which can be found in the my communities feed. + * + * @method getCommunity + * @param {String } communityUuid + * @param {Object} args Object containing the query arguments to be + * sent (defined in IBM Connections Communities REST API) + */ + getCommunity : function(communityUuid, args) { + var community = new Community({ + service : this, + _fields : { communityUuid : communityUuid } + }); + return community.load(args); + }, - /** - * Get Files in a folder - * @param {String} folderId the ID of the folder - * @param {Object} [args] the additional arguments - * @returns {Object} Files - */ - getFilesInFolder : function(folderId, args) { + /** + * Create a community by sending an Atom entry document containing the + * new community to the My Communities resource. + * + * @method createCommunity + * @param {Object} community Community object which denotes the community to be created. + * @param {Object} [args] Argument object + */ + createCommunity : function(communityOrJson,args) { + var community = this._toCommunity(communityOrJson); + var promise = this._validateCommunity(community, false, args); + if (promise) { + return promise; + } - var url = this.constructUrl(consts.AtomGetFilesInFolder, null, { - collectionId : folderId - }); + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + var communityUuid = this.getLocationParameter(response, "communityUuid"); + community.setCommunityUuid(communityUuid); + return community; + }; - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + var options = { + method : "POST", + query : args || {}, + headers : consts.AtomXmlHeaders, + data : community.createPostData() + }; + + return this.updateEntity(consts.AtomCommunitiesMy, options, callbacks, args); + }, - return this.getEntities(url, options, this.getFileFeedCallbacks()); + /** + * Update a community by sending a replacement community entry document in Atom format + * to the existing community's edit web address. + * All existing community entry information will be replaced with the new data. To avoid + * deleting all existing data, retrieve any data you want to retain first, and send it back + * with this request. For example, if you want to add a new tag to a community entry, retrieve + * the existing tags, and send them all back with the new tag in the update request. + * + * @method updateCommunity + * @param {Object} community Community object + * @param {Object} [args] Argument object + */ + updateCommunity : function(communityOrJson,args) { + var community = this._toCommunity(communityOrJson); + var promise = this._validateCommunity(community, true, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service, data, response) { + // preserve the communityUuid + var communityUuid = community.getCommunityUuid(); + if (data) { + community.setData(data, response); + } + community.setCommunityUuid(communityUuid); + return community; + }; - }, + var requestArgs = lang.mixin({ + communityUuid : community.getCommunityUuid() + }, args || {}); + + var options = { + method : "PUT", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : community.createPostData() + }; + + return this.updateEntity(consts.AtomCommunityInstance, options, callbacks, args); + }, - /** - * Get Files in my recycle bin - * @param {Object} [args] the addtional arguments - * @returns - */ - getFilesInMyRecycleBin : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + /** + * Delete a community, use the HTTP DELETE method. + * Only the owner of a community can delete it. Deleted communities cannot be restored + * + * @method deleteCommunity + * @param {String/Object} community id of the community or the community object (of the community to be deleted) + * @param {Object} [args] Argument object + */ + deleteCommunity : function(communityUuid,args) { + var promise = this._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ + communityUuid : communityUuid + }, args || {}); + + var options = { + method : "DELETE", + query : requestArgs, + handleAs : "text" + }; + + return this.deleteEntity(consts.AtomCommunityInstance, options, communityUuid); + }, - return this.getEntities(consts.AtomGetFilesInMyRecycleBin, options, this.getFileFeedCallbacks()); - }, + /** + * Add member to a community + * + * @method addMember + * @param {String/Object} community id of the community or the community object. + * @param {Object} member member object representing the member of the community to be added + * @param {Object} [args] Argument object + */ + addMember : function(communityUuid,memberOrId,args) { + var promise = this._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } + var member = this._toMember(memberOrId); + promise = this._validateMember(member); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + var userid = this.getLocationParameter(response, "userid"); + member.setUserid(userid); + member.communityUuid = communityUuid; + return member; + }; + var requestArgs = lang.mixin({ + communityUuid : communityUuid + }, args || {}); + var options = { + method : "POST", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : member.createPostData() + }; + + return this.updateEntity(consts.AtomCommunityMembers, options, callbacks, args); + }, + /** - * Get a file with given version - * @param {String} fileId the ID of the file - * @param {String} versionId the ID of the version - * @param {Object} [args] the additional arguments - * @returns {Object} File + * Updates a member in the access control list for an application, sends a replacement member entry document in Atom format to the existing ACL + * node's edit web address. + * @method updateMember + * @param {String} activityUuid + * @param {Object} memberOrJson */ - getFileWithGivenVersion : function(fileId, versionId, args) { - - var promise = this.validateField("fileId", fileId); + updateMember : function(communityUuid, memberOrJson, args) { + var promise = this.validateField("communityUuid", communityUuid); if (promise) { return promise; } - if (!versionId) { - return this.getFile(fileId, args); - } - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = this.constructUrl(consts.AtomGetFileWithGivenVersion, null, { - documentId : fileId, - versionId : versionId - }); - - var callbacks = { - createEntity : function(service, data, response) { - self.dataHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.FileXPath - }); - return self; - } - }; - - return this.getEntity(url, options, callbacks); - }, - - /** - * Get a folder - * @param {String} folderId the ID of the folder - * @returns - */ - getFolder : function(folderId) { - var promise = this.validateField("folderId", folderId); + var member = this._toMember(memberOrJson); + promise = this._validateMember(member, true, true); if (promise) { return promise; } + + var requestArgs = { + communityUuid : communityUuid + }; + var key = member.getEmail() ? "email" : "userid"; + var value = member.getEmail() ? member.getEmail() : member.getUserid(); + requestArgs[key] = value; + requestArgs = lang.mixin(requestArgs, args || {}); + var options = { - method : "GET", - handleAs : "text" + method : "PUT", + headers : consts.AtomXmlHeaders, + query : requestArgs, + data : member.createPostData() }; - var url = this.constructUrl(consts.AtomGetFolder, null, { - collectionId : folderId - }); var callbacks = { createEntity : function(service, data, response) { - self.dataHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.FileXPath - }); - return self; + return response; } }; - return this.getEntity(url, options, callbacks); - }, - - /** - * Get Folders With Recently Added Files - * @param {Object} [args] the additional arguents - * @returns {Object} List of Files - */ - getFoldersWithRecentlyAddedFiles : function(args) { - - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomGetFoldersWithRecentlyAddedFiles, options, this.getFileFeedCallbacks()); + return this.updateEntity(consts.AtomCommunityMembers, options, callbacks); }, - /** - * Gets the folders pinned by the logged in user. - * - * @method getPinnedFolders - * @param {Object} [args] Argument object for the additional parameters like pageSize etc. - */ - getPinnedFolders : function(args) { + /** + * Remove member of a community + * + * @method + * @param {String/Object} community id of the community or the community object. + * @param {String} memberId id of the member + * @param {Object} [args] Argument object + */ + removeMember : function(communityUuid,memberId,args) { + var promise = this._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } + var member = this._toMember(memberId); + promise = this._validateMember(member); + if (promise) { + return promise; + } - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + var requestArgs = { + communityUuid : communityUuid + }; + var key = member.getEmail() ? "email" : "userid"; + var value = member.getEmail() ? member.getEmail() : member.getUserid(); + requestArgs[key] = value; + requestArgs = lang.mixin(requestArgs, args || {}); + var options = { + method : "DELETE", + query : requestArgs, + handleAs : "text" + }; + + return this.deleteEntity(consts.AtomCommunityMembers, options, value); + }, + + /** + * Retrieve a community invite. + * + * @method getInvite + * @param {String} communityUuid + * @param (String} userid + */ + getInvite : function(communityUuid, userid) { + var invite = new Invite({ + service : this, + _fields : { communityUuid : communityUuid, userid : userid } + }); + return invite.load(); + }, - return this.getEntities(consts.AtomGetPinnedFolders, options, this.getFileFeedCallbacks()); - }, + /** + * Create an invite to be a member of a community. + * + * @method createInvite + * @param {Object} inviteOrJson + * @param {Object} [args] Argument object + */ + createInvite: function(inviteOrJson, args) { + var invite = this._toInvite(inviteOrJson); + var promise = this._validateInvite(invite, true); + if (promise) { + return promise; + } - /** - * Get public folders - * - * @param {Object} [args] Additional arguments like ps, sort by, etc - */ - getPublicFolders : function(args) { + var callbacks = {}; + callbacks.createEntity = function(service, data, response) { + invite.setData(data, response); + return invite; + }; - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + var requestArgs = lang.mixin({ + communityUuid : invite.getCommunityUuid() + }, args || {}); + + var options = { + method : "POST", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : invite.createPostData() + }; + + return this.updateEntity(consts.AtomCommunityInvites, options, callbacks, args); + }, + + /** + * Decline or revoke an invite to be a member of a community + * + * @method removeInvite + * @param {Object} inviteOrJson + * @param {Object} [args] Argument object + */ + removeInvite: function(inviteOrJson, args) { + var invite = this._toInvite(inviteOrJson); + var promise = this._validateInvite(invite, true); + if (promise) { + return promise; + } - return this.getEntities(consts.AtomGetPublicFolders, options, this.getFileFeedCallbacks()); - }, + var requestArgs = lang.mixin({ + communityUuid : invite.getCommunityUuid(), + userid : invite.getInviteeUuid() + }, args || {}); + + var options = { + method : "DELETE", + query : requestArgs, + handleAs : "text" + }; + var entityId = invite.getCommunityUuid() + "-" + invite.getInviteeUuid(); + return this.deleteEntity(consts.AtomCommunityInvites, options, entityId); + }, + + /** + * Accept an invite to be a member of a community. + * + * @method acceptInvite + * @param {Object} inviteOrJson. + * @param {Object} [args] Argument object + */ + acceptInvite: function(inviteOrJson, args) { + var invite = this._toInvite(inviteOrJson); + var promise = this._validateInvite(invite, true); + if (promise) { + return promise; + } - /** - * Pin a folder, by sending a POST request to the myfavorites feed. - * - * @method pinFolder - * @param {String} folderId ID of folder which needs to be pinned - * @param {Object} [args] Argument object. + var requestArgs = lang.mixin({ + communityUuid : invite.getCommunityUuid() + }, args || {}); + + var options = { + method : "POST", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : invite.createPostData() + }; + + // return the community id for the community whose invite is accepted in the argument of the success promise. + var callbacks = {}; + callbacks.createEntity = function(service, data, response) { + invite.setData(data, response); + return invite; + }; + + return this.updateEntity(consts.AtomCommunityMembers, options, callbacks, args); + }, + + /** + * Create a forum topc by sending an Atom entry document containing the + * new forum to the forum replies resource. + * + * @method createForumTopic + * @param {String} communityUuid This argument is deprecated and has no effect if provided. + * @param {Object} forumTopic Forum topic object which denotes the forum topic to be created. + * @param {Object} [args] Argument object + */ + createForumTopic : function(communityUuid, topicOrJson, args) { + if(!lang.isString(communityUuid)){ + args = topicOrJson; + topicOrJson = communityUuid; + } + return this.getForumService().createForumTopic(topicOrJson, args); + }, + + /** + * Updates the Logo picture of a community + * @method updateCommunityLogo + * @param {Object} fileControlOrId The Id of html control or the html control + * @param {String} communityUuid the Uuid of community */ - pinFolder : function(folderId, args) { - - var promise = this.validateField("folderId", folderId); + updateCommunityLogo : function(fileControlOrId, communityUuid) { + var promise = this.validateField("File Control Or Id", fileControlOrId); if (promise) { return promise; } - var parameters = args ? lang.mixin({}, args) : {}; - parameters["itemId"] = folderId; - - var options = { - method : "POST", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - }, - query : parameters - }; - - var callbacks = { - createEntity : function(service, data, response) { - } - }; - - return this.updateEntity(consts.AtomPinFolder, options, callbacks); - - }, - - /** - * Remove a File from a Folder - * - * @param {String} folderId the ID of the folder - * @param {Stirng} fileId The ID of the File - */ - removeFileFromFolder : function(folderId, fileId) { - - var promise = this.validateField("folderId", folderId); + promise = this.validateHTML5FileSupport(); if (promise) { return promise; } - promise = this.validateField("fileId", fileId); + promise = this.validateField("CommunityUuid", communityUuid); if (promise) { return promise; } - var parameters = args ? lang.mixin({}, args) : {}; - parameters["itemId"] = fileId; - - var url = this.constructUrl(consts.AtomRemoveFileFromFolder, null, { - collectionId : folderId - }); - var options = { - method : "DELETE", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - }, - query : parameters - }; - - return this.deleteEntity(url, options, fileId); - - }, - - /** - * Restore a File from Recycle Bin (trash) - * - * @param {String} fileId the ID of the file - * @param {String} userId the ID of the user - */ - restoreFileFromRecycleBin : function(fileId, userId) { - var promise = this.validateField("fileId", fileId); - if (promise) { - return promise; - } - promise = this.validateField("userId", userId); - if (promise) { - return promise; + var files = null; + var fileControl = this.getFileControl(fileControlOrId); + if(!fileControl){ + return this.createBadRequestPromise("File Control or ID is required"); } - var parameters = args ? lang.mixin({}, args) : {}; - parameters["undelete"] = "true"; - - var options = { - method : "POST", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - }, - query : parameters - }; - - var callbacks = { - createEntity : function(service, data, response) { - self.dataHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.FileXPath - }); - return self; - } - }; - - var url = this.constructUrl(consts.AtomRestoreFileFromRecycleBin, null, { - userId : userId, - documentId : fileId - }); - - return this.updateEntity(url, options, callbacks); - }, - - /** - * Share a File with community(ies) - * - * @param {String} fileId the ID of the file - * @param {Object} communityIds The list of community IDs - * @param {Object} args the additional arguments - */ - shareFileWithCommunities : function(fileId, communityIds, args) { + var filePath = fileControl.value; + var files = fileControl.files; - var promise = this.validateField("fileId", fileId); - if (!promise) { - promise = this.validateField("communityIds", communityIds); - } - if (promise) { - return promise; + if (files.length != 1) { + return this.createBadRequestPromise("Only one file can be upload as a community logo."); } - var url = this.constructUrl(consts.AtomShareFileWithCommunities, null, { - documentId : fileId + var file = files[0]; + var formData = new FormData(); + formData.append("file", file); + var requestArgs = { + "communityUuid" : communityUuid + }; + var url = this.constructUrl(consts.AtomUpdateCommunityLogo, null, { + endpointName : this.endpoint.proxyPath, + fileName : encodeURIComponent(file.name) }); - - var payload = this._constructPayloadForMultipleEntries(communityIds, "itemId", "community"); - + if (this.endpoint.proxy) { + url = config.Properties.serviceUrl + url; + } else { + return this.createBadRequestPromise("File Proxy is required to upload a community logo"); + } + + var headers = { + "Content-Type" : false, + "Process-Data" : false //processData = false is reaquired by jquery + }; var options = { - method : "POST", - headers : consts.AtomXmlHeaders, - data : payload + method : "PUT", + headers : headers, + query : requestArgs, + data : formData }; - var callbacks = { createEntity : function(service, data, response) { - return response; + return data; // Since this API does not return any response in case of success, returning empty data } }; return this.updateEntity(url, options, callbacks); }, - /** - * Unpin a folder, by sending a DELETE request to the myfavorites feed. - * - * @method unpinFolder - * @param {String} folderId ID of folder which needs to be unpinned - * @param {Object} [args] Argument object. + /** + * Updates the Logo picture of a community + * @method updateCommunityLogo + * @param {Object} fileControlOrId The Id of html control or the html control + * @param {String} communityUuid the Uuid of community */ - unpinFolder : function(folderId, args) { - var promise = this.validateField("folderId", folderId); + uploadCommunityFile : function(fileControlOrId, communityUuid) { + var promise = this.validateField("File Control Or Id", fileControlOrId); if (promise) { return promise; } - - var parameters = args ? lang.mixin({}, args) : {}; - parameters["itemId"] = folderId; - - var options = { - method : "DELETE", - headers : { - "X-Update-Nonce" : "{X-Update-Nonce}" - }, - query : parameters - }; - - return this.deleteEntity(consts.AtomPinFolder, options, folderId); - - }, - - /** - * Update comment created by logged in user - * @param {String} fileId the ID of the file - * @param {String}commentId the ID of the comment - * @param {String} comment the updated comment - * @param {Object} args the additional arguments - * @returns - */ - updateMyComment : function(fileId, commentId, comment, args) { - - return updateComment(fileId, commentId, comment, null, args); - }, - - /** - * updates a comment - * @param {String} fileId the ID of the file - * @param {String} commentId the ID of the comment - * @param {String} comment the comment - * @param {String} [userId] the ID of the user - * @param {Object} [args] the additional arguments - * @returns {Object} the updated Comment - */ - updateComment : function(fileId, commentId, comment, userId, args) { - - var promise = this.validateField("fileId", fileId); - if (!promise) { - promise = this.validateField("comment", comment); - } + promise = this.validateHTML5FileSupport(); if (promise) { return promise; } - if (!promise) { - promise = this.validateField("commentId", commentId); - } + promise = this.validateField("CommunityUuid", communityUuid); if (promise) { return promise; } - var options = { - method : "POST", - query : args || {}, - headers : consts.AtomXmlHeaders, - data : this._constructPayloadForComment(false, comment) - }; - var url = null; - - if (!userId) { - url = this.constructUrl(consts.AtomUpdateMyComment, null, { - documentId : fileId, - commentId : commentId - }); - } else { - url = this.constructUrl(consts.AtomUpdateComment, null, { - userId : userId, - documentId : fileId, - commentId : commentId - }); - } - return this.updateEntity(url, options, this.getCommentFeedCallbacks()); - }, - - /** - * Add a file to a folder. - * - * You cannot add a file from your local directory to a folder; the file must already have been uploaded to the Files application. To add a file - * to a folder you must be an editor of the folder. - * - * @method addFileToFolder - * @param {String} fileId the Id of the file - * @param {String} folderId the ID of the folder - * @param {String} [userId] the userId of the user in case of own file - * @param {Object} [args] Argument object. - */ - addFileToFolder : function(fileId, folderId, userId, args) { - - return this.addFileToFolders(fileId, [ folderId ], userId, args); - }, - - /* - * Callbacks used when reading a feed that contains File entries. - */ - getFileFeedCallbacks : function() { - return FileFeedCallbacks; - }, - - /* - * Callbacks used when reading a feed that contains File Comment entries. - */ - getCommentFeedCallbacks : function() { - return CommentCallbacks; - }, - - _constructPayloadFolder : function(name, description, shareWith, operation, entityId) { - var _this = this; - var shareWithId = null; - var shareWithWhat = null; - var shareWithRole = null; - if (shareWith && stringUtil.trim(shareWith) != "") { - var parts = shareWith.split(","); - if (parts.length == 3) { - shareWithId = parts[0]; - shareWithWhat = parts[1]; - shareWithRole = parts[2]; - } - } - var trans = function(value, key) { - if (key == "category") { - value = xml.encodeXmlEntry("collection"); - } else if (key == "id") { - value = xml.encodeXmlEntry(entityId); - } else if (key == "label") { - value = xml.encodeXmlEntry(name); - } else if (key == "title") { - value = xml.encodeXmlEntry(name); - } else if (key == "summary") { - value = xml.encodeXmlEntry(description); - } else if (key == "visibility") { - value = xml.encodeXmlEntry("private"); - } else if (key == "shareWithId" && shareWithId) { - value = xml.encodeXmlEntry(shareWithId); - } else if (key == "shareWithWhat" && shareWithWhat) { - value = xml.encodeXmlEntry(shareWithWhat); - } else if (key == "shareWithRole" && shareWithRole) { - value = xml.encodeXmlEntry(shareWithRole); - } - return value; - }; - var transformer = function(value, key) { - if (key == "getCategory") { - value = stringUtil.transform(FileCategoryTmpl, _this, trans, _this); - } else if (key == "getId" && entityId) { - value = stringUtil.transform(FileIdTmpl, _this, trans, _this); - } else if (key == "getFolderLabel") { - value = stringUtil.transform(FolderLabelTmpl, _this, trans, _this); - } else if (key == "getTitle") { - value = stringUtil.transform(FileTitleTmpl, _this, trans, _this); - } else if (key == "getSummary") { - value = stringUtil.transform(FileSummaryTmpl, _this, trans, _this); - } else if (key == "getVisibility") { - value = stringUtil.transform(FileVisibilityTmpl, _this, trans, _this); - } else if (key == "getVisibilityShare" && shareWithId) { - value = stringUtil.transform(FileVisibilityShareTmpl, _this, trans, _this); - } - return value; - }; - var postData = stringUtil.transform(FolderTmpl, this, transformer, this); - return stringUtil.trim(postData); - }, - - _constructPayloadForMultipleEntries : function(listOfIds, multipleEntryId, category) { - var payload = FileFeedTmpl; - var entriesXml = ""; - var categoryXml = ""; - var itemXml = ""; - var currentId = ""; - var transformer = function(value, key) { - if (key == "category") { - value = xml.encodeXmlEntry(category); - } else if (key == "getCategory") { - value = categoryXml; - } else if (key == "fileId") { - value = xml.encodeXmlEntry(currentId); - } else if (key == "getItem") { - value = itemXml; - } else if (key == "getEntries") { - value = entriesXml; - } - return value; - }; - var _this = this; - - for ( var counter in listOfIds) { - currentId = listOfIds[counter]; - var entryXml = FileItemEntryTmpl; - if (category) { - categoryXml = stringUtil.transform(FileCategoryTmpl, _this, transformer, _this); - } - itemXml = stringUtil.transform(FileItemIdTmpl, _this, transformer, _this); - entryXml = stringUtil.transform(entryXml, _this, transformer, _this); - entriesXml = entriesXml + entryXml; - } - - if (entriesXml != "") { - payload = stringUtil.transform(payload, _this, transformer, _this); - } - return payload; - }, - - _constructPayloadForComment : function(isDelete, comment) { - - var payload = FileCommentsTmpl; - var categoryXml = ""; - var contentXml = ""; - var deleteXml = ""; - var _this = this; - - var transformer = function(value, key) { - if (key == "category") { - value = xml.encodeXmlEntry("comment"); - } else if (key == "content") { - value = xml.encodeXmlEntry(comment); - } else if (key == "deleteWithRecord") { - value = "true"; - } else if (key == "getCategory" && categoryXml != "") { - value = categoryXml; - } else if (key == "getContent" && contentXml != "") { - value = contentXml; - } else if (key == "getDeleteComment" && deleteXml != "") { - value = deleteXml; - } - return value; - }; - - categoryXml = stringUtil.transform(FileCategoryTmpl, _this, transformer, _this); - - contentXml = stringUtil.transform(FileContentTmpl, _this, transformer, _this); - if (isDelete) { - deleteXml = stringUtil.transform(FileDeleteCommentTmpl, _this, transformer, _this); - } - - payload = stringUtil.transform(payload, this, transformer, this); - return payload; - }, - - _constructPayload : function(payloadMap, documentId) { - - var payload = FileEntryTmpl; - var categoryXml = ""; - var idXml = ""; - var uuidXml = ""; - var labelXml = ""; - var titleXml = ""; - var summaryXml = ""; - var visibilityXml = ""; - var itemXml = ""; - var tagsXml = ""; - var notificationXml = ""; - var currentValue = null; - var transformer = function(value, key) { - if (currentValue) { - value = xml.encodeXmlEntry(currentValue); - } else if (key == "getCategory" && categoryXml != "") { - value = categoryXml; - } else if (key == "getId" && idXml != "") { - value = idXml; - } else if (key == "getUuid" && uuidXml != "") { - value = uuidXml; - } else if (key == "getLabel" && labelXml != "") { - value = labelXml; - } else if (key == "getTitle" && titleXml != "") { - value = titleXml; - } else if (key == "getSummary" && summaryXml != "") { - value = summaryXml; - } else if (key == "getVisibility" && visibilityXml != "") { - value = visibilityXml; - } else if (key == "getItem" && itemXml != "") { - value = itemXml; - } else if (key == "getTags" && tagsXml != "") { - value = tagsXml; - } else if (key == "getNotification" && notificationXml != "") { - value = notificationXml; - } - return value; - }; - for ( var currentElement in payloadMap) { - currentValue = payloadMap[currentElement]; - if (currentElement.indexOf("category") != -1) { - categoryXml = stringUtil.transform(FileCategoryTmpl, this, transformer, this); - } else if (currentElement.indexOf("id") != -1) { - idXml = stringUtil.transform(FileIdTmpl, this, transformer, this); - } else if (currentElement.indexOf("uuid") != -1) { - uuidXml = stringUtil.transform(FileUuidTmpl, this, transformer, this); - } else if (currentElement.indexOf("label") != -1) { - labelXml = stringUtil.transform(FileLabelTmpl, this, transformer, this); - titleXml = stringUtil.transform(FileTitleTmpl, this, transformer, this); - } else if (currentElement.indexOf("summary") != -1) { - summaryXml = stringUtil.transform(FileSummaryTmpl, this, transformer, this); - } else if (currentElement.indexOf("visibility") != -1) { - visibilityXml = stringUtil.transform(FileVisibilityTmpl, this, transformer, this); - } else if (currentElement.indexOf("itemId") != -1) { - itemXml = stringUtil.transform(FileItemIdTmpl, this, transformer, this); - } else if (currentElement.indexOf("tags") != -1) { - var tags = currentValue; - for ( var tag in tags) { - tagsXml += stringUtil.transform(TagsTmpl, { - "tag" : tags[tag] - }); - } - } else if (currentElement.contains("notification")) { - notificationXml = stringUtil.transform(NotificationTmpl, this, transformer, this); - } + var files = null; + var fileControl = this.getFileControl(fileControlOrId); + if(!fileControl){ + return this.createBadRequestPromise("File Control or ID is required"); } - currentValue = null; - - payload = stringUtil.transform(payload, this, transformer, this); - return payload; - } - }); - return FileService; -}); + var filePath = fileControl.value; + var files = fileControl.files; -}, -'url:sbt/connections/controls/forums/templates/TopicRow.html':"\r\n\t\r\n\t\t

    \r\n \r\n\t\r\n\t\t

    \r\n\t\t\t${title}\r\n\t\t

    \r\n\t\r\n\t\r\n\t\t\r\n\t${threadCount}\r\n\t\r\n\t${getDateLabel}\r\n", -'sbt/_bridge/text':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ + if (files.length != 1) { + return this.createBadRequestPromise("Only one file can be uploaded to a community at a time"); + } -/** - * Social Business Toolkit SDK. - */ -define([ "dojo/text" ], function(text) { - var load = function(id,require,load) { - text.load(id, require, load); - }; - return { - load : load - }; -}); + var file = files[0]; + var formData = new FormData(); + formData.append("file", file); + var requestArgs = { + }; + var url = this.constructUrl(consts.AtomUploadCommunityFile, null, { + endpointName : this.endpoint.proxyPath, + communityUuid : communityUuid + }); + if (this.endpoint.proxy) { + url = config.Properties.serviceUrl + url; + } else { + return this.createBadRequestPromise("File proxy is required to upload a community file"); + } + + var headers = { + "Content-Type" : false, + "Process-Data" : false, //processData = false is reaquired by jquery + "X-Endpoint-name" : this.endpoint.name + }; + var options = { + method : "POST", + headers : headers, + query : requestArgs, + data : formData + }; -}, -'sbt/connections/controls/communities/CommunityGrid':function(){ -/* - * © 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. - */ + var callbacks = { + createEntity : function(service, data, response) { + return data; + } + }; -/** - * @module sbt.connections.controls.communities.CommunityGrid - */ -define([ "../../../declare", - "../../../controls/grid/Grid", - "./CommunityGridRenderer", - "./CommunityAction", - "../../../connections/controls/vcard/SemanticTagService", - "../../../config", - "../../../connections/CommunityConstants", - "../../../store/parameter"], - function(declare, Grid, CommunityGridRenderer, CommunityAction, SemanticTagService, sbt, consts, parameter) { - - var sortVals = { - date: "modified", - popularity: "count", - name: "title" - }; - - var ParamSchema = { - pageNumber: parameter.oneBasedInteger("page"), - pageSize: parameter.oneBasedInteger("ps"), - sortBy: parameter.sortField("sortField",sortVals), - sortOrder: parameter.booleanSortOrder("asc") - }; - - /** - * @class CommunityGrid - * @namespace sbt.connections.controls.communities - */ - var CommunityGrid = declare(Grid, { + return this.updateEntity(url, options, callbacks); + }, + + /** + * Create a bookmark by sending an Atom entry document containing the + * new bookmark. + * + * @method createBookmark + * @param {String/Object} bookmarkOrJson Bookmark object which denotes the bookmark to be created. + * @param {Object} [args] Argument object + */ + createBookmark : function(communityUuid, bookmarkOrJson, args) { + args = lang.mixin({ + url : consts.AtomCommunityBookmarks, + communityUuid : communityUuid + }, args || {}); + return this.getBookmarkService().createBookmark(bookmarkOrJson, args); + }, - contextRootMap: { - communities: "communities" + // + // Internals + // + + /* + * Return a Community instance from Community or JSON or String. Throws + * an error if the argument was neither. + */ + _toCommunity : function(communityOrJsonOrString) { + if (communityOrJsonOrString instanceof Community) { + return communityOrJsonOrString; + } else { + if (lang.isString(communityOrJsonOrString)) { + communityOrJsonOrString = { + communityUuid : communityOrJsonOrString + }; + } + return new Community({ + service : this, + _fields : lang.mixin({}, communityOrJsonOrString) + }); + } }, - - /** - * Options are for which type of community grid is to be created - * public will show public communities and my will show communities - * the specified user is a member or owner of. - */ - options : { - "public" : { - storeArgs : { - url : consts.AtomCommunitiesAll, - attributes : consts.CommunityXPath, - feedXPath : consts.CommunityFeedXPath, - paramSchema : ParamSchema - }, - rendererArgs : null - }, - "my" : { - storeArgs : { - url : consts.AtomCommunitiesMy, - attributes : consts.CommunityXPath, - feedXPath : consts.CommunityFeedXPath, - paramSchema : ParamSchema - }, - rendererArgs : null - }, - "invited" : { - storeArgs : { - url : consts.AtomCommunityInvitesMy, - attributes : consts.CommunityXPath, - feedXPath : consts.CommunityFeedXPath, - paramSchema : ParamSchema - }, - rendererArgs : null + + /* + * Return as Invite instance from Invite or JSON or String. Throws + * an error if the argument was neither. + */ + _toInvite : function(inviteOrJsonOrString, args){ + if (inviteOrJsonOrString instanceof Invite) { + return inviteOrJsonOrString; + } else { + if (lang.isString(inviteOrJsonOrString)) { + inviteOrJsonOrString = { + communityUuid : inviteOrJsonOrString + }; + } + return new Invite({ + service : this, + _fields : lang.mixin({}, inviteOrJsonOrString) + }); } }, - - /** - * set the grids action to be an instance of CommunityAction - * This means an event will be provided for when the user moves the mouse over the - * community name or clicks on a community. + + /* + * Return a Community UUID from Community or communityUuid. Throws an + * error if the argument was neither or is invalid. */ - communityAction: new CommunityAction(), + _toCommunityUuid : function(communityOrUuid) { + var communityUuid = null; + if (communityOrUuid) { + if (lang.isString(communityOrUuid)) { + communityUuid = communityOrUuid; + } else if (communityOrUuid instanceof Community) { + communityUuid = communityOrUuid.getCommunityUuid(); + } + } + + return communityUuid; + }, - /** - * Default grid option is to display a list of public communities. - */ - defaultOption: "public", - - /** - * Constructor function - * @method constructor + /* + * Return a Community Member from Member or memberId. Throws an error if + * the argument was neither or is invalid. */ - constructor: function(args) { - var nls = this.renderer.nls; - - /** - * Set the sorting information - */ - this._sortInfo = { - date: { - title: nls.date, - sortMethod: "sortByDate", - sortParameter: "date" - }, - popularity: { - title: nls.popularity, - sortMethod: "sortByPopularity", - sortParameter: "popularity" - }, - name: { - title: nls.name, - sortMethod: "sortByName", - sortParameter: "name" + _toMember : function(idOrJson) { + if (idOrJson) { + if (idOrJson instanceof Member) { + return idOrJson; } - }; - this._activeSortAnchor = this._sortInfo.date; - this._activeSortIsDesc = true; + var member = new Member({ + service : this + }); + if (lang.isString(idOrJson)) { + if (this.isEmail(idOrJson)) { + member.setEmail(idOrJson); + } else { + member.setUserid(idOrJson); + } + } else { + if(idOrJson.id && !idOrJson.userid && !idOrJson.email){ + this.isEmail(idOrJson.id) ? idOrJson.email = idOrJson.id : idOrJson.userid = idOrJson.id; + delete idOrJson.id; + } + member._fields = lang.mixin({}, idOrJson); + } + return member; + } }, - - /** - * Create the CommunityGrid Renderer - * @method createDefaultRenderer - * @param args Arguments that can be passed to the renderer - * @returns {CommunityGridRenderer} + + /* + * Validate a community UUID, and return a Promise if invalid. */ - createDefaultRenderer : function(args) { - return new CommunityGridRenderer(args,this); + _validateCommunityUuid : function(communityUuid) { + if (!communityUuid || communityUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected communityUuid."); + } }, - /** - * Function is called after the grid is created, - * Here we call the superclass postCreate and then load the - * Semantic tag service, which will handle business card functionality - * @method postCreate + /* + * Validate a userid, and return a Promise if invalid. */ - postCreate: function() { - this.inherited(arguments); - if(this.displayBusinessCard){ - SemanticTagService.loadSemanticTagService(); - } + _validateUserid : function(userid) { + if (!userid || userid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected userid."); + } }, - /** - * Event handler for onClick Events - * Stops the default onClick event and calls the CommunityAction execute function - * @method handleClick - * @param el The element that fired the event - * @param data the data associated with the row - * @param ev the event + /* + * Validate that the date-time is not empty, return a promise if invalid */ - handleClick: function(el, data, ev) { - if (this.communityAction) { - this._stopEvent(ev); - - this.communityAction.execute(data, { grid : this.grid }, ev); + _validateDateTimes : function(startDate, endDate){ + if ((!startDate || startDate.length === 0) && (!endDate || endDate.length === 0)) { + return this.createBadRequestPromise("Invalid date arguments, expected either a startDate, endDate or both as parameters."); } }, - - /** - * Filter the community by specified tag - * @param el - * @param data - * @param ev + + /* + * Validate contributor id */ - filterByTag: function(el, data, ev){ - this._stopEvent(ev); - - var options = { - tag: el.text - }; + _validateContributorId : function(contributorId) { + if (!contributorId || contributorId.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected contributorId."); + } + }, - this._filter(options,data); + /* + * Validate a community, and return a Promise if invalid. + */ + _validateCommunity : function(community,checkUuid) { + if (!community || !community.getTitle()) { + return this.createBadRequestPromise("Invalid argument, community with title must be specified."); + } + if (checkUuid && !community.getCommunityUuid()) { + return this.createBadRequestPromise("Invalid argument, community with UUID must be specified."); + } }, - - /** - * Gets sorting information, such as - * if the results are ascending or descending, and the sort anchors - * @method getSortInfo - * @returns An object containing sorting information + + /* + * Validate an invite, and return a Promise if invalid. */ - getSortInfo: function() { - return { - active: { - anchor: this._activeSortAnchor, - isDesc: this._activeSortIsDesc - }, - list: [this._sortInfo.date, this._sortInfo.popularity, this._sortInfo.name] - }; + _validateInvite : function(invite, checkCommunityUuid) { + if (!invite || (!invite.getEmail() && !invite.getUserid() && !invite.getInviteeUuid())) { + return this.createBadRequestPromise("Invalid argument, invite with email or userid or invitee must be specified."); + } + if (checkCommunityUuid && !invite.getCommunityUuid()) { + return this.createBadRequestPromise("Invalid argument, invite with community UUID must be specified."); + } }, - - /** - * Sort the grid rows by last modified date - * @method sortByLastModified - * @param el The element that was clicked, typically a "sort by" button - * @param data the data associated with the element - * @param ev the event + + /* + * Validate a member, and return a Promise if invalid. */ - sortByDate: function(el, data, ev) { - this._sort("date", true, el, data, ev); + _validateMember : function(member) { + if (!member || (!member.getUserid() && !member.getEmail())) { + return this.createBadRequestPromise("Invalid argument, member with userid or email must be specified."); + } }, - /** - * Sort the grid rows by popularity - * @method sortByPopularity - * @param el The element that was clicked, typically a "sort by" button - * @param data the data associated with the element - * @param ev the event + /* + * Validate an event inst uuid, and return a Promise if invalid. */ - sortByPopularity: function(el, data, ev) { - this._sort("popularity", true, el, data, ev); + _validateEventInstUuid : function(eventInstUuid) { + if (!eventInstUuid || eventInstUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected event inst uuid."); + } }, - /** - * Sort the grid rows by title - * @method sortByTitle - * @param el The element that was clicked, typically a "sort by" button - * @param data the data associated with the element - * @param ev the event + /* + * Validate an event UUID, and return a Promise if invalid. */ - sortByName: function(el, data, ev) { - this._sort("name", false, el, data, ev); + _validateEventUuid : function(eventUuid) { + if (!eventUuid || eventUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected eventUuid."); + } } - - }); - - return CommunityGrid; -}); - -}, -'sbt/connections/controls/search/nls/SearchBoxRenderer':function(){ -/* - * © 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. - */ -// NLS_CHARSET=UTF-8 -define({ - root: { - selectedApplication: "All Connections", - allConnections: "All Connections", - statusUpdates: "Status Updates", - activities: "Activities", - blogs: "Blogs", - bookmarks: "Bookmarks", - communities: "Communities", - files: "Files", - forums: "Forums", - profiles: "Profiles", - wikis: "Wikis", - refine: "Refine Search Results", - search: "Search", - allConnectionsIcon: "All Connections Icon", - icon: "Icon" - } + }); + return CommunityService; }); }, -'sbt/WPSProxy':function(){ +'url:sbt/connections/controls/communities/templates/TagAnchor.html':"${tagName}", +'url:sbt/connections/controls/templates/WidgetFrame.html':"", +'sbt/ErrorTransport':function(){ /* * © Copyright IBM Corp. 2012 * @@ -25244,55 +20516,59 @@ define({ */ /** - * Social Business Toolkit SDK to be used with WebSphere Portal server - * Definition of a proxy re-writer. - * - * @module sbt.Proxy + * Implementation of a transport that emits an error the first time it is invoked. + * @module sbt.ErrorTransport */ -define(['./declare','./lang','./pathUtil'],function(declare,lang,pathUtil) { - - /** - * Definition of the proxy module - * - * @class sbt.Proxy - * - */ - var Proxy = declare(null, { - - proxyUrl : null, - - constructor: function(args){ - lang.mixin(this, args); - }, - - rewriteUrl: function(baseUrl,serviceUrl,proxyPath) { - var u = serviceUrl; - if(this.proxyUrl) { - if(u.indexOf("http://")==0) { - u = "/http/"+u.substring(7); - } else if(u.indexOf("https://")==0) { - u = "/https/"+u.substring(8); - } - - if(baseUrl.indexOf("http://")==0) { - baseUrl = "/http/"+baseUrl.substring(7); - } else if(baseUrl.indexOf("https://")==0) { - baseUrl = "/https/"+baseUrl.substring(8); - } - var networkUrl = pathUtil.concat(this.proxyUrl, baseUrl); - networkUrl = pathUtil.concat(networkUrl, serviceUrl); - return networkUrl; - } - return u; - } +define(['./declare','./lang','./Promise','./stringUtil','./log','sbt/i18n!sbt/nls/ErrorTransport'], function(declare,lang,Promise,stringUtil,log,nls) { + return declare(null, { + _called: false, + _endpointName: null, + _message: null, + + constructor: function(endpointName, message) { + this._endpointName = endpointName; + if (message) { + this._message = message; + } else { + this._message = stringUtil.substitute(nls.endpoint_not_available, [endpointName]); + } + }, + + request : function(url,options) { + if (!this._called) { + alert(this._message); + this._called = true; + } + var promise = new Promise(); + var error = new Error(this._message); + error.status = 400; + promise.rejected(error); + return promise; + }, + + xhr: function(method, args, hasBody) { + if (!this._called) { + log.error(this._message); + this._called = true; + } + var _handle = args.handle; + var _error = args.error; + if (lang.isFunction(_error) || lang.isFunction(_handle)) { + var error = new Error(this._message); + error.status = 400; + if(lang.isFunction(_error)){ + _error(error); + } + if(lang.isFunction(_handle)){ + _handle(error); + } + } + } }); - - return Proxy; - }); }, -'url:sbt/connections/controls/search/templates/ProfileHeader.html':"
    \r\n

    \r\n \r\n \r\n ${formattedTitle}\r\n \r\n \r\n ${authorUid}\r\n \r\n \r\n

    \r\n
    ", -'sbt/connections/ActivityService':function(){ +'url:sbt/connections/controls/profiles/templates/BootstrapProfile.html':"\r\n\t\r\n\t\t\"${name}\"\r\n\t\r\n\t\r\n\t

    \r\n \t\t${name}\r\n \t

    \r\n\t\r\n\r\n", +'sbt/connections/controls/communities/CommunityMembersGrid':function(){ /* * © Copyright IBM Corp. 2013 * @@ -25310,2561 +20586,5089 @@ define(['./declare','./lang','./pathUtil'],function(declare,lang,pathUtil) { */ /** - * The Activities application of IBM© Connections enables a team to collect, organize, share, and reuse work related to a project goal. The Activities API - * allows application programs to create new activities, and to read and modify existing activities. - * - * @module sbt.connections.ActivityService + * @module sbt.connections.controls.profiles.ProfileGrid */ -define( - [ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./ActivityConstants", "./ConnectionsService", "../base/AtomEntity", - "../base/BaseEntity", "../base/XmlDataHandler", "../xml" ], - function(declare, config, lang, stringUtil, Promise, consts, ConnectionsService, AtomEntity, BaseEntity, XmlDataHandler, xml) { - - var ActivityCategory = ""; - var PositionTmpl = "${getPosition}"; - var CommunityTmpl = "${getCommunityUuid}" - + ""; - var CompletedTmpl = ""; - var TemplateTmpl = ""; - var DueDateTmpl = "${getDueDate}"; - var InReplytoTmpl = ""; - var FieldTmpl = "${getText}${getPerson}${getDate}${getLink}${getFile}"; - var TextFieldTmpl = "${summary}"; - var PersonFieldTmpl = "${personName} {email} ${userId}"; - var LinkFieldTmpl = ""; - var DateFieldTmpl = "${date}"; - var IconTmpl = "${getIconUrl}"; - var AssignedToTmpl = "${getAssignedToEmail}"; - var RoleTmpl = "${getRole}"; - var MemberCategory = ""; - var ActivityIdTmpl = "${getActivityUuid}"; - var ActivityNodeIdTmpl = "urn:lsid:ibm.com:oa:${getActivityNodeUuid}"; - - var extractId = function(id, token) { - //decode uri component returns "null" for null input - if(id) id = decodeURIComponent(id); // to make sure the Id doesnt contain encoded characters - if (id) { - var index = id.indexOf(token); - if (index != -1) { - var len = token.length; - id = id.substring(index + len); - } - } - return id; - }; - - var transformer = function(value, key) { - if (value) { - return value; - } - }; - - /** - * Field class represents a Field in an Activity Node. - * - * @class Field - * @namespace sbt.connections - */ - var Field = declare(null, { - name : null, - fid : null, - position : null, - type : null, - - /** - * Returns Field Name - * @method getName - * @returns {String} field name - */ - getName : function() { - return this.name; - }, - - /** - * Sets Field Name - * @method setName - * @param {String} field name - */ - setName : function(newName) { - this.name = newName; - }, - - /** - * Returns Field ID - * @method getFid - * @returns {String} field ID - */ - getFid : function() { - return this.fid; - }, - - /** - * Returns Field Position - * @method getPosition - * @returns {String} field position - */ - getPosition : function() { - return this.position; - }, - - /** - * Returns Field Type - * @method getType - * @returns {String} field type - */ - getType : function() { - return this.type; - } - }); - - /** - * TextField class represents a Text Field in an Activity Node. - * - * @class TextField - * @namespace sbt.connections - */ - var TextField = declare(Field, { - summary : null, - - /** - * Returns Field Summary - * @method getSummary - * @returns {String} field summary - */ - getSummary : function() { - return this.summary; - }, - - /** - * Sets Field Summary - * @method setSummary - * @param {String} field summary - */ - setSummary : function(newSumamry) { - this.summary = newSummary; - } - - }); - - /** - * DateField class represents a Date Field in an Activity Node. - * - * @class DateField - * @namespace sbt.connections - */ - var DateField = declare(Field, { - date : null, - - /** - * Returns Field Date - * @method getDate - * @returns {Date} field date - */ - getDate : function() { - return this.date; - }, - /** - * Sets Field Date - * @method setDate - * @param {Date} field date - */ - setDate : function(newDate) { - this.date = newDate; - } - - }); - - /** - * LinkField class represents a Link Field in an Activity Node. - * - * @class LinkField - * @namespace sbt.connections - */ - var LinkField = declare(Field, { - url : null, - title : null, - /** - * Returns Link Field URL - * @method getUrl - * @returns {String} field Url - */ - getUrl : function() { - return this.url; - }, - /** - * Sets Link Field URL - * @method setUrl - * @param {String} field Url - */ - setUrl : function(newUrl) { - this.url = newUrl; - }, - /** - * Returns Link Field Title - * @method getTitle - * @returns {String} field Title - */ - getTitle : function() { - return this.title; - }, - /** - * Sets Link Field Title - * @method setTitle - * @param {String} field Title - */ - setTitle : function(title) { - this.title = title; - } +define([ "../../../declare", + "../../../config", + "../../../lang", + "../../../controls/grid/Grid", + "./CommunityMembersGridRenderer", + "./CommunityMembersAction", + "../../../connections/controls/vcard/SemanticTagService", + "../../../store/parameter", + "../../../connections/ProfileConstants", + "../../../connections/CommunityConstants", + "sbt/connections/CommunityService"], + function(declare, sbt, lang, Grid, ProfileGridRenderer, CommunityMembersAction, SemanticTagService, parameter, consts, communities, + CommunityService) { - }); + var sortVals = { + displayName: "displayName", + recent: "3" + }; + + var communityMembersSortVals = { + displayName: "displayName", + created: "created" + }; + + var ParamSchema = { + pageNumber: parameter.oneBasedInteger("page"), + pageSize: parameter.oneBasedInteger("ps"), + sortBy: parameter.sortField("sortBy",sortVals), + sortOrder: parameter.sortOrder("sortOrder") + }; + + var CommunityMembersParamSchema = { + pageNumber: parameter.oneBasedInteger("page"), + pageSize: parameter.oneBasedInteger("ps"), + sortBy: parameter.sortField("sortBy", communityMembersSortVals), + sortOrder: parameter.sortOrder("sortOrder") + }; + + /** + * @class ProfileGrid + * @namespace sbt.connections.controls.communities + * @module sbt.connections.controls.communities.CommunityMembersGrid + */ + var CommunityMembersGrid = declare(Grid, { + + /** + * @param options, This is a list of all + * the different types of profile grids available. + * Depending on which one is selected specific arguments will be given to + * the atom store and grid renderer. + */ + options : { + "communityMembers" : { + storeArgs : { + url : communities.AtomCommunityMembers, + attributes : communities.MemberXPath, + feedXPath : communities.CommunityFeedXPath, + paramSchema: CommunityMembersParamSchema + }, + rendererArgs : { + type : "communityMembers" + } + } + }, + + /** + * A community members action, defines default behaviour for when + * items in the grid are clicked on or hovered on, + * it is possible to override these actions + */ + communityMembersAction: new CommunityMembersAction(), + + /** + * This is the default grid that will be created if no + * arguments are given. + */ + defaultOption: "communityMembers", + + /**Constructor function + * @method constructor + * */ + constructor: function(args){ + + var nls = this.renderer.nls; - /** - * FileField class represents a File Field in an Activity Node. - * - * @class FileField - * @namespace sbt.connections - */ - var FileField = declare(Field, { - url : null, - fileType : null, - size : null, - length : null, - /** - * Returns File Field URL - * @method getUrl - * @returns {String} field URL - */ - getUrl : function() { - return this.url; - }, - /** - * Returns File Field File Type - * @method getFileType - * @returns {String} File Type - */ - getFileType : function() { - return this.type; - }, + if (args.type == "communityMembers") { + + this._sortInfo = { + displayName: { + title: nls.displayName, + sortMethod: "sortByTitle", + sortParameter: "title" + }, + recent: { + title: nls.created, + sortMethod: "sortByCreated", + sortParameter: "created" + } + }; + this._activeSortAnchor = this._sortInfo.created; + this._activeSortIsDesc = false; + } else { + this._sortInfo = { + displayName: { + title: nls.displayName, + sortMethod: "sortByDisplayName", + sortParameter: "displayName" + }, + recent: { + title: nls.recent, + sortMethod: "sortByRecent", + sortParameter: "recent" + } + + }; + this._activeSortAnchor = this._sortInfo.recent; + this._activeSortIsDesc = false; + } + + }, + + + + /** + * Override buildUrl to add outputType, format and email/userid's + * + * @method buildUrl + * @param url base url + * @param args arguments that will be passed to the store + * @param endpoint An endpoint which may contain custom service mappings. + * @returns Built url + */ + buildUrl: function(url, args, endpoint) { + var params = { + outputType : "profile", + format : "full" + }; + + if (this.query) { + params = lang.mixin(params, this.query); + } + if (this.type == "colleagues") { + params = lang.mixin(params, { connectionType : "colleague" }); + } else if (this.type == "communityMembers") { + params = lang.mixin(params, { communityUuid : this.communityUuid }); + } + + if (this.email) { + params = lang.mixin(params, { email : this.email }); + } + if (this.email1 && this.email2) { + params = lang.mixin(params, { email : this.email1 + "," + this.email2 }); + } + if (this.userid) { + params = lang.mixin(params, { userid : this.userid }); + } + if (this.userid1 && this.userid2) { + params = lang.mixin(params, { userid : this.userid1 + "," + this.userid2 }); + } - /** - * Returns File Field File Size - * @method getSize - * @returns {String} File Size - */ - getSize : function() { - return this.size; - }, - /** - * Returns File Field File Length - * @method getLength - * @returns {String} File Length - */ - getLength : function() { - return this.length; - } - }); + return this.constructUrl(url, params, this.getUrlParams(), endpoint); + }, - /** - * PersonField class represents a Person Field in an Activity Node. - * - * @class PersonField - * @namespace sbt.connections - */ - var PersonField = declare(Field, { - personName : null, - userId : null, - email : null, + /** + * The post create function is called, after the grid has been created. + * The function will call the super classes post create + * then load the semantic tag service. The semantic tag service + * is Javascript for creating business card functionality. + * @method postCreate + */ + postCreate: function() { + this.inherited(arguments); + + SemanticTagService.loadSemanticTagService(); + }, + + /** + * Creates a renderer for the grid.The renderer is responsible for + * loading the grid's HTML content. + * @method createDefaultRenderer + * @param args sets the template the renderer will use, by checking args.type, but for + * profile grids this will always be "profile" + * @returns an instance of a profile gird renderer. + */ + createDefaultRenderer : function(args) { + return new ProfileGridRenderer(args,this); + }, + + /** + * In the grid HTML an element can have an event attached + * using dojo-attach-event="onClick: handleClick". + * This method is the handler for the onclick event. + * @method handleClick + * @param el the element that fired the event + * @param data all of the items from the current row of the grid. + * @param ev the event + */ + handleClick: function(el, data, ev) { + if (this.communityMembersAction) { + this._stopEvent(ev); + + this.communityMembersAction.execute(data, this, ev); + } + }, + + updateMember: function(el, data, ev) { + if (this.communityMembersAction) { + this._stopEvent(ev); + + this.communityMembersAction.updateMember(this, el, data, ev, this.communityUuid); + } + }, + + removeMember: function(el, data, ev) { + if (this.communityMembersAction) { + this._stopEvent(ev); + + this.communityMembersAction.removeMember(this, el, data, ev, this.communityUuid); + } + }, + + closeEditForm: function(el, data, ev) { + if (this.communityMembersAction) { + this._stopEvent(ev); + this.communityMembersAction.closeEditForm(this, el, data, ev); + } + }, + + openEditForm: function(el, data, ev) { + if (this.communityMembersAction) { + this._stopEvent(ev); + this.communityMembersAction.openEditForm(data); + } + }, + + /** + * In the grid HTML an element can have an event attached + * using dojo-attach-event="onClick: removeMember". + * This method is the handler for for the onclick event fired when + * clicking the "remove member" link on a member row. + * @method handleClick + * @param el the element that fired the event + * @param data all of the items from the current row of the grid. + * @param ev the event + */ + removeMember: function(el, data, ev) { + if (this.communityMembersAction) { + this._stopEvent(ev); + this.communityMembersAction.removeMember(this, this.communityUuid, data); + } + }, + + /** + * @method getSortInfo + * @returns A list of strings that describe how the grid can be sorted + * for profile grids these strings are "Display Name" and "Recent" + */ + getSortInfo: function() { + return { + active: { + anchor: this._activeSortAnchor, + isDesc: this._activeSortIsDesc + }, + list: [this._sortInfo.displayName, this._sortInfo.recent] + }; + + }, + + sortByDisplayName: function(el, data, ev){ + this._sort("displayName", true, el, data, ev); + }, - /** - * Returns Person Name - * @method getPersonName - * @returns {String} Person Name - */ - getPersonName : function() { - return this.personName; - }, - /** - * Sets Person Name - * @method setPersonName - * @param {String} Person Name - */ - setPersonName : function(newName) { - this.personName = newName; - }, - /** - * Returns Person User ID - * @method getUserId - * @returns {String} Person User ID - */ - getUserId : function() { - return this.userId; - }, - /** - * Sets Person User ID - * @method setUserId - * @param {String} Person User ID - */ - setUserId : function(newUserId) { - this.userId = newUserId; - }, - /** - * Returns Person Email - * @method getEmail - * @returns {String} Person Email - */ - getEmail : function() { - return this.email; - }, - /** - * Sets Person Email - * @method setEmail - * @param {String} Person Email - */ - setEmail : function(newEmail) { - this.email = newEmail; - } - }); + sortByRecent: function(el, data, ev){ + this._sort("recent", true, el, data, ev); + }, + + sortByCreated: function(el, data, ev){ + this._sort("created", true, el, data, ev); + }, + + sortByTitle: function(el, data, ev){ + this._sort("title", true, el, data, ev); + } - /** - * Tag class represents an entry for a Tag feed returned by the Connections REST API. - * - * @class Tag - * @namespace sbt.connections - */ - var Tag = declare(BaseEntity, { - /** - * Construct a Tag entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, + // Internals + + }); - /** - * Returns tag term - * @method getTerm - * @returns {String} tag term - */ - getTerm : function() { - return this.getAsString("term"); - }, - /** - * Returns tag frequency - * @method getFrequency - * @returns {String} tag frequency - */ - getFrequency : function() { - return this.getAsString("frequency"); - }, + return CommunityMembersGrid; +}); +}, +'url:sbt/connections/controls/search/templates/ul.html':"
      ${content}
    ", +'sbt/smartcloud/controls/profiles/ColleagueGrid':function(){ +define(["../../../declare", + "./ProfileGrid", + "./ColleagueGridRenderer"], + function(declare,ProfileGrid,ColleagueGridRenderer){ + + var ColleagueGrid = declare(ProfileGrid,{ + + hideViewAll: false, + + createDefaultRenderer : function(args) { + return new ColleagueGridRenderer(args); + }, + + handleViewAll: function(item, opts, event){ + this.hideViewAll = true; + this.renderer.template = this.renderer.fullTemplate; + this.renderer.render(this, this.domNode, opts.items, opts); + + } + }); + + + + return ColleagueGrid; +}); +}, +'url:sbt/connections/controls/search/templates/SuggestPopUpTemplate.html':"\r\n
    \r\n", +'sbt/connections/controls/communities/nls/CommunityMembersGridRenderer':function(){ +/* + * © 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. + */ - /** - * Returns tag bin - * @method getBin - * @returns {String} tag bin - */ - getBin : function() { - return this.getAsString("bin"); - } - }); +// NLS_CHARSET=UTF-8 +define({ + root: { + summary : "Profiles Grid", + updatedBy : "Updated by ", + displayName: "Display Name", + recent: "Recent", + telephone: "Telephone:", + email: "Email:", + altEmail: "Alternate Email", + clickToEmail: "Click here to email the user, using their alternate email address", + ariaVcard: "Press control and enter for the business card", + role: "Role", + created: "Created", + edit: "Edit", + remove: "Remove", + save: "Save", + cancel: "Close", + member: "Member", + owner: "Owner", + feed : "Feed for these Community Members" + } +}); - /** - * Activity class represents an entry for a activities feed returned by the Connections REST API. - * - * @class Activity - * @namespace sbt.connections - */ - var Activity = declare(AtomEntity, { + +}, +'sbt/store/AtomStore':function(){ +/* + * © 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. + */ - xpath : consts.ActivityNodeXPath, - namespaces : consts.ActivityNamespaces, - contentType : "html", - categoryScheme : null, +/** + * @module sbt.store.AtomStore + */ +define(["../declare","../config","../lang", "../base/core", "../xml", "../xpath", "../itemFactory", "../Promise", + "dojo/_base/Deferred", "dojo/promise/Promise", "dojo/store/util/QueryResults", "../entities"], + function(declare, config, lang, core, xml, xpath, itemFactory, SbtPromise, Deferred, Promise, QueryResults, entities) { + + /** + * @class sbt.store.AtomStore + */ + var AtomStorePromise = declare(Promise, { + // private + _store : null, + _isRejected : false, + _isFulfilled : false, + _isCancelled : false, + _callbacks : [], + _errbacks : [], + _endpoint : null, + _xmlData : null, + // read only + totalResults : null, + startIndex : 0, + itemsPerPage : 5, + items : null, + // public + url : "", + sendQuery : true, + unescapeHTML : false, + atom : core.feedXPath, + attributes : core.entryXPath, + namespaces : core.namespaces, + paramSchema: {}, + total: null, + + /** + * Constructor for the AtomStore promise. + * @param args requires + * endpoint: the endpoint to be used + */ + constructor: function(args, query, options) { + this._endpoint = config.findEndpoint(args.endpoint || "connections"); + this._options = options; + this._callbacks = []; + this._errbacks = []; + this.total = new SbtPromise(); + + if (args) { + this.url = args.url; + this.attributes = args.attributes || this.attributes; + this.atom = args.feedXPath || this.atom; + this.namespaces = args.namespaces || this.namespaces; + this.sendQuery = args.hasOwnProperty("sendQuery") ? args.sendQuery : this.sendQuery; + this.unescapeHTML = args.unescapeHTML || this.unescapeHTML; + this.paramSchema = args.paramSchema || this.paramSchema; + } + + // add paging information to the query + if (this.paramSchema.pageNumber) { + var page = Math.floor(options.start / options.count) + 1; + query.pageNumber = query.pageNumber || page; + } + if (this.paramSchema.startIndex) { + query.startIndex = query.startIndex || options.start; + } + if (this.paramSchema.pageSize) { + query.pageSize = query.pageSize || options.count; + } + + // add the sorting information to the query + if (options.sort && options.sort[0]) { + if (options.sort[0].attribute) { + query.sortBy = options.sort[0].attribute; + } - /** - * Construct an Activity entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, + if(options.sort[0].descending === true) { + query.sortOrder = "desc"; + } + else if(options.sort[0].descending === false) { + query.sortOrder = "asc"; + } + } - /** - * Sets template for category Scheme - */ - setCategoryScheme : function() { - this.categoryScheme = stringUtil.transform(ActivityCategory, this, transformer, this); - }, - + var fetchArgs = { + query : query + }; - /** - * Returns the ID - * @method getUuid - * @returns {String} Uuid - */ - getUuid : function() { - var _id = this.id || this._fields.id || this.getId(); - this.id = _id; - this._fields.id = _id; - return _id; - }, + this._doFetch(fetchArgs); + }, - /** - * Return the value of id from result ATOM entry document. - * - * @method getActivityUuid - * @return {String} ID of the activity - */ - getActivityUuid : function() { - return extractId(this.getUuid(), "urn:lsid:ibm.com:oa:"); - }, + /* + * Add new callbacks to the promise. + */ + then: function(callback, errback, progback) { + if (this._isFulfilled) { + callback(this.items); + return; + } + + if (callback) { + this._callbacks.push(callback); + } + if (errback) { + this._errbacks.push(errback); + } + }, - /** - * Returns the Author LdapId - * - * @method getAuthorLdapId - * @returns {Stirng} authorLdapId - */ - getAuthorLdapId : function() { - return this.getAsString("authorLdapid"); - }, + /* + * Inform the deferred it may cancel its asynchronous operation. + */ + cancel: function(reason, strict) { + this._isCancelled = true; + }, - /** - * Returns the contributor LdapId - * - * @method getContributorLdapId - * @returns {Object} contributor - */ - getContributorLdapId : function() { - return this.getAsString("contributorLdapid"); - }, + /* + * Checks whether the promise has been resolved. + */ + isResolved: function() { + return this._isRejected || this._isFulfilled; + }, - /** - * Returns Activity Node Type - * - * @method getType - * @returns {String} type - */ - getType : function() { - return this.getAsString("type"); - }, + /* + * Checks whether the promise has been rejected. + */ + isRejected: function() { + return this._isRejected; + }, - /** - * Sets Activity Node Type - * @method setType - * @param {String} type - */ - setType : function(type) { - return this.setAsString("type", type); - }, - /** - * Returns Activity Node Priority - * - * @method getPriority - * @returns {String} priority - */ - getPriority : function() { - return this.getAsString("priority"); - }, + /* + * Checks whether the promise has been resolved or rejected. + */ + isFulfilled: function() { + return this._isFulfilled; + }, - /** - * Return tags of IBM Connections activity from activity ATOM entry document. - * - * @method getTags - * @return {Object} Array of tags of the activity - */ - getTags : function() { - return this.getAsArray("tags"); - }, + /* + * Checks whether the promise has been canceled. + */ + isCanceled: function() { + return this._isCancelled; + }, + + // Internals + + /* + * Given a query and set of defined options, such as a start and count of items to return, + * this method executes the query and makes the results available as data items. + */ + _doFetch: function(args) { + var self = this; + var scope = args.scope || self; + + var serviceUrl = this._getServiceUrl(args.query); + if (!serviceUrl) { + if (args.onError) { + args.onError.call(new Error("sbt.store.AtomStore: No service URL specified.")); + } + return; + } + + this._endpoint.xhrGet({ + serviceUrl : serviceUrl, + handleAs : "text", + preventCache: true, + load : function(response) { + try { + // parse the data + self.response = response; + self._xmlData = xml.parse(response); + self.totalResults = parseInt(xpath.selectText(self._xmlData, self.atom.totalResults, self.namespaces)); + self.startIndex = parseInt(xpath.selectText(self._xmlData, self.atom.startIndex, self.namespaces)); + self.itemsPerPage = parseInt(xpath.selectText(self._xmlData, self.atom.itemsPerPage, self.namespaces)); + self.items = self._createItems(self._xmlData); + + + if (self._options.onComplete) { + self._options.onComplete.call(self._options.scope || self, self.items, self._options); + } + // invoke callbacks + self.total.fulfilled(self.totalResults); + self._fulfilled(self.items); + } catch (error) { + self.total._rejected(error); + self._rejected(error); + } + }, + error : function(error) { + self.total._rejected(error); + self._rejected(error); + } + }); + }, + + /* + * Create the service url and include query params + */ + _getServiceUrl: function(query) { + if (!this.sendQuery) { + return this.url; + } + if (!query) { + return this.url; + } + if (lang.isString(query)) { + return this.url + (~this.url.indexOf('?') ? '&' : '?') + query; + } + + var pairs = []; + var paramSchema = this.paramSchema; + for(var key in query) { + if (key in paramSchema) { + var val = paramSchema[key].format(query[key]); + if (val) { + pairs.push(val); + } + } else { + pairs.push(encodeURIComponent(key) + "=" + encodeURIComponent(query[key])); + } + } + if (pairs.length == 0) { + return this.url; + } + + return this.url + (~this.url.indexOf('?') ? '&' : '?') + pairs.join("&"); + }, + + /* + * Create a query string from an object + */ + _createQuery: function(queryMap) { + if (!queryMap) { + return null; + } + var pairs = []; + for(var name in queryMap){ + var value = queryMap[name]; + pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(value)); + } + return pairs.join("&"); + }, - /** - * Set new tags to be associated with this IBM Connections activity. - * - * @method setTags - * @param {Object} Array of tags to be added to the activity - */ + _createItems: function(document) { + var nodes = xpath.selectNodes(document, this.atom.entries, this.namespaces); + var items = []; + for (var i=0; i 0) { + var callback = this._callbacks.shift(); + callback(totalCount); + } + }, + + _rejected : function(error) { + if (this._isCancelled) { + return; + } + this._isRejected = true; + while (this._errbacks.length > 0) { + var errback = this._errbacks.shift(); + errback(error); + } + } + + }); + + /** + * @module sbt.store.AtomStore + */ + var AtomStore = declare(null, { + + // Indicates the property to use as the identity property. The values of this + // property should be unique. + idProperty: "id", + + _args : null, + + /** + * Constructor for the Atom store. + * + * @param args + * An anonymous object to initialize properties. It expects the following values: + * url: The url to a service or an XML document that represents the store + * unescapeHTML: A boolean to specify whether or not to unescape HTML text + * sendQuery: A boolean indicate to add a query string to the service URL + */ + constructor: function(args) { + this._args = args; - /** - * Returns the dueDate Date - * - * @method getDueDate - * @returns {Date} DueDate - */ - getDueDate : function() { - return this.getAsDate("dueDate"); - }, + //if(!args.url) { + // throw new Error("sbt.store.AtomStore: A service URL must be specified when creating the data store"); + //} + }, + + /** + * @method getEndpoint + * @returns + */ + getEndpoint: function() { + return config.findEndpoint(this._args.endpoint || "connections"); + }, + + /** + * Retrieves an object by its identity + * @method get + * @param id + */ + get: function(id) { + throw new Error("sbt.store.AtomStore: Not implemented yet!"); + }, - /** - * Sets the Due Date of Activity - * @method setDueDate - * @param {Date} dueDate - */ - setDueDate : function(dueDate) { - return this.setAsDate("dueDate", dueDate); - }, + /** + * Returns an object's identity + * @method getIdentity + * @param object + */ + getIdentity: function(object) { + return object.id; + }, + + setUrl: function(url){ + this._args.url = url; + }, + + getUrl: function(){ + return this._args.url; + }, + + setAttributes: function(attributes){ + this._args.attributes = attributes; + }, + + /** + * Queries the store for objects. This does not alter the store, but returns a set of data from the store. + * @method query + * @param query + * @param options + */ + query: function(query, options) { + var results = new AtomStorePromise(this._args, query, options); + return QueryResults(results); + } + }); + return AtomStore; + +}); - /** - * Returns Activity Node Members Url - * - * @method getMembersUrl - * @returns {String} membersUrl - */ - getMembersUrl : function() { - return this.getAsString("membersUrl"); - }, +}, +'sbt/nls/Locale':function(){ +/* + * © Copyright IBM Corp. 2015 + * + * 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. + */ - /** - * Returns Activity Node History Url - * - * @method getHistoryUrl - * @returns {String} historyUrl - */ - getHistoryUrl : function() { - return this.getAsString("historyUrl"); - }, +/** + * Social Business Toolkit SDK + */ - /** - * Returns Activity Node Templates Url - * - * @method getTemplatesUrl - * @returns {String} templatesUrl - */ - getTemplatesUrl : function() { - return this.getAsString("templatesUrl"); - }, - /** - * Returns Activity Position - * - * @method getPosition - * @returns {String} position - */ - getPosition : function() { - return this.getAsString("position"); - }, +define({ + root: ({ + todayAt : "Today at ", + on : "on " + }) + +}); +}, +'sbt/connections/SearchService':function(){ +/* + * © 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. + */ - /** - * Sets Activity Position - * @method setPosition - * @param position - */ - setPosition : function(position) { - return this.setAsString("position", position); - }, +/** + * Use the Search API to perform searches across the installed Connections applications. + * + * Returns a list of results with the specified text in the title, description, or content. Encode the strings. By default, spaces are treated as an AND operator. The following operators are supported: + * + * AND or &&: Searches for items that contain both words. For example: query=red%20AND%20test returns items that contain both the word red and the word test. AND is the default operator. + * NOT or !: Excludes the word that follows the operator from the search. For example: query=test%20NOT%20red returns items that contain the word test, but not the word red. + * OR: Searches for items that contain either of the words. For example: query=test%20OR%20red + * To search for a phrase, enclose the phrase in quotation marks (" "). + * +: The plus sign indicates that the word must be present in the result. For example: query=+test%20red returns only items that contain the word test and many that also contain red, but none that contain only the word red. + * ?: Use a question mark to match individual characters. For example: query=te%3Ft returns items that contain the words test, text, tent, and others that begin with te. + * -: The dash prohibits the return of a given word. This operator is similar to NOT. For example: query=test%20-red returns items that contains the word test, but not the word red. + * + * Note: Wildcard searches are permitted, but wildcard only searches (*) are not. + * For more details about supported operators, see Advanced search options in the Using section of the product documentation. + * + * @module sbt.connections.SearchService + */ +define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "../json", "./SearchConstants", + "./ConnectionsService", "../base/BaseEntity", "../base/AtomEntity", "../base/XmlDataHandler" ], + function(declare,config,lang,stringUtil,Promise,json,consts,ConnectionsService,BaseEntity,AtomEntity,XmlDataHandler) { - /** - * Returns Completed Flag for Activity - * @method isCompleted - * @returns {Boolean} completed flag - */ - isCompleted : function() { - return this.getAsBoolean("categoryFlagCompleted"); - }, + /** + * Scope class represents an entry for a scopes feed returned by the + * Connections REST API. + * + * @class Scope + * @namespace sbt.connections + */ + var Scope = declare(AtomEntity, { - /** - * Set Completed Flag - * @param {Boolean} completed - * @returns - */ - setCompleted : function(completed) { - return this.setAsBoolean("categoryFlagCompleted", completed); - }, + /** + * Construct a Scope entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, + + /** + * Return the scope search link. + * + * @method getLink + * @return {String} Scope link + */ + getLink : function() { + return this.getAsString("link"); + } - /** - * Get Delete Flag - * - * @returns {Boolean} isDelete - */ - isDeleted : function() { - return this.getAsBoolean("categoryFlagDelete"); - }, + }); + + /** + * Result class represents an entry for a search feed returned by the + * Connections REST API. + * + * @class Result + * @namespace sbt.connections + */ + var Result = declare(AtomEntity, { - /** - * Gets Teplate Flag - * - * @returns {Boolean} template - */ - isTemplate : function() { - return this.getAsBoolean("categoryFlagTemplate"); - }, + /** + * Construct a Scope entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, + + /** + * Return the primary component for a particular search + * result with respect to the search query. + * + * @method getPrimaryComponent + * @return {String} Primary component + */ + getPrimaryComponent : function() { + return this.getAsString("primaryComponent"); + }, - /** - * Sets Template Flag - * - * @param {Boolean} templateFlag - */ - setTemplate : function(templateFlag) { - return this.setAsBoolean("categoryFlagTemplate", templateFlag); - }, + /** + * Indicates a relative assessment of relevance for a particular search + * result with respect to the search query. + * + * @method getRelevance + * @return {String} Relative assessment of relevance + */ + getRelevance : function() { + return this.getAsNumber("relevance"); + } - /** - * Returns Activity Node Depth - * - * @method getDepth - * @returns {String} depth - */ - getDepth : function() { - return this.getAsString("depth"); - }, + }); + + /** + * FacetValue class represents an entry for a search facet returned by the + * Connections REST API. + * + * @class FacetValue + * @namespace sbt.connections + */ + var FacetValue = declare(BaseEntity, { - /** - * Returns Activity Node Permissions - * - * @method getPermissions - * @returns {String} permissions - */ - getPermissions : function() { - return this.getAsString("permissions"); - }, + /** + * Construct an FacetValue. + * + * @constructor + * @param args + */ + constructor : function(args) { + // create XML data handler + this.dataHandler = new XmlDataHandler({ + service : args.service, + data : args.data, + namespaces : lang.mixin(consts.Namespaces, args.namespaces || {}), + xpath : lang.mixin(consts.FacetValueXPath, args.xpath || this.xpath || {}) + }); + this.id = this.getAsString("uid"); + }, + + /** + * Return the value of id from facet entry. + * + * @method getId + * @return {String} ID of the facet entry + */ + getId : function() { + var id = this.getAsString("id"); + var parts = id.split("/"); + return (parts.length == 1) ? parts[0] : parts[1]; + }, - /** - * Returns Activity Node IconUrl - * - * @method getIconUrl - * @returns {String} iconUrl - */ - getIconUrl : function() { - return this.getAsString("iconUrl"); - }, + /** + * Return the value of label from facet entry. + * + * @method getLabel + * @return {String} Facet entry label + */ + getLabel : function() { + return this.getAsString("label"); + }, - /** - * setIconUrl - * @param iconUrl - */ - setIconUrl : function(iconUrl) { - return this.setAsString("iconUrl", iconUrl); - }, + /** + * Return the value of weigth from facet entry. + * + * @method getWeight + * @return {Number} Facet entry weight + */ + getWeight : function() { + return this.getAsNumber("weight"); + } - /** - * getCommunityUuid - * @method getCommunityUuid - * @returns {String} communityUuid - */ - getCommunityUuid : function() { - return this.getAsString("communityUuid"); - }, + }); + + /* + * Callbacks used when reading a feed that contains scope entries. + */ + var ScopeFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + namespaces : consts.Namespaces, + xpath : consts.SearchFeedXPath, + service : service, + data : data + }); + }, + createEntity : function(service,data,response) { + return new Scope({ + namespaces : consts.Namespaces, + service : service, + data : data + }); + } + }; - /** - * setCommunityUuid - * @method setCommunityUuid - * @param communityUuid - */ - setCommunityUuid : function(communityUuid) { - return this.setAsString("communityUuid", communityUuid); - }, - /** - * getCommunityUrl - * @method getCommunityUrl - * @returns {String} communityUrl - */ - getCommunityUrl : function() { - return this.getAsString("communityUrl"); - }, + /* + * Callbacks used when reading a feed that contains search entries. + */ + var ResultFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + namespaces : consts.Namespaces, + xpath : consts.SearchFeedXPath, + service : service, + data : data + }); + }, + createEntity : function(service,data,response) { + return new Result({ + namespaces : consts.Namespaces, + xpath : consts.SearchXPath, + service : service, + data : data + }); + } + }; + + /* + * Callbacks used when reading a feed that contains search facets. + */ + var FacetsCallbacks = { + createEntities : function(service,data,response) { + var xpathExprs = lang.mixin({}, consts.SingleFacetXPath); + // facet param looks like this "{"id": "Person"}" + var facet = json.parse(response.options.query.facet); + xpathExprs.entries = xpathExprs.entries.replace("{facet.id}", facet.id); + return new XmlDataHandler({ + namespaces : consts.Namespaces, + xpath : xpathExprs, + service : service, + data : data + }); + }, + createEntity : function(service,data,response) { + return new FacetValue({ + namespaces : consts.Namespaces, + xpath : consts.FacetValueXPath, + service : service, + data : data + }); + } + }; + + /** + * SearchService class. + * + * @class SearchService + * @namespace sbt.connections + */ + var SearchService = declare(ConnectionsService, { + + contextRootMap: { + search: "search" + }, + + serviceName : "search", - /** - * setCommunityUrl - * @method setCommunityUrl - * @param communityUrl - */ - setCommunityUrl : function(communityUrl) { - return this.setAsString("communityUrl", communityUrl); - }, + /** + * Constructor for SearchService + * + * @constructor + * @param args + */ + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } + }, + + /** + * Returns the set of supported values that can be passed to the "scope" parameter of the Search API. + * Scopes relating to Connections applications that have not been installed will not be returned. + * + * @method getScopes + * @param requestArgs + */ + getScopes: function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.AtomScopes, options, ScopeFeedCallbacks); + }, + + /** + * Search Lotus Connection for public information. + * + * @method getResults + * @param query Text to search for + * @param requestArgs + */ + getResults: function(queryArg, requestArgs) { + requestArgs = this._stringifyRequestArgs(requestArgs); + var options = { + method : "GET", + handleAs : "text", + query : lang.mixin({ query : queryArg } , requestArgs || {}) + }; + + return this.getEntities(consts.AtomSearch, options, ResultFeedCallbacks); + }, + + /** + * Search Lotus Connections for both public information and + * private information that you have access to. You must provide + * authentication information in the request to retrieve this + * resource. + * + * @method getMyResults + * @param query Text to search for + * @param requestArgs + */ + getMyResults: function(queryArg, requestArgs) { + requestArgs = this._stringifyRequestArgs(requestArgs); + var options = { + method : "GET", + handleAs : "text", + query : lang.mixin({ query : queryArg } , requestArgs || {}) + }; + + return this.getEntities(consts.AtomMySearch, options, ResultFeedCallbacks); + }, + + /** + * Search Lotus Connection for public information. + * + * @method getResultsWithConstraint + * @param query Text to search for + * @param constraint Constraint(s) to be used while searching + * @param requestArgs + */ + getResultsWithConstraint: function(queryArg, constraint, requestArgs) { + requestArgs = this._stringifyRequestArgs(requestArgs); + + var query = { + query : queryArg, + constraint : json.stringify(constraint) + }; + + var options = { + method : "GET", + handleAs : "text", + query : lang.mixin(query, requestArgs || {}) + }; + + return this.getEntities(consts.AtomSearch, options, ResultFeedCallbacks); + }, + + /** + * Search Lotus Connections for both public information and + * private information that you have access to. You must provide + * authentication information in the request to retrieve this + * resource. + * + * @method getMyResultsWithConstraint + * @param query Text to search for + * @param constraint Constraint(s) to be used while searching + * @param requestArgs + */ + getMyResultsWithConstraint: function(queryArg, constraint, requestArgs) { + requestArgs = this._stringifyRequestArgs(requestArgs); + + var query = { + query : queryArg, + constraint : json.stringify(constraint) + }; + + var options = { + method : "GET", + handleAs : "text", + query : lang.mixin(query, requestArgs || {}) + }; + + return this.getEntities(consts.AtomMySearch, options, ResultFeedCallbacks); + }, + + /** + * Search IBM Connections for public information, tagged + * with the specified tags. + * + * @method getTagged + * @param tags tags to search for + * @param requestArgs + */ + getResultsByTag: function(tags, requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : lang.mixin({ + constraint : this._createTagConstraint(tags) + } , + requestArgs || {}) + }; + + return this.getEntities(consts.AtomSearch, options, ResultFeedCallbacks); + }, + + /** + * Search IBM Connections for both public information and private + * information that you have access to, tagged + * with the specified tags. + * + * @method getMyResultsByTag + * @param tags Tags to search for + * @param requestArgs + */ + getMyResultsByTag: function(tags, requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : lang.mixin({ + constraint : this._createTagConstraint(tags) + } , + requestArgs || {}) + }; + + return this.getEntities(consts.AtomMySearch, options, ResultFeedCallbacks); + }, + + /** + * Search IBM Connections Profiles for people using the specified + * query string and return public information. + * + * @method getPeople + * @param query Text to search for + * @param requestArgs + */ + getPeople: function(queryArg, requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : lang.mixin({ + query : queryArg, + pageSize : "0", + facet : "{\"id\": \"Person\"}" + } , + requestArgs || {}) + }; + + return this.getEntities(consts.AtomSearch, options, FacetsCallbacks); + }, + + /** + * Search IBM Connections Profiles for people using the specified + * query string and return public information. + * + * @method getMyPeople + * @param query Text to search for + * @param requestArgs + */ + getMyPeople: function(queryArg, requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : lang.mixin({ + query : queryArg, + pageSize : "0", + facet : "{\"id\": \"Person\"}" + } , + requestArgs || {}) + }; + + return this.getEntities(consts.AtomMySearch, options, FacetsCallbacks); + }, + + // + // Internals + // + + /* + * + */ + _stringifyRequestArgs: function(requestArgs) { + if (!requestArgs) { + return null; + } + var _requestArgs = {}; + for(var name in requestArgs){ + var value = requestArgs[name]; + if (lang.isObject(value)) { + _requestArgs[name] = json.stringify(value); + } else { + _requestArgs[name] = value; + } + } + return _requestArgs; + }, + + /* + * Create a contraint JSON string for the specified tags + */ + _createTagConstraint: function(tags) { + var jsonObj = { "type" : "category", "values" : new Array() }; + if (lang.isArray(tags)) { + for (var i=0;i\r\n\t
    \r\n\t\t${nls.sortBy}\r\n\t\t
      \r\n\t\t\t${sortAnchors}\r\n\t\t
    \r\n\t
    \r\n", +'url:sbt/connections/controls/search/templates/BookmarkBody.html':"
    \r\n
      \r\n
    • \r\n ${bodyBookmarkLiContent}\r\n
    • \r\n
    • \r\n ${updatedLabel}\r\n
    • \r\n ${tagsList}\r\n
    \r\n\r\n
    \r\n
    \r\n ${resultLink}\r\n
    ", +'sbt/compat':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - /** - * Creats an entry in an activity, such as a to-do item or to add a reply to another entry, send an Atom entry document containing the new - * activity node of the appropriate type to the parent activity's node list. - * - * @mehtod createActivityNode - * @param {Object} activityNodeOrJson - * @returns {Object} ActivityNode - */ - createActivityNode : function(activityNodeOrJson) { - return this.service.createActivityNode(this.getActivityUuid(), activityNodeOrJson); - }, +/** + * Social Business Toolkit SDK - Compatibility with older browsers + * + * @module sbt.compat + */ +define([],function() { + if (!Array.prototype.indexOf){ + Array.prototype.indexOf = function(item, start) { + var index = start || 0; + var max = this.length; + for (; index < max; index++) { + if (this[index] === item) { return index; } + } + return -1; + }; + } + return { + + }; +}); +}, +'sbt/connections/controls/vcard/CommunityVCard':function(){ +require({cache:{ +'url:sbt/connections/controls/vcard/templates/CommunityVCard.html':"\r\n ${name}\r\n ${uuid}\r\n ${selectedWidgetId}\r\n"}}); +/* + * © 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. + */ - /** - * Returns the tags for given actiivity - * @method getActivityTags - * @param {Object} [requestArgs] the optional arguments - * @returns {Array} tags - */ - getActivityTags : function(requestArgs) { - return this.service.getActivityTags(this.getActivityUuid(), requestArgs); - }, - /** - * Return contributor element to be included in post data for this ATOM entry. - * - * @method createContributor - * @returns {String} - */ - createContributor : function() { - return ""; - }, - - /** - * Return extra entry data to be included in post data for this ATOM entry. - * - * @method createEntryData - * @returns {String} - */ - createEntryData : function() { - var postData = ""; - if (this.getPosition && this.getPosition()) { - postData += stringUtil.transform(PositionTmpl, this, transformer, this); - } - if (this.getCommunityUuid && this.getCommunityUuid()) { - postData += stringUtil.transform(CommunityTmpl, this, transformer, this); - } - if (this.getActivityUuid && this.getActivityUuid()) { - postData += stringUtil.transform(ActivityIdTmpl, this, transformer, this); - } - if (this.getActivityNodeUuid && this.getActivityNodeUuid()) { - postData += stringUtil.transform(ActivityNodeIdTmpl, this, transformer, this); - } - if (this.isCompleted && this.isCompleted()) { - postData += CompletedTmpl; - } - if (this.getDueDate && this.getDueDate()) { - postData += stringUtil.transform(DueDateTmpl, this, transformer, this); - } - if (this.getInReplyToId && this.getInReplyToId()) { - postData += stringUtil.transform(InReplytoTmpl, this, transformer, this); - } - if (this.getAssignedToUserId && this.getAssignedToUserId()) { - postData += stringUtil.transform(AssignedToTmpl, this, transformer, this); - } - if (this.getIconUrl && this.getIconUrl()) { - postData += stringUtil.transform(IconTmpl, this, transformer, this); - } - if (this.isTemplate && this.isTemplate()) { - postData += TemplateTmpl; - } +/** + * + */ +define(["../../../declare", + "../../../dom", + "../../../widget/_TemplatedWidget", + "../../../lang", + "../../../connections/controls/vcard/SemanticTagService", + "../../../text!./templates/CommunityVCard.html"], + function(declare, dom, _TemplatedWidget, lang, SemanticTagService, template) { - if (this.getFields && this.getFields().length > 0) { - var fields = this.getFields(); - for ( var counter in fields) { - var field = fields[counter]; - var innerXml = ""; - var trans = function(value, key) { - if (field[key]) { - value = xml.encodeXmlEntry(field[key]); - } else if (innerXml != "") { - value = innerXml; - } - return value; - }; - var tmpl = TextFieldTmpl; - if (field.type == "person") { - tmpl = PersonFieldTmpl; - } else if (field.type == "link") { - tmpl = LinkFieldTmpl; - } else if (field.type == "date") { - tmpl = DateFieldTmpl; - } - innerXml = stringUtil.transform(tmpl, this, trans, this); - postData += stringUtil.transform(FieldTmpl, this, trans, this); - } - } + /** + * @class sbt.controls.CommunityVCard + */ + var communityVCard = declare([ _TemplatedWidget ], { - return postData; - } - }); + /** + * The html template of the vcard. + * + * @property configUtil + * @type String + */ + templateString: template, + + /** + * Whether or not to encode HTML. + * + * @property encodeHtml + * @type Boolean + * @default true + */ + encodeHtml: true, + + /** + * The uuid of the community. + * + * @property uuid + * @type String + * @default "" + */ + uuid: "", + + /** + * A text string that corresponds to the widgetDefId of the widget that has been added to the community. + * This text string is used to highlight the menu item in the navigation bar. + * This argument is optional, and must only be provided for iWidgets that are integrated into Communities. + * The widget ID is defined by the iWidget developer, and you need to request it from your administrator or the iWidget developer. + * + * @property selectedWidgetId + * @type String + * @default "" + */ + selectedWidgetId: "", + + + /** + * The name of the community. + * + * @property name + * @type String + * @default "" + */ + name: "", + + /** + * The constructor + * + * @method constructor + * @param {Object} args + * @param {String} [args.name] The name to display on the community vcard. + * @param {String} args.uuid The uuid of the community. + * @param {String} [args.selectedWidgetId] a text string that corresponds to the widgetDefId of the widget that has been added to the community. + * This text string is used to highlight the menu item in the navigation bar. The element is optional, and must only be provided for iWidgets that are integrated into Communities. + * The widget ID is defined by the iWidget developer, and you need to request it from your administrator or the iWidget developer. + */ + constructor: function(args) { + if(!args.selectedWidgetId) + args.selectedWidgetId=""; + lang.mixin(args); + }, + + /** + * @method postCreate + */ + postCreate: function() { + this.inherited(arguments); + + SemanticTagService.loadSemanticTagService(); + } + + }); + + return communityVCard; +}); +}, +'sbt/connections/BlogService':function(){ +/* + * © 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. + */ - /** - * Activity Node class represents an entry for a activities Node feed returned by the Connections REST API. - * - * @class ActivityNode - * @namespace sbt.connections - */ - var ActivityNode = declare(Activity, { - /** - * Construct a Result entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, +/** + * The Blogs API allows application programs to retrieve blog information, subscribe to blog updates, and create or modify blogs. + * + * @module sbt.connections.BlogService + */ +define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./BlogConstants", "./ConnectionsService", + "../base/AtomEntity", "../base/XmlDataHandler", "./Tag", "./BlogPost"], + function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler, Tag, BlogPost) { + + var BlogTmpl = "${getTitle}${getTimezone}${getHandle}${getSummary}${getTags}"; + var BlogPostTmpl = "${getTitle}${getContent}${getTags}"; + var BlogCommentTmpl = "${getContent}"; + CategoryTmpl = ""; + var CategoryBlog = ""; + var CategoryPerson = ""; - /** - * Return the value of id from result ATOM entry document. - * - * @method getActivityNodeUuid - * @return {String} ID of the result - */ - getActivityNodeUuid : function() { - return extractId(this.getUuid(), "urn:lsid:ibm.com:oa:"); - }, + /** + * Blog class represents an entry for a Blogs feed returned by the + * Connections REST API. + * + * @class Blog + * @namespace sbt.connections + */ + var Blog = declare(AtomEntity, { - /** - * Return the value of activity uuid from result ATOM entry document. - * - * @method getActivityUuid - * @return {String} cctivityUuid of the result - */ - getActivityUuid : function() { - return this.getAsString("activityUuid"); - }, + xpath : consts.BlogXPath, + namespaces : consts.BlogNamespaces, + categoryScheme : CategoryBlog, + + /** + * Construct a Blog entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, - /** - * - * @param activityUuid - * @returns - */ - setActivityUuid : function(activityUuid) { - return this.setAsString("activityUuid", activityUuid); - }, + /** + * Return the value of IBM Connections blog handle from blog ATOM + * entry document. + * + * @method getHandle + * @return {String} handle of the blog + */ + getHandle : function() { + return this.getAsString("handle"); + }, - /** - * getInReplyToId - * @returns {String} getInReplyToId - */ - getInReplyToId : function() { - return this.getAsString("inReplyToId"); - }, + /** + * Sets Handle of IBM Connections blog. + * + * @method setHandle + * @param {String} setHandle of the blog + */ + setHandle : function(handle) { + return this.setAsString("handle", handle); + }, - /** - * getInReplyToUrl - * @returns {String} getInReplyToUrl - */ - getInReplyToUrl : function() { - return this.getAsString("inReplyToUrl"); - }, - /** - * - * @param inReplytoId - * @param inReplyToUrl - * @param inReplyToActivity - */ - setInReplyTo : function(inReplyToId, inReplyToUrl) { - var id = "urn:lsid:ibm.com:oa:" + inReplyToId; - var inReplyTo = { - "inReplyToId" : id, - "inReplyToUrl" : inReplyToUrl - }; + /** + * Return the value of IBM Connections blog ID from blog ATOM + * entry document. + * + * @method getBlogUuid + * @return {String} ID of the blog + */ + getBlogUuid : function() { + var blogUuidPrefix = "urn:lsid:ibm.com:blogs:blog-"; + var blogUuid = this.getAsString("blogUuid"); + if(blogUuid && blogUuid.indexOf(blogUuidPrefix) != -1){ + blogUuid = blogUuid.substring(blogUuidPrefix.length, blogUuid.length); + } + return blogUuid; + }, + + /** + * Sets id of IBM Connections blog. + * + * @method setBlogUuid + * @param {String} blogUuid of the blog + */ + setBlogUuid : function(blogUuid) { + return this.setAsString("blogUuid", blogUuid); + }, - return this.setAsObject(inReplyTo); - }, + /** + * Return the value of IBM Connections blog URL from blog ATOM + * entry document. + * + * @method getBlogUrl + * @return {String} Blog URL of the blog + */ + getBlogUrl : function() { + return this.getAsString("alternateUrl"); + }, - /** - * getAssignedToUserId - * @returns {String} getAssignedToUserId - */ - getAssignedToUserId : function() { - return this.getAsString("assignedToUserId"); - }, + /** + * Return tags of IBM Connections blog + * document. + * + * @method getTags + * @return {Object} Array of tags of the blog + */ + getTags : function() { + return this.getAsArray("tags"); + }, - /** - * getAssignedToName - * @returns {String} getAssignedToName - */ - getAssignedToName : function() { - return this.getAsString("assignedToName"); - }, + /** + * Set new tags to be associated with this IBM Connections blog. + * + * @method setTags + * @param {Object} Array of tags to be added to the blog + */ - /** - * getAssignedToEmail - * @returns {String} getAssignedToEmail - */ - getAssignedToEmail : function() { - return this.getAsString("assignedToEmail"); - }, + setTags : function(tags) { + return this.setAsArray("tags", tags); + }, - /** - * Sets Assigned to in fields for creating playload - * @method setAssignedTo - * @param {String} assignedToUserId - * @param {String} assignedToName - * @param {String} assignedToEmail - * @returns - */ - setAssignedTo : function(assignedToUserId, assignedToName, assignedToEmail) { - var assignedTo = { - "assignedToUserId" : assignedToUserId, - "assignedToName" : assignedToName, - "assignedToEmail" : assignedToEmail - }; - return this.setAsObject(assignedTo); - }, + /** + * Return the value of IBM Connections blog's community id from blog ATOM + * entry document. Only valid for Ideation Blog and community blog + * + * @method getCommunityUuid + * @return {String} Blog Container URL of the blog + */ + getCommunityUuid : function() { + return this.getAsString("communityUuid"); + }, - /** - * returns Text Fields in Activity node feed - * @returns {Array} textFields - */ - getTextFields : function() { - var nodes = this.getAsNodesArray("textFields"); - var textFields = []; - for ( var counter in nodes) { - var node = nodes[counter]; - var textField = new TextField(); - for ( var i = 0; i < node.attributes.length; i++) { - var attr = node.attributes[i]; - var attrName = attr.name; - var attrValue = attr.value; - textField[attrName] = attrValue; - } - var dataHandler = new XmlDataHandler({ - service : this.service, - data : node, - namespaces : consts.Namespaces, - xpath : consts.TextFieldXPath - }); - textField.summary = dataHandler.getAsString("summary"); - textFields.push(textField); - this.addTextField(textField); - } - return textFields; - }, + /** + * Return the value of IBM Connections blog's container url from blog ATOM + * entry document. Only valid for Ideation Blog + * + * @method getContainerUrl + * @return {String} Blog Container URL of the blog + */ + getContainerUrl : function() { + return this.getAsString("containerUrl"); + }, - /** - * Adds a test field - * @param {Object} textField - * @returns - */ - addTextField : function(textField) { - if (this._fields["fields"]) { - this._fields["fields"].push(textField); - return this; - } else { - return this.setAsArray("fields", [ textField ]); - } - }, + /** + * Return the value of IBM Connections blog's container type from blog ATOM + * entry document. Only valid for Ideation Blog + * + * @method getContainerType + * @return {String} Blog Container type of the blog + */ + getContainerType : function() { + return this.getAsString("containerType"); + }, - /** - * returns Date Fields in Activity node feed - * @returns {Array} dateFields - */ - getDateFields : function() { - var nodes = this.getAsNodesArray("dateFields"); - var dateFields = []; - for ( var counter in nodes) { - var node = nodes[counter]; - var dateField = new DateField; - for ( var i = 0; i < node.attributes.length; i++) { - var attr = node.attributes[i]; - var attrName = attr.name; - var attrValue = attr.value; - dateField[attrName] = attrValue; - } - dateField["date"] = new Date(stringUtil.trim(node.textContent)); - dateFields.push(dateField); - this.addDateField(dateField); - } - return dateFields; - }, + /** + * Return all flags of IBM Connections blog ATOM entry document. Only valid + * for Ideation Blog + * + * @method getCategoryFlags + * @return {Object} Array of all flags of the blog + */ + getCategoryFlags : function() { + return this.getAsArray("categoryFlags"); + }, - /** - * adds a DateField - * @param {Object} DateField - * @returns - */ - addDateField : function(dateField) { - if (this._fields["fields"]) { - this._fields["fields"].push(dateField); - return this; - } else { - return this.setAsArray("fields", [ dateField ]); - } - }, + /** + * Loads the blog object with the atom entry associated with the + * blog. By default, a network call is made to load the atom entry + * document in the blog object. + * + * @method load + * @param {Object} [args] Argument object + */ + load : function(args) { + // detect a bad request by validating required arguments + var blogUuid = this.getBlogUuid(); + var promise = this.service._validateBlogUuid(blogUuid); + if (promise) { + return promise; + } - /** - * returns Link Fields in Activity node feed - * @returns {Array} linkFields - */ - getLinkFields : function() { - var nodes = this.getAsNodesArray("linkFields"); - var linkFields = []; - for ( var counter in nodes) { - var node = nodes[counter]; - var linkField = new LinkField; - for ( var i = 0; i < node.attributes.length; i++) { - var attr = node.attributes[i]; - var attrName = attr.name; - var attrValue = attr.value; - linkField[attrName] = attrValue; - } - var dataHandler = new XmlDataHandler({ - service : this.service, - data : node, - namespaces : consts.Namespaces, - xpath : consts.LinkFieldXPath - }); - linkField.url = dataHandler.getAsString("url"); - linkField.title = dataHandler.getAsString("title"); - linkFields.push(linkField); - this.addLinkField(linkField); - } - return linkFields; - }, + var self = this; + var callbacks = { + createEntity : function(service,data,response) { + self.setDataHandler(new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BlogXPath + })); + return self; + } + }; + var requestArgs = lang.mixin({}, args || {}); + var options = { + handleAs : "text", + query : requestArgs + }; + var url = null; + + url = this.service._constructBlogsUrl(consts.AtomBlogInstance, { + blogUuid : blogUuid + }); + return this.service.getEntity(url, options, blogUuid, callbacks); + }, - /** - * Adds a LinkField - * @param {Object} LinkField - * @returns - */ - addLinkField : function(linkField) { - if (this._fields["fields"]) { - this._fields["fields"].push(linkField); - return this; - } else { - return this.setAsArray("fields", [ linkField ]); - } - }, + /** + * Remove this blog + * + * @method remove + * @param {Object} [args] Argument object + */ + remove : function(args) { + return this.service.deleteBlog(this.getBlogUuid(), args); + }, - /** - * returns Person Fields in Activity node feed - * @returns {Array} personFields - */ - getPersonFields : function() { - var nodes = this.getAsNodesArray("personFields"); - var personFields = []; - for ( var counter in nodes) { - var node = nodes[counter]; - var personField = new PersonField; - for ( var i = 0; i < node.attributes.length; i++) { - var attr = node.attributes[i]; - var attrName = attr.name; - var attrValue = attr.value; - personField[attrName] = attrValue; - } - var dataHandler = new XmlDataHandler({ - service : this.service, - data : node, - namespaces : consts.Namespaces, - xpath : consts.PersonFieldXPath - }); - personField.personName = dataHandler.getAsString("name"); - personField.userId = dataHandler.getAsString("userId"); - personField.email = dataHandler.getAsString("email"); - personFields.push(personField); - this.addPersonField(personField); - } - return personFields; - }, + /** + * Update this blog + * + * @method update + * @param {Object} [args] Argument object + */ + update : function(args) { + return this.service.updateBlog(this, args); + }, + + /** + * Save this blog + * + * @method save + * @param {Object} [args] Argument object + */ + save : function(args) { + if (this.getBlogUuid()) { + return this.service.updateBlog(this, args); + } else { + return this.service.createBlog(this, args); + } + } - /** - * adds a person fields to activity node - * @param {Object} PersonField - * @returns - */ - addPersonField : function(personField) { - if (this._fields["fields"]) { - this._fields["fields"].push(personField); - return this; - } else { - return this.setAsArray("fields", [ personField ]); - } - }, + }); + + /** + * Comment class represents a comment on a Blogs post returned by the + * Connections REST API. + * + * @class Comment + * @namespace sbt.connections + */ + var Comment = declare(AtomEntity, { + + xpath : consts.CommentXPath, + namespaces : consts.BlogNamespaces, - /** - * returns File Fields in Activity node feed - * @returns {Array} fileFields - */ - getFileFields : function() { - var nodes = this.getAsNodesArray("fileFields"); - var fileFields = []; - for ( var counter in nodes) { - var node = nodes[counter]; - var fileField = new FileField; - for ( var i = 0; i < node.attributes.length; i++) { - var attr = node.attributes[i]; - var attrName = attr.name; - var attrValue = attr.value; - fileField[attrName] = attrValue; - } - var dataHandler = new XmlDataHandler({ - service : this.service, - data : node, - namespaces : consts.Namespaces, - xpath : consts.FileFieldXPath - }); - fileField.url = dataHandler.getAsString("url"); - fileField.size = dataHandler.getAsString("size"); - fileField.type = dataHandler.getAsString("type"); - fileField.length = dataHandler.getAsString("length"); - fileFields.push(fileField); - } - return fileFields; - }, + /** + * Construct a Blog Post Comment. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, - /** - * returns all fields in activity nodes feed - * @returns {Array} fields - */ - getFields : function() { - if (this._fields.fields && this._fields.fields.length > 0) { - return this._fields.fields; - } - var fields = []; - var textFields = this.getTextFields(); - var personFields = this.getPersonFields(); - var linkFields = this.getLinkFields(); - var fileFields = this.getFileFields(); - var dateFields = this.getDateFields(); - for ( var counter in textFields) { - var field = textFields[counter]; - feilds.push(field); - } - for ( var counter in personFields) { - var field = personFields[counter]; - feilds.push(field); - } - for ( var counter in linkFields) { - var field = linkFields[counter]; - feilds.push(field); - } - for ( var counter in fileFields) { - var field = fileFields[counter]; - feilds.push(field); - } - for ( var counter in dateFields) { - var field = dateFields[counter]; - feilds.push(field); - } - return fields; - }, + /** + * Return the value of IBM Connections blog post comment id + * entry document. + * + * @method getCommentUuid + * @return {String} id of the blog post comment + */ + getCommentUuid : function() { + var commentUuidPrefix = "urn:lsid:ibm.com:blogs:comment-"; + var commentUuid = this.getAsString("commentUuid"); + if(commentUuid && commentUuid.indexOf(commentUuidPrefix) != -1){ + commentUuid = commentUuid.substring(commentUuidPrefix.length, commentUuid.length); + } + return commentUuid; + }, + + /** + * Sets id of IBM Connections blog post comment. + * + * @method setCommentUuid + * @param {String} CommentUuid of the blog post + */ + setCommentUuid : function(CommentUuid) { + return this.setAsString("CommentUuid", CommentUuid); + }, + + /** + * Return the last updated dateRecommendations URL of the IBM Connections blog post comment from + * blog ATOM entry document. + * + * @method getRecommendationsURL + * @return {String} Recommendations URL of the Blog Post comment + */ + getRecommendationsURL : function() { + return this.getAsString("recommendationsUrl"); + }, + + /** + * Return the Recommendations count of the IBM Connections blog post comment from + * blog ATOM entry document. + * + * @method getRecommendationsCount + * @return {String} Number of recommendations for the Blog post comment + */ + getRecommendationsCount : function() { + return this.getAsString("rankRecommendations"); + }, + + /** + * Return the get-reply-to of the IBM Connections blog post comment from + * blog ATOM entry document. + * + * @method getReplyTo + * @return {String} Entity Id of the entity in reply to which comment was created + */ + getReplyTo : function() { + return this.getAsString("replyTo"); + }, + + /** + * Return the postUuid of the blog post on which comment was created. + * + * @method getPostUuid + * @return {String} Blog post Id of the entity in reply to which comment was created + */ + getPostUuid : function() { + var postUuid = this.getAsString("blogPostUuid"); + if(postUuid){ + return postUuid; + } + var postUuidPrefix = "urn:lsid:ibm.com:blogs:entry-"; + postUuid = this.getAsString("replyTo"); + if(postUuid && postUuid.indexOf(postUuidPrefix) != -1){ + postUuid = postUuid.substring(postUuidPrefix.length, postUuid.length); + } + return postUuid; + }, - setFields : function(fields) { - this._fields["fields"] = fields; - }, + /** + * Sets blog post id of IBM Connections blog post comment. + * + * @method setPostUuid + * @param {String} blogPostUuid of the comment's blog post + */ + setPostUuid : function(blogPostUuid) { + return this.setAsString("blogPostUuid", blogPostUuid); + }, + + /** + * Return the bloghandle of the blog post on which comment was created. + * + * @method getBlogHandle + * @return {String} Blog handle of the entity in reply to which comment was created + */ + getBlogHandle : function() { + var blogHandle = this.getAsString("blogHandle"); + if(blogHandle){ + return blogHandle; + } + var commentUrlAlternate = this.getAsString("alternateUrl"); + var blogHandle = this.service._extractBlogHandle(commentUrlAlternate); + return blogHandle; + }, - /** - * Loads the ActivityNode object with the atom entry associated with the activity node. By default, a network call is made to load the atom - * entry document in the ActivityNode object. - * - * @method load - */ - load : function() { - var promise = this.service.validateField("activityNodeUuid", this.getActivityNodeUuid()); - if (promise) { - return promise; - } - var requestArgs = { - "activityNodeUuid" : this.getActivityNodeUuid() - }; - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - var self = this; - var callbacks = { - createEntity : function(service, data, response) { - self.setData(data, response); - return self; - } - }; - return this.service.getEntity(consts.AtomActivityNode, options, this.getActivityNodeUuid(), callbacks); - }, - - /** - * Creats an entry in an activity, such as a to-do item or to add a reply to another entry, send an Atom entry document containing the new - * activity node of the appropriate type to the parent activity's node list. - * - * @mehtod create - * @param {String} activityUuid - * @returns {Object} ActivityNode - */ - create : function(activityUuid) { - return this.service.createActivityNode(activityUuid, this); - }, + /** + * Sets blog handle of IBM Connections blog post comment. + * + * @method setBlogHandle + * @param {String} blogHandle of the comments's blog + */ + setBlogHandle : function(blogHandle) { + this.setAsString("blogHandle", blogHandle); + return this.setAsString("blogHandle", blogHandle); + }, + + /** + * Return the Trackback Title of the IBM Connections blog post comment from + * blog ATOM entry document. + * + * @method getTrackbackTitle + * @return {String} TrackbackTitle of the Blog post comment + */ + getTrackbackTitle : function() { + return this.getAsDate("trackbacktitle"); + }, - /** - * updates an activity node entry, sends a replacement Atom entry document containing the modified activity node to the existing activity's edit - * web address. - * @method update - * @returns {Object} activityNode - */ - update : function() { - return this.service.updateActivityNode(this); - }, + /** + * Gets an source of IBM Connections Blog post. + * + * @method getSource + * @return {Object} Source of the blog post + */ + getSource : function() { + return this.getAsObject([ "sourceId", "sourceTitle", "sourceLink", "sourceLinkAlternate" ]); + }, - /** - * Deletes an activity node entry, sends an HTTP DELETE method to the edit web address specified for the node. - * - * @method deleteActivityNode - */ - deleteActivityNode : function() { - return this.service.deleteActivityNode(this.getActivityNodeUuid()); - }, - /** - * Restores a deleted entry to an activity, sends a HTTP PUT request to the edit web address for the node defined in the trash feed. This moves - * the entry from the trash feed to the user's activity node list. - * - * @method restoreActivityNode - */ - restore : function() { - return this.service.restoreActivityNode(this.getActivityNodeUuid()); - }, - - /** - * Changes certain activity entries from one type to another. - * - *
     
    -				 * The following types of entries can be changed to other types:
    -				 * chat
    -				 * email
    -				 * entry
    -				 * reply
    -				 * todo<
    -				 * 
    - * - * @method changeEntryType - * @param {String} newType - * @returns {Object} ActivityNode - */ - changeEntryType : function(newType) { - this.setType(newType); - return this.service.changeEntryType(this); - }, - - /** - * Moves a standard entry or a to-do entry to a section in an activity, send an updated Atom entry document to the parent activity's node list. - * - * @method moveToSection - * @param {String} sectionId - * @param {String} [newTitle] - * @returns {Object} ActivityNode - */ - moveToSection : function(sectionId, newTitle) { - return this.service.moveEntryToSection(this, sectionId); - } + /** + * Loads the blog comment object associated with the + * blog. By default, a network call is made to load the atom entry + * document in the comment object. + * + * @method load + * @param {Object} [args] Argument object + */ + load : function(blogHandle, commentUuid, args) { + var promise = this.service._validateUuid(commentUuid); + if (promise) { + return promise; + } + + var self = this; + var callbacks = { + createEntity : function(service,data,response) { + self.setDataHandler(new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommentXPath + })); + return self; + } + }; + var requestArgs = lang.mixin({}, args || {}); + var options = { + handleAs : "text", + query : requestArgs + }; + var url = null; + url = this.service.constructUrl(consts.AtomBlogCommentEditRemove, null, { + blogHandle : blogHandle, + commentUuid : commentUuid }); + return this.service.getEntity(url, options, commentUuid, callbacks); + }, - /** - * Member class represents an entry for a members feed returned by the Connections REST API. - * - * @class Member - * @namespace sbt.connections - */ - var Member = declare(AtomEntity, { - - xpath : consts.MemberXPath, - namespaces : consts.ActivityNamespaces, - categoryScheme : null, - - /** - * Sets template for category Scheme - */ - setCategoryScheme : function() { - this.categoryScheme = stringUtil.transform(MemberCategory, this, transformer, this); - }, - - /** - * Return the member Id - * - * @method getMemberId - * @return {String} ID of the result - */ - getMemberId : function() { - return extractId(this.getId(), "&memberid="); - }, + /** + * Remove this blog post comment + * + * @method remove + * @param {Object} [args] Argument object + */ + remove : function(args) { + return this.service.deleteComment(this.getCommentUuid(), args); + }, + + /** + * Save this blog post comment + * + * @method save + * @param {Object} [args] Argument object + */ + save : function(args) { + return this.service.createPost(this, args); + } - /** - * Get role - * @method getRole - * @returns {String} role - */ - getRole : function() { - return this.getAsString("role"); - }, + }); + + /** + * Recommender class represents a recommender of a Blogs post returned by the + * Connections REST API. + * + * @class Recommender + * @namespace sbt.connections + */ + var Recommender = declare(AtomEntity, { - /** - * Set role - * @method setRole - * @param {String} role - * @returns - */ - setRole : function(role) { - return this.setAsString("role", role); - }, - - /** - * getPermissions - * @method getPermissions - * @returns {Array} permissions - */ - getPermissions : function() { - var permissions = this.getAsString("permissions"); - if (permissions) { - return permissions.split(", "); - } - return permissions; - }, - - /** - * getCategory - * @method getCategory - * @returns {String} category - */ - getCategory : function() { - this.getAsString("category"); - }, + xpath : consts.RecommendersXPath, + categoryScheme : CategoryPerson, + namespaces : consts.BlogNamespaces, + + /** + * Construct a Blog Post Recommender. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, - /** - * setCategory - * @method setCategory - * @param {String} category - */ - setCategory : function(category) { - this.setAsString("category", category); - }, - - /** - * get contributor user ID - * @method getUserId - * @returns {String} userId - */ - getUserId : function() { - return this.getContributor().userid; - }, + /** + * Return the value of IBM Connections blog post recommender id + * + * @method getRecommenderUuid + * @return {String} id of the blog post recommender + */ + getRecommenderUuid : function() { + var recommenderUuidPrefix = "urn:lsid:ibm.com:blogs:person-"; + var recommenderUuid = this.getAsString("recommenderUuid"); + if(recommenderUuid && recommenderUuid.indexOf(recommenderUuidPrefix) != -1){ + recommenderUuid = recommenderUuid.substring(recommenderUuidPrefix.length, recommenderUuid.length); + } + return recommenderUuid; + } + + }); + + /* + * Callbacks used when reading a feed that contains blog entries. + */ + var ConnectionsBlogFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BlogFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new Blog({ + service : service, + data : data + }); + } + }; + + /* + * Callbacks used when reading a feed that contains forum recommendation entries. + */ + var RecommendBlogPostCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.ForumsFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new BlogPost({ + service : service, + data : data + }); + } + }; + + /* + * Callbacks used when reading a feed that contains blog entries. + */ + var ConnectionsTagsFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.TagsXPath + }); + }, + createEntity : function(service,data,response) { + var entryHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.TagsXPath + }); + return new Tag({ + service : service, + id : entryHandler.getEntityId(), + dataHandler : entryHandler + }); + } + }; + + /* + * Callbacks used when reading a feed that contains blog entries. + */ + var ConnectionsBlogPostsCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BlogFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new BlogPost({ + service : service, + data : data + }); + } + }; + + /* + * Callbacks used when reading a feed that contains blog entries. + */ + var ConnectionsBlogPostRecommendersCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, +// xpath : consts.RecommendersFeedXpath + xpath : consts.BlogFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new Recommender({ + service : service, + data : data + }); + } + }; + /* + * Callbacks used when reading a feed that contains blog entries. + */ + var ConnectionsBlogPostCommentsCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BlogFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new Comment({ + service : service, + data : data + }); + } + }; + /** + * BlogService class. + * + * @class BlogService + * @namespace sbt.connections + */ + var BlogService = declare(ConnectionsService, { + + contextRootMap: { + blogs : "blogs" + }, + + serviceName : "blogs", + + /** + * Default blog homepage handle name if there is not one specified in sbt.properties. + * @returns {String} + */ + handle : "homepage", + + /** + * Constructor for BlogService + * + * @constructor + * @param args + */ + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } + this.handle = this.endpoint.serviceMappings.blogHomepageHandle?this.endpoint.serviceMappings.blogHomepageHandle:this.handle; + }, + + /** + * Get the All Blogs feed to see a list of all blogs to which the + * authenticated user has access. + * + * @method getAllBlogs + * + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of all blogs. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getAllBlogs : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogsAll); + return this.getEntities(url, options, this.getBlogFeedCallbacks()); + }, - /** - * Sets the contributor user ID - * @method setUserId - * @param {String} userId - */ - setUserId : function(userId) { - return this.setAsString("contributorUserid", userId); - }, - - // Overriding the below methods since they are not relevant for Activity Member Entity in Post Data - - /** - * Return title element to be included in post data for this ATOM entry. - * - * @method createTitle - * @returns {String} - */ - createTitle : function() { - return ""; - }, - + /** + * Get the My Blogs feed to see a list of the blogs to which the + * authenticated user is a member. + * + * @method getMyBlogs + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of my blogs. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getMyBlogs : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogsMy); + return this.getEntities(url, options, this.getBlogFeedCallbacks()); + }, - /** - * Return content element to be included in post data for this ATOM entry. - * - * @method createContent - * @returns {String} - */ - createContent : function() { - return ""; - }, - - /** - * Return summary element to be included in post data for this ATOM entry. - * - * @method createSummary - * @returns {String} - */ - createSummary : function() { - return ""; - }, - - // Overriding the above methods since they are not relevant for Activity Member Entity in Post Data - - /** - * Return extra entry data to be included in post data for this entity. - * - * @returns {String} - */ - createEntryData : function() { - var postData = ""; - postData += stringUtil.transform(RoleTmpl, this, transformer, this); - return stringUtil.trim(postData); - }, + /** + * Get the featured posts feed to find the blog posts that have had the most activity across + * all of the blogs hosted by the Blogs application within the past two weeks + * + * @method getFeaturedBlogs + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of my blogs. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getFeaturedBlogs : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogsFeatured); + return this.getEntities(url, options, this.getBlogFeedCallbacks()); + }, + /** + * Get the featured posts feed to find the blog posts that have had the most activity across + * all of the blogs hosted by the Blogs application within the past two weeks + * + * @method getFeaturedPosts + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of my blogs. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getFeaturedPosts : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogsPostsFeatured); + return this.getEntities(url, options, this.getBlogPostsCallbacks()); + }, - /** - * Loads the Member object with the atom entry part with the activity. By default, a network call is made to load the atom entry document in the - * Member object. - * - * @method load - * @param {Stirng} activityUuid The Activity ID - */ - load : function(activityUuid) { + /** + * Get a feed that includes all of the recommended blog posts + * in all of the blogs hosted by the Blogs application. + * + * @method getRecommendedPosts + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of my blogs. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getRecommendedPosts : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogsPostsRecommended); + return this.getEntities(url, options, this.getBlogPostsCallbacks()); + }, + + /** + * Get the blog posts feed to see a list of posts for all blog . + * + * @method getAllBlogPosts + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of all blogs posts. The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getAllBlogPosts : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomEntriesAll); + return this.getEntities(url, options, this.getBlogPostsCallbacks()); + }, + + /** + * Get the blog posts feed to see a list of posts for a blog . + * + * @method getBlogPosts + * @param {String} blogHandle Handle of the blog of which posts are to be get. + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of posts of a blog . The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getBlogPosts : function(blogHandle, args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this.constructUrl(consts.AtomBlogEntries, null, { + blogHandle : blogHandle + }); + return this.getEntities(url, options, this.getBlogPostsCallbacks()); + }, + + /** + * Get the blog posts recommenders feed to see a list of recommenders of a blog post. + * + * @method getBlogPostRecommenders + * @param {Object} object representing a blog post. + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of posts of a blog . The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getBlogPostRecommenders : function(blogPost, args) { + var post = this._toBlogPost(blogPost); + var promise = this._validateBlogPost(post); + if (promise) { + return promise; + } + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this.constructUrl(consts.AtomRecommendBlogPost, null, { + postUuid : post.getBlogPostUuid(), + blogHandle : post.getBlogHandle() + }); + return this.getEntities(url, options, this.getBlogPostRecommendersCallbacks()); + }, + + /** + * Get the blog comments feed to see a list of comments for all blogs . + * + * @method getAllBlogComments + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of posts of a blog . The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getAllBlogComments : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogCommentsAll); + return this.getEntities(url, options, this.getBlogPostCommentsCallbacks()); + }, + + /** + * Get the blog comments feed to see a list of comments for a blog post . + * + * @method getBlogPostComments + * @param {blogHandle} Handle of the blog of which Comments are to be get + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of posts of a blog . The + * parameters must be exactly as they are supported by IBM + * Connections like ps, sortBy etc. + */ + getBlogComments : function(blogHandle, args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this.constructUrl(consts.AtomBlogComments, null, { + blogHandle : blogHandle + }); + return this.getEntities(url, options, this.getBlogPostCommentsCallbacks()); + }, + + /** + * Retrieve a blog instance. + * + * @method getBlog + * @param {String } blogUuid + * @param {Object} args Object containing the query arguments to be + * sent (defined in IBM Connections Blogs REST API) + */ + getBlog : function(blogUuid, args) { + var blog = new Blog({ + service : this, + _fields : { blogUuid : blogUuid } + }); + return blog.load(args); + }, - var promise = this.service.validateField("memberId", this.getMemberId()); - if (!promise) { - promise = this.service.validateField("activityUuid", activityUuid); - } - if (promise) { - return promise; - } - var options = { - method : "GET", - handleAs : "text" - }; + /** + * Create a blog by sending an Atom entry document containing the + * new blog. + * + * @method createBlog + * @param {String/Object} blogOrJson Blog object which denotes the blog to be created. + * @param {Object} [args] Argument object + */ + createBlog : function(blogOrJson,args) { + var blog = this._toBlog(blogOrJson); + var promise = this._validateBlog(blog, false, args); + if (promise) { + return promise; + } - var url = this.service.constructUrl(consts.AtomActivitiesMember, null, { - "activityUuid" : activityUuid, - "memberId" : this.getMemberId() - }); - - var self = this; - var callbacks = { - createEntity : function(service, data, response) { - // This is required because the feed starts from insttead of - var feedHandler = new XmlDataHandler({ - data : data, - namespaces : consts.ActivityNamespaces, - xpath : consts.MemberXPath - }); - var entry = feedHandler.data; - self.setData(entry, response); - return self; - } - }; - - return this.service.getEntity(url, options, this.getMemberId(), callbacks); - }, - /** - * Adds a member to the access control list of an activity, sends an Atom entry document containing the new member to the access control list - * feed. You can only add one member per post. - * @method addToActivity - * @param {String} activityUuid - */ - addToActivity : function(actvitiyUuid) { - return this.service.addMember(actvitiyUuid, this); - }, + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + if (data) { + var dataHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BlogXPath + }); + blog.setDataHandler(dataHandler); + } + blog.setData(data); + return blog; + }; - /** - * Removes a member from the acl list for an application, use the HTTP DELETE method. - * @method removeFromActivity - * @param {String} activityUuid - */ - removeFromActivity : function(activityUuid) { - return this.service.deleteMember(activityUuid, this.getMemberId()); - }, + var options = { + method : "POST", + query : args || {}, + headers : consts.AtomXmlHeaders, + data : this._constructBlogPostData(blog) + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogCreate); + return this.updateEntity(url, options, callbacks, args); + }, - /** - * Updates a member in the access control list for an application, sends a replacement member entry document in Atom format to the existing ACL - * node's edit web address. - * @method updateInActivity - * @param {String} activityUuid - */ - updateInActivity : function(activityUuid) { - return this.service.updateMember(activityUuid, this); - } + /** + * Update a blog by sending a replacement blog entry document + * to the existing blog's edit web address. + * All existing blog entry information will be replaced with the new data. To avoid + * deleting all existing data, retrieve any data you want to retain first, and send it back + * with this request. For example, if you want to add a new tag to a blog entry, retrieve + * the existing tags, and send them all back with the new tag in the update request. + * + * @method updateBlog + * @param {String/Object} blogOrJson Blog object + * @param {Object} [args] Argument object + */ + updateBlog : function(blogOrJson,args) { + var blog = this._toBlog(blogOrJson); + var promise = this._validateBlog(blog, true, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + var blogUuid = blog.getBlogUuid(); + if (data) { + var dataHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BlogXPath + }); + blog.setDataHandler(dataHandler); + } + blog.setBlogUuid(blogUuid); + return blog; + }; + var requestArgs = lang.mixin({}, args || {}); + + var options = { + method : "PUT", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : this._constructBlogPostData(blog) + }; + var blogUuid = blog.getBlogUuid(); + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogEditDelete, { + blogUuid : blogUuid }); + return this.updateEntity(url, options, callbacks, args); + }, - /* - * Callbacks used when reading a feed that contains Tag entries. - */ - var TagFeedCallbacks = { - createEntities : function(service, data, response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.TagXPath - }); - }, - createEntity : function(service, data, response) { - var entryHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.TagXPath - }); - return new Tag({ - service : service, - dataHandler : entryHandler - }); - } - }; - - /* - * Callbacks used when reading a feed that contains activities entries. - */ - var MemberFeedCallbacks = { - createEntities : function(service, data, response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.ActivitiesFeedXPath - }); - }, - createEntity : function(service, data, response) { - var entry = null; - if (typeof data == "object") { - entry = data; - } else { - var feedHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.MemberXPath - }); - entry = feedHandler.data; - } - var entryHandler = new XmlDataHandler({ - data : entry, - namespaces : consts.Namespaces, - xpath : consts.MemberXPath - }); - return new Member({ - service : service, - dataHandler : entryHandler - }); - } - }; + /** + * Delete a blog, use the HTTP DELETE method. + * + * @method deleteBlog + * @param {String} blogUuid blog id of the blog or the blog object (of the blog to be deleted) + * @param {Object} [args] Argument object + */ + deleteBlog : function(blogUuid,args) { + var promise = this._validateBlogUuid(blogUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({}, args || {}); + + var options = { + method : "DELETE", + query : requestArgs, + handleAs : "text" + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogEditDelete, { + blogUuid : blogUuid + }); + return this.deleteEntity(url, options, blogUuid); + }, + + /** + * Retrieve a blog post instance. + * + * @method getBlogPost + * @param {String} blogPostUuid blog post id + * @param {Object} args Object containing the query arguments to be + * sent (defined in IBM Connections Blogs REST API) + */ + getBlogPost : function(blogPostUuid, args) { + var blogPost = new BlogPost({ + service : this, + _fields : { postUuid : blogPostUuid } + }); + return blogPost.load(args); + }, - /* - * Callbacks used when reading a feed that contains activities entries. - */ - var ActivityFeedCallbacks = { - createEntities : function(service, data, response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.ActivityNamespaces, - xpath : consts.ActivitiesFeedXPath - }); - }, - createEntity : function(service, data, response) { - return new Activity({ - service : service, - data : data - }); - } - }; + /** + * Retrieve a list of comments for the specified entry in the specified blog. + * + * @method getEntryComments + * @param {String} blogHandle blog handle + * @param {String} entryAnchor entry anchor + * @param {Object} args Object containing the query arguments to be + * sent (defined in IBM Connections Blogs REST API) + */ + getEntryComments : function(blogHandle, entryAnchor, args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this.constructUrl(consts.AtomBlogEntryComments, null, { + blogHandle : blogHandle, + entryAnchor : entryAnchor + }); + return this.getEntities(url, options, this.getBlogPostCommentsCallbacks()); + }, - /* - * Callbacks used when reading a feed that contains activities nodes and activity entries. - */ - var ActivityNodeFeedCallbacks = { - createEntities : function(service, data, response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.ActivityNamespaces, - xpath : consts.ActivitiesFeedXPath - }); - }, - createEntity : function(service, data, response) { - var entry = null; - if (typeof data == "object") { - entry = data; - } else { - var feedHandler = new XmlDataHandler({ - data : data, - namespaces : consts.ActivityNamespaces, - xpath : consts.ActivityNodeXPath - }); - entry = feedHandler.data; - } - return new ActivityNode({ - service : service, - data : entry - }); - } - }; + /** + * Create a blog post by sending an Atom entry document containing the + * new blog post. + * + * @method createPost + * @param {String/Object} postOrJson Blog post object which denotes the blog post to be created. + * @param {Object} [args] Argument object + */ + createPost : function(postOrJson, args) { + var post = this._toBlogPost(postOrJson); + var promise = this._validateBlog(post, false, args); + if (promise) { + return promise; + } - /** - * ActivityService class which provides wrapper APIs to the Activities application of IBM© Connections which enables a team to collect, organize, - * share, and reuse work related to a project goal. The Activities API allows application programs to create new activities, and to read and modify - * existing activities. - * - * @class ActivityService - * @namespace sbt.connections - */ - var ActivityService = declare(ConnectionsService, { + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + if (data) { + var dataHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BlogPostXPath + }); + post.setDataHandler(dataHandler); + } + post.setData(data); + return post; + }; - contextRootMap : { - activities : "activities" - }, - - serviceName : "activities", + var options = { + method : "POST", + query : args || {}, + headers : consts.AtomXmlHeaders, + data : this._constructBlogPostPostData(post) + }; + var url = null; + url = this.constructUrl(consts.AtomBlogPostCreate, null, { + blogHandle : postOrJson.getBlogHandle() + }); + return this.updateEntity(url, options, callbacks, args); + }, - /** - * Constructor for ActivitiesService - * - * @constructor - * @param args - */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } - }, + /** + * Update a post by sending a replacement post entry document + * to the existing post's edit web address. + * All existing post entry information will be replaced with the new data. To avoid + * deleting all existing data, retrieve any data you want to retain first, and send it back + * with this request. For example, if you want to add a new tag to a post entry, retrieve + * the existing tags, and send them all back with the new tag in the update request. + * + * @method updateBost + * @param {String/Object} BlogPost object + * @param {Object} [args] Argument object + */ + updatePost : function(postOrJson, args) { + var post = this._toBlogPost(postOrJson); + var promise = this._validateBlogPost(post, true, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + var postUuid = post.getBlogPostUuid(); + if (data) { + var dataHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.BlogPostXPath + }); + post.setDataHandler(dataHandler); + } + post.setBlogPostUuid(postUuid); + return post; + }; - /** - * Get a list of all active activities that match a specific criteria. - * - * @method getMyActivitiesU - * @param {Object} [requestArgs] Optional arguments like ps, page, asc etc. - * @returns {Array} Activity array - */ - getMyActivities : function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; + var requestArgs = lang.mixin({}, args || {}); + + var options = { + method : "PUT", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : this._constructBlogPostPostData(post) + }; + var url = null; + url = this.constructUrl(consts.AtomBlogPostEditDelete, null, { + postUuid : post.getBlogPostUuid(), + blogHandle : post.getBlogHandle() + }); + return this.updateEntity(url, options, callbacks, args); + }, - return this.getEntities(consts.AtomActivitiesMy, options, ActivityFeedCallbacks); - }, + /** + * Recommend a post + * + * @method recommendPost + * @param {String/Object} BlogPost object + * @param {String} blogHandle Id of post + */ + recommendPost : function(blogPost) { + var post = this._toBlogPost(blogPost); + var promise = this._validateBlogPost(post); + if (promise) { + return promise; + } + var options = { + method : "POST", + headers : consts.AtomXmlHeaders + }; + var url = null; + url = this.constructUrl(consts.AtomRecommendBlogPost, null, { + postUuid : post.getBlogPostUuid(), + blogHandle : post.getBlogHandle() + }); + + return this.updateEntity(url, options, this.getRecommendBlogPostCallbacks()); + }, - /** - * Get a list of all active activity nodes that match a specific criteria in an activity. - * - * @method getActivityNodes - * @param {String} activityUuid The Activity I - * @param {Object} [requestArgs] Optional arguments like ps, page, asc etc. - * @returns {Array} ActivityNode array - */ - getActivityNodes : function(activityUuid, requestArgs) { - var args = lang.mixin(requestArgs || {}, { - "nodeUuid" : activityUuid - }); + /** + * Unrecommend a post + * + * @method unRecommendPost + * @param {String/Object} blogPost object + * @param {String} blogHandle Id of post + */ + unrecommendPost : function(blogPost) { + var post = this._toBlogPost(blogPost); + var promise = this._validateBlogPost(post); + if (promise) { + return promise; + } + var options = { + method : "DELETE", + headers : consts.AtomXmlHeaders + }; + var url = null; + url = this.constructUrl(consts.AtomRecommendBlogPost, null, { + postUuid : post.getBlogPostUuid(), + blogHandle : post.getBlogHandle() + }); + return this.deleteEntity(url, options, blogPost.getBlogPostUuid()); + }, - var options = { - method : "GET", - handleAs : "text", - query : args - }; + /** + * Delete a blog post, use the HTTP DELETE method. + * + * @method deletePost + * @param {String/Object} blogHandle handle of the blog(of which the post is to be deleted) + * @param {String/Object} postUuid post id of the blog post(of the blog post to be deleted) + * @param {Object} [args] Argument object + */ + deletePost : function(blogHandle, postUuid, args) { + var promise = this._validateUuid(postUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({}, args || {}); + + var options = { + method : "DELETE", + query : requestArgs, + handleAs : "text" + }; + var url = null; + url = this.constructUrl(consts.AtomBlogPostEditDelete, null, { + blogHandle : blogHandle, + postUuid : postUuid + }); + return this.deleteEntity(url, options, postUuid); + }, - return this.getEntities(consts.AtomActivityNodes, options, ActivityNodeFeedCallbacks); - }, + /** + * Delete a blog comment, use the HTTP DELETE method. + * + * @method deleteComment + * @param {String/Object} blogHandle handle of the blog(of which the post is to be deleted) + * @param {String/Object} comment id of the blog comment(of the blog comment to be deleted) + * @param {Object} [args] Argument object + */ + deleteComment : function(blogHandle, commentUuid, args) { + var promise = this._validateUuid(commentUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({}, args || {}); + + var options = { + method : "DELETE", + query : requestArgs, + handleAs : "text" + }; + var url = null; + url = this.constructUrl(consts.AtomBlogCommentEditRemove, null, { + blogHandle : blogHandle, + commentUuid : commentUuid + }); + return this.deleteEntity(url, options, commentUuid); + }, + + /** + * Create a comment post by sending an Atom entry document containing the + * new blog comment. + * + * @method createComment + * @param {String/Object} commentOrJson Blog comment object. + * @param {Object} [args] Argument object + */ + createComment : function(commentOrJson, args) { + var comment = this._toComment(commentOrJson); + var promise = this._validateComment(comment); + if (promise) { + return promise; + } - /** - * Search for content in all of the activities, both completed and active, that matches a specific criteria. - * - * @method getAllActivities - * @param requestArgs - * @returns {Array} Activity array - */ - getAllActivities : function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + if (data) { + var dataHandler = new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.CommentXPath + }); + comment.setDataHandler(dataHandler); + } + comment.setData(data); + return comment; + }; - return this.getEntities(consts.AtomActivitiesEverything, options, ActivityFeedCallbacks); - }, + var options = { + method : "POST", + query : args || {}, + headers : consts.AtomXmlHeaders, + data : this._constructCommentBlogPostData(comment) + }; + var url = null; + url = this.constructUrl(consts.AtomBlogCommentCreate, null, { + blogHandle : commentOrJson.getBlogHandle(), + postUuid : commentOrJson.getPostUuid() + }); + return this.updateEntity(url, options, callbacks, args); + }, + + /** + * Retrieve a blog comment, use the edit link for the blog entry + * which can be found in the my blogs feed. + * + * @method getComment + * @param {String } blogHandle + * @param {String } commentUuid + * @param {Object} args Object containing the query arguments to be + * sent (defined in IBM Connections Blogs REST API) + */ + getComment : function(blogHandle, commentUuid, args) { + var comment = new Comment({ + service : this, + _fields : { commentUuid : commentUuid } + }); + return comment.load(blogHandle, commentUuid, args); + }, - /** - * Search for a set of completed activities that match a specific criteria. - * - * @method getCompletedActivities - * @param {Object} [requestArgs] The optional arguments - * @returns {Array} Activity array - */ - getCompletedActivities : function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; + /** + * Get the tags feed to see a list of the tags for all blogs. + * + * @method getAllBlogTags + * @param {Object} [args] Object representing various parameters. + * The parameters must be exactly as they are supported by IBM + * Connections. + */ + getAllBlogTags : function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this._constructBlogsUrl(consts.AtomBlogsTags); + return this.getEntities(url, options, this.getTagsFeedCallbacks(), args); + }, + + /** + * Get the tags feed to see a list of the tags for a perticular blog. + * + * @method getBlogTags + * @param {String} blogHandle handle of the blog + * @param {Object} [args] Object representing various parameters + * that can be passed to get a feed of blog tags. The + * parameters must be exactly as they are supported by IBM + * Connections. + */ + getBlogTags : function(blogHandle, args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + var url = null; + url = this.constructUrl(consts.AtomBlogTags, null, { + blogHandle : blogHandle + }); + return this.getEntities(url, options, this.getTagsFeedCallbacks(), args); + }, + + /** + * Create a Blog object with the specified data. + * + * @method newBlog + * @param {Object} args Object containing the fields for the + * new blog + */ + newBlog : function(args) { + return this._toBlog(args); + }, + + /** + * Create a Blog Post object with the specified data. + * + * @method newBlogPost + * @param {Object} args Object containing the fields for the + * new post + */ + newBlogPost : function(args) { + return this._toBlogPost(args); + }, + + /** + * Create a Blog Post comment object with the specified data. + * + * @method newComment + * @param {Object} args Object containing the fields for the + * new comment + */ + newComment : function(args) { + return this._toComment(args); + }, + + /* + * Callbacks used when reading a feed that contains Blog entries. + */ + getBlogFeedCallbacks: function() { + return ConnectionsBlogFeedCallbacks; + }, + + /* + * Callbacks used when reading a feed that contains Blog entries. + */ + getTagsFeedCallbacks: function() { + return ConnectionsTagsFeedCallbacks; + }, + + /* + * Callbacks used when reading a feed that contains Blog entries. + */ + getRecommendBlogPostCallbacks: function() { + return RecommendBlogPostCallbacks; + }, + + /* + * Callbacks used when reading a feed that contains Blog entries. + */ + getBlogPostsCallbacks: function() { + return ConnectionsBlogPostsCallbacks; + }, + + /* + * Callbacks used when reading a feed that contains Blog entries. + */ + getBlogPostRecommendersCallbacks: function() { + return ConnectionsBlogPostRecommendersCallbacks; + }, + + /* + * Callbacks used when reading a feed that contains Blog post comments. + */ + getBlogPostCommentsCallbacks: function() { + return ConnectionsBlogPostCommentsCallbacks; + }, + + /* + * Return a Blog instance from Blog or JSON or String. Throws + * an error if the argument was neither. + */ + _toBlog : function(blogOrJsonOrString) { + if (blogOrJsonOrString instanceof Blog) { + return blogOrJsonOrString; + } else { + if (lang.isString(blogOrJsonOrString)) { + blogOrJsonOrString = { + blogUuid : blogOrJsonOrString + }; + } + return new Blog({ + service : this, + _fields : lang.mixin({}, blogOrJsonOrString) + }); + } + }, + + /* + * Return a BlogPost instance from BlogPost or JSON or String. Throws + * an error if the argument was neither. + */ + _toBlogPost : function(postOrJsonOrString) { + if (postOrJsonOrString instanceof BlogPost) { + return postOrJsonOrString; + } else { + if (lang.isString(postOrJsonOrString)) { + postOrJsonOrString = { + postUuid : postOrJsonOrString + }; + } + return new BlogPost({ + service : this, + _fields : lang.mixin({}, postOrJsonOrString) + }); + } + }, + + /* + * Return a Comment instance from Comment or JSON or String. Throws + * an error if the argument was neither. + */ + _toComment : function(commentOrJsonOrString) { + if (commentOrJsonOrString instanceof Comment) { + return commentOrJsonOrString; + } else { + if (lang.isString(commentOrJsonOrString)) { + commentOrJsonOrString = { + commentUuid : commentOrJsonOrString + }; + } + return new Comment({ + service : this, + _fields : lang.mixin({}, commentOrJsonOrString) + }); + } + }, - return this.getEntities(consts.AtomActivitiesCompleted, options, ActivityFeedCallbacks); - }, + /* + * Validate a blog UUID, and return a Promise if invalid. + */ + _validateBlogUuid : function(blogUuid) { + if (!blogUuid || blogUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected blogUuid."); + } + }, + + /* + * Validate a post, and return a Promise if invalid. + */ + _validateUuid : function(postUuid) { + if (!postUuid) { + return this.createBadRequestPromise("Invalid argument, blog post id must be specified."); + } + }, + + /* + * Validate a post, and return a Promise if invalid. + */ + _validateBlogPost : function(post) { + if (!post || !post.getTitle()) { + return this.createBadRequestPromise("Invalid argument, blog post with title must be specified."); + } + }, + + /* + * Validate a comment, and return a Promise if invalid. + */ + _validateComment : function(comment,checkUuid) { + if (!comment || !comment.getContent()) { + return this.createBadRequestPromise("Invalid argument, blog comment with content must be specified."); + } + }, - /** - * Retrieve an activity node entry, uses the edit link found in the corresponding activity node in the user's My Activities feed. - * - * @method getActivityNode - * @param {String} activityNodeUuid the ID of Activity Node - * @returns {Object} ActivityNode - */ - getActivityNode : function(activityNodeUuid) { - var promise = this.validateField("activityNodeUuid", activityNodeUuid); - if (promise) { - return promise; - } - var activityNode = this.newActivityNode(activityNodeUuid); - return activityNode.load(); - }, + /* + * Validate a blog, and return a Promise if invalid. + */ + _validateBlog : function(blog,checkUuid) { + if (!blog || !blog.getTitle()) { + return this.createBadRequestPromise("Invalid argument, blog with title must be specified."); + } + if (checkUuid && !blog.getBlogUuid()) { + return this.createBadRequestPromise("Invalid argument, blog with UUID must be specified."); + } + }, + + /* + * Construct a post data for a Blog + */ + _constructBlogPostData : function(blog) { + var transformer = function(value,key) { + if (key == "getTags") { + var tags = value; + value = ""; + for (var tag in tags) { + value += stringUtil.transform(CategoryTmpl, { + "tag" : tags[tag] + }); + } + } + return value; + }; + + var postData = stringUtil.transform(BlogTmpl, blog, transformer, blog); + return stringUtil.trim(postData); + }, + + /* + * Construct a post data for a Blog Post + */ + _constructBlogPostPostData : function(post) { + var transformer = function(value,key) { + if (key == "getTags") { + var tags = value; + value = ""; + for (var tag in tags) { + value += stringUtil.transform(CategoryTmpl, { + "tag" : tags[tag] + }); + } + } + return value; + }; + + var postData = stringUtil.transform(BlogPostTmpl, post, transformer, post); + return stringUtil.trim(postData); + }, + + /* + * Construct a post data for a Blog Post + */ + _constructCommentBlogPostData : function(comment) { + var transformer = function(value,key) { + return value; + }; + + var postData = stringUtil.transform(BlogCommentTmpl, comment, transformer, comment); + return stringUtil.trim(postData); + }, + + /* + * Extract Blog handle from comment source url + */ + _extractBlogHandle : function(source) { + var urlSuffix = "/entry/"; + source = source.substring(0,source.indexOf(urlSuffix)); + var bloghandle = source.substring(source.lastIndexOf("/")+1,source.length); + return bloghandle; + + }, + + /* + * Extract Blog handle from comment source url + */ + _constructBlogsUrl : function(url, urlParams) { + urlParams = lang.mixin({blogHomepageHandle : this.handle}, urlParams || {}); + return this.constructUrl(url, null, urlParams); + } + + }); + return BlogService; +}); - /** - * Retrieve an activity entry, uses the edit link found in the corresponding activity node in the user's My Activities feed. - * - * @method getActivity - * @param {String} activityUuid the ID of Activity - * @returns {Object} Activity - */ - getActivity : function(activityUuid) { - var promise = this.validateField("activityUuid", activityUuid); - if (promise) { - return promise; - } - var activity = this.newActivity(activityUuid); - return activity.load(); - }, +}, +'sbt/WPSProxy':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - /** - * Creats an entry in an activity, such as a to-do item or to add a reply to another entry, send an Atom entry document containing the new - * activity node of the appropriate type to the parent activity's node list. - * - * @mehtod createActivityNode - * @param {String} activityUuid - * @param {Object} activityNodeOrJson - * @returns {Object} ActivityNode - */ - createActivityNode : function(activityUuid, activityNodeOrJson) { - var promise = this.validateField("activityUuid", activityUuid); - if (!promise) { - promise = this.validateField("activityNodeOrJson", activityNodeOrJson); - } - if (promise) { - return promise; - } - var activityNode = this.newActivityNode(activityNodeOrJson); - activityNode.setActivityUuid(activityUuid); - activityNode.setCategoryScheme(); - var payload = activityNode.createPostData(); - var requestArgs = { - "activityUuid" : activityUuid - }; +/** + * Social Business Toolkit SDK to be used with WebSphere Portal server + * Definition of a proxy re-writer. + * + * @module sbt.Proxy + */ +define(['./declare','./lang','./pathUtil'],function(declare,lang,pathUtil) { - var options = { - method : "POST", - headers : consts.AtomXmlHeaders, - query : requestArgs, - data : payload - }; + /** + * Definition of the proxy module + * + * @class sbt.Proxy + * + */ + var Proxy = declare(null, { + + proxyUrl : null, + + constructor: function(args){ + lang.mixin(this, args); + }, + + rewriteUrl: function(baseUrl,serviceUrl,proxyPath) { + var u = serviceUrl; + if(this.proxyUrl) { + if(u.indexOf("http://")==0) { + u = "/http/"+u.substring(7); + } else if(u.indexOf("https://")==0) { + u = "/https/"+u.substring(8); + } - return this.updateEntity(consts.AtomCreateActivityNode, options, ActivityNodeFeedCallbacks); - }, + if(baseUrl.indexOf("http://")==0) { + baseUrl = "/http/"+baseUrl.substring(7); + } else if(baseUrl.indexOf("https://")==0) { + baseUrl = "/https/"+baseUrl.substring(8); + } + var networkUrl = pathUtil.concat(this.proxyUrl, baseUrl); + networkUrl = pathUtil.concat(networkUrl, serviceUrl); + return networkUrl; + } + return u; + } + }); + + return Proxy; - /** - * Creates an activity, sends an Atom entry document containing the new activity to the user's My Activities feed. - * - * @method createActivity - * @param {Object} activityOrJson - * @returns {Object} Activity - */ - createActivity : function(activityOrJson) { - var promise = this.validateField("activityOrJson", activityOrJson); - if (promise) { - return promise; - } - var activity = this.newActivity(activityOrJson); - activity.setType(consts.ActivityNodeTypes.Activity); - activity.setCategoryScheme(); - var payload = activity.createPostData(); +}); +}, +'sbt/connections/controls/ConnectionsGridRenderer':function(){ +require({cache:{ +'url:sbt/controls/grid/templates/GridPager.html':"
    \r\n\t
    \r\n\t
    ${pagingResults}
    \r\n\t
      \r\n\t\t
    • \r\n\t\t\t${nls.previous}\r\n\t\t\t${nls.previous}\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t${nls.next}\r\n\t\t\t${nls.next}\r\n\t\t
    • \r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t
    \r\n
    \r\n", +'url:sbt/controls/grid/bootstrap/templates/GridPager.html':"
    \r\n\t
      \r\n\t\t
    • \r\n\t\t\t${nls.previous}\r\n\t\t\t${nls.previous}\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t${pagingResults}\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t${nls.next}\r\n\t\t\t${nls.next}\r\n\t\t
    • \r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t
    \r\n
    \r\n\r\n\r\n", +'url:sbt/controls/grid/templates/GridSorter.html':"
    \r\n\t
      \r\n\t\t
    • ${nls.sortBy}
    • \r\n\t\t${sortAnchors}\r\n\t
    \r\n
    \r\n", +'url:sbt/controls/grid/bootstrap/templates/GridSorter.html':"
    \r\n\t
    \r\n\t\t${nls.sortBy}\r\n\t\t
      \r\n\t\t\t${sortAnchors}\r\n\t\t
    \r\n\t
    \r\n
    ", +'url:sbt/controls/grid/templates/SortAnchor.html':"
  • \r\n\t${title}\r\n
  • \r\n", +'url:sbt/controls/grid/bootstrap/templates/SortAnchor.html':"
  • \r\n\t ${title}\r\n
  • ", +'url:sbt/controls/grid/templates/GridFooter.html':"
    \r\n\t
      \r\n\t\tShow:\r\n\t\t
    • \r\n\t\t\t10\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t25\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t50\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t100\r\n\t\t
    • ${nls.items}\r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t
    \r\n
    \r\n
    \r\n\t${nls.feed}\r\n
    ", +'url:sbt/controls/grid/bootstrap/templates/GridFooter.html':"
    \r\n
    \r\n\t\r\n\t\tShow:\r\n\t\t\r\n\t\t\t10\r\n\t\t|\r\n\t\t\r\n\t\t\t25\r\n\t\t|\r\n\t\t\r\n\t\t\t50\r\n\t\t|\r\n\t\t\r\n\t\t\t100\r\n\t\t ${nls.items}\r\n\t\r\n
    \r\n
    \r\n\t${nls.feed}\r\n
    \r\n
    "}}); +/* + * © 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. + */ - var options = { - method : "POST", - headers : consts.AtomXmlHeaders, - data : payload - }; +/** + * + */ +define([ "../../declare", "../../controls/grid/GridRenderer", + "../../text!../../controls/grid/templates/GridPager.html", + "../../text!../../controls/grid/bootstrap/templates/GridPager.html", + "../../text!../../controls/grid/templates/GridSorter.html", + "../../text!../../controls/grid/bootstrap/templates/GridSorter.html", + "../../text!../../controls/grid/templates/SortAnchor.html", + "../../text!../../controls/grid/bootstrap/templates/SortAnchor.html", + "../../i18n!./nls/ConnectionsGridRenderer", + "../../text!../../controls/grid/templates/GridFooter.html", + "../../text!../../controls/grid/bootstrap/templates/GridFooter.html", - return this.updateEntity(consts.AtomActivitiesMy, options, ActivityFeedCallbacks); - }, + "../../lang"], + function(declare, GridRenderer, GridPager,BootstrapGridPager, + GridSorter,BootstrapGridSorter, SortAnchor,BootstrapSortAnchor, + nls, GridFooter,BootstrapGridFooter,lang) { - _validateActivityNode : function(activityNode, checkUuid, checkType) { - if (checkUuid && !activityNode.getActivityNodeUuid()) { - return this.createBadRequestPromise("Invalid argument, activity node with UUID must be specified."); - } - if (checkType && !activityNode.getType()) { - return this.createBadRequestPromise("Invalid argument, activity node with Type must be specified."); - } - }, + /** + * @module sbt.connections.controls.ConnectionsGridRenderer + * @class ConnectionsGridRenderer + * @namespace sbt.connections.controls + */ + var ConnectionsGridRenderer = declare(GridRenderer, { + + /**Strings used in the grid*/ + nls : {}, + /**CSS class for tables*/ + tableClass : "lotusTable", + /**CSS Class for empty icon*/ + emptyClass : "lconnEmpty", + /**CSS Class for an error on an icon*/ + errorClass : "lconnEmpty", + /**The css class to use when the grid is loading,null here as an image is used instead*/ + loadingClass : "", + /**The loading image*/ + loadingImgClass : "lotusLoading", + /**The css class for the first row of the grid*/ + firstClass : "lotusFirst", + /**CSS classes for sorting*/ + defaultSortClass : "lotusActiveSort lotusDescending", + ascendingSortClass : "lotusActiveSort lotusAscending", + descendingSortClass : "lotusActiveSort lotusDescending", + /**The HTML template to use to show paging (moving forward and backward through sets of results)*/ + pagerTemplate : GridPager, + /**The bootstrap pager template*/ + bootstrapPagerTemplate: BootstrapGridPager, + /**The HTML template to use to show the grid footer */ + footerTemplate : GridFooter, + /**The bootstrap footer template*/ + bootstrapFooterTemplate: BootstrapGridFooter, + /**The HTML template to show sorting options*/ + sortTemplate : GridSorter, + /**The bootstrap sorter template*/ + bootstrapSortTemplate: BootstrapGridSorter, + /**The HTML template for sort Anchors*/ + sortAnchor : SortAnchor, + /**The bootstrap html sorting anchor template */ + bootstrapSortAnchor: BootstrapSortAnchor, + + /** + * Merge this class with the GridRenderer Class + * @method constructor + * @param args + */ + constructor : function(args) { + if(!this.grid.tableClass){ + if(this.grid.theme == "bootstrap"){ + this.tableClass = "table"; + } + } + lang.mixin(this, args); + this.nls = lang.mixin(nls, this._nls); + } - _validateActivity : function(activity, checkUuid) { - if (checkUuid && !activity.getActivityUuid()) { - return this.createBadRequestPromise("Invalid argument, activity with UUID must be specified."); - } - }, - /** - * updates an activity node entry, sends a replacement Atom entry document containing the modified activity node to the existing activity's edit - * web address. - * @method updateActivityNode - * @param {Object} activityNodeOrJson ActivityNode or Json Object with Uuid populated - * @returns {Object} ActivityNode - */ - updateActivityNode : function(activityNodeOrJson) { - var promise = this.validateField("activityNodeOrJson", activityNodeOrJson); - if (promise) { - return promise; - } - var newActivityNode = this.newActivityNode(activityNodeOrJson); - promise = this._validateActivityNode(newActivityNode, true); - if (promise) { - return promise; - } - return this._update(newActivityNode, ActivityNodeFeedCallbacks); - }, + }); - /** - * Updates an activity, send a replacement Atom Entry document containing the modified activity to the existing activity's edit URL - * @method updateActivity - * @param {Object} activityOrJson Activity or Json Object - * @returns {Object} Activity - */ - updateActivity : function(activityOrJson) { - var promise = this.validateField("activityOrJson", activityOrJson); - if (promise) { - return promise; - } - var newActivity = this.newActivity(activityOrJson); - promise = this._validateActivity(newActivity, true); - if (promise) { - return promise; - } - return this._update(activityOrJson, ActivityFeedCallbacks); - }, + return ConnectionsGridRenderer; +}); +}, +'url:sbt/connections/controls/search/templates/StatusUpdateExtraHeader.html':"
    \r\n \r\n ${authorUid}\r\n \r\n
    \r\n", +'sbt/controls/grid/GridRenderer':function(){ +/* + * © 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. + */ - _update : function(activityOrActivityNode, callbacks) { - var promise = new Promise(); - var _this = this; - var uuid = extractId(activityOrActivityNode.getUuid()); - var update = function() { - activityOrActivityNode.setCategoryScheme(); - var payload = activityOrActivityNode.createPostData(); - var requestArgs = { - "activityNodeUuid" : uuid - }; - var options = { - method : "PUT", - headers : consts.AtomXmlHeaders, - query : requestArgs, - data : payload - }; - _this.updateEntity(consts.AtomActivityNode, options, callbacks).then(function(node) { - promise.fulfilled(node); - }, function(error) { - promise.rejected(error); - }); - }; - if (activityOrActivityNode.isLoaded()) { - update(); - } else { - var fields = activityOrActivityNode._fields; - activityOrActivityNode.load().then(function() { - activityOrActivityNode._fields = fields; - update(); - }, function(error) { - promise.rejected(error); - }); - } - return promise; - }, - /** - * Changes certain activity entries from one type to another. - * - *
     
    -				 * The following types of entries can be changed to other types:
    -				 * chat
    -				 * email
    -				 * entry
    -				 * reply
    -				 * todo<
    -				 * /pre>
    -				 * 
    -				 * @method changeEntryType
    -				 * @param {Object} activityNodeOrJson ActivityNode or Json object with Uuid and type populated
    -				 * @returns {Object} ActivityNode
    -				 */
    -				changeEntryType : function(activityNodeOrJson) {
    -					var promise = this.validateField("activityNodeOrJson", activityNodeOrJson);
    -					if (promise) {
    -						return promise;
    -					}
    -					var activityNode = this.newActivityNode(activityNodeOrJson);
    -					promise = this._validateActivityNode(activityNode, true, true);
    +/**
    + * 
    + */
    +define([ "../../declare", "../../dom", "../../lang"], 
    +         function(declare, dom, lang) {
     
    -					return this.updateActivityNode(activityNode);
    -				},
    +    /**
    +     * @module sbt.controls.grid.GridRenderer
    +     * @class  GridRenderer
    +     * @namespace  sbt.controls.grid
    +     */
    +    var GridRenderer = declare(null, {
    +        /**
    +         * Strings used in the grid
    +         */
    +            nls: null,
    +            
    +            /**
    +             * CSS class to be used for tables - see ConnectionsGridRenderer
    +             */
    +        tableClass: null,
    +        emptyClass: null,
    +        errorClass: null,
    +        loadingClass: null,
    +        loadingImgClass: null,
    +        grid: null,
    +        
    +        /**
    +         * Constructor function
    +         * @method - constructor
    +         */
    +        constructor: function(args,grid) {
    +        	
    +        	this.grid = grid;
    +        	lang.mixin(this, args);
    +           
    +        },
    +        
    +        /**
    +         * Function to render the Paging , sorting and the table
    +         * @method - render
    +         * @param grid - the grid
    +         * @param el - the grid DOM node
    +         * @param items - the items in the grid row, for example icon, displayName,email etc.
    +         * @param data - the data associated with the grid row
    +         */
    +        render: function(grid, el, items, data) {
    +           while (el.childNodes[0]) {
    +               dom.destroy(el.childNodes[0]);
    +           }
    +           if(!grid.theme || grid.theme == "oneui"){
    +        	   dom.addClass(el,"lotusui30");
    +        	   dom.addClass(el,"lotusui30_body");
    +           }
    +           var size = items.length;
    +           if (size === 0) {
    +              this.renderEmpty(grid, el);
    +           }
    +           else {
    +              this.renderPager(grid, el, items, data);
    +              this.renderSorter(grid, el, data);
    +              var container = null;
    +              if (!this.containerType || this.containerType == "table") {
    +                      container = this.renderTable(grid, el, items, data);
    +              } else {
    +                      container = this.renderList(grid, el, this.containerType, "");  
    +              }
    +              for (var i=0; i 1) ? "" : "display: none;";
    +        },
    +        
    +        /**Hides the back page label
    +         * @method - hidePreviousLabel
    +         * @return - A String used as a CSS style
    +         */
    +        hidePreviousLabel : function(grid,renderer,items,data) {
    +            return (data.start == 0) ? "" : "display: none;";
    +        },
    +        
    +        /**If there is only one page of results the user cannot move forward 
    +         * to the next page, this function hides the next link
    +         * @method - hideNextLink
    +         * @return - A String used as CSS style
    +         */
    +        hideNextLink : function(grid,renderer,items,data) {
    +            return (data.start + data.count < data.totalCount) ? "" : "display: none;";
    +        },
    +        
    +        /**
    +         * If there is only one page of results the user cannot move forward 
    +         * to the next page, this function hides the next label
    +         * @method - hideNextLabel
    +         * @return - A String used as CSS style
    +         */
    +        hideNextLabel : function(grid,renderer,items,data) {
    +            return (data.start + data.count >= data.totalCount) ? "" : "display: none;";
    +        },
    +        
    +        /**
    +         * A sort anchor is what the grid is sorted against.
    +         * For example sort by name, date etc. This function returns a string of HTML links
    +         * @method - sortAnchors
    +         * @param grid - the grid
    +         * @param renderer - the associated renderer
    +         * @param items - items contains a list of sort anchors, which will be substituted into the html
    +         * @returns {String} - a HTML string consisting of the various sort anchors
    +         */
    +        sortAnchors : function(grid,renderer,items) {
    +            if (items.list == undefined || items.list.length == 0) {
    +                return "";
    +            } else {
    +                var sortStr = "";
    +                for ( var i = 0; i < items.list.length; i++) {
    +                	if(grid.theme == "bootstrap"){
    +                		sortStr += this._substituteItem(this.bootstrapSortAnchor, grid, items.list[i], i, items);
    +                	}else{
    +                		sortStr += this._substituteItem(this.sortAnchor, grid, items.list[i], i, items);
    +                	}
    +                    
    +                }
    +                return sortStr;
    +            }
    +        },
    +
    +        /**
    +         * @method sortItemClass
    +         * @param grid
    +         * @param item
    +         * @param i
    +         * @param items
    +         * @returns
    +         */
    +        sortItemClass : function(grid,item,i,items) {
    +            return (i === 0 ? this.firstClass : "");
    +        },
    +        
    +        /**
    +         * Sets the CSS class for the sort anchor which is currently being used
    +         * Also sets CSS classes for whether the results are ascending or descending
    +         * @method - sortAnchorClass
    +         * @param grid - The Grid
    +         * @param item - the current sort anchor - for example "name"
    +         * @param i - the number of the grid row
    +         * @param items - all of the sort anchors
    +         * @returns - A CSS class
    +         */
    +        sortAnchorClass : function(grid,item,i,items) {
    +            if(item !== items.active.anchor) {
    +                return "";
    +            }
    +            
    +            if(items.active.isDesc) {
    +                return this.descendingSortClass;
    +            }
    +            else {
    +                return this.ascendingSortClass;
    +            }
    +        },
    +        
    +        /**
    +         * Converts the HTML template into a dom node and attaches it.
    +         * @method - rendeItem
    +         * @param grid - the grid
    +         * @param el - the current element
    +         * @param data - the data for the current row, ie name, last updated etc
    +         * @param item - the current item and its associated data
    +         * @param i - the number of the grid row
    +         * @param items - All of the elements & data for each row
    +         */
    +        renderItem : function(grid,el,data,item,i,items) {
    +            if (this.template) {
    +                var node;
    +                if (lang.isString(this.template)) {
    +                    var domStr = this._substituteItem(this.template, grid, item, i, items);
    +                    node = dom.toDom(domStr, el.ownerDocument);
    +                } else {
    +                    node = this.template.cloneNode(true);
    +                }
    +                el.appendChild(node);
    +                
    +                grid._doAttachEvents(el, item);
    +                grid._doAttachPoints(el,grid);
    +            }
    +        },
     
    -				/**
    -				 * Deletes an activity node entry, sends an HTTP DELETE method to the edit web address specified for the node.
    -				 * 
    -				 * @method deleteActivityNode
    -				 * @param {String} activityNodeUuid
    -				 */
    -				deleteActivityNode : function(activityNodeUuid) {
    -					var promise = this.validateField("activityNodeUuid", activityNodeUuid);
    -					if (promise) {
    -						return promise;
    -					}
    -					var requestArgs = {
    -						"activityNodeUuid" : activityNodeUuid
    -					};
    -					var options = {
    -						method : "DELETE",
    -						headers : consts.AtomXmlHeaders,
    -						query : requestArgs
    -					};
    +        // Internals
     
    -					return this.deleteEntity(consts.AtomActivityNode, options, activityNodeUuid);
    -				},
    +        /*
    +         * Does substitution of ${foo} type properties in template string
    +         */
    +        _substituteItem : function(template,grid,item,i,items) {
    +            var self = this;
    +            return grid._substitute(template, item, function(value,key) {
    +                if (typeof value == "undefined") {
    +                    // check the renderer for the property
    +                    value = lang.getObject(key, false, self);
    +                }
     
    -				/**
    -				 * Deletes an activity entry, sends an HTTP DELETE method to the edit web address specified for the node.
    -				 * 
    -				 * @method deleteActivity
    -				 * @param {String} activityUuid
    -				 */
    -				deleteActivity : function(activityUuid) {
    -					var promise = this.validateField("activityUuid", activityUuid);
    -					if (promise) {
    -						return promise;
    -					}
    -					return this.deleteActivityNode(activityUuid);
    -				},
    +                if (typeof value == 'function') {
    +                    // invoke function to return the value
    +                    try {
    +                        value = value.apply(self, [grid, item, i, items]);
    +                    } catch (ex) {
    +                        value = "ERROR:" + key + " " + ex;
    +                    }
    +                }
    +                
    +                if (typeof value == "undefined" && typeof item.getValue == 'function') {
    +                    // invoke function to return the value
    +                    try {
    +                        value = item.getValue(key);
    +                    } catch (ex) {
    +                        value = "ERROR:" + key + " " + ex;
    +                    }
    +                }
     
    -				/**
    -				 * Restores a deleted activity, use a HTTP PUT request. This moves the activity from the trash feed to the user's My Activities feed.
    -				 * 
    -				 * @method restoreActivity
    -				 * @param {String} activityUuid
    -				 */
    -				restoreActivity : function(activityUuid) {
    -					var promise = this.validateField("activityUuid", activityUuid);
    -					if (promise) {
    -						return promise;
    -					}
    -					var _this = this;
    -					promise = new Promise();
    -					this.getActivityNodeFromTrash(activityUuid).then(function(deleted) {
    -						return deleted;
    -					}).then(function(activity) {
    -						if (!activity.isDeleted()) {
    -							promise.rejected("Activity is not in Trash");
    -						} else {
    -							var requestArgs = {
    -								"activityNodeUuid" : activityUuid
    -							};
    -							activity.setCategoryScheme();
    -							var options = {
    -								method : "PUT",
    -								headers : consts.AtomXmlHeaders,
    -								query : requestArgs,
    -								data : activity.createPostData()							
    -							};
    -							var callbacks = {
    -								createEntity : function(service, data, response) {
    -									return response;
    -								}
    -							};
    -							_this.updateEntity(consts.AtomActivityNodeTrash, options, callbacks).then(function(response) {
    -								promise.fulfilled(response);
    -							}, function(error) {
    -								promise.rejected(error);
    -							});
    -						}
    -					});
    -					return promise;
    -				},
    +                if (typeof value == "undefined" || value == null) {
    +                    return "";
    +                }
     
    -				/**
    -				 * Restores a deleted entry to an activity, sends a HTTP PUT request to the edit web address for the node defined in the trash feed. This moves
    -				 * the entry from the trash feed to the user's activity node list.
    -				 * 
    -				 * @method restoreActivityNode
    -				 * @param {String} activityNodeUuid
    -				 */
    -				restoreActivityNode : function(activityNodeUuid) {
    -					var promise = this.validateField("activityNodeUuid", activityNodeUuid);
    -					if (promise) {
    -						return promise;
    -					}
    -					var _this = this;
    -					var promise = new Promise();
    -					this.getActivityNodeFromTrash(activityNodeUuid).then(function(deletedNode) {
    -						return deletedNode;
    -					}).then(function(activityNode) {
    -						if (!activityNode.isDeleted()) {
    -							promise.rejected("Activity Node is not in Trash");
    -						} else {
    -							var requestArgs = {
    -								"activityNodeUuid" : activityNodeUuid
    -							};
    -							activityNode.setCategoryScheme();
    -							var options = {
    -								method : "PUT",
    -								headers : consts.AtomXmlHeaders,
    -								query : requestArgs,
    -								data : activityNode.createPostData()							
    -							};
    -							var callbacks = {
    -								createEntity : function(service, data, response) {
    -									return response;
    -								}
    -							};
    -							_this.updateEntity(consts.AtomActivityNodeTrash, options, callbacks).then(function(response) {
    -								promise.fulfilled(response);
    -							}, function(error) {
    -								promise.rejected(error);
    -							});
    -						}
    -					});
    -					return promise;
    -				},
    +                return value;
    +            }, this);
    +        },
     
    -				/**
    -				 * Retrieves and activity node from trash
    -				 * 
    -				 * @method getActivityNodeFromTrash
    -				 * @param {String} activityNodeUuid
    -				 * @returns {Object} ActivityNode
    -				 */
    -				getActivityNodeFromTrash : function(activityNodeUuid) {
    -					var promise = this.validateField("activityNodeUuid", activityNodeUuid);
    -					if (promise) {
    -						return promise;
    -					}
    -					var requestArgs = {
    -						"activityNodeUuid" : activityNodeUuid
    -					};
    -					var options = {
    -						method : "GET",
    -						handleAs : "text",
    -						query : requestArgs
    -					};
    -					return this.getEntity(consts.AtomActivityNodeTrash, options, activityNodeUuid, ActivityNodeFeedCallbacks);
    -				},
    +        _substituteItems : function(template,grid,renderer,items,data) {
    +            var self = this;
    +            return grid._substitute(template, renderer, function(value,key) {
    +                if (typeof value == "undefined") {
    +                    // check the renderer for the property
    +                    value = lang.getObject(key, false, self);
    +                }
     
    -				/**
    -				 * Returns a ActivityNode instance from ActivityNode or JSON or String. Throws an error if the argument was neither.
    -				 * 
    -				 * @method newActivityNode
    -				 * @param {Object} activityNodeOrJsonOrString The ActivityNode Object or json String for ActivityNode
    -				 */
    -				newActivityNode : function(activityNodeOrJsonOrString) {
    -					if (activityNodeOrJsonOrString instanceof ActivityNode || activityNodeOrJsonOrString instanceof Activity) {
    -						return activityNodeOrJsonOrString;
    -					} else {
    -						if (lang.isString(activityNodeOrJsonOrString)) {
    -							activityNodeOrJsonOrString = {
    -								id : activityNodeOrJsonOrString
    -							};
    -						}
    -						return new ActivityNode({
    -							service : this,
    -							_fields : lang.mixin({}, activityNodeOrJsonOrString)
    -						});
    -					}
    -				},
    +                if (typeof value == 'function') {
    +                    // invoke function to return the value
    +                    try {
    +                        value = value.apply(self, [grid, renderer, items, data]);
    +                    } catch (ex) {
    +                        value = "ERROR:" + key + " " + ex;
    +                    }
    +                }
     
    -				/**
    -				 * Gets All activity nodes in trash which match given criteria
    -				 * @method getActivityNodesInTrash
    -				 * @param {String} activityUuid
    -				 * @param {Object} [requestArgs] optional arguments
    -				 * @returns {Array} ActivityNode list
    -				 */
    -				getActivityNodesInTrash : function(activityUuid, requestArgs) {
    +                if (typeof value == "undefined" || value == null) {
    +                    return "";
    +                }
     
    -					var promise = this.validateField("activityUuid", activityUuid);
    -					if (promise) {
    -						return promise;
    -					}
    -					var args = lang.mixin(requestArgs || {}, {
    -						"activityUuid" : activityUuid
    -					});
    -					var options = {
    -						method : "GET",
    -						handleAs : "text",
    -						query : args || {}
    -					};
    +                return value;
    +            }, this);
    +        },
    +               
    +        getProfileUrl: function(grid,id){
    +                var endpoint = grid.store.getEndpoint();
    +                var profileURL = "/${profiles}/html/profileView.do?userid="+id;
    +                profileURL = grid.constructUrl(profileURL,{},{},endpoint);
    +                profileURL = endpoint.baseUrl+profileURL;
    +                return profileURL;
    +        }
    +        
    +    });
    +    
    +    return GridRenderer;
    +});
    +},
    +'url:sbt/connections/controls/search/templates/StatusUpdateHeader.html':"",
    +'sbt/smartcloud/controls/profiles/ProfilePanel':function(){
    +require({cache:{
    +'url:sbt/smartcloud/controls/profiles/templates/ProfilePanel.html':"
    \r\n\t
    \r\n\t\t
    \r\n\t\t\t\"${getThumbnailAlt}\"\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t${getDisplayName}\r\n\t\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t${getAbout}\r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n
    "}}); +/* + * © 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. + */ - return this.getEntities(consts.AtomActivitiesTrash, options, ActivityNodeFeedCallbacks); +/** + * @module sbt.connections.controls.profiles.ProfilePanel + */ +define(["../../../declare", "../../../lang", "../../../config", + "../../../smartcloud/ProfileService", + "../../../controls/panel/_ProfilePanel", + "../../../text!sbt/smartcloud/controls/profiles/templates/ProfilePanel.html"], + function(declare, lang, config, ProfileService, _ProfilePanel, PanelTmpl) { - }, + var getUserIdentity = "/manage/oauth/getUserIdentity"; + + /** + * @module sbt.connections.controls.profiles.ProfilePanel + */ + var ProfilePanel = declare([ _ProfilePanel ], { + + template: PanelTmpl, + profileService: null, + + constructor: function(args) { + }, + + getMyProfile: function() { + var path = getUserIdentity; + + if (this.userid) { + this.getProfile(this.userid); + } else { + var self = this; + var endpoint = this._getEndpoint(); + endpoint.request(path, { handleAs : "json", preventCache : true }).then( + function(response) { + var userid = response.subscriberid; + self.getProfile(userid); + }, + function(error) { + self._displayError(error); + } + ); + } + }, + + getProfile: function(id) { + var self = this; + var promise = this._getProfileService().getProfile(id); + promise.then( + function(profile) { + self.profile = profile; + self.showProfile(); + }, + function(error) { + self.profile = null; + self._displayError(error); + } + ); + }, + + // Internals + + _getProfileService: function() { + if (!this.profileService) { + this.profileService = new ProfileService(this._getEndpointName()); + } + return this.profileService; + }, + + _getEndpoint: function() { + return config.findEndpoint(this._getEndpointName()); + }, + + _getEndpointName: function() { + return this.endpoint || "smartcloud"; + } + + }); + + return ProfilePanel; +}); +}, +'sbt/base/XmlDataHandler':function(){ +/* + * © Copyright IBM Corp. 2012,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. + */ - /** - * Returns a Activity instance from Activity or JSON or String. Throws an error if the argument was neither. - * @method newActivity - * @param {Object} activityOrJsonOrString The Activity Object or json String for Activity - */ - newActivity : function(activityOrJsonOrString) { +/** + * Social Business Toolkit SDK. Helpers for the base capabilities of data + * handlers. + * + * @module sbt.base.DataHandler + */ +define([ "../declare", "../lang", "../stringUtil", "../xml", "../xpath", "./DataHandler" ], + function(declare,lang,stringUtil,xml,xpath,DataHandler) { - if (activityOrJsonOrString instanceof Activity) { - return activityOrJsonOrString; - } else { - if (lang.isString(activityOrJsonOrString)) { - activityOrJsonOrString = { - id : activityOrJsonOrString - }; - } - return new Activity({ - service : this, - _fields : lang.mixin({}, activityOrJsonOrString) - }); - } - }, + /** + * XmlDataHandler class + * + * @class XmlDataHandler + * @namespace sbt.base + */ + var XmlDataHandler = declare(DataHandler, { - /** - * Search for a set of to-do items that match a specific criteria. - * - * @method getAllToDos - * @param {Object} [requestArgs] the optional arguments - * @returns {Array} ActivityNode Array - */ - getAllToDos : function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; + /** + * Data type for this DataHandler is 'xml' + */ + dataType : "xml", - return this.getEntities(consts.AtomActivitiesToDos, options, ActivityFeedCallbacks); - }, + /** + * Set of XPath expressions used by this handler. Required for entity: + * uid, entry Required for summary: totalResults, startIndex, + * itemsPerPage + */ + xpath : null, - /** - * Search for a set of tags that match a specific criteria. - * @method getAllTags - * @param {Object} [requestArgs] the optional arguments - * @returns {Array} - */ - getAllTags : function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; + /** + * Set of namespaces used by this handler. + */ + namespaces : null, - return this.getEntities(consts.AtomActivitiesTags, options, TagFeedCallbacks); - }, + /** + * Set of values that have already been read. + */ + _values : null, - /** - * Search for sctivities in trash which math a specif criteria - * - * @method getActivitiesInTrash - * @param {Object} [requestArgs] the optional arguments - * @returns {Array} activities - */ - getActivitiesInTrash : function(requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} - }; + /** + * Summary of a feed. + */ + _summary : null, - return this.getEntities(consts.AtomActivitiesTrash, options, ActivityFeedCallbacks); + /** + * @constructor + * @param {Object} + * args Arguments for this data handler. + */ + constructor : function(args) { + lang.mixin(this, args); - }, + this._values = {}; // TODO option to disable cache + this.data = this._fromNodeOrString(args.data); + }, - /** - * Returns the tags for given actiivity - * @method getActivityTags - * @param {String} activityUuid - * @param {Object} [requestArgs] the optional arguments - * @returns {Array} tags - */ - getActivityTags : function(activityUuid, requestArgs) { + /** + * Called to set the handler data. + * + * @param data + */ + setData : function(data) { + this._values = {}; // TODO option to disable cache + this.data = this._fromNodeOrString(data); + }, + + /** + * @method getAsString + * @param property + * @returns + */ + getAsString : function(property) { + this._validateProperty(property, "getAsString"); + + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._selectText(property); + } + return this._values[property]; + } else { + return _selectText(property); + } + }, - var promise = this.validateField("activityUuid", activityUuid); - if (promise) { - return promise; - } + /** + * @method getAsNumber + * @param property + * @returns + */ + getAsNumber : function(property) { + this._validateProperty(property, "getAsNumber"); + + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._selectNumber(property); + } + return this._values[property]; + } else { + return this._selectNumber(property); + } + }, - var args = lang.mixin(requestArgs || {}, { - "activityUuid" : activityUuid - }); + /** + * @method getAsDate + * @param property + * @returns + */ + getAsDate : function(property) { + this._validateProperty(property, "getAsDate"); + + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._selectDate(property); + } + return this._values[property]; + } else { + return this._selectDate(property); + } + }, - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + /** + * @method getAsBoolean + * @param property + * @returns + */ + getAsBoolean : function(property) { + this._validateProperty(property, "getAsBoolean"); + + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._selectBoolean(property); + } + return this._values[property]; + } else { + return this._selectBoolean(property); + } + }, - return this.getEntities(consts.AtomActivitiesTags, options, TagFeedCallbacks); - }, + /** + * @method getAsArray + * @param property + * @returns + */ + getAsArray : function(property) { + this._validateProperty(property, "getAsArray"); + + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._selectArray(property); + } + return this._values[property]; + } else { + return this._selectArray(property); + } + }, + + /** + * @method getNodesArray + * @param property + * @returns + */ + getAsNodesArray : function(property) { + this._validateProperty(property, "getNodesArray"); + + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._selectNodesArray(property); + } + return this._values[property]; + } else { + return this._selectNodesArray(property); + } + }, - /** - * Returns the tags for given actiivity node. - * @method getActivityNodeTags - * @param activityNodeUuid - * @param {Object} [requestArgs] the optional arguments - * @returns {Array} tags - */ - getActivityNodeTags : function(activityNodeUuid, requestArgs) { + /** + * @method getEntityId + * @returns + */ + getEntityId : function() { + return stringUtil.trim(this.getAsString("uid")); + }, - var promise = this.validateField("activityNodeUuid", activityNodeUuid); - if (promise) { - return promise; - } - var args = lang.mixin(requestArgs || {}, { - "activityNodeUuid" : activityNodeUuid - }); + /** + * getEntityData + * + * @returns + */ + getEntityData : function(document) { + var entry = this.xpath["entry"]; + if (!entry) { + return document; + } + if (!this._values["entry"]) { + var nodes = xpath.selectNodes(document, entry, this.namespaces); + this._values["entry"] = nodes[0] || null; + } + return this._values["entry"]; + }, - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + /** + * @method getSummary + * @returns + */ + getSummary : function() { + if (!this._summary && this._getXPath("totalResults")) { + this._summary = { + totalResults : xpath.selectNumber(this.data, this._getXPath("totalResults"), this.namespaces), + startIndex : xpath.selectNumber(this.data, this._getXPath("startIndex"), this.namespaces), + itemsPerPage : xpath.selectNumber(this.data, this._getXPath("itemsPerPage"), this.namespaces) + }; + } + return this._summary; + }, - return this.getEntities(consts.AtomActivitiesTags, options, TagFeedCallbacks); - }, + /** + * @method getEntitiesDataArray + * @returns {Array} + */ + getEntitiesDataArray : function() { + var entries = this.xpath["entries"]; + if (!entries) { + return this.data; + } + if (!this._values["entries"]) { + this._values["entries"] = xpath.selectNodes(this.data, entries, this.namespaces); + } + return this._values["entries"]; + }, + + /** + * @method toJson + * @returns {Object} + */ + toJson : function() { + var jsonObj = {}; + + for (var name in this.xpath) { + if (this.xpath.hasOwnProperty(name)) { + jsonObj[name] = this.getAsString(name); + } + } + + return jsonObj; + }, - /** - * Retrieves activity members from the access control list for a application, use the edit link found in the member entry in the ACL list feed. - * @method getMembers - * @param {String} activityUuid - * @param {Object} [requestArgs] the optional arguments - * @returns {Array} members - */ - getMembers : function(activityUuid, requestArgs) { - var promise = this.validateField("activityUuid", activityUuid); - if (promise) { - return promise; - } - var args = lang.mixin(requestArgs || {}, { - "activityUuid" : activityUuid - }); + /* + * Convert the input to a node by parsing as string and using + * getEntityData, if not already one + */ + _fromNodeOrString : function(nodeOrString) { + if (lang.isString(nodeOrString)) { + nodeOrString = stringUtil.trim(nodeOrString); + var document = xml.parse(nodeOrString); + return this.getEntityData(document); + } + return nodeOrString; + }, - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; + /* + * Return xpath expression from the set or the property itself (assume + * it's already xpath) + */ + _getXPath : function(property) { + return this.xpath[property] || property; + }, + + /* + * Validate that the property is valid + */ + _validateProperty : function(property, method) { + if (!property) { + var msg = stringUtil.substitute("Invalid argument for XmlDataHandler.{1} {0}", [ property, method ]); + throw new Error(msg); + } + }, + + /* + * Select xpath as string + */ + _selectText : function(property) { + if (!this.data) { + return null; + } + return stringUtil.trim(xpath.selectText(this.data, this._getXPath(property), this.namespaces)); + }, + + /* + * Select xpath as number + */ + _selectNumber : function(property) { + if (!this.data) { + return null; + } + return xpath.selectNumber(this.data, this._getXPath(property), this.namespaces); + }, + + /* + * Select xpath as date + */ + _selectDate : function(property) { + if (!this.data) { + return null; + } + var text = this._selectText(property); + return text ? new Date(Date.parse(text)) : null; + }, + + /* + * Select xpath as boolean + */ + _selectBoolean : function(property) { + if (!this.data) { + return false; + } + var nodes = xpath.selectNodes(this.data, this._getXPath(property), this.namespaces); + var ret = false; + if (nodes) { + if (nodes.length == 1) { + // handle case were node has text value equal true/false + var text = stringUtil.trim(nodes[0].text || nodes[0].textContent); + if (text) { + text = text.toLowerCase(); + if ("false" == text) { + return false; + } + if ("true" == text) { + return true; + } + } + } + ret = (nodes.length > 0); + } + return ret; + }, + + /* + * Select xpath as array + */ + _selectArray : function(property) { + if (!this.data) { + return null; + } + var nodes = xpath.selectNodes(this.data, this._getXPath(property), this.namespaces); + var ret = null; + if (nodes) { + ret = []; + for ( var i = 0; i < nodes.length; i++) { + ret.push(stringUtil.trim(nodes[i].text || nodes[i].textContent)); + } + } + return ret; + }, + + /* + * Select xpath as nodes array + */ + _selectNodesArray : function(property) { + if (!this.data) { + return null; + } + return xpath.selectNodes(this.data, this._getXPath(property), this.namespaces); + } + - return this.getEntities(consts.AtomActivitiesMembers, options, MemberFeedCallbacks); - }, + }); + return XmlDataHandler; +}); +}, +'sbt/Endpoint':function(){ +/* + * (C) Copyright IBM Corp. 2012 + * + * 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. + */ - _validateMember : function(member, checkId, checkUserIdOrEmail) { - if (checkId && !member.getMemberId()) { - return this.createBadRequestPromise("Invalid argument, member with ID must be specified."); - } - if (checkUserIdOrEmail) { - var id = member.getContributor().userid || member.getContributor().email; - if (!id) { - return this.createBadRequestPromise("Invalid argument, member with User ID or Email must be specified."); - } - } - }, +/** + * Definition of the endpoint module + * @module sbt.Endpoint + */ - /** - * Retrieves a member from the access control list for a application, use the edit link found in the member entry in the ACL list feed. - * @method getMember - * @param {String} activityUuid - * @param {String} memberId - * @returns {Object} Member - */ - getMember : function(activityUuid, memberId) { +/** + * Endpoint which defines a connection to a back-end server. + * + * @module sbt.Endpoint + */ +define(['./declare','./lang','./ErrorTransport','./Promise','./pathUtil','./compat','./log', './stringUtil', 'sbt/i18n!sbt/nls/Endpoint', './xml'], +function(declare,lang,ErrorTransport,Promise,pathUtil,compat,log,stringUtil,nls,xml) { - var promise = this.validateField("memberId", memberId); - if (!promise) { - promise = this.validateField("activityUuid", activityUuid); - } - if (promise) { - return promise; - } - var member = this._toMember(memberId); - return member.load(activityUuid); - }, +/** + * This class encapsulates an actual endpoint, with its URL, proxy and its authentication mechanism. + * + * @class sbt.Endpoint + */ +var Endpoint = declare(null, { + + /** + * URL of the server used to connect to the endpoint + * @property baseUrl + * @type String + */ + baseUrl: null, + + /** + * Proxy to be used + * @property proxy + * @type String + */ + proxy: null, + + /** + * Path to be added to the proxy url, if any + * @property proxyPath + * @type String + */ + proxyPath: null, + + /** + * Transport to be used + * @property transport + * @type String + */ + transport: null, + + /** + * Authenticator to be used + * @property authenticator + * @type String + */ + authenticator: null, + + /** + * Auth Type to be used + * @property authType + * @type String + */ + authType: null, + + /** + * UI Login mode: mainWindow, dialog or popup + * @property loginUi + * @type String + */ + loginUi: "", + + /** + * Page for login form for mainWindow and popup + * @property loginPage + * @type String + */ + loginPage: null, + + /** + * Page for login form for dialog + * @property dialogLoginPage + * @type String + */ + dialogLoginPage: null, + + /** + * Whether auth dialog should come up automatically or not. In case of not 401 would be propagated to user. + * @property autoAuthenticate + * @type String + */ + autoAuthenticate: null, + + /** + * Whether user is authenticated to endpoint or not. + * @property isAuthenticated + * @type String + */ + isAuthenticated: false, + + /** + * The error code that is returned from the endpoint on authentication failure. + * @property authenticationErrorCode + * @type String + */ + authenticationErrorCode: null, + + /** + * Simple constructor that mixes in its parameters as object properties + * @constructor + * @param {Array} args + */ + constructor: function(args) { + lang.mixin(this, args || {}); + }, + + /** + * Provides an asynchronous request using the associated Transport. + * + * @method request + * @param {String) + * url The URL the request should be made to. + * @param {String) + * loginUi The type of UI to use when authenticating, + * valid values are: mainWindow, popup, dialog. + * @param {Boolean) + * authAuthenticate if true the Endpoint with authenticate + * when a 401 (or associated authenication code) is received. + * @param {Object} + * [options] Optional A hash of any options for the provider. + * @param {String|Object} + * [options.data=null] Data, if any, that should be sent with + * the request. + * @param {String|Object} + * [options.query=null] The query string, if any, that should + * be sent with the request. + * @param {Object} + * [options.headers=null] The headers, if any, that should + * be sent with the request. + * @param {Boolean} + * [options.preventCache=false] If true will send an extra + * query parameter to ensure the the server won't supply + * cached values. + * @param {String} + * [options.method=GET] The HTTP method that should be used + * to send the request. + * @param {Integer} + * [options.timeout=null] The number of milliseconds to wait + * for the response. If this time passes the request is + * canceled and the promise rejected. + * @param {String} + * [options.handleAs=text] The content handler to process the + * response payload with. + * @return {sbt.Promise} + */ + request : function(url, options) { + // rewrite the url if needed + var qurl = url; + if (qurl.indexOf("http") != 0) { + if (this.proxy) { + qurl = this.proxy.rewriteUrl(this.baseUrl, url, this.proxyPath); + } else { + qurl = pathUtil.concat(this.baseUrl, url); + } + } + + if (!options) { + options = { + method : "GET", + handleAs : "text" + }; + } + options.name = this.name; + + var promise = new Promise(); + promise.response = new Promise(); - /** - * Adds a member to the access control list of an activity, sends an Atom entry document containing the new member to the access control list - * feed. You can only add one member per post. - * @method addMember - * @param {String} activityUuid - * @param {Object} memberOrJson - */ - addMember : function(activityUuid, memberOrJson) { - var promise = this.validateField("memberOrJson", memberOrJson); - if (!promise) { - promise = this.validateField("activityUuid", activityUuid); - } - if (promise) { - return promise; + var self = this; + this.transport.request(qurl, options).response.then(function(response) { + + // Check for form based authentication + if(self.authType == "form"){ + var authRequiredFlag = self._isAuthRequiredFormBasedEP(response, options); + if(authRequiredFlag){ + self._authenticate(url, options, promise); } - var member = this._toMember(memberOrJson); - promise = this._validateMember(member, false, true); - if (promise) { - return promise; + } + + promise.fulfilled(response.data); + promise.response.fulfilled(response); + }, function(error) { + if (!error.message) { + error.message = self.getErrorMessage(error.cause); + } + var authRequiredPromise = self._isAuthRequired(error, options); + authRequiredPromise.then( + function(response) { + if (response) { + self._authenticate(url, options, promise); + } else { + promise.rejected(error); + promise.response.rejected(error); } - if (!member.getRole()) { - member.setRole("member"); + }, + function(error) { + promise.rejected(error); + promise.response.rejected(error); + } + ); + }); + + return promise; + }, + + /* + * Sends a request using XMLHttpRequest with the given URL and options. + * + * @method xhr + * @param {String} [method] The HTTP method to use to make the request. Must be uppercase. Default is 'GET'. + * @param {Object} [args] + * @param {String} [args.url] + * @param {Function} [args.handle] + * @param {Function} [args.load] + * @param {Function} [args.error] + * @param {Boolean} [hasBody] + */ + xhr: function(method,args,hasBody) { + var self = this; + var _args = lang.mixin({},args); + // We make sure that args has a 'url' member, with or without a proxy + if(!_args.url) { + if(this.proxy) { + _args.url = this.proxy.rewriteUrl(this.baseUrl,_args.serviceUrl,this.proxyPath); + } else { + _args.url = pathUtil.concat(this.baseUrl,_args.serviceUrl); + } + } + // Make sure the initial methods are not called + // seems that Dojo still call error(), even when handle is set + delete _args.load; delete _args.error; + _args.handle = function(data,ioArgs) { + if(data instanceof Error) { + var error = data; + if(!error.message){ + error.message = self.getErrorMessage(error.cause); + } + var isForbiddenErrorButAuthenticated = false; + // check for if authentication is required + if(error.code == 403 && self.authenticationErrorCode == 403){ + // case where 403 is configured to be treated similar to 401 (unAuthorized) + // checking if we are getting 403 inspite of being already authenticated (eg. Get Public Files/Folders API on Smartcloud + if(self.isAuthenticated){ + isForbiddenErrorButAuthenticated = true; + } + } + if ((error.code == 401)|| (!isForbiddenErrorButAuthenticated && error.code == self.authenticationErrorCode)) { + var autoAuthenticate = _args.autoAuthenticate || self.autoAuthenticate; + if(autoAuthenticate == undefined){ + autoAuthenticate = true; } - member.setCategoryScheme(); - var payload = member.createPostData(); - var requestArgs = { - "activityUuid" : activityUuid - }; - var options = { - method : "POST", - headers : consts.AtomXmlHeaders, - query : requestArgs, - data : payload - }; - var callbacks = { - createEntity : function(service, data, response) { - return response; + if(autoAuthenticate){ + if(self.authenticator) { + options = { + dialogLoginPage:self.loginDialogPage, + loginPage:self.loginPage, + transport:self.transport, + proxy: self.proxy, + proxyPath: self.proxyPath, + loginUi: _args.loginUi || self.loginUi, + name: self.name, + callback: function() { + self.xhr(method,args,hasBody); + } + }; + if(self.authenticator.authenticate(options)) { + return; + } } - }; - - return this.updateEntity(consts.AtomActivitiesMembers, options, callbacks); - - }, - - /** - * Updates a member in the access control list for an application, sends a replacement member entry document in Atom format to the existing ACL - * node's edit web address. - * @method updateMember - * @param {String} activityUuid - * @param {Object} memberOrJson - */ - updateMember : function(activityUuid, memberOrJson) { - var promise = this.validateField("memberOrJson", memberOrJson); - if (!promise) { - promise = this.validateField("activityUuid", activityUuid); - } - if (promise) { - return promise; - } - var member = this._toMember(memberOrJson); - promise = this._validateMember(member, true, true); - if (promise) { - return promise; } - member.setCategoryScheme(); - var payload = member.createPostData(); - var requestArgs = { - "activityUuid" : activityUuid, - "memberid" : member.getMemberId() - }; - - var options = { - method : "PUT", - headers : consts.AtomXmlHeaders, - query : requestArgs, - data : payload - }; - - var callbacks = { - createEntity : function(service, data, response) { - return response; - } - }; - - return this.updateEntity(consts.AtomActivitiesMembers, options, callbacks); + } + // notify handle and error callbacks is available + self._notifyError(args, error, ioArgs); + } else { + // notify handle and load callbacks is available + self._notifyResponse(args, data, ioArgs); + } + }; + this.transport.xhr(method, _args, hasBody); + }, + + /* + * @method xhrGet + * @param args + */ + xhrGet: function(args) { + this.xhr("GET",args); + }, + + /* + * @method xhrPost + * @param args + */ + xhrPost: function(args){ + this.xhr("POST", args, true); + }, + + /* + * @method xhrPut + * @param args + */ + xhrPut: function(args){ + this.xhr("PUT", args, true); + }, + + /* + * @method xhrDelete + * @param args + */ + xhrDelete: function(args){ + this.xhr("DELETE", args); + }, + + /** + * authenticate to an endpoint + * + * @method authenticate + * @param {Object} [args] Argument object + * @param {boolean} [args.forceAuthentication] Whether authentication is to be forced in case user is already authenticated. + * @param {String} [args.loginUi] LoginUi to be used for authentication. possible values are: 'popup', 'dialog' and 'mainWindow' + * @param {String} [args.loginPage] login page to be used for authentication. this property should be used in case default + * login page is to be overridden. This only applies to 'popup' and 'mainWindow' loginUi + * @param {String} [args.dialogLoginPage] dialog login page to be used for authentication. this property should be used in + * case default dialog login page is to be overridden. This only applies to 'dialog' loginUi. + */ + authenticate : function(args) { + var promise = new Promise(); + args = args || {}; + if (args.forceAuthentication || !this.isAuthenticated) { + var options = { + dialogLoginPage : this.loginDialogPage, + loginPage : this.loginPage, + transport : this.transport, + proxy : this.proxy, + proxyPath : this.proxyPath, + loginUi : args.loginUi || this.loginUi, + name: this.name, + callback: function(response) { + promise.fulfilled(response); }, + cancel: function(response) { + promise.rejected(response); + } + }; + this.authenticator.authenticate(options); + } else { + promise.fulfilled(true); + } + return promise; + }, + + /** + * Logout from an endpoint + * + * @method logout + * @param {Object} [args] Argument object + */ + logout : function(args) { + var promise = new Promise(); + args = args || {}; + var self = this; + var actionURL = ""; + if (!args.actionUrl) { + var proxy = this.proxy.proxyUrl; + actionURL = proxy.substring(0, proxy.lastIndexOf("/")) + "/authHandler/" + this.proxyPath + "/logout"; + } else { + actionURL = args.actionUrl; + } + this.transport.xhr('POST',{ + handleAs : "json", + url : actionURL, + load : function(response) { + self.isAuthenticated = false; + promise.fulfilled(response); + }, + error : function(response) { + self.isAuthenticated = false; + promise.rejected(response); + } + }, true); + return promise; + }, + + /** + * Find whether endpoint is authenticated or not. + * + * @method isAuthenticated + * @param {Object} [args] Argument object + */ + isAuthenticated : function(args) { + var promise = new Promise(); + args = args || {}; + var self = this; + var actionURL = ""; + if (!args.actionUrl) { + var proxy = this.proxy.proxyUrl; + actionURL = proxy.substring(0, proxy.lastIndexOf("/")) + "/authHandler/" + this.proxyPath + "/isAuth"; + } else { + actionURL = args.actionUrl; + } + this.transport.xhr('POST',{ + handleAs : "json", + url : actionURL, + load : function(response) { + self.isAuthenticated = true; + promise.fulfilled(response); + }, + error : function(response) { + promise.rejected(response); + } + }, true); + return promise; + }, + + /** + Find whether endpoint authentication is valid or not. + + @method isAuthenticationValid + @param {Object} [args] Argument object + @param {Function} [args.load] This is the function which isAuthenticationValid invokes when + authentication information is retrieved. + @param {Function} [args.error] This is the function which isAuthenticationValid invokes if an error occurs. + result property in response object returns true/false depending on whether authentication is valid or not. + */ + isAuthenticationValid : function(args) { + var promise = new Promise(); + args = args || {}; + var self = this; + var actionURL = ""; + if (!args.actionUrl) { + var proxy = this.proxy.proxyUrl; + actionURL = proxy.substring(0, proxy.lastIndexOf("/")) + "/authHandler/" + this.proxyPath + "/isAuthValid"; + } else { + actionURL = args.actionUrl; + } + this.transport.xhr('POST',{ + handleAs : "json", + url : actionURL, + load : function(response) { + self.isAuthenticated = response.result; + promise.fulfilled(response); + }, + error : function(response) { + promise.rejected(response); + } + }, true); + return promise; + }, + + // Internal stuff goes here and should not be documented + + /* + * Invoke error function with the error + */ + _notifyError: function(args, error, ioArgs) { + if (args.handle) { + try { + args.handle(error, ioArgs); + } catch (ex) { + // TODO log an error + var msg = ex.message; + } + } + if (args.error) { + try { + args.error(error, ioArgs); + } catch (ex) { + // TODO log an error + var msg = ex.message; + } + } + }, + + /* + * Invoke handle and/or load function with the response + */ + _notifyResponse: function(args, data, ioArgs) { + if (args.handle) { + try { + args.handle(data, ioArgs); + } catch (ex) { + // TODO log an error + var msg = ex.message; + } + } + if (args.load) { + try { + args.load(data, ioArgs); + } catch (ex) { + // TODO log an error + var msg = ex.message; + } + } + }, - /** - * Removes a member from the acl list for an application, use the HTTP DELETE method. - * @method deleteMember - * @param {String} activityUuid - * @param {String} memberId - */ - deleteMember : function(activityUuid, memberId) { - var promise = this.validateField("activityUuid", activityUuid); - if (!promise) { - promise = this.validateField("memberId", memberId); - } - if (promise) { - return promise; - } - var requestArgs = { - "activityUuid" : activityUuid, - "memberid" : memberId - }; - var options = { - method : "DELETE", - headers : consts.AtomXmlHeaders, - query : requestArgs - }; - - return this.deleteEntity(consts.AtomActivitiesMembers, options, memberId); - }, + /* + * Invoke automatic authentication for the specified request. + */ + _authenticate: function(url, options, promise) { + var self = this; + var authOptions = { + dialogLoginPage: this.loginDialogPage, + loginPage: this.loginPage, + transport: this.transport, + proxy: this.proxy, + proxyPath: this.proxyPath, + actionUrl: options.actionUrl, + loginUi: options.loginUi || this.loginUi, + name: this.name, + callback: function() { + self.request(url, options).response.then( + function(response) { + promise.fulfilled(response.data); + promise.response.fulfilled(response); + }, function(error) { + promise.rejected(error); + promise.response.rejected(error); + } + ); + }, + cancel: function() { + self._authRejected = true; + var error = new Error(); + error.message = "Authentication is required and has failed or has not yet been provided."; + error.code = 401; + promise.rejected(error); + promise.response.rejected(error); + } + }; + + return this.authenticator.authenticate(authOptions); + }, - _toMember : function(memberOrJsonOrString) { - if (memberOrJsonOrString) { - if (memberOrJsonOrString instanceof Member) { - return memberOrJsonOrString; - } - var member = new Member({ - service : this - }); - if (lang.isString(memberOrJsonOrString)) { - memberOrJsonOrString = { - id : memberOrJsonOrString - }; - } - member._fields = lang.mixin({}, memberOrJsonOrString); - if(member._fields.userId) { - member._fields.contributorUserid = member._fields.userId; - } - return member; + /* + * Return true if automatic authentication is required. This method returns a promise with the success callback returning + * a boolean whether authentication is required. It first checks if the client is already authenticated + * and if yes, whether the authentication is valid. Else, it checks for the status code and other + * configuration paramters to decide if authentication is required. + */ + _isAuthRequired : function(error, options) { + var promise = new Promise(); + var status = error.response.status || null; + var isAuthErr = status == 401 || status == this.authenticationErrorCode; + if (this.isAuthenticated) { + if (!isAuthErr) { + promise.fulfilled(false); + } else { + this.isAuthenticationValid().then( + function(response) { + promise.fulfilled(!response.result); + }, + function(response) { + promise.rejected(response); } - }, + ); + } + } else { + // User can mention autoAuthenticate as part service wrappers call that is the args json variable or + // as a property of endpoint in managed-beans.xml. + // isAutoAuth variable is true when autoAuthenticate property is true in args json variable or + // autoAuthenticate property in endpoint defination in managed-beans.xml is true. It is false otherwise. + var isAutoAuth = options.autoAuthenticate || this.autoAuthenticate; + if (isAutoAuth == undefined) { + isAutoAuth = true; + } + // The response is returned as a boolean value as an argument to the success callback of the promise. This + // value is true when the error code is 401 or any authentication error code for a particular endpoint + // (isAuthErr variable) and autoAuthenticate parameter is mentioned true (based on isAutoAuth variable) + // and authenticator property the endpoint (could be js object of type Basic or OAuth)is defined and the + // authentication was not rejected earlier. + // It is false otherwise. The true value of this expression triggers the authentication process from the client. + promise.fulfilled(isAuthErr && isAutoAuth && this.authenticator && !this._authRejected); + } + return promise; + }, + + /* + * Method ensures we trigger authentication for Smartcloud when response code is 200 and content is login page + */ + _isAuthRequiredFormBasedEP : function (response, options){ + if(response.status == 200 && response.getHeader("Content-Type") == "text/html"){ + return true; + }else{ + return false; + } + }, + + getErrorMessage: function(error) { + var text = error.responseText || (error.response&&error.response.text) ; + if (text) { + try { + var dom = xml.parse(text); + var messages = dom.getElementsByTagName("message"); + if (messages && messages.length != 0) { + text = messages[0].text || messages[0].textContent; + text = lang.trim(text); + } + } catch(ex) { + } + var trimmedText = text.replace(/(\r\n|\n|\r)/g,""); + if(!(trimmedText)){ + return error.message; + }else{ + return text; + } + } else { + return error; + } + }, + + getProxyUrl: function(){ + return this.proxy.proxyUrl + "/" + this.proxyPath; + }, + + /** + * Takes a url with a context root to replace, and returns a url with the context root replaced. + * + * e.g. url: 'http://example.com/${replaceMe}' + * If this endpoint has serviceMappings like: + * { + * replaceMe: 'replacement' + * } + * + * returns 'http://example.com/replacement' + * + * If there is no replacement available, the replacement will be the string inside the braces. e.g. 'http://example.com/replaceMe' will be returned. + * + * @method modifyUrlContextRoot + * + * @param {String} url + * @param {Object} [defaultContextRootMap] If specified, this object will be used for replacements in the event there is no equivalent serviceMapping object. + */ + modifyUrlContextRoot: function(url, defaultContextRootMap){ + var defaultMap = defaultContextRootMap ? {} : lang.mixin({}, defaultContextRootMap); + var map = lang.mixin(defaultMap, this.serviceMapping); + + return stringUtil.transform(url, map, function(value, key){ + if(!value){ + return key; + } + else{ + return value; + } + }, this); + } + +}); - /** - * Returns a Member instance from Member or JSON or String. Throws an error if the argument was neither. - * @method newMember - * @param {Object} memberOrJsonOrString The Member Object or json String for Member - */ - newMember : function(memberOrJsonOrString) { - return this._toMember(memberOrJsonOrString); - } - }); - return ActivityService; - }); +return Endpoint; +}); }, -'url:sbt/connections/controls/profiles/templates/BootstrapProfile.html':"\r\n\t\r\n\t\t\"${name}\"\r\n\t\r\n\t\r\n\t

    \r\n \t\t${name}\r\n \t

    \r\n\t\r\n\r\n", -'sbt/authenticator/Basic':function(){ +'url:sbt/connections/controls/search/templates/CalendarBody.html':"
    \r\n
      \r\n
    • \r\n ${_nls.eventDateOn}\r\n \r\n ${eventStartDate}\r\n \r\n
    • \r\n ${bodyCalendarLis}\r\n ${personCard}\r\n
    \r\n
    ", +'url:sbt/connections/controls/search/templates/ProfileHeader.html':"
    \r\n

    \r\n \r\n \r\n ${formattedTitle}\r\n \r\n \r\n ${authorUid}\r\n \r\n \r\n

    \r\n
    ", +'sbt/nls/util':function(){ /* - * © Copyright IBM Corp. 2012 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27878,154 +25682,584 @@ define( * implied. See the License for the specific language governing * permissions and limitations under the License. */ + /** - * Social Business Toolkit SDK. - * Definition of an authentication mechanism. + * Social Business Toolkit SDK - Default resource bundle for validate module. */ -define(["../declare", "../lang", "../util", "../i18n!../nls/loginForm"],function(declare, lang, util, loginForm) { + + +define({ + root: ({ + error_callback:"Error running error callback : {0}", + error_console:"Error received. Error Code = {0}. Error Message = {1}" + }) + +}); +}, +'sbt/base/BaseService':function(){ +/* + * © Copyright IBM Corp. 2012, 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. + */ + /** - * Proxy basic authentication. + * Javascript Base APIs for IBM Connections * - * This class triggers the authentication for a service. + * @module sbt.base.BaseService + * @author Carlos Manias */ -return declare(null, { - loginUi: "", - loginPage: "/sbt/authenticator/templates/login.html", - dialogLoginPage:"authenticator/templates/loginDialog.html", - url: "", - actionUrl: "", - - /** - * Constructor, necessary so that this.url is not empty. - * It may also mixin loginUi, loginPage or dialogLoginPage if they are present in sbt.properties. - */ - constructor: function(args){ - lang.mixin(this, args || {}); - }, +define(["../config", "../declare", "../lang", "../log", "../stringUtil", "../Cache", "../Promise", "../util" ], + function(config, declare,lang,log,stringUtil,Cache,Promise, util) { + // TODO sbt/config is required here to solve module loading + // issues with jquery until we remove the global sbt object - /** - * Method that authenticate the current user . - * - * This is a working version. But this is work in progress with following todos - * - * todos: - * Internationalization - */ - authenticate: function(options) { - var self = this; - require(['sbt/config'], function(config){ - var mode = options.loginUi || config.Properties["loginUi"] || self.loginUi; - var loginPage = options.loginPage || config.Properties["loginPage"] || self.loginPage; - var dialogLoginPage = options.dialogLoginPage || config.Properties["dialogLoginPage"] || self.dialogLoginPage; - if(mode=="popup") { - self._authPopup(options, loginPage, config, self.url); - } else if(mode=="dialog") { - self._authDialog(options, dialogLoginPage, config); - } else { - self._authMainWindow(options, loginPage, self.url); - } - }); + var BadRequest = 400; + + var requests = {}; + + /** + * BaseService class. + * + * @class BaseService + * @namespace sbt.base + */ + var BaseService = declare(null, { + + /** + * The Endpoint associated with the service. + */ + endpoint : null, + + /* + * The Cache associated with the service. + */ + _cache : null, + + /* + * Regular expression used to remove // from url's + */ + _regExp : new RegExp("/{2}"), + + /** + * A map of default context roots to custom, if any. This will be implemented in subClasses of BaseService. + */ + contextRootMap: {}, + + /** + * Constructor for BaseService + * + * An endpoint is required so subclasses must check if one + * was created here and if not set the default endpoint. + * + * @constructor + * @param {Object} args Arguments for this service. + */ + constructor : function(args) { + args = args || {}; + + // set endpoint if specified in args + if (args.endpoint) { + if (lang.isString(args.endpoint)) { + this.endpoint = config.findEndpoint(args.endpoint); + } else { + this.endpoint = args.endpoint; + } + } + + // optionally create a cache + if (args.cacheSize) { + this._cache = new Cache(args.cacheSize); + } + }, + + /** + * Construct a url using the specified parameters + * + * @method constructUrl + * @param url Base part of the URL to construct + * @param params Params to be encoded in the URL + * @param urlParams Params to be encoded in the URL query + * @returns The constructed URL + */ + constructUrl : function(url,params,urlParams) { + if (!url) { + throw new Error("BaseService.constructUrl: Invalid argument, url is undefined or null."); + } + + if(this.endpoint){ + lang.mixin(this.contextRootMap, this.endpoint.serviceMappings); + + url = stringUtil.transform(url, this.contextRootMap, function(value, key){ + if(!value){ + return key; + } + else{ + return value; + } + }, this); + } + + if (urlParams) { + url = stringUtil.replace(url, urlParams); + + if (url.indexOf("//") != -1) { + // handle empty values + url = url.replace(this._regExp, "/"); + } + } + if (params) { + for (param in params) { + if (url.indexOf("?") == -1) { + url += "?"; + } else if (url.indexOf("&") != (url.length - 1)) { + url += "&"; + } + var value = encodeURIComponent(params[param]); + if (value) { + url += param + "=" + value; + } + } + } + return url; + }, + + /** + * Get a collection of entities. + * + * @method getEntities + * @param url The URL to get the entities. + * @param options Optional. Options for the request. + * @param callbacks Callbacks used to parse the response and create the entities. + * @returns {sbt/Promise} + */ + getEntities : function(url,options,callbacks) { + url = this.constructUrl(url); + var self = this; + var promise = new Promise(); + this.request(url,options,null,promise).response.then( + function(response) { + promise.response = response; + try { + var feedHandler = callbacks.createEntities.apply(self, [ self, response.data, response ]); + var entitiesArray = feedHandler.getEntitiesDataArray(); + var entities = []; + for ( var i = 0; i < entitiesArray.length; i++) { + var entity = callbacks.createEntity.apply(self, [ self, entitiesArray[i], response ]); + entities.push(entity); + } + promise.summary = feedHandler.getSummary(); + promise.fulfilled(entities); + } catch (cause) { + var error = new Error("Error parsing response caused by: "+cause); + error.cause = cause; + promise.rejected(error); + } + }, + function(error) { + promise.rejected(error); + } + ); + return promise; + }, + + /** + * Get a single entity. + * + * @method getEntity + * @param url The URL to get the entity. + * @param options Options for the request. + * @param callbacks Callbacks used to parse the response and create the entity. + * @returns {sbt/Promise} + */ + getEntity : function(url,options,entityId,callbacks) { + url = this.constructUrl(url); + var promise = this._validateEntityId(entityId); + if (promise) { + return promise; + } + + // check cache + var promise = new Promise(); + var data = this.getFromCache(entityId); + if (data) { + promise.fulfilled(data); + return promise; + } + + var self = this; + this.request(url,options,entityId,promise).response.then( + function(response) { + promise.response = response; + try { + var entity = callbacks.createEntity.apply(self, [ self, response.data, response ]); + if (self._cache && entityId) { + self.fullFillOrRejectPromises.apply(self, [ entityId, entity, response ]); + } else { + promise.fulfilled(entity); + } + } catch (cause) { + var error = new Error("Invalid response"); + error.cause = cause; + if (self._cache && entityId) { + self.fullFillOrRejectPromises.apply(self, [ entityId, error ]); + } else { + promise.rejected(error); + } + } + }, + function(error) { + if (self._cache && entityId) { + self.fullFillOrRejectPromises.apply(self, [ entityId, error ]); + } else { + promise.rejected(error); + } + } + ); + return promise; + }, + + /** + * Update the specified entity. + * + * @method updateEntity + * @param url The URL to update the entity. + * @param options Options for the request. + * @param callbacks Callbacks used to parse the response. + * @param sbt/Promise + */ + updateEntity : function(url, options, callbacks) { + url = this.constructUrl(url); + var self = this; + var promise = new Promise(); + this.endpoint.request(url,options,null,promise).response.then( + function(response) { + promise.response = response; + var entity = callbacks.createEntity.apply(self, [ self, response.data, response ]); + // callback can return a promise if an additional + // request is required to load the associated entity + if (entity instanceof Promise) { + entity.then( + function(response) { + // it is the responsibility of the createEntity callback to clear the cache in this case. + promise.fulfilled(response); + }, + function(error) { + promise.rejected(error); + } + ); + } else { + if(entity.id){ + self.removeFromCache(entity.id); + } + if(entity.id && entity.data){ + self.addToCache(entity.id, entity); + } + promise.fulfilled(entity); + } + }, + function(error) { + promise.rejected(error); + } + ); + return promise; + }, + + /** + * Delete the specified entity. + * + * @method deleteEntity + * @param url The URL to delete the entity. + * @param options Options for the request. + * @param entityId Id of the entity to delete. + * @param sbt/Promise + */ + deleteEntity : function(url,options,entityId) { + url = this.constructUrl(url); + var promise = this._validateEntityId(entityId); + if (promise) { + return promise; + } + + var self = this; + var promise = new Promise(); + this.endpoint.request(url,options,entityId,promise).response.then( + function(response) { + promise.response = response; + promise.fulfilled(entityId); + self.removeFromCache(entityId); + }, + function(error) { + promise.rejected(error); + } + ); + return promise; + }, + + /** + * Perform an XML HTTP Request with cache support. + * + * @method request + * @param url URL to request + * @param options Options for the request. + * @param entityId Id of the rntity associated with the request. + * @param promise Promise being returned + * @param sbt/Promise + */ + request : function(url,options,entityId,promise) { + url = this.constructUrl(url); + if (this._cache && entityId) { + this.pushPromise(entityId, promise); + } + return this.endpoint.request(url,options); + }, - return true; - }, - - _authDialog: function(options, dialogLoginPage, sbtConfig) { - var self = this; - require(["sbt/_bridge/ui/BasicAuth_Dialog", "sbt/dom"], function(dialog, dom) { - if(options.cancel){ - sbtConfig.cancel = options.cancel; - } - - options.actionUrl = self._computeActionURL(options); - - dialog.show(options, dialogLoginPage); - dom.setText('wrongCredsMessage', loginForm.wrong_creds_message); - dom.setText('basicLoginFormUsername', loginForm.username); - dom.setText('basicLoginFormPassword', loginForm.password); - dom.setAttr(dom.byId('basicLoginFormOK'), "value", loginForm.login_ok); - dom.setAttr(dom.byId('basicLoginFormCancel'), "value", loginForm.login_cancel); - }); - return true; - }, - - _authPopup: function(options, loginPage, sbtConfig, sbtUrl) { - var actionURL = this._computeActionURL(options); - var urlParamsMap = { - actionURL: actionURL, - redirectURL: 'empty', - loginUi: 'popup', - showWrongCredsMessage: 'false' - }; - var urlParams = util.createQuery(urlParamsMap, "&"); - var url = sbtUrl+loginPage + '?' + urlParams; - - var windowParamsMap = { - width: window.screen.availWidth / 2, - height: window.screen.availHeight / 2, - left: window.screen.availWidth / 4, - top: window.screen.availHeight / 4, - menubar: 0, - toolbar: 0, - status: 0, - location: 0, - scrollbars: 1, - resizable: 1 - }; - var windowParams = util.createQuery(windowParamsMap, ","); - var loginWindow = window.open(url,'Authentication', windowParams); - if(options.callback){ - sbtConfig.callback = options.callback; - loginWindow.callback = options.callback; - } - if(options.cancel){ - sbtConfig.cancel = options.cancel; - loginWindow.cancel = options.cancel; - } - globalLoginFormStrings = loginForm; - globalEndpointAlias = options.name; - loginWindow.focus(); + /** + * Push set of promise onto stack for specified request id. + * + * @method pushPromise + * @param id Id of the request. + * @param promise Promise to push. + */ + pushPromise : function(id,promise) { + log.debug("pushPromise, id : {0}, promise : {1}", id, promise); + if (!requests[id]) { + requests[id] = []; + } + requests[id].push(promise); + }, + + /** + * Notify set of promises and pop from stack for specified request id. + * + * @method fullFillOrRejectPromises + * @param id + * @param data + * @param response + */ + fullFillOrRejectPromises : function(id,data,response) { + log.debug("fullFillOrRejectPromises, id : {0}, data : {1}, response : {2}", id, data, response); + this.addToCache(id, data); + var r = requests[id]; + if (r) { + delete requests[id]; + for ( var i = 0; i < r.length; i++) { + var promise = r[i]; + this.fullFillOrReject.apply(this, [ promise, data, response ]); + } + } + }, + + /** + * Fullfill or reject specified promise. + * + * @method fullFillOrReject + * @param promise + * @param data + * @param response + */ + fullFillOrReject : function(promise,data,response) { + if (promise) { + try { + promise.response = response; + if (data instanceof Error) { + promise.rejected(data); + } else { + promise.fulfilled(data); + } + } catch (error) { + log.debug("fullFillOrReject: " + error.message); + } + } + }, + + /** + * Add the specified data into the cache. + * + * @method addToCache + * @param id + * @param data + */ + addToCache : function(id, data) { + if (this._cache && !(data instanceof Error)) { + this._cache.put(id, data); + } + }, - return true; - }, - - _authMainWindow: function(options, loginPage, sbtUrl) { - var actionURL = this._computeActionURL(options); - var urlParamsMap = { - actionURL: actionURL, - redirectURL: document.URL, - loginUi: 'mainWindow', - showWrongCredsMessage: 'false', - username: loginForm.username, - password: loginForm.password, - login_ok: loginForm.login_ok, - login_cancel: loginForm.login_cancel, - wrong_creds_message: loginForm.wrong_creds_message - }; - - var urlParams = util.createQuery(urlParamsMap, "&"); - var url = sbtUrl+loginPage + '?' + urlParams; - window.location.href = url; - - return true; - }, - - _computeActionURL: function(options) { - if (!this.actionUrl) { - var proxy = options.proxy.proxyUrl; - return proxy.substring(0,proxy.lastIndexOf("/"))+"/basicAuth/"+options.proxyPath+"/JSApp"; - } - return this.actionUrl; - } - -} -); + /** + * Remove the cached data for the specified id. + * + * @method removeFromCache + * @param id + */ + removeFromCache : function(id) { + if (this._cache) { + this._cache.remove(id); + } + }, + + /** + * Get the cached data for the specified id. + * + * @method getFromCache + * @param id + */ + getFromCache : function(id) { + if (this._cache) { + return this._cache.get(id); + } + }, + + /** + * Create a bad request Error. + * + * @method createBadRequestError + * @param message + * @returns {Error} + */ + createBadRequestError : function(message) { + var error = new Error(); + error.code = BadRequest; + error.message = message; + return error; + }, + + /** + * Create a bad request Promise. + * + * @method createBadRequestPromise + * @param message + * @returns {sbt/Promise} + */ + createBadRequestPromise : function(message) { + return new Promise(this.createBadRequestError(message)); + }, + + /** + * Return true if the specified id is an email. + * + * @method isEmail + * @param id + * @returns {Boolean} + */ + isEmail : function(id) { + return id && id.indexOf('@') >= 0; + }, + + /** + * Extract the Location parameter from a URL. + * + * @method getLocationParameter + * @param ioArgs + * @param name + * @returns {String} + */ + getLocationParameter: function (response, name) { + var location = response.getHeader("Location") || undefined; + if (location) { + return this.getUrlParameter(location, name); + } + }, + + /** + * Extract the specified parameter from a URL. + * + * @mehtod getUrlParameter + * @param url + * @param name + * @returns {Boolean} + */ + getUrlParameter : function (url, name) { + return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url)||[,""])[1].replace(/\+/g, '%20'))||null; + }, + + /** + * Validate a string field, and return a Promise if invalid. + * + * @param fieldName + * @param fieldValue + */ + validateField : function(fieldName, fieldValue) { + if (!fieldValue) { + var message = "Invalid value {0} for field {1}, the field must not be empty or undefined."; + message = stringUtil.substitute(message, [ fieldValue || "'undefined'", fieldName ]); + return this.createBadRequestPromise(message); + } + }, + + /** + * Validate a map of fields, and return a Promise for first invalid field found. + * + * @param fieldMap + */ + validateFields : function(fieldMap) { + for(var name in fieldMap){ + var value = fieldMap[name]; + var promise = this.validateField(name, value); + if (promise) { + return promise; + } + } + }, + + /** + * Validate HTML5 File API Support for browser and JS Library + */ + validateHTML5FileSupport : function() { + if (!window.File || !window.FormData) { + var message = "HTML 5 File API is not supported by the Browser."; + return this.createBadRequestPromise(message); + } + // Dojo 1.4.3 does not support HTML5 FormData + if(util.getJavaScriptLibrary().indexOf("Dojo 1.4") != -1) { + return this.createBadRequestPromise("Dojo 1.4.* is not supported for Update Profile Photo"); + } + }, + + /* + * Validate the entityId and if invalid notify callbacks + */ + _validateEntityId : function(entityId) { + if (!entityId || !lang.isString(entityId)) { + var message = "Invalid argument {0}, expected valid entity identifier."; + message = stringUtil.substitute(message, [ entityId || "'undefined'" ]); + return this.createBadRequestPromise(message); + } + }, + + /** + * Returns HTML5 File Control object + * @param {Object} fileControlOrId FileControl or ID of File Control + * @returns {Object} FileControl + */ + getFileControl : function(fileControlOrId) { + var fileControl = null; + if (typeof fileControlOrId == "string") { + fileControl = document.getElementById(fileControlOrId); + } else if (typeof fileControlOrId == "object") { + fileControl = fileControlOrId; + } + return fileControl; + } + + }); + return BaseService; }); }, -'sbt/smartcloud/controls/profiles/ProfileGridRenderer':function(){ +'sbt/connections/controls/bootstrap/FileRendererMixin':function(){ require({cache:{ -'url:sbt/smartcloud/controls/profiles/templates/ProfileRow.html':"\r\n\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t \r\n\t\t\t\t\r\n\t\t\t\t\t${name}\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t

    \r\n\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t${title}\r\n\t\t\t\t${orgName}\r\n\t\t\t
    \r\n\t\t\t
    ${address}
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t\r\n\t\t\tNetwork Contact\r\n\t\t\r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t ${primaryTelephone}\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t \r\n\t\t\t${email}\r\n\t\t
    \r\n\t\r\n\r\n", -'url:sbt/smartcloud/controls/profiles/templates/CommunityMember.html':"\r\n\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t${title}\r\n\r\n\t\t

    \r\n\t\t\r\n\t\r\n\t\r\n\t\t\r\n\t\t\tRole: ${role}\r\n\t\t\r\n\t\r\n\r\n"}}); +'url:sbt/connections/controls/bootstrap/templates/FileRow.html':"\r\n \r\n \r\n \r\n \r\n \r\n \"\"${_nls.download}\r\n \r\n \r\n \r\n

    \r\n ${title} \r\n

    \r\n
    \r\n
      \r\n
    • \r\n \r\n \t\t\t\t\t\t${authorName}\r\n \t\t\t\t\t\t${authorUid}\r\n\t\t\t\t\t\r\n ${_nls.created} ${createdLabel}\r\n
    • \r\n
    • \r\n ${hitCount} ${_nls.downloads}\r\n
    • \r\n
    • \r\n ${commentCount} ${_nls.comments}\r\n
    • \r\n
    \r\n
    \r\n \r\n \r\n \r\n\r\n\r\n\r\n"}}); /* * © Copyright IBM Corp. 2013 * @@ -28043,142 +26277,22 @@ require({cache:{ */ /** - * @module sbt.smartcloud.controls.profiles.ProfileGridRenderer + * */ -define(["../../../declare", "../../../lang", "../../../stringUtil", "../BaseGridRenderer", - "../../../i18n!./nls/ProfileGridRenderer", - "../../../text!./templates/ProfileRow.html", - "../../../text!./templates/CommunityMember.html"], - function(declare, lang, stringUtil, BaseGridRenderer, nls, profileTemplate,communityMemberTemplate) { - +define(["../../../lang", "../../../controls/grid/bootstrap/GridRendererMixin", + "../../../text!./templates/FileRow.html" ], + function(lang, GridRendererMixin, FileRow) { + /** - * @class ProfileGridRenderer - * @namespace sbt.smartcloud.controls.profiles + * @module sbt.controls.grid.bootstrap.FileRendererMixin */ - var ProfileGridRenderer = declare(BaseGridRenderer, { - - /* - * The strings used in the grid, these are stored in a separate file, in the nls folder - */ - _nls: nls, - - /** - * The template used to display a row in the grid - */ - template: profileTemplate, - - /** - * The template used to construct a photo url - */ - contactImageUrl: "{baseUrl}/contacts/img/photos/{photo}", - - /** - * The template used to construct a no photo url - */ - noContactImageUrl: "{baseUrl}/contacts/img/noContactImage.gif", - - /** - * URL for community member photos - */ - communityMemberImageUrl: "{baseUrl}/contacts/profiles/photo/{uid}", - - /** - * The constructor function - * @method constructor - * @param args - */ - constructor: function(args) { - if(args){ - if(args.type === "communityMembers"){ - this.template = communityMemberTemplate; - } - } - }, - - /** - * Sets the css class for the row - * @method rowClass - * @param grid The Grid Dijit - * @param item the current row - * @param i the number of the current row, ie 0, 1, 2 etc - * @param items all of the rows in the grid - */ - rowClass: function(grid, item, i, items) { - item.rowClass = (i === 0 ? "lotusFirst" : (i % 2 === 1 ? "lotusAltRow" : null)); - }, - - /** - * - * @param grid - * @param item - * @param i - * @param items - * @returns {String} - */ - photoUrl: function(grid, item, i, items) { - var ep = grid.store.getEndpoint(); - if (!ep) return null; - - var photos = item.getValue("photos"); - if (photos && lang.isArray(photos) && photos.length > 1) { - return stringUtil.replace(this.contactImageUrl, { baseUrl : ep.baseUrl , photo : photos[1] }); - } else { - return stringUtil.replace(this.noContactImageUrl, { baseUrl : ep.baseUrl }); - } - }, - - getMemberPhoto: function(grid, item, i, items){ - var ep = grid.store.getEndpoint(); - if (!ep) return null; - - var id = item.getValue("uid"); - if(lang.isString(id)){ - return stringUtil.replace(this.communityMemberImageUrl, { baseUrl : ep.baseUrl , uid : id }); - }else{ - return stringUtil.replace(this.noContactImageUrl, { baseUrl : ep.baseUrl }); - } - }, - - /** - * - * @param grid - * @param item - * @param i - * @param items - * @returns {String} - */ - primaryTelephone: function(grid, item, i, items) { - var phoneNumbers = item.getValue("phoneNumbers"); - if (phoneNumbers && lang.isArray(phoneNumbers) && phoneNumbers.length > 0) { - return phoneNumbers[0]; - } else { - return undefined; - } - }, - - /** - * Displays a tooltip by calling the getTooltip function in the ProfileAction class - * @method tooltip - * @param grid The Grid control - * @param item the element to display the tooltip - * @param i the number of the current row - * @param items all of the items in the grid row - * @returns A Tooltip the default for profiles is to display the vCard - */ - tooltip: function(grid, item, i, items) { - if (grid.profileAction) { - return grid.profileAction.getTooltip(item); - } - } - - }); + return lang.mixin(GridRendererMixin, { template : FileRow }); - return ProfileGridRenderer; }); }, -'sbt/connections/controls/astream/_XhrHandler':function(){ +'sbt/base/DataHandler':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012,2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28192,182 +26306,179 @@ define(["../../../declare", "../../../lang", "../../../stringUtil", "../BaseGrid * implied. See the License for the specific language governing * permissions and limitations under the License. */ -define(["../../../declare", "../../../config", "../../../stringUtil", "../../../lang", "../../../util"], function(declare, config, stringUtil, lang, util){ - /* - * @class _XhrHandler - */ - var _XhrHandler = declare(null, - { - /* - * The endpoint to use when making xhr requests. - * - * @property endpoint - * @type Object - * @default null + +/** + * Social Business Toolkit SDK. Helpers for the base capabilities of data + * handlers. + * + * @module sbt.base.DataHandler + */ +define([ "../declare", "../lang" ], function(declare,lang) { + + /** + * DataHandler class + * + * @class DataHandler + * @namespace sbt.base + */ + var DataHandler = declare(null, { + + /** + * Data type for this DataHandler */ - endpoint: null, - - - authString: "basic/", - - /* - * If it is public, make sure the AS urls go through the "anonymous" (i.e. requires no auth) urls. - * - * @property isPublic - * @type Boolean - * @default false + dataType : null, + + /** + * Data for this DataHandler */ - isPublic: false, - - /* - * Service mappings, e.g. if /files path is customised to /myfiles - * - * @property contextRootMap - * @type Object + data : null, + + /** + * @constructor + * @param {Object} + * args Arguments for this data handler. */ - contextRootMap: { - connections: "connections" + constructor : function(args) { + lang.mixin(this, args); }, - - /* - * The endpoint auth mapped to their AS url equivalents. This will be used to ensure each request uses the right url. + + /** + * Called to set the handler data. * - * @property _authStrings - * @type Object + * @param data */ - _authStrings : { - "sso" : "", - "basic" : "basic/", - "oauth" : "oauth/", - "public" : "anonymous/" + setData : function(data) { + this.data = data; }, - /* - * This method modifies the activitystream request urls so that they - * 1. Go through our proxy, and have the correct service mapping. - * 2. Have the correct auth signature - * 3. Are using the right application protocol - * - * Most urls will be using sso by default. - * - * @method modifyUrl - * - * @param {Object} args + /** + * Called to get the handler data. * - * @param {String} args.url The url which we will xhr to. If this is not present this method does nothing. + * @param data */ - modifyUrl: function(args){ - if(!args.url){ - return; - } - if (args.url.indexOf("/") === 0){ - args.serviceUrl = args.url; - args.serviceUrl = this.correctUrlAuth(args.serviceUrl); - delete args.url; - } else if (args.url.indexOf("proxy") === -1){ - if(args.url.indexOf("https") !== -1){ - args.url = this.endpoint.proxy.proxyUrl + "/" + this.endpoint.proxyPath + "/" + args.url.replace(/https:\/\/.[^\/]+\//, ""); - } - else if(args.url.indexOf("http") !== -1){ - args.url = this.endpoint.proxy.proxyUrl + "/" + this.endpoint.proxyPath + "/" + args.url.replace(/http:\/\/.[^\/]+\//, ""); - } - args.url = this.correctUrlAuth(args.url); - } + getData : function() { + return this.data; }, - /* - * @param {String} url An ActivityStream url. - * - * @return {String} A url with the correct authentication pattern for our current endpoint. + /** + * @method getAsString + * @param data + * @returns */ - correctUrlAuth: function (url){ - // replace the piece from 'opensocial/' to 'rest/' with the correct auth. - var authType = this.isPublic ? "anonymous/" : this._authStrings[this.endpoint.authType]; - var correctASAuthSig = "opensocial/" + authType + "rest/"; - var opensocialIndex = url.indexOf("opensocial/"); - var restEndIndex = url.indexOf("rest/") + 5; - - if(opensocialIndex !== -1 && restEndIndex !== -1 && url.indexOf(correctASAuthSig) === -1){ - url = url.slice(0, opensocialIndex) + correctASAuthSig + url.slice(restEndIndex); - } - - return url; + getAsString : function(property) { + return null; }, - - getEndpoint: function(){ - return this.endpoint; + + /** + * @method getAsNumber + * @returns + */ + getAsNumber : function(property) { + return null; }, - - /* - * The constructor. - * - * @method constructor - * @param {String} endpointName The name of the endpoint to use. + + /** + * @method getAsDate + * @returns */ - constructor: function(endpointName){ - this.endpoint = config.findEndpoint(endpointName); + getAsDate : function(property) { + return null; }, - - /* - * Make an XHR HEAD request. - * @method xhrGet - * @param args The xhr args. + + /** + * @method getAsBoolean + * @returns */ - xhrGet: function(args){ - this.modifyUrl(args); - return this.xhr("GET", args); + getAsBoolean : function(property) { + return null; }, - - /* - * Make an XHR POST request. - * @param args xhr args + + /** + * @method getAsArray + * @returns */ - xhrPost: function(args){ - this.modifyUrl(args); - return this.xhr("POST", args); + getAsArray : function(property) { + return null; }, - - /* - * Make an XHR PUT request. - * @param args xhr args + + /** + * @method getEntityId + * @returns */ - xhrPut: function(args){ - this.modifyUrl(args); - return this.xhr("PUT", args); + getEntityId : function(data) { + return null; }, - - /* - * Make an XHR DELETE request. - * @param args xhr args + + /** + * @param parent + * @returns */ - xhrDelete: function(args){ - this.modifyUrl(args); - return this.xhr("DELETE", args); + getEntityData : function(parent) { + return data; }, - - /* - * Make an XHR GET request. - * @param args xhr args + + /** + * @method getSummary + * @returns */ - xhrHead: function(args){ - this.modifyUrl(args); - return this.xhr("HEAD", args); + getSummary : function() { + return null; }, + + /** + * @method getEntitiesDataArray + * @returns {Array} + */ + getEntitiesDataArray : function() { + return []; + }, - /* - * An xhrHandler needs to have an xhr function to use the xhr handler init in connections >= 4.5 + /** + * @method toJso + * @returns {Object} */ - xhr: function(method, args){ - this.modifyUrl(args); - return this.endpoint.xhr(method, args); + toJson : function() { } + }); - - return _XhrHandler; + return DataHandler; }); +}, +'sbt/nls/messageSSO':function(){ +/* + * © 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. + */ + +/** + * Social Business Toolkit SDK - Default resource bundle for validate module. + */ + +define({ + root: ({ + message_title: "ReAuthenticate", + message:"Authentication expired, Please login again.", + relogin_button_text: "Re-Login" + }) +}); }, -'sbt/connections/ActivityStreamService':function(){ +'sbt/connections/controls/profiles/ColleagueGridRenderer':function(){ +require({cache:{ +'url:sbt/connections/controls/profiles/templates/ColleagueItem.html':"
    \r\n \r\n \r\n \"${title}\"\r\n \r\n ${uid}\r\n ${title}\r\n \r\n
    ", +'url:sbt/connections/controls/profiles/templates/ViewAll.html':"\r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n ${viewAllTitle}\r\n \r\n
    ", +'url:sbt/connections/controls/profiles/templates/ColleagueItemFull.html':"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \"${name}\r\n \r\n ${uid}\r\n ${name}\r\n \r\n
    \r\n
    \r\n \r\n ${name}\r\n ${uid}\r\n ${name}\r\n \r\n
    \r\n"}}); /* * © Copyright IBM Corp. 2013 * @@ -28385,633 +26496,434 @@ define(["../../../declare", "../../../config", "../../../stringUtil", "../../../ */ /** - * JavaScript API for IBM Connections Activity Stream Service. * - * @module sbt.connections.ActivityStreamService */ -define([ "../declare", "../lang", "../stringUtil", "../config", "../Promise", "./ActivityStreamConstants", "./ConnectionsService","../base/BaseEntity", "../base/DataHandler", 'sbt/json'], - function(declare,lang,stringUtil,config,Promise,consts,ConnectionsService, BaseEntity,DataHandler, json) { - - /** - * JsonDataHandler class - * - * @class JsonDataHandler - * @namespace sbt.base - */ - var ActivityStreamsDataHandler = declare(DataHandler, { - - constructor : function(args) { - lang.mixin(this, args); - this.data = args.data; - }, - - getSummary : function() { - if (!this._summary && this.data.totalResults) { - this._summary = { - totalResults : this.data.totalResults, - startIndex : this.data.startIndex, - itemsPerPage : this.data.itemsPerPage - }; - } - return this._summary; - }, - - getEntitiesDataArray : function() { - return this.data.list; - } - - }); - - +define(["../../../declare", "../../../stringUtil", + "../../../dom","../../../lang", + "../ConnectionsGridRenderer", + "../../../i18n!./nls/ColleagueGridRenderer", + "../../../text!./templates/ColleagueItem.html", + "../../../text!./templates/ViewAll.html", + "../../../text!./templates/ColleagueItemFull.html"], + function(declare, stringUtil, dom, lang, ConnectionsGridRenderer, nls, colleagueItemTemplate, viewAllTemplate, colleagueItemFullTemplate) { + /** - * ActivityStreamEntry class. - * - * @class ActivityStreamEntry - * @namespace sbt.connections + * @class ColleagueGridRenderer + * @namespace sbt.connections.controls.profiles + * @module sbt.connections.controls.profiles.ColleagueGridRenderer */ - var ActivityStreamEntry = declare(BaseEntity, { + var ColleagueGridRenderer = declare(ConnectionsGridRenderer, { - data: null, - - /** - * Get published date of activity stream entry - * - * @method getPublishedDate - */ - getPublishedDate: function(){ - return this.dataHandler.data.published; - }, + _nls: nls, + + containerClass: "lotusChunk", + + template: colleagueItemTemplate, + viewAllTemplate: viewAllTemplate, + fullTemplate: colleagueItemFullTemplate, + + countAlign: "left", + verticalAlign: "middle", + + render: function(grid, el, items, data) { + while (el.childNodes[0]) { + dom.destroy(el.childNodes[0]); + } + var size = items.length; + if (size === 0) { + this.renderEmpty(grid, el); + } + else { + var container = this.renderContainer(grid, el, items, data); + for (var i=0; i\r\n
      \r\n ${bodyPersonCardLi}\r\n ${bodyUpdatedLi}\r\n ${bodyCommentCountLi}\r\n ${objectReferenceLi}\r\n ${tagsList}\r\n ${bodyBookmarkLi}\r\n
    \r\n", +'url:sbt/connections/controls/search/templates/SingleSearchPopUp.html':"
      \r\n \r\n
    ", +'url:sbt/connections/controls/search/templates/DefaultHeader.html':"", +'sbt/xml':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - /** - * Get actor name of the activity stream entry - * - * @method getActorDisplayName - */ - getActorDisplayName: function(){ - return this.dataHandler.data.actor.displayName; - }, +/** + * Social Business Toolkit SDK - XML utilities. + */ +define(['./lang'], function(lang) { + var xml_to_encoded = { + '&': '&', + '"': '"', + '<': '<', + '>': '>' + }; + + var encoded_to_xml = { + '&': '&', + '"': '"', + '<': '<', + '>': '>' + }; - /** - * Get full actor object of the activity stream entry. Object holds all properties of actor. - Here is an example of an actor object: - { - connections:{ - state:"active" - }, - objectType:"person", - id:"urn:lsid:lconn.ibm.com:profiles.person:0EE5A7FA-3434-9A59-4825-7A7000278DAA", - displayName:"Frank Adams" + return { + /** + * XML Parser. + * This function parses an XML string and returns a DOM. + */ + parse: function(xml) { + var xmlDoc=null; + try { + if(!document.evaluate){ + xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); + xmlDoc.async="false"; + xmlDoc.loadXML(xml); + }else{ + if(window.DOMParser){ + parser=new DOMParser(); + xmlDoc=parser.parseFromString(xml,"text/xml"); + } } - * - * @method getActor - */ - getActor: function(){ - return this.dataHandler.data.actor; + }catch(ex){ + console.log(ex.message); + } + return xmlDoc; }, - - /** - * Get verb of activity stream entry, verb represents the type of action that was done - * - * @method getVerb - */ - getVerb: function(){ - return this.dataHandler.data.verb; + asString: function(xmlDoc) { + if (xmlDoc==null) { + return ""; + } else if(window.ActiveXObject){ + return xmlDoc.xml; + } else { + return (new XMLSerializer()).serializeToString(xmlDoc); + } }, - - /** - * Get id of activity stream entry - * - * @method getId - */ - getId: function(){ - return this.dataHandler.data.id; + getText : function (xmlElement){ + if(!document.evaluate){ + return xmlElement.text; + }else{ + return xmlElement.textContent; + } + }, + encodeXmlEntry: function(string) { + if (lang.isArray(string)) { + string = string.join(); + } + if (!lang.isString(string)) { + string = string.toString(); + } + return string.replace(/([\&"<>])/g, function(str, item) { + return xml_to_encoded[item]; + }); + }, + decodeXmlEntry: function (string) { + return string.replace(/("|<|>|&)/g,function(str, item) { + return encoded_to_xml[item]; + }); } - - - }); - - /** - * Callbacks used when reading a feed that contains ActivityStream entries. - */ - var getActivityStreamServiceCallbacks = { - createEntities : function(service,data,response) { - return new ActivityStreamsDataHandler({ - data : data - }); - }, - createEntity : function(service,data,response) { - var entryHandler = new ActivityStreamsDataHandler({ - data : data - }); - return new ActivityStreamEntry({ - service : service, - dataHandler : entryHandler - }); - } - }; + }; +}); +}, +'url:sbt/connections/controls/vcard/templates/ProfileVCardInline.html':"\r\n ${userName}\r\n ${userId}\r\n\r\n", +'url:sbt/connections/controls/templates/FileGridWrapperContent.html':"\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n
    \r\n
    \r\n \r\n \r\n\r\n", +'sbt/IWidget':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - /** - * ActivityStreamService class. - * - * @class ActivityStreamService - * @namespace sbt.connections - */ - var ActivityStreamService = declare(ConnectionsService, { - - contextRootMap: { - connections: "connections" - }, - - serviceName : "connections", - - /** - * Constructor for ActivityStreamService - * - * @constructor - * @param args - */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } - }, - - /** - * Callbacks used when reading a feed that contains Activity Stream entries. - */ - getActivityStreamCallbacks: function() { - return getActivityStreamServiceCallbacks; - }, - - /** - * Get activity stream for given user, group and application type - * - * @method getStream - * @param {String} [userType] user type for which activity stream is to be obtained. - * If null is passed for userType, then '@public' will be used as - * default - * @param {String} [groupType] group type for which activity stream is to be obtained - * If null is passed for userType, then '@all' will be used as - * default - * @param {String} [applicationType] application type for which activity stream is to be obtained - * If null is passed for userType, then '@all' will be used as - * default - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getStream : function(userType, groupType, applicationType, args) { - var _userType = userType || consts.ASUser.PUBLIC; //Default is public updates - var _groupType = groupType || consts.ASGroup.ALL; // Default is all groups - var _applicationType = applicationType || consts.ASApplication.STATUS; // Default is all Applications -// var url = consts.ActivityStreamUrls.activityStreamBaseUrl+this.endpoint.authType+consts.ActivityStreamUrls.activityStreamRestUrl+_userType+"/"+_groupType+"/"+_applicationType; - var url = this.constructUrl(consts.ActivityStreamUrls.activityStreamBaseUrl+"{authType}"+consts.ActivityStreamUrls.activityStreamRestUrl+"{userType}/{groupType}/{appType}", - {}, - { authType : (this.endpoint.authType == "sso") ? "":this.endpoint.authType, userType : _userType, groupType : _groupType, appType : _applicationType }); - var options = { - method : "GET", - handleAs : "json", - query : args || {} - }; - return this.getEntities(url, options, this.getActivityStreamCallbacks()); - }, - - /** - * Get all updates. - * - * @method getAllUpdates - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getAllUpdates : function(args) { - return this.getStream(consts.ASUser.PUBLIC, consts.ASGroup.ALL, consts.ASApplication.ALL, args); - }, - - /** - * Get my status updates. - * - * @method getMyStatusUpdates - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getMyStatusUpdates : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.ALL, consts.ASApplication.STATUS, args); - }, - - /** - * Get status updates from my network. - * - * @method getStatusUpdatesFromMyNetwork - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getStatusUpdatesFromMyNetwork : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.FRIENDS, consts.ASApplication.STATUS, args); - }, +/** + * Social Business Toolkit SDK - iWidget specific helpers. + */ +define([],function() { - /** - * Get Updates from My Network - * - * @method getUpdatesFromMyNetwork - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getUpdatesFromMyNetwork : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.FRIENDS, consts.ASApplication.ALL, args); - }, +sbt.getUserPref = function(ns,name) { + +}; - /** - * Get Updates from People I Follow - * - * @method getUpdatesFromPeopleIFollow - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getUpdatesFromPeopleIFollow : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.FOLLOWING, consts.ASApplication.STATUS, args); - }, +}); +}, +'sbt/dom':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - /** - * Get Updates from Communities I Follow - * - * @method getUpdatesFromCommunitiesIFollow - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getUpdatesFromCommunitiesIFollow : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.ALL, consts.ASApplication.COMMUNITIES, args); - }, +/** + * Definition of some DOM utilities. + * + * @module sbt.dom + */ +define(['./_bridge/dom'],function(dom) { + // The actual implementation is library dependent + // NOTE: dom.byId returns either a DOM element or false (null/undefined) + return dom; +}); - /** - * Get Updates from a Community +}, +'url:sbt/connections/controls/search/templates/li.html':"
  • ${content}
  • ", +'sbt/connections/controls/astream/_XhrHandler':function(){ +/* + * © 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. + */ +define(["../../../declare", "../../../config", "../../../stringUtil", "../../../lang", "../../../util"], function(declare, config, stringUtil, lang, util){ + /* + * @class _XhrHandler + */ + var _XhrHandler = declare(null, + { + /* + * The endpoint to use when making xhr requests. * - * @method getUpdatesFromCommunity - * @param {String} communityID Community id Community id for which activity Stream - * is to be obtained - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. + * @property endpoint + * @type Object + * @default null */ - getUpdatesFromCommunity : function(communityID, args) { - var promise = this._validateCommunityUuid(communityID); - if (promise) { - return promise; - } - return this.getStream(consts.ASUser.COMMUNITY+communityID, consts.ASGroup.ALL, consts.ASApplication.ALL, args); - }, + endpoint: null, - /** - * Get Updates from a User - * - * @method getUpdatesFromUser - * @param {String} userId User id for which activity Stream - * is to be obtained - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getUpdatesFromUser : function(userId, args) { - var promise = this._validateUserId(userId); - if (promise) { - return promise; - } - return this.getStream(userId, consts.ASGroup.INVOLVED, consts.ASApplication.ALL, args); - }, - /** - * Get Notifications for Me - * - * @method getNotificationsForMe - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getNotificationsForMe : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.RESPONSES, consts.ASApplication.ALL, args); - }, + authString: "basic/", - /** - * Get Notifications from Me + /* + * If it is public, make sure the AS urls go through the "anonymous" (i.e. requires no auth) urls. * - * @method getNotificationsFromMe - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. + * @property isPublic + * @type Boolean + * @default false */ - getNotificationsFromMe : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.NOTESFROMME, consts.ASApplication.ALL, args); - }, + isPublic: false, - /** - * Get Responses to My Content - * - * @method getResponsesToMyContent - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getResponsesToMyContent : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.RESPONSES, consts.ASApplication.ALL, args); - }, - - /** - * Get Actions pending on me - * - * @method getMyActionableItems - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getMyActionableItems : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.ACTIONS, consts.ASApplication.ALL, args); - }, - - /** - * Get Actions pending on me for an applications + /* + * Service mappings, e.g. if /files path is customised to /myfiles * - * @method getMyActionableItemsForApplication - * @param {String} application name for which pending action items - * are to be obtained - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. + * @property contextRootMap + * @type Object */ - getMyActionableItemsForApplication : function(application, args) { - var promise = this._validateApplicationName(application); - if (promise) { - return promise; - } - return this.getStream(consts.ASUser.ME, consts.ASGroup.ACTIONS, application, args); + contextRootMap: { + connections: "connections" }, - /** - * Get Updates Saved by me + /* + * The endpoint auth mapped to their AS url equivalents. This will be used to ensure each request uses the right url. * - * @method getMySavedItems - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. + * @property _authStrings + * @type Object */ - getMySavedItems : function(args) { - return this.getStream(consts.ASUser.ME, consts.ASGroup.SAVED, consts.ASApplication.ALL, args); + _authStrings : { + "sso" : "", + "basic" : "basic/", + "oauth" : "oauth/", + "public" : "anonymous/" }, - /** - * Get Updates Saved by me + /* + * This method modifies the activitystream request urls so that they + * 1. Go through our proxy, and have the correct service mapping. + * 2. Have the correct auth signature + * 3. Are using the right application protocol * - * @method getMySavedItemsForApplication - * @param {String} application name for which saved items - * are to be obtained - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - getMySavedItemsForApplication : function(application, args) { - var promise = this._validateApplicationName(application); - if (promise) { - return promise; - } - return this.getStream(consts.ASUser.ME, consts.ASGroup.SAVED, application, args); - }, - - /** - * Get searched view by query + * Most urls will be using sso by default. * - * @method searchByQuery - * @param {String} query string for which activity stream search is to be done. - */ - searchByQuery : function(searchString) { - var promise = this._validateSearchQuery(searchString); - if (promise) { - return promise; - } - var args = { - query : searchString - }; - return this.getStream(null, null, null, args); - }, - - /** - * Get searched view by filters + * @method modifyUrl * - * @method searchByFilters - * @param {String} query Filters can be passed to this method to get as activity stream - * filtered by them. here is a sample string of two filters: - * "[{'type':'tag','values':['"+tags+"']},{'type':'tag','values':['test','mobile']}]" - * @param {String} filters Filters can be passed to this method to get as activity stream - * filtered by them. here is a sample string of two filters: - * "[{'type':'tag','values':['"+tags+"']},{'type':'tag','values':['test','mobile']}]" - */ - searchByFilters : function(query, filters) { - var promise = this._validateSearchQuery(query); - if (promise) { - return promise; - } - var promise = this._validateSearchFilters(filters); - if (promise) { - return promise; - } - var args = {}; - args.query = query; - args.filters = filters; - return this.getStream(null, null, null, args); - }, - - /** - * Get searched view by tags + * @param {Object} args * - * @method searchByTags - * @param {String} tags string containing tags separated by commas for which activity - * stream search is to be done. + * @param {String} args.url The url which we will xhr to. If this is not present this method does nothing. */ - searchByTags : function(tags) { - var promise = this._validateSearchTags(tags); - if (promise) { - return promise; + modifyUrl: function(args){ + if(!args.url){ + return; } - var args = {}; - args.filters = "[{'type':'tag','values':['"+tags+"']}]"; - return this.getStream(null, null, null, args); - }, - - /** - * Get searched view by pattern - * - * @method searchByPattern - * @param {String} pattern string containing tags separated by commas for which activity - * stream search is to be done. - */ - searchByPattern : function(pattern) { - var promise = this._validateSearchTags(pattern); - if (promise) { - return promise; + if (args.url.indexOf("/") === 0){ + args.serviceUrl = args.url; + args.serviceUrl = this.correctUrlAuth(args.serviceUrl); + delete args.url; + } else if (args.url.indexOf("proxy") === -1){ + if(args.url.indexOf("https") !== -1){ + args.url = this.endpoint.proxy.proxyUrl + "/" + this.endpoint.proxyPath + "/" + args.url.replace(/https:\/\/.[^\/]+\//, ""); + } + else if(args.url.indexOf("http") !== -1){ + args.url = this.endpoint.proxy.proxyUrl + "/" + this.endpoint.proxyPath + "/" + args.url.replace(/http:\/\/.[^\/]+\//, ""); + } + args.url = this.correctUrlAuth(args.url); } - var args = {}; - args.custom = pattern; - return this.getStream(null, null, null, args); }, - - /** - * post an Activity Stream entry + + /* + * @param {String} url An ActivityStream url. * - * @method postEntry - * @param {Object} postData a json object representing data to be posted - * @param {String} [userType] user type for which activity stream is to be posted - * If null is passed for userType, then '@me' will be used as - * default - * @param {String} [groupType] group type for which activity stream is to be posted - * If null is passed for userType, then '@all' will be used as - * default - * @param {String} [applicationType] for which activity stream is to be posted - * If null is passed for userType, then '@all' will be used as - * default - * @param {Object} [args] Object representing various query parameters - * that can be passed. The parameters must be exactly as they are - * supported by IBM Connections. - */ - postEntry : function(postData, userType, groupType, applicationType, args) { - var _userType = userType || consts.ASUser.ME; //Default is public updates - var _groupType = groupType || consts.ASGroup.ALL; // Default is all groups - var _applicationType = applicationType || consts.ASApplication.ALL; // Default is all Applications - var url = consts.ActivityStreamUrls.activityStreamBaseUrl+this.endpoint.authType+consts.ActivityStreamUrls.activityStreamRestUrl+_userType+"/"+_groupType+"/"+_applicationType; - var headers = {"Content-Type" : "application/json"}; - var options = { - method : "POST", - query : args || {}, - handleAs : "json", - headers : headers, - data : json.stringify(postData) - }; - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - return data; - }; - return this.updateEntity(url, options, callbacks, args); + * @return {String} A url with the correct authentication pattern for our current endpoint. + */ + correctUrlAuth: function (url){ + // replace the piece from 'opensocial/' to 'rest/' with the correct auth. + var authType = this.isPublic ? "anonymous/" : this._authStrings[this.endpoint.authType]; + var correctASAuthSig = "opensocial/" + authType + "rest/"; + var opensocialIndex = url.indexOf("opensocial/"); + var restEndIndex = url.indexOf("rest/") + 5; + + if(opensocialIndex !== -1 && restEndIndex !== -1 && url.indexOf(correctASAuthSig) === -1){ + url = url.slice(0, opensocialIndex) + correctASAuthSig + url.slice(restEndIndex); + } + + return url; }, - /** - * post an Activity Stream microblog entry + getEndpoint: function(){ + return this.endpoint; + }, + + /* + * The constructor. * - * @method postMicroblogEntry - * @param {Object/String} postData a json object representing data to be posted - * @param {String} [userType] user type for which activity stream is to be posted - * If null is passed for userType, then '@public' will be used as - * default - * @param {String} [groupType] group type for which activity stream is to be posted - * If null is passed for userType, then '@all' will be used as - * default - * @param {String} [applicationType] for which activity stream is to be posted - * If null is passed for userType, then '@all' will be used as - * default - * @param {Object} [args] Object representing various parameters - * that can be passed to post an activity stream. - * The parameters must be exactly as they are - * supported by IBM Connections. + * @method constructor + * @param {String} endpointName The name of the endpoint to use. */ - postMicroblogEntry : function(postData, userType, groupType, applicationType, args) { - if (typeof postData == "string") { - postData = {"content":postData}; - } else if (typeof postData == "object") { - postData = postData; - } else { - return this.createBadRequestPromise("Invalid argument with postMicroblogEntry, expected String or Object"); - } - var _userType = userType || consts.ASUser.ME; //Default is public updates - var _groupType = groupType || consts.ASGroup.ALL; // Default is all groups - var _applicationType = applicationType || ""; // Default is all Applications - var url = consts.ActivityStreamUrls.activityStreamBaseUrl+this.endpoint.authType+consts.ActivityStreamUrls.activityStreamUBlogRestUrl+_userType+"/"+_groupType+"/"+_applicationType; - var headers = {"Content-Type" : "application/json"}; - var options = { - method : "POST", - query : args || {}, - handleAs : "json", - headers : headers, - data : json.stringify(postData) - }; - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - return data; - }; - return this.updateEntity(url, options, callbacks, args); + constructor: function(endpointName){ + this.endpoint = config.findEndpoint(endpointName); }, /* - * Validate a community UUID, and return a Promise if invalid. + * Make an XHR HEAD request. + * @method xhrGet + * @param args The xhr args. */ - _validateCommunityUuid : function(communityUuid) { - if (!communityUuid || communityUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected communityUuid."); - } + xhrGet: function(args){ + this.modifyUrl(args); + return this.xhr("GET", args); }, /* - * Validate a search query, and return a Promise if invalid. + * Make an XHR POST request. + * @param args xhr args */ - _validateSearchQuery : function(searchQuery) { - if (!searchQuery || searchQuery.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected communityUuid."); - } + xhrPost: function(args){ + this.modifyUrl(args); + return this.xhr("POST", args); }, /* - * Validate application name, and return a Promise if invalid. + * Make an XHR PUT request. + * @param args xhr args */ - _validateApplicationName : function(application) { - if (!application || application.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected application name."); - } + xhrPut: function(args){ + this.modifyUrl(args); + return this.xhr("PUT", args); }, /* - * Validate search tags, and return a Promise if invalid. + * Make an XHR DELETE request. + * @param args xhr args */ - _validateSearchTags : function(searchTags) { - if (!searchTags || searchTags.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected communityUuid."); - } + xhrDelete: function(args){ + this.modifyUrl(args); + return this.xhr("DELETE", args); }, /* - * Validate search filters, and return a Promise if invalid. + * Make an XHR GET request. + * @param args xhr args */ - _validateSearchFilters : function(searchFilters) { - if (!searchFilters || searchFilters.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected communityUuid."); - } + xhrHead: function(args){ + this.modifyUrl(args); + return this.xhr("HEAD", args); }, /* - * Validate a user ID, and return a Promise if invalid. + * An xhrHandler needs to have an xhr function to use the xhr handler init in connections >= 4.5 */ - _validateUserId : function(userId) { - if (!userId || userId.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected userId."); - } + xhr: function(method, args){ + this.modifyUrl(args); + return this.endpoint.xhr(method, args); } - }); - return ActivityStreamService; + + return _XhrHandler; }); }, -'sbt/connections/controls/astream/ActivityStreamWrapper':function(){ +'sbt/connections/controls/profiles/ProfilePanel':function(){ require({cache:{ -'url:sbt/connections/controls/astream/templates/ActivityStreamContent.html':"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n"}}); +'url:sbt/connections/controls/profiles/templates/ProfilePanel.html':"
    \r\n\t
    \r\n\t\t
    \r\n\t\t\t\"${getThumbnailAlt}\"\r\n\t\t
    \r\n\t
    \r\n\t\r\n\t
    \r\n\t\t\r\n\t\t\t\r\n\t\t\t${getName}\r\n\t\t\t\r\n\t\t\t${getUserid}\r\n\t\t\r\n\t
    \r\n\t\r\n\t
    \r\n\t\t ${getJobTitle}
    \r\n\t\t${getTelephoneNumber}
    \r\n\t\t${getEmail}
    \r\n\t
    \r\n
    "}}); /* * © Copyright IBM Corp. 2013 * @@ -29027,199 +26939,324 @@ require({cache:{ * implied. See the License for the specific language governing * permissions and limitations under the License. */ -define(["../../../declare", "../../../lang", "../../../url", - "../../../config", "../../../util", "../../../stringUtil", "../../../connections/controls/WidgetWrapper", - "../../../text!../../../connections/controls/astream/templates/ActivityStreamContent.html", - "../../../i18n!sbt/connections/controls/astream/nls/ActivityStreamWrapper"], - function(declare, lang, Url, config, util, stringUtil, WidgetWrapper, defaultTemplate, nls) { +/** + * @module sbt.connections.controls.profiles.ProfilePanel + */ +define(["../../../declare", "../../../lang", "../../../config", + "../../../connections/ProfileService", + "../../../controls/panel/_ProfilePanel", + "../../../text!sbt/connections/controls/profiles/templates/ProfilePanel.html"], + function(declare, lang, config, ProfileService, _ProfilePanel, PanelTmpl) { + + var basicPeopleMe = "/connections/opensocial/basic/rest/people/@me/"; + var oauthPeopleMe = "/connections/opensocial/oauth/rest/people/@me/"; + /** - * The wrapper for the ActivityStream. - * This class just has to provide its own template and the args it receives back to to the WidgetWrapper, which will take care of everything else. - * - * Takes EITHER a feedUrl and an optional extensions object, OR an ActivityStream config object. - * If a feedUrl is specified any config object supplied will be ignored. - * - * The feedUrl is relative to the opensocial context root, and takes the following form for different authentication: - * sso url pattern: '.../opensocial/rest/...' - * oauth url pattern: '.../opensocial/oauth/rest/...' - * basic url pattern: '.../opensocial/basic/rest/...' - * public url pattern: '.../opensocial/anonymous/rest/...' - * - * The endpoint you use should support the authentication you specify with the url. - * - * @method constructor - * - * @param {Object} args - * @params {String} args.feedUrl The url of the feed to populate the ActivityStream with. - * @params {Object} [args.extensions] A simple list of extensions to load. - * @params {Boolean} [args.extensions.commenting] If true load the commenting extension. - * @params {Boolean} [args.extensions.saving] If true load the saving extension. - * @params {Boolean} [args.extensions.refreshButton] If true load the refresh button extension. - * @params {Boolean} [args.extensions.DeleteButton] If true load the delete button extension. - * - * @params {Object} args.config An ActivityStream config object. Only specify this without a feedUrl argument. - * - * @class sbt.controls.astream.ActivityStreamWrapper + * @module sbt.connections.controls.profiles.ProfilePanel */ - var ActivityStreamWrapper = declare([ WidgetWrapper ], { - - /** - * Set the html template which will go inside the iframe. - * - * @property defaultTemplate - * @type String - */ - defaultTemplate: defaultTemplate, - standardExtensionsMap: { - commenting: "com.ibm.social.as.extension.CommentExtension", - saving: "lconn.homepage.as.extension.SavedActionExtension", - refreshButton: "com.ibm.social.as.gadget.refresh.RefreshButtonExtension", - deleteButton: "com.ibm.social.as.lconn.extension.MicroblogDeletionExtension" + var ProfilePanel = declare([ _ProfilePanel ], { + + template: PanelTmpl, + profileService: null, + + constructor: function(args) { }, - /** - * Overriding the method in WidgetWrapper for providing the substitutions for variables in the template. - * - * @method getTemplateReplacements - * @returns {Object} - */ - getTemplateReplacements: function(){ - var proxyUrl = this._endpoint.proxy.proxyUrl + "/" + this._endpoint.proxyPath; - var connectionsUrl = this._endpoint.baseUrl; - var libUrl = new Url(config.Properties.libraryUrl); - var libQuery = libUrl.getQuery(); - var libQueryObj = {}; - var serviceMappings = this.getEndpoint().serviceMappings; - var connectionsServiceMapping = serviceMappings ? this.getEndpoint().serviceMappings.connections : null; - var connectionsContextRoot = connectionsServiceMapping ? connectionsServiceMapping : "connections"; - var extraIncludes = "~"; // extra classes we need to require in the aggregated call for js, e.g. extensions and side navs. - var extraExcludes = "~"; // extra classes we want to exclude, must be a string - - if(libQuery){ - libQueryObj = util.splitQuery(libQuery, "&"); - } - - lang.mixin(libQueryObj, { - lib: "dojo", - ver: "1.4.3" - }); - libQuery = util.createQuery(libQueryObj, "&"); - libUrl.setQuery(libQuery); - - var cssUrl = stringUtil.substitute("{0}/{1}/resources/web/com.ibm.social.as/css/activityStream.css", [connectionsUrl, connectionsContextRoot]); - if(this.cssUrl){ // in case there is one supplied in the constructor args - cssUrl = connectionsUrl + this.cssUrl; + getMyProfile: function() { + var endpoint = this._getEndpoint(); + var path = basicPeopleMe; + if (endpoint.authType == 'oauth') { + path = oauthPeopleMe; } - var sbtProps = lang.mixin({}, config.Properties); - lang.mixin(sbtProps, { - libraryUrl: libUrl.getUrl(), - loginUi: "popup" - }); - if(lang.isObject(this.args.extensions) && !(this.args.extensions instanceof Array)){ - var extensions = this.args.extensions; - var arrayConversion = []; - for (var key in extensions) { - if (extensions.hasOwnProperty(key)) { - arrayConversion.push(this.standardExtensionsMap[key]); - extraIncludes += this.standardExtensionsMap[key] + ".js~"; - } + var self = this; + endpoint.request(path, { handleAs : "json", preventCache : true }).then( + function(response) { + var userid = response.entry.id.replace('urn:lsid:lconn.ibm.com:profiles.person:', ''); + self.getProfile(userid); + }, + function(error) { + self._displayError(error); } - this.args.extensions = arrayConversion; - } - if(!this.args.feedUrl && this.args.config){ - var asConfig = this.args.config; - var extensionsArray = []; - this.getExtensionsToArray(asConfig, extensionsArray); + ); + }, + + getProfile: function(id) { + var self = this; + var promise = this._getProfileService().getProfile(id); + promise.then( + function(profile) { + self.profile = profile; + self.showProfile(); + }, + function(error) { + self.profile = null; + self._displayError(error); + } + ); + }, + + // Internals + + _getProfileService: function() { + if (!this.profileService) { + this.profileService = new ProfileService(this._getEndpointName()); + } + return this.profileService; + }, + + _getEndpoint: function() { + return config.findEndpoint(this._getEndpointName()); + }, + + _getEndpointName: function() { + return this.endpoint || "connections"; + } + + }); + + return ProfilePanel; +}); +}, +'sbt/authenticator/nls/SSO':function(){ +/* + * © 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. + */ - var i; - for(i = 0; i < extensionsArray.length; i++){ - extraIncludes += extensionsArray[i] + ".js~"; +/** + * Social Business Toolkit SDK - Default resource bundle for validate module. + */ + + +define({ + root: ({ + message_title: "ReAuthenticate", + message:"Authentication expired, Please login again." + }) + +}); +}, +'sbt/smartcloud/controls/profiles/ProfileGrid':function(){ +/* + * © 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. + */ + +/** + * + * @module sbt.smartcloud.controls.profiles.ProfileGrid + */ +define([ "../../../declare", + "../../../lang", + "../../../config", + "../../../controls/grid/Grid", + "./ProfileGridRenderer", + "./ProfileAction", + "../../../store/parameter", + "../../ProfileConstants", + "../../CommunityConstants"], + function(declare, lang, sbt, Grid, ProfileGridRenderer, ProfileAction, parameter, ProfileConstants,CommunityConstants) { + + var ProfileXPath = { + id : "o:person/o:id", + entry : "/o:response/o:entry", + uid : "o:person/o:id", + name : "o:person/o:displayName", + email : "o:person/o:emailAddress", + title : "o:person/o:jobtitle", + profileUrl : "o:person/o:profileUrl", + orgName : "o:person/o:org/o:name", + address : "o:person/o:address", + phoneNumbers : "o:person/o:phoneNumbers/o:phone", + photos : "o:person/o:photos/o:value" + }; + + var FeedXPath = { + "entry" : "/o:response/o:entry", + "entries" : "/o:response/o:entry", + "totalResults" : "/o:response/o:totalResults", + "startIndex" : "/o:response/o:startIndex", + "itemsPerPage" : "/o:response/o:itemsPerPage" + }; + + var Namespaces = { + o : "http://ns.opensocial.org/2008/opensocial" + }; + + var ParamSchema = { + startIndex : parameter.zeroBasedInteger("startIndex"), + pageSize : parameter.oneBasedInteger("count") + }; + + /** + * @class ProfileGrid + * @namespace sbt.connections.controls.profiles + */ + var ProfileGrid = declare(Grid, { + + /** + * @param options, This is a list of all + * the different types of profile grids available. + * Depending on which one is selected specific arguments will be given to + * the atom store and grid renderer. + */ + options : { + "contacts" : { + storeArgs : { + url : ProfileConstants.GetMyContacts, + attributes : ProfileXPath, + paramSchema : ParamSchema, + feedXPath : FeedXPath, + namespaces : Namespaces + }, + rendererArgs : { + type : "contacts" } - } - - var templateReplacements = { - args: JSON.stringify(this.args), - proxyUrl: proxyUrl, - connectionsUrl: connectionsUrl, - libraryUrl: libUrl.getUrl(), - sbtProps: JSON.stringify(sbtProps), - cssUrl: cssUrl, - connectionsContextRoot: connectionsContextRoot, - extraIncludes: extraIncludes, - extraExcludes: extraExcludes - }; - - return templateReplacements; + }, + "friends" : { + storeArgs : { + url : ProfileConstants.GetMyConnections, + attributes : ProfileXPath, + paramSchema : ParamSchema, + feedXPath : FeedXPath, + namespaces : Namespaces + }, + rendererArgs : { + type : "friends" + } + }, + "communityMembers" : { + storeArgs : { + url : CommunityConstants.AtomCommunityMembers, + attributes : CommunityConstants.MemberXPath, + paramSchema : ParamSchema, + feedXPath : CommunityConstants.CommunityFeedXPath, + namespaces: CommunityConstants.CommunityNamespaces + }, + rendererArgs : { + type : "communityMembers" + } + } }, - /* - * Used to recursively get all of the extension arrays in an activity stream configuration object. - * The result is placed in the second argument. - * - * @method getTemplateReplacements - * @params asConfig the configuration object - * @params resultArray The array to add new extensions to + /** + * Endpoint to use, default is 'smartcloud' */ - getExtensionsToArray: function(asConfig, resultArray){ - for (var key in asConfig) { - if (asConfig.hasOwnProperty(key)) { - if(lang.isObject(asConfig[key])){ - this.getExtensionsToArray(asConfig[key], resultArray); - } - - if(key == "extensions"){ - var extensionsArray = asConfig[key]; - if(lang.isArray(extensionsArray)){ - var i; - for(i = 0; i < extensionsArray.length; i++){ - var j; - var containsExtension = false; - for(j = 0; j < resultArray.length; j++){ - if(resultArray[j] == extensionsArray[i]){ - containsExtension = true; - } - } - if(!containsExtension){ - resultArray.push(extensionsArray[i]); - } - } - } - } - } - } + endpoint: "smartcloud", + + /** + * A profile action, defines default behaviour for when + * items in the grid are clicked on or hovered on, + * it is possible to override these actions + */ + profileAction: new ProfileAction(), + + /** + * This is the default grid that will be created if no + * arguments are given. + */ + defaultOption: "contacts", + + /** + * Constructor function + * @method constructor + */ + constructor: function(args){ + }, + + buildUrl: function(url, args, endpoint){ + var params; + if (this.communityUuid) { + params = {communityUuid: this.communityUuid}; + } + + return this.constructUrl(url, params, {},endpoint); }, /** - * Store the args so that they can be substituted into the defaultTemplate. - * - * @property args - * @type Object - * @default null + * Creates a renderer for the grid.The renderer is responsible for + * loading the grid's HTML content. + * @method createDefaultRenderer + * @param args sets the template the renderer will use, by checking args.type, but for + * profile grids this will always be "profile" + * @returns an instance of a profile gird renderer. */ - args: null, + createDefaultRenderer : function(args) { + return new ProfileGridRenderer(args); + }, + + postCreate: function(){ + this.inherited(arguments); + if(this.type === "communityMembers"){ + if(!arguments.communityUuid){ + this._updateWithError({message:this.renderer._nls.communityIdError}); + + } + } + }, /** - * Can be supplied in args to override the location of the ActivityStream's css. This url is relative to the connections server. - * - * @property cssUrl - * @type String - * @default "" + * In the grid HTML an element can have an event attached + * using dojo-attach-event="onClick: handleClick". + * This method is the handler for the onclick event. + * @method handleClick + * @param el the element that fired the event + * @param data all of the items from the current row of the grid. + * @param ev the event */ - cssUrl: "", + handleClick: function(el, data, ev) { + if (this.profileAction) { + console.log(data); + this.stopEvent(ev); + + this.profileAction.execute(data, { grid : this.grid }, ev); + } + }, + + // Internals - constructor: function(args){ - this.args = args; + /* + * Override to change count if needed + */ + _doQuery: function(store, options) { + // OpenSocial API doesn't like requests for more than is available + if (options && options.total) { + options.count = Math.min(options.count, options.total - options.start); + } + + this.inherited(arguments); } + }); - - return ActivityStreamWrapper; + + return ProfileGrid; }); }, -'url:sbt/connections/controls/forums/templates/TopicHeader.html':"\r\n\t\r\n\t${nls.topics}\r\n\t${nls.replies}\r\n\t\r\n\t${nls.latestPost}\r\n", -'url:sbt/connections/controls/templates/FileGridWrapperContent.html':"\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n
    \r\n
    \r\n \r\n \r\n\r\n", -'sbt/ready':function(){ +'sbt/log':function(){ /* * © Copyright IBM Corp. 2012 * @@ -29237,245 +27274,166 @@ define(["../../../declare", "../../../lang", "../../../url", */ /** - * @module sbt.ready - */ -define(['./_bridge/ready'],function(ready) { - return ready; -}); - -}, -'sbt/smartcloud/controls/nls/BaseGridRenderer':function(){ -/* - * © 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. + * Social Business Toolkit SDK - Logging Utilities + * @module sbt.log */ +define(['./stringUtil'], function(stringUtil) { -// NLS_CHARSET=UTF-8 -define({ - root: { - empty : "Empty", - loading : "Loading...", - previous : "Previous", - previousPage : "Previous Page", - next : "Next", - nextPage : "Next Page", - pagingResults : "${start} - ${end} of ${totalCount}", - sortBy : "Sort by:", - msgNoData : "Please wait..." - } -}); - + var loggingEnabled = function isLoggingEnabled(){ + return sbt.Properties["js.logging.enabled"] ? sbt.Properties["js.logging.enabled"].toLowerCase() == "true" : true; + }; -}, -'url:sbt/connections/controls/search/templates/SearchSuggestTemplate.html':"\r\n\t\r\n\t\t\r\n\t\t\t
    \r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t
    ${nls.refine}
    \r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t${nls.search}\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n
    ", -'sbt/control-main':function(){ -/* -* © Copyright IBM Corp. 2012 -* -* 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. -*/ + var Level = { + DEBUG : 1, + INFO : 2, + WARN : 3, + ERROR : 4 + }; + + var loggingLevel = function getLoggingLevel(){ + return Level[sbt.Properties["js.logging.level"] ? sbt.Properties["js.logging.level"] : "DEBUG"]; + }; -/** -* @module sbt.main -*/ -define([ - 'sbt/main', - 'sbt/connections/controls/ConnectionsGridRenderer', - 'sbt/connections/controls/ViewAllAction', - 'sbt/connections/controls/WidgetWrapper', - 'sbt/connections/controls/_ConnectionsWidget', - 'sbt/controls/dialog/Dialog', - 'sbt/controls/grid/Grid', - 'sbt/controls/grid/GridAction', - 'sbt/controls/grid/GridRenderer', - 'sbt/controls/panel/_ProfilePanel', - 'sbt/smartcloud/controls/BaseGridRenderer', - 'sbt/connections/controls/activities/ActivityAction', - 'sbt/connections/controls/activities/ActivityGrid', - 'sbt/connections/controls/activities/ActivityGridRenderer', - 'sbt/connections/controls/astream/ActivityStreamWrapper', - 'sbt/connections/controls/astream/_ActivityStream', - 'sbt/connections/controls/astream/_SbtAsConfigUtil', - 'sbt/connections/controls/astream/_XhrHandler', - 'sbt/connections/controls/bookmarks/BookmarkGrid', - 'sbt/connections/controls/bookmarks/BookmarkGridRenderer', - 'sbt/connections/controls/bootstrap/CommunityRendererMixin', - 'sbt/connections/controls/bootstrap/FileRendererMixin', - 'sbt/connections/controls/bootstrap/ProfileRendererMixin', - 'sbt/connections/controls/communities/CommunityAction', - 'sbt/connections/controls/communities/CommunityGrid', - 'sbt/connections/controls/communities/CommunityGridRenderer', - 'sbt/connections/controls/communities/CommunityMembersAction', - 'sbt/connections/controls/communities/CommunityMembersGrid', - 'sbt/connections/controls/communities/CommunityMembersGridRenderer', - 'sbt/connections/controls/files/FileAction', - 'sbt/connections/controls/files/FileGrid', - 'sbt/connections/controls/files/FileGridRenderer', - 'sbt/connections/controls/forums/BackAction', - 'sbt/connections/controls/forums/ForumAction', - 'sbt/connections/controls/forums/ForumGrid', - 'sbt/connections/controls/forums/ForumGridRenderer', - 'sbt/connections/controls/nls/ConnectionsGridRenderer', - 'sbt/connections/controls/nls/WidgetWrapper', - 'sbt/connections/controls/profiles/ColleagueGrid', - 'sbt/connections/controls/profiles/ColleagueGridRenderer', - 'sbt/connections/controls/profiles/EditProfilePhoto.html', - 'sbt/connections/controls/profiles/ProfileAction', - 'sbt/connections/controls/profiles/ProfileGrid', - 'sbt/connections/controls/profiles/ProfileGridRenderer', - 'sbt/connections/controls/profiles/ProfilePanel', - 'sbt/connections/controls/profiles/ProfileTagAction', - 'sbt/connections/controls/profiles/ProfileTagsGrid', - 'sbt/connections/controls/profiles/ProfileTagsGridRenderer', - 'sbt/connections/controls/search/SearchBox', - 'sbt/connections/controls/search/SearchBoxRenderer', - 'sbt/connections/controls/search/SearchGrid', - 'sbt/connections/controls/search/SearchGridRenderer', - 'sbt/connections/controls/sharebox/InputFormWrapper', - 'sbt/connections/controls/sharebox/_InputForm', - 'sbt/connections/controls/templates/FileGridWrapperContent.html', - 'sbt/connections/controls/templates/LoadingPage.html', - 'sbt/connections/controls/templates/ProfileCardWrapperContent.html', - 'sbt/connections/controls/templates/WidgetFrame.html', - 'sbt/connections/controls/vcard/CommunityVCard', - 'sbt/connections/controls/vcard/ProfileVCard', - 'sbt/connections/controls/vcard/ProfileVCardInline', - 'sbt/connections/controls/vcard/SemanticTagService', - 'sbt/connections/controls/wrappers/FileGridWrapper', - 'sbt/connections/controls/wrappers/ProfileCardWrapper', - 'sbt/controls/dialog/nls/dialog', - 'sbt/controls/dialog/templates/Dialog.html', - 'sbt/controls/grid/bootstrap/GridRendererMixin', - 'sbt/controls/grid/templates/Grid.html', - 'sbt/controls/grid/templates/GridFooter.html', - 'sbt/controls/grid/templates/GridPager.html', - 'sbt/controls/grid/templates/GridSorter.html', - 'sbt/controls/grid/templates/SortAnchor.html', - 'sbt/smartcloud/controls/nls/BaseGridRenderer', - 'sbt/smartcloud/controls/profiles/ColleagueGrid', - 'sbt/smartcloud/controls/profiles/ColleagueGridRenderer', - 'sbt/smartcloud/controls/profiles/ProfileAction', - 'sbt/smartcloud/controls/profiles/ProfileGrid', - 'sbt/smartcloud/controls/profiles/ProfileGridRenderer', - 'sbt/smartcloud/controls/profiles/ProfilePanel', - 'sbt/connections/controls/activities/nls/ActivityGridRenderer', - 'sbt/connections/controls/activities/templates/ActivityRow.html', - 'sbt/connections/controls/astream/templates/ActivityStreamContent.html', - 'sbt/connections/controls/bookmarks/nls/BookmarkGridRenderer', - 'sbt/connections/controls/bookmarks/templates/BookmarkListItem.html', - 'sbt/connections/controls/bookmarks/templates/BookmarkRow.html', - 'sbt/connections/controls/bookmarks/templates/TagAnchor.html', - 'sbt/connections/controls/bootstrap/templates/CommunityRow.html', - 'sbt/connections/controls/bootstrap/templates/FileRow.html', - 'sbt/connections/controls/bootstrap/templates/ProfileRow.html', - 'sbt/connections/controls/bootstrap/templates/TagAnchor.html', - 'sbt/connections/controls/communities/nls/CommunityGridRenderer', - 'sbt/connections/controls/communities/nls/CommunityMembersGridRenderer', - 'sbt/connections/controls/communities/templates/CommunityMemberRow.html', - 'sbt/connections/controls/communities/templates/CommunityRow.html', - 'sbt/connections/controls/communities/templates/TagAnchor.html', - 'sbt/connections/controls/files/nls/FileGridRenderer', - 'sbt/connections/controls/files/templates/CommentRow.html', - 'sbt/connections/controls/files/templates/FileRow.html', - 'sbt/connections/controls/files/templates/FolderRow.html', - 'sbt/connections/controls/files/templates/RecycledFileRow.html', - 'sbt/connections/controls/forums/nls/ForumGridRenderer', - 'sbt/connections/controls/forums/templates/ForumRow.html', - 'sbt/connections/controls/forums/templates/MyTopicsBreadCrumb.html', - 'sbt/connections/controls/forums/templates/ReplyBreadCrumb.html', - 'sbt/connections/controls/forums/templates/ReplyHeader.html', - 'sbt/connections/controls/forums/templates/ReplyRow.html', - 'sbt/connections/controls/forums/templates/TableHeader.html', - 'sbt/connections/controls/forums/templates/TopicBreadCrumb.html', - 'sbt/connections/controls/forums/templates/TopicHeader.html', - 'sbt/connections/controls/forums/templates/TopicRow.html', - 'sbt/connections/controls/profiles/nls/ColleagueGridRenderer', - 'sbt/connections/controls/profiles/nls/ProfileGridRenderer', - 'sbt/connections/controls/profiles/nls/ProfileTagsGridRenderer', - 'sbt/connections/controls/profiles/templates/ColleagueItem.html', - 'sbt/connections/controls/profiles/templates/ColleagueItemFull.html', - 'sbt/connections/controls/profiles/templates/ColleagueRow.html', - 'sbt/connections/controls/profiles/templates/CommunityMemberRow.html', - 'sbt/connections/controls/profiles/templates/ProfilePanel.html', - 'sbt/connections/controls/profiles/templates/ProfileRow.html', - 'sbt/connections/controls/profiles/templates/SharedConnectionsRow.html', - 'sbt/connections/controls/profiles/templates/StatusUpdateRow.html', - 'sbt/connections/controls/profiles/templates/TagListHeader.html', - 'sbt/connections/controls/profiles/templates/TagListRow.html', - 'sbt/connections/controls/profiles/templates/ViewAll.html', - 'sbt/connections/controls/search/nls/SearchBoxRenderer', - 'sbt/connections/controls/search/nls/SearchGridRenderer', - 'sbt/connections/controls/search/templates/BookmarkBody.html', - 'sbt/connections/controls/search/templates/CalendarBody.html', - 'sbt/connections/controls/search/templates/CommunityBody.html', - 'sbt/connections/controls/search/templates/DefaultBody.html', - 'sbt/connections/controls/search/templates/DefaultHeader.html', - 'sbt/connections/controls/search/templates/DefaultSummary.html', - 'sbt/connections/controls/search/templates/MemberListItemTemplate.html', - 'sbt/connections/controls/search/templates/MemberListTemplate.html', - 'sbt/connections/controls/search/templates/NoResults.html', - 'sbt/connections/controls/search/templates/PersonCard.html', - 'sbt/connections/controls/search/templates/PopUpTemplate.html', - 'sbt/connections/controls/search/templates/ProfileBody.html', - 'sbt/connections/controls/search/templates/ProfileHeader.html', - 'sbt/connections/controls/search/templates/SearchBoxTemplate.html', - 'sbt/connections/controls/search/templates/SearchSuggestTemplate.html', - 'sbt/connections/controls/search/templates/SingleApplicationSearch.html', - 'sbt/connections/controls/search/templates/SingleSearchPopUp.html', - 'sbt/connections/controls/search/templates/StatusUpdateExtraHeader.html', - 'sbt/connections/controls/search/templates/StatusUpdateHeader.html', - 'sbt/connections/controls/search/templates/SuggestPopUpTemplate.html', - 'sbt/connections/controls/search/templates/a.html', - 'sbt/connections/controls/search/templates/div.html', - 'sbt/connections/controls/search/templates/em.html', - 'sbt/connections/controls/search/templates/img.html', - 'sbt/connections/controls/search/templates/li.html', - 'sbt/connections/controls/search/templates/span.html', - 'sbt/connections/controls/search/templates/td.html', - 'sbt/connections/controls/search/templates/tr.html', - 'sbt/connections/controls/search/templates/ul.html', - 'sbt/connections/controls/sharebox/templates/InputFormContent.html', - 'sbt/connections/controls/vcard/templates/CommunityVCard.html', - 'sbt/connections/controls/vcard/templates/ProfileVCard.html', - 'sbt/connections/controls/vcard/templates/ProfileVCardInline.html', - 'sbt/controls/grid/bootstrap/templates/GridPager.html', - 'sbt/controls/grid/bootstrap/templates/GridSorter.html', - 'sbt/controls/grid/bootstrap/templates/SortAnchor.html', - 'sbt/smartcloud/controls/profiles/nls/ColleagueGridRenderer', - 'sbt/smartcloud/controls/profiles/nls/ProfileGridRenderer', - 'sbt/smartcloud/controls/profiles/templates/ColleagueItem.html', - 'sbt/smartcloud/controls/profiles/templates/ColleagueItemFull.html', - 'sbt/smartcloud/controls/profiles/templates/CommunityMember.html', - 'sbt/smartcloud/controls/profiles/templates/ProfilePanel.html', - 'sbt/smartcloud/controls/profiles/templates/ProfileRow.html', - 'sbt/smartcloud/controls/profiles/templates/ViewAll.html' -],function() { - return; + return { + /** + * Sets the logging level. + * @param {String} [l ]logging level. Possible values are DEBUG, INFO, WARN, ERROR + * @static + * @method setLevel + */ + setLevel : function(l) { + loggingLevel = Level[l]; + }, + /** + * Enables/disables logging. + * @param {Boolean} [enabled] logging enabled true or false + * @static + * @method setEnabled + */ + setEnabled : function(enabled) { + loggingEnabled = enabled; + }, + /** + * log a debug statement. + * @static + * @method debug + */ + debug : function() { + if (!loggingEnabled) { + return; + } + if (loggingLevel > 1) { + return; + } + if (console && arguments.length > 0) { + var args = Array.prototype.slice.call(arguments); + var text = args[0]; + args = args.slice(1); + var formattedText = stringUtil.substitute(text, args); + if (console.debug) { + console.debug(formattedText); + } else { + console.log("DEBUG : " + formattedText); + } + } + }, + /** + * log an info statement. + * @static + * @method info + */ + info : function() { + if (!loggingEnabled) { + return; + } + if (loggingLevel > 2) { + return; + } + if (console && arguments.length > 0) { + var args = Array.prototype.slice.call(arguments); + var text = args[0]; + args = args.slice(1); + var formattedText = stringUtil.substitute(text, args); + if (console.info) { + console.info(formattedText); + } else { + console.log("INFO : " + formattedText); + } + } + }, + /** + * log a warning statement. + * @static + * @method warn + */ + warn : function() { + if (!loggingEnabled) { + return; + } + if (loggingLevel > 3) { + return; + } + if (console && arguments.length > 0) { + var args = Array.prototype.slice.call(arguments); + var text = args[0]; + args = args.slice(1); + var formattedText = stringUtil.substitute(text, args); + if (console.warn) { + console.warn(formattedText); + } else { + console.log("WARN : " + formattedText); + } + } + }, + /** + * log an error statement. + * @static + * @method error + */ + error : function() { + if (!loggingEnabled) { + return; + } + if (console && arguments.length > 0) { + var args = Array.prototype.slice.call(arguments); + var text = args[0]; + args = args.slice(1); + var formattedText = stringUtil.substitute(text, args); + if (console.error) { + console.error(formattedText); + } else { + console.log("ERROR : " + formattedText); + } + } + }, + /** + * log an exception + * @static + * @method error + */ + exception : function() { + if (!loggingEnabled) { + return; + } + if (console && arguments.length > 0) { + var args = Array.prototype.slice.call(arguments); + var text = args[0]; + args = args.slice(1); + var formattedText = stringUtil.substitute(text, args); + if (console.error) { + console.error("EXCEPTION : " + formattedText); + } else { + console.log("EXCEPTION : " + formattedText); + } + } + } + }; }); - }, -'sbt/authenticator/templates/login':function(){ +'url:sbt/connections/controls/profiles/templates/StatusUpdateRow.html':"\r\n\t\r\n\t\t\r\n\t\t
    \r\n\t\t
    \r\n\t\t \r\n\t\t ${name} ${statusUpdate}\r\n\t\t \r\n\t\t \r\n\t\t
    \r\n\t\t
    \r\n\t\t \t
      \r\n\t\t \t
    • \r\n\t\t\t\t\t\t\"\"\r\n\t\t\t\t\t \r\n\t\t\t\t\t \r\n\t\t\t\t\t\t ${statusLastUpdate}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
    • \r\n\t\t\t\t
    \r\n\t\t
    \r\n\t\t
    \r\n\t\t\r\n\t\r\n", +'url:sbt/connections/controls/forums/templates/TableHeader.html':" \r\n \r\n ${nls.forums}\r\n \r\n ${nls.threads}\r\n \r\n ${nls.latestPost}\r\n ", +'url:sbt/smartcloud/controls/profiles/templates/ColleagueItemFull.html':"\r\n \t\r\n \r\n \"${name}\r\n \r\n \r\n \r\n ${name}\r\n \r\n\r\n", +'sbt/base/core':function(){ /* * © Copyright IBM Corp. 2012 * @@ -29487,91 +27445,62 @@ define([ * * 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. - */ -function submitOnClick(contentForm) { - if (contentForm.username.value == "" || contentForm.password.value == "") { - document.getElementById("wrongCredsMessage").style.display = "block"; - return; - } - var argsMap = getArgsMap();// get map of query string arguments - var actionURL = decodeURIComponent(argsMap.actionURL); - var loginUi = decodeURIComponent(argsMap.loginUi); - if (loginUi.length == 0) { - loginUi = "mainWindow"; - } - if (loginUi == "popup") { - contentForm.action = actionURL + "?loginUi=popup&redirectURLToLogin=" - + encodeURIComponent(document.URL)+"&endpointAlias="+opener.globalEndpointAlias; - } else if (loginUi == "mainWindow") { - var redirectURL = argsMap.redirectURL; - contentForm.action = actionURL - + "?loginUi=mainWindow&redirectURLToLogin=" - + encodeURIComponent(document.URL) + "&redirectURL=" - + encodeURIComponent(redirectURL); - } - contentForm.submit(); -} - -function cancelOnClick() { - var argsMap = getArgsMap();// get map of query string arguments - var redirectURL = decodeURIComponent(argsMap.redirectURL); - var loginUi = decodeURIComponent(argsMap.loginUi); - if (loginUi == "popup") { - if(window.cancel){ - window.cancel(); - delete window.cancel; - } - window.close(); - } else { - window.location.href = redirectURL; - } -} + * 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. + */ -function onLoginPageLoad() { - var argsMap = getArgsMap();// get map of query string arguments - var showWrongCredsMessage = argsMap.showWrongCredsMessage; - if (showWrongCredsMessage == "true") { - document.getElementById("wrongCredsMessage").style.display = "block"; - } - if(opener && opener.globalLoginFormStrings){ - var loginForm = opener.globalLoginFormStrings; - document.getElementById('wrongCredsMessage').appendChild(document.createTextNode(loginForm.wrong_creds_message)); - document.getElementById('basicLoginFormUsername').appendChild(document.createTextNode(loginForm.username)); - document.getElementById('basicLoginFormPassword').appendChild(document.createTextNode(loginForm.password)); - document.getElementById('basicLoginFormOK').value = loginForm.login_ok; - document.getElementById('basicLoginFormCancel').value = loginForm.login_cancel; - }else{ - document.getElementById('wrongCredsMessage').appendChild(document.createTextNode(decodeURIComponent(argsMap.wrong_creds_message))); - document.getElementById('basicLoginFormUsername').appendChild(document.createTextNode(decodeURIComponent(argsMap.username))); - document.getElementById('basicLoginFormPassword').appendChild(document.createTextNode(decodeURIComponent(argsMap.password))); - document.getElementById('basicLoginFormOK').value = decodeURIComponent(argsMap.login_ok); - document.getElementById('basicLoginFormCancel').value = decodeURIComponent(argsMap.login_cancel); - } -} +/** + * Social Business Toolkit SDK. + * Helpers for the core capabilities + */ +define(['../config'],function(sbt) { -function getArgsMap() { - try { - var qString = location.search.substring(1);// getting query string args - var qStringParams = qString.split("&");// getting array of all query - // string arg key value pairs - var argsMap = {}; - var i; - for (i = 0; i < qStringParams.length; i++) { - var argArray = qStringParams[i].split("="); - argsMap[argArray[0]] = argArray[1]; - } - return argsMap; - } catch (err) { - console.log("Error making agrs map in login.js " + err); - } -} + /** + * Global Namespaces Object. + */ + return { + // Namespaces used when parsing Atom feeds + namespaces : { + o : "http://ns.opensocial.org/2008/opensocial", + app : "http://www.w3.org/2007/app", + thr : "http://purl.org/syndication/thread/1.0", + fh : "http://purl.org/syndication/history/1.0", + snx : "http://www.ibm.com/xmlns/prod/sn", + opensearch : "http://a9.com/-/spec/opensearch/1.1/", + a : "http://www.w3.org/2005/Atom", + h : "http://www.w3.org/1999/xhtml", + td: "urn:ibm.com/td", + relevance: "http://a9.com/-/opensearch/extensions/relevance/1.0/", + ibmsc: "http://www.ibm.com/search/content/2010", + xhtml: "http://www.w3.org/1999/xhtml" + }, + + feedXPath : { + "entry" : "/a:feed/a:entry", + "entries" : "/a:feed/a:entry", + "totalResults" : "/a:feed/opensearch:totalResults", + "startIndex" : "/a:feed/opensearch:startIndex", + "itemsPerPage" : "/a:feed/opensearch:itemsPerPage" + }, + + entryXPath : { + "title" : "a:title", + "summaryText" : "a:summary[@type='text']", + "selfUrl" : "a:link[@rel='self']/@href", + "terms" : "a:category/@term", + "contentHtml" : "a:content[@type='html']", + "published" : "a:published", + "updated" : "a:updated", + "authorId" : "a:author/snx:userid", + "contributorId" : "a:contributor/snx:userid" + } + }; +}); }, -'sbt/_bridge/dom':function(){ +'sbt/connections/ForumService':function(){ /* - * © Copyright IBM Corp. 2012 + * © 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. @@ -29586,1466 +27515,2101 @@ function getArgsMap() { * permissions and limitations under the License. */ -/** - * Social Business Toolkit SDK - Some DOM utilities. - */ -define(['dojo/dom','dojo/_base/window', 'dojo/dom-construct', 'dojo/dom-class'],function(dom,win,domConstruct,domClass) { - return { - byId: function(id) { - return dom.byId(id); - }, - createTextNode: function(text) { - //return dojo.doc.createTextNode(text); - //change also made to define, added 'dojo/_base/window' - return win.doc.createTextNode(text); - }, - create: function(element, props, refNode) { - return domConstruct.create(element, props, refNode); - }, - destroy: function(node) { - return domConstruct.destroy(node); +/** + * The Forums application of IBM© Connections enables a team to discuss issues that are pertinent to their work. + * The Forums API allows application programs to create new forums, and to read and modify existing forums. + * + * @module sbt.connections.ForumService + */ +define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./ForumConstants", "./ConnectionsService", "../base/AtomEntity", "../base/XmlDataHandler" ], + function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler) { + + var CategoryForum = ""; + var CategoryTopic = ""; + var CategoryReply = ""; + var CategoryRecommendation = ""; + + var CommunityTmpl = "${getCommunityUuid}"; + var TopicTmpl = ""; + var ReplyTmpl = ""; + var FlagTmpl = ""; + + /** + * Forum class represents an entry from a Forums feed returned by the + * Connections REST API. + * + * @class Forum + * @namespace sbt.connections + */ + var Forum = declare(AtomEntity, { + + xpath : consts.ForumXPath, + contentType : "html", + categoryScheme : CategoryForum, + + /** + * Construct a Forum entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, + + /** + * Return extra entry data to be included in post data for this entity. + * + * @returns {String} + */ + createEntryData : function() { + if (!this.getCommunityUuid()) { + return ""; + } + var transformer = function(value,key) { + return value; + }; + var postData = stringUtil.transform(CommunityTmpl, this, transformer, this); + return stringUtil.trim(postData); + }, + + /** + * Return the value of id from Forum ATOM + * entry document. + * + * @method getForumUuid + * @return {String} ID of the Forum + */ + getForumUuid : function() { + var uid = this.getAsString("forumUuid"); + return extractForumUuid(uid); + }, + + /** + * Sets id of IBM Connections forum. + * + * @method setForumUuid + * @param {String} forumUuid Id of the forum + */ + setForumUuid : function(forumUuid) { + return this.setAsString("forumUuid", forumUuid); + }, + + /** + * Return the value of communityUuid from Forum ATOM + * entry document. + * + * @method getCommunityUuid + * @return {String} Uuid of the Community + */ + getCommunityUuid : function() { + return this.getAsString("communityUuid"); + }, + + /** + * Sets communityUuid of IBM Connections forum. + * + * @method setCommunityUuid + * @param {String} communityUuid Community Uuid of the forum + */ + setCommunityUuid : function(communityUuid) { + return this.setAsString("communityUuid", communityUuid); + }, + + /** + * Return the moderation of the IBM Connections forum from + * forum ATOM entry document. + * + * @method getModeration + * @return {String} Moderation of the forum + */ + getModeration : function() { + return this.getAsDate("moderation"); + }, + + /** + * Return the thread count of the IBM Connections forum from + * forum ATOM entry document. + * + * @method getThreadCount + * @return {Number} Thread count of the forum + */ + getThreadCount : function() { + return this.getAsNumber("threadCount"); + }, + + /** + * Return the url of the IBM Connections forum from + * forum ATOM entry document. + * + * @method getForumUrl + * @return {String} Url of the forum + */ + getForumUrl : function() { + return this.getAlternateUrl(); + }, + + /** + * Get a list for forum topics that includes the topics in the specified forum. + * + * @method getTopics + * @param {Object} args + */ + getTopics : function(args) { + return this.service.getTopics(this.getForumUuid(), args); + }, + + /** + * Return an array containing the tags for this forum. + * + * @method getTags + * @return {Array} + */ + getTags : function() { + return this.getAsArray("tags"); + }, + + /** + * Return an array containing the tags for this forum. + * + * @method setTags + * @param {Array} + */ + setTags : function(tags) { + return this.setAsArray("tags", tags); + }, + + /** + * Loads the forum object with the atom entry associated with the + * forum. By default, a network call is made to load the atom entry + * document in the forum object. + * + * @method load + * @param {Object} [args] Argument object + */ + load : function(args) { + // detect a bad request by validating required arguments + var forumUuid = this.getForumUuid(); + var promise = this.service._validateForumUuid(forumUuid); + if (promise) { + return promise; + } + + var self = this; + var callbacks = { + createEntity : function(service,data,response) { + self.setData(data); + return self; + } + }; + + var requestArgs = lang.mixin({ + forumUuid : forumUuid + }, args || {}); + var options = { + handleAs : "text", + query : requestArgs + }; + + return this.service.getEntity(consts.AtomForum, options, forumUuid, callbacks); + }, + + /** + * Remove this forum + * + * @method remove + * @param {Object} [args] Argument object + */ + remove : function(args) { + return this.service.deleteForum(this.getForumUuid(), args); + }, + + /** + * Update this forum + * + * @method update + * @param {Object} [args] Argument object + */ + update : function(args) { + return this.service.updateForum(this, args); + }, + + /** + * Save this forum + * + * @method save + * @param {Object} [args] Argument object + */ + save : function(args) { + if (this.getForumUuid()) { + return this.service.updateForum(this, args); + } else { + return this.service.createForum(this, args); + } + } + + }); + + /** + * ForumTopic class represents an entry for a forums topic feed returned by the + * Connections REST API. + * + * @class ForumTopic + * @namespace sbt.connections + */ + var ForumTopic = declare(AtomEntity, { + + xpath : consts.ForumTopicXPath, + contentType : "html", + categoryScheme : CategoryTopic, + + /** + * Construct a ForumTopic entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, + + /** + * Return extra entry data to be included in post data for this entity. + * + * @returns {String} + */ + createEntryData : function() { + var entryData = ""; + if (this.isPinned()) { + entryData += stringUtil.transform(FlagTmpl, this, function(v,k) { return consts.FlagPinned; }, this); + } + if (this.isLocked()) { + entryData += stringUtil.transform(FlagTmpl, this, function(v,k) { return consts.FlagLocked; }, this); + } + if (this.isQuestion()) { + entryData += stringUtil.transform(FlagTmpl, this, function(v,k) { return consts.FlagQuestion; }, this); + } + return stringUtil.trim(entryData); + }, + + /** + * Return the value of id from Forum Topic ATOM + * entry document. + * + * @method getTopicUuid + * @return {String} ID of the Forum Topic + */ + getTopicUuid : function() { + var uid = this.getAsString("topicUuid"); + return extractForumUuid(uid); + }, + + /** + * Sets id of IBM Connections Forum Topic. + * + * @method setTopicUuid + * @param {String} topicUuid Id of the forum topic + */ + setTopicUuid : function(topicUuid) { + return this.setAsString("topicUuid", topicUuid); + }, + + getTopicTitle: function(){ + return this.getAsString("topicTitle"); + }, + + setTopicTitle: function(title){ + return this.setAsString("topicTitle", title); + }, + + /** + * Return the value of IBM Connections forum ID from forum ATOM + * entry document. + * + * @method getForumUuid + * @return {String} Forum ID of the forum + */ + getForumUuid : function() { + var uid = this.getAsString("forumUuid"); + return extractForumUuid(uid); + }, + + /** + * Sets id of IBM Connections forum. + * + * @method setForumUuid + * @param {String} forumUuid Id of the forum + */ + setForumUuid : function(forumUuid) { + return this.setAsString("forumUuid", forumUuid); + }, + + /** + * Return the value of communityUuid from Forum ATOM + * entry document. + * + * @method getCommunityUuid + * @return {String} Uuid of the Community + */ + getCommunityUuid : function() { + return this.getAsString("communityUuid"); + }, + + /** + * Sets communityUuid of IBM Connections forum. + * + * @method setCommunityUuid + * @param {String} communityUuid Community Uuid of the forum + * @return {ForumTopic} + */ + setCommunityUuid : function(communityUuid) { + return this.setAsString("communityUuid", communityUuid); + }, + + /** + * Return the url of the IBM Connections forum from + * forum ATOM entry document. + * + * @method getTopicUrl + * @return {String} Url of the forum + */ + getTopicUrl : function() { + return this.getAsString("alternateUrl"); + }, + + /** + * Return the permissions of the IBM Connections forum topic from + * forum ATOM entry document. + * + * @method getPermisisons + * @return {String} Permissions of the forum topic + */ + getPermisisons : function() { + return this.getAsString("permissions"); + }, + + /** + * True if you want the topic to be added to the top of the forum thread. + * + * @method isPinned + * @return {Boolean} + */ + isPinned : function() { + var terms = this.getAsArray("categoryTerm"); + var pinned = consts.FlagPinned; + + if(lang.isArray(terms)){ + for(var i=0;i\r\n \r\n \r\n \r\n \r\n \r\n \"\"${_nls.download}\r\n \r\n \r\n \r\n

    \r\n ${title} \r\n

    \r\n
    \r\n
      \r\n
    • \r\n \r\n \t\t\t\t\t\t${authorName}\r\n \t\t\t\t\t\t${authorUid}\r\n\t\t\t\t\t\r\n ${_nls.created} ${createdLabel}\r\n
    • \r\n
    • \r\n ${hitCount} ${_nls.downloads}\r\n
    • \r\n
    • \r\n ${commentCount} ${_nls.comments}\r\n
    • \r\n
    \r\n
    \r\n \r\n \r\n \r\n\r\n\r\n\r\n", -'sbt/connections/CommunityConstants':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ - -/** - * Social Business Toolkit SDK. Definition of constants for CommunityService. - * - * @module sbt.connections.CommunityConstants - */ -define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - - return lang.mixin({}, conn, { /** - * Public community + * If true, indicates that the topic is a question. * - * @property Public - * @type String - * @for sbt.connections.Community + * @method isQuestion + * @return {Boolean} */ - Public : "public", - + isQuestion : function() { + var terms = this.getAsArray("categoryTerm"); + var question = consts.FlagQuestion; + + if(lang.isArray(terms)){ + for(var i=0;i Loading profile... ", - template: null, - - profile: null, - - errorClass: null, - - constructor: function(args) { - lang.mixin(this, args); - - if (this.templateId) { - this.template = this._getTemplate(this.templateId); + load : function(args) { + // detect a bad request by validating required arguments + var replyUuid = this.getReplyUuid(); + var promise = this.service._validateReplyUuid(replyUuid); + if (promise) { + return promise; } - }, - - postMixInProperties: function() { - }, - postCreate: function() { - this.inherited(arguments); - - if (this.email || this.userid) { - this.getProfile(this.email || this.userid); - } else { - this.getMyProfile(); - } - }, - - getMyProfile: function() { - }, - - getProfile: function(id) { - }, - - showProfile: function(profile) { - this.profile = profile || this.profile; - if (!this.profile) { - this._displayError(new Error("Invalid profile")); - return; - } - - try { - var el = this.domNode; - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - - var node; - if (lang.isString(this.template)) { - var domStr = this._substituteItems(this.template, this.profile); - node = dom.toDom(domStr, el.ownerDocument); - } else { - node = this.template.cloneNode(true); - } - el.appendChild(node); - } catch (error) { - this._displayError(error); - } - }, - - getThumbnailAlt: function() { - return this.profile.getName() || ""; - }, - - // Internals - - _substituteItems : function(template, profile) { var self = this; - return this._substitute(template, profile, function(value,key) { - if (typeof value == "undefined") { - // check the self for the property - value = lang.getObject(key, false, self); - } - - if (typeof value == 'function') { - // invoke function to return the value - try { - value = value.apply(profile); - } catch (ex) { - try { - value = value.apply(self, [profile]); - } catch (ex1) { - value = "ERROR:" + key + " " + ex1; - } - } - } - - if (typeof value == "undefined" || value == null) { - return ""; + var callbacks = { + createEntity : function(service,data,response) { + self.setData(data); + return self; } + }; - return value; - }, this); - }, - - _displayError: function(error) { - var el = this.domNode; - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - var ediv = dom.create("div", { - "class": this.errorClass, - innerHTML: error, - role: "alert", - tabIndex: 0 - }, el, "only"); + var requestArgs = lang.mixin({ + replyUuid : replyUuid + }, args || {}); + var options = { + handleAs : "text", + query : requestArgs + }; + + return this.service.getEntity(consts.AtomReply, options, replyUuid, callbacks); }, - - _getTemplate: function(domId) { - var domNode = dom.byId(domId); - return domNode ? domNode.innerHTML : "Unable to load template: "+domId+""; - } - - }); - - return _ProfilePanel; -}); -}, -'url:sbt/connections/controls/bookmarks/templates/BookmarkRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\r\n\t

    \r\n\t\t\t${title}\r\n\t\t

    \r\n\t\t\r\n\t\t
    \r\n\t\t\t${authorName}\r\n\r\n\t\t\t| ${updatedDate}\r\n\r\n\r\n\t\t\t| \r\n\t\t\t\t${tagsLabel} \r\n\t\t\t\t\t${tagsAnchors}\r\n\r\n\t\t\t\r\n\t\t\t\r\n\r\n\t\t
    \r\n\t\t\r\n", -'sbt/connections/controls/activities/ActivityGrid':function(){ -/* - * © 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. - */ - -/** - * - */ -define([ "../../../declare", - "../../../controls/grid/Grid", - "../../../store/parameter", - "./ActivityGridRenderer", - "./ActivityAction", - "../../../connections/ActivityConstants"], - -function(declare, Grid, parameter, ActivityGridRenderer, ActivityAction, consts) { - - /**Sorting Values*/ - var sortVals = { - modified: "lastmod", - dueDate: "duedate", - name: "title" - }; - - /**URL parameters */ - var ParamSchema = { - pageNumber: parameter.oneBasedInteger("page"), - pageSize: parameter.oneBasedInteger("ps"), - sortBy: parameter.sortField("sortfields",sortVals), - sortOrder: parameter.sortOrder("sortorder") - }; - - /** - * @class ActivityGrid - * @namespace sbt.connections.controls.activities - * @module sbt.connections.controls.activities.ActivityGrid - */ - var ActivityGrid = declare(Grid,{ - options : { - "my" : { - storeArgs : { - url : consts.AtomActivitiesMy, - attributes : consts.ActivityNodeXPath, - feedXPath : consts.ActivitiesFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "my" - } - } - }, - - /**The default type to use if none is specified */ - defaultOption: "my", - - /**class to handle on click and tooltip actions */ - activityAction : new ActivityAction(), - - /** - * ActivitiesGrid Constructor - * @method constructor - * @param args - */ - constructor: function(args){ - /** - * Set the sorting information - */ - this._sortInfo = { - modified: { - title: this.renderer._nls.modified, - sortMethod: "sortBylastModified", - sortParameter: "modified" - }, - dueDate: { - title: this.renderer._nls.dueDate, - sortMethod: "sortByDueDate", - sortParameter: "dueDate" - }, - name: { - title: this.renderer._nls.name, - sortMethod: "sortByName", - sortParameter: "name" - } - }; - this._activeSortAnchor = this._sortInfo.modified; - this._activeSortIsDesc = true; - }, - - /** - * Returns Sorting info - * @method getSortInfo - * @returns {#an object containing sorting information} - */ - getSortInfo : function() { - return { - active : { - anchor : this._activeSortAnchor, - isDesc : this._activeSortIsDesc - }, - list : [ this._sortInfo.modified, this._sortInfo.dueDate, - this._sortInfo.name ] - }; - }, - - /** - * Sort the activities by last modification date - * @method sortByLastModified - * @param el The Grid Element - * @param data The grid data - * @param ev the event - */ - sortBylastModified: function(el, data, ev){ - this._sort("modified", true, el, data, ev); - }, - - /** - * Sort the activities by Due Date - * @method sortByDueDate - * @param el The Grid Element - * @param data The grid data - * @param ev the event - */ - sortByDueDate: function(el, data, ev){ - this._sort("dueDate", true, el, data, ev); - }, - - /** - * Sort the activities by name - * @method sortByName - * @param el The Grid Element - * @param data The grid data - * @param ev the event - */ - sortByName: function(el, data, ev){ - this._sort("name", true, el, data, ev); - }, - - /** - * Event handler function for onClick events - * @method handleClick - * @param el The Grid Element - * @param data The grid data - * @param ev the event - */ - handleClick: function(el, data, ev) { - if (this.activityAction) { - this._stopEvent(ev); - this.activityAction.execute(data, this , ev); - } - }, - - /** - * Creates a renderer for the grid.The renderer is responsible for - * loading the grid's HTML content. - * @method createDefaultRenderer - * @param args sets the template the renderer will use, by checking args.type - * @returns an instance of an ActivitiesGridRenderer. + /** + * Remove this forum reply + * + * @method remove + * @param {Object} [args] Argument object */ - createDefaultRenderer : function(args) { - return new ActivityGridRenderer(args,this); - } - - }); - - return ActivityGrid; -}); -}, -'sbt/connections/SearchService':function(){ -/* - * © 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. - */ + remove : function(args) { + return this.service.deleteForumReply(this.getReplyUuid(), args); + }, -/** - * Use the Search API to perform searches across the installed Connections applications. - * - * Returns a list of results with the specified text in the title, description, or content. Encode the strings. By default, spaces are treated as an AND operator. The following operators are supported: - * - * AND or &&: Searches for items that contain both words. For example: query=red%20AND%20test returns items that contain both the word red and the word test. AND is the default operator. - * NOT or !: Excludes the word that follows the operator from the search. For example: query=test%20NOT%20red returns items that contain the word test, but not the word red. - * OR: Searches for items that contain either of the words. For example: query=test%20OR%20red - * To search for a phrase, enclose the phrase in quotation marks (" "). - * +: The plus sign indicates that the word must be present in the result. For example: query=+test%20red returns only items that contain the word test and many that also contain red, but none that contain only the word red. - * ?: Use a question mark to match individual characters. For example: query=te%3Ft returns items that contain the words test, text, tent, and others that begin with te. - * -: The dash prohibits the return of a given word. This operator is similar to NOT. For example: query=test%20-red returns items that contains the word test, but not the word red. - * - * Note: Wildcard searches are permitted, but wildcard only searches (*) are not. - * For more details about supported operators, see Advanced search options in the Using section of the product documentation. - * - * @module sbt.connections.SearchService - */ -define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "../json", "./SearchConstants", - "./ConnectionsService", "../base/BaseEntity", "../base/AtomEntity", "../base/XmlDataHandler" ], - function(declare,config,lang,stringUtil,Promise,json,consts,ConnectionsService,BaseEntity,AtomEntity,XmlDataHandler) { + /** + * Update this forum reply + * + * @method update + * @param {Object} [args] Argument object + */ + update : function(args) { + return this.service.updateForumReply(this, args); + }, + + /** + * Save this forum reply + * + * @method save + * @param {Object} [args] Argument object + */ + save : function(args) { + if (this.getReplyUuid()) { + return this.service.updateForumReply(this, args); + } else { + return this.service.createForumReply(this, args); + } + } + + }); + + /** + * ForumMember class represents an entry for a forums member feed returned by the + * Connections REST API. + * + * @class ForumMember + * @namespace sbt.connections + */ + var ForumMember = declare(AtomEntity, { + categoryScheme : null, + + /** + * Construct a Forum Tag entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + } + + }); + /** - * Scope class represents an entry for a scopes feed returned by the + * ForumRecommendation class represents an entry for a forums recommendation feed returned by the * Connections REST API. * - * @class Scope + * @class ForumTag * @namespace sbt.connections */ - var Scope = declare(AtomEntity, { + var ForumRecommendation = declare(AtomEntity, { + xpath : consts.ForumRecommendationXPath, + contentType : "text", + categoryScheme : CategoryRecommendation, + /** - * Construct a Scope entity. + * Construct a Forum Tag entity. * * @constructor * @param args */ constructor : function(args) { }, + + /** + * Return the value of title from ATOM entry document. + * + * @method getTitle + * @return {String} ATOM entry title + */ + getTitle : function() { + return this.getAsString("title") || "liked"; + }, + + /** + * Return the value of IBM Connections recommendation ID from recommendation ATOM + * entry document. + * + * @method getRecommendationUuid + * @return {String} ID of the recommendation topic + */ + getRecommendationUuid : function() { + var uid = this.getAsString("id"); + return extractForumUuid(uid); + }, + + /** + * Return the value of IBM Connections post ID from recommendation ATOM + * entry document. + * + * @method getPostUuid + * @return {String} ID of the forum post + */ + getPostUuid : function() { + var postUuid = this.getAsString("postUuid"); + return this.service.getUrlParameter(postUuid, "postUuid") || postUuid; + }, /** - * Return the scope search link. + * Set the value of IBM Connections post ID from recommendation ATOM + * entry document. * - * @method getLink - * @return {String} Scope link + * @method setPostUuid + * @return {String} ID of the forum post */ - getLink : function() { - return this.getAsString("link"); - } + setPostUuid : function(postUuid) { + return this.setAsString("postUuid", postUuid); + } }); /** - * Result class represents an entry for a search feed returned by the + * ForumTag class represents an entry for a forums tag feed returned by the * Connections REST API. * - * @class Result + * @class ForumTag * @namespace sbt.connections */ - var Result = declare(AtomEntity, { + var ForumTag = declare(AtomEntity, { + + categoryScheme : null, + + /** + * Construct a Forum Tag entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + } + + }); + + /* + * Method used to extract the forum uuid for an id string. + */ + var extractForumUuid = function(uid) { + if (uid && uid.indexOf("urn:lsid:ibm.com:forum:") == 0) { + return uid.substring("urn:lsid:ibm.com:forum:".length); + } else { + return uid; + } + }; + + /* + * Callbacks used when reading a feed that contains forum entries. + */ + var ForumFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.ForumsFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new Forum({ + service : service, + data : data + }); + } + }; + + /* + * Callbacks used when reading a feed that contains forum topic entries. + */ + var ForumTopicFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.ForumsFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new ForumTopic({ + service : service, + data : data + }); + } + }; + + /* + * Callbacks used when reading a feed that contains forum topic reply entries. + */ + var ForumReplyFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.ForumsFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new ForumReply({ + service : service, + data : data + }); + } + }; + + /* + * Callbacks used when reading a feed that contains forum recommendation entries. + */ + var ForumRecommendationFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.ForumsFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new ForumRecommendation({ + service : service, + data : data + }); + } + }; + + + /** + * ForumsService class. + * + * @class ForumsService + * @namespace sbt.connections + */ + var ForumService = declare(ConnectionsService, { + contextRootMap: { + forums: "forums" + }, + + serviceName : "forums", + + /** + * Constructor for ForumsService + * + * @constructor + * @param args + */ + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } + }, + + /** + * Create a Forum object with the specified data. + * + * @method newForum + * @param {Object} args Object containing the fields for the + * new Forum + */ + newForum : function(args) { + return this._toForum(args); + }, + + /** + * Create a ForumTopic object with the specified data. + * + * @method newForumTopic + * @param {Object} args Object containing the fields for the + * new ForumTopic + */ + newForumTopic : function(args) { + return this._toForumTopic(args); + }, + + /** + * Create a ForumReply object with the specified data. + * + * @method newForumReply + * @param {Object} args Object containing the fields for the + * new ForumReply + */ + newForumReply : function(args) { + return this._toForumReply(args); + }, + + /** + * Get a feed that includes forums created by the authenticated user or associated with communities to which the user belongs. + * + * @method getMyForums + * @param args + */ + getMyForums: function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomForumsMy, options, ForumFeedCallbacks); + }, + + /** + * Get a feed that includes the topics that the authenticated user created in stand-alone forums and in forums associated + * with communities to which the user belongs. + * + * @method getMyTopics + * @param requestArgs + */ + getMyTopics: function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.AtomTopicsMy, options, ForumTopicFeedCallbacks); + }, + + /** + * Get a feed that includes all stand-alone and forum forums created in the enterprise. + * + * @method getAllForums + * @param requestArgs + */ + getAllForums: function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.AtomForums, options, ForumFeedCallbacks); + }, + + /** + * Get a feed that includes all stand-alone and forum forums created in the enterprise. + * + * @method getPublicForums + * @param args + */ + getPublicForums: function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args || {} + }; + + return this.getEntities(consts.AtomForumsPublic, options, ForumFeedCallbacks); + }, + + /** + * Get a list for forum topics that includes the topics in the specified forum. + * + * @method getForumTopics + * @param forumUuid + * @param args + * @returns + */ + getForumTopics: function(forumUuid, args) { + var promise = this._validateForumUuid(forumUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ forumUuid : forumUuid }, args || {}); + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + return this.getEntities(consts.AtomTopics, options, ForumTopicFeedCallbacks); + }, + + /** + * Get a list for forum topics that includes the topics in the specified community. + * + * @method getCommunityForumTopics + * @param forumUuid + * @param args + * @returns + */ + getCommunityForumTopics: function(communityUuid, args) { + var promise = this._validateCommunityUuid(communityUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ communityUuid : communityUuid }, args || {}); + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + return this.getEntities(consts.AtomTopics, options, ForumTopicFeedCallbacks); + }, + + /** + * Get a list for forum recommendations that includes the recommendations in the specified post. + * + * @method getForumRecommendations + * @param postUuid + * @param args + * @returns + */ + getForumRecommendations: function(postUuid, args) { + var promise = this._validatePostUuid(postUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ postUuid : postUuid }, args || {}); + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + return this.getEntities(consts.AtomRecommendationEntries, options, ForumRecommendationFeedCallbacks); + }, + + /** + * Get a list for forum replies that includes the replies in the specified topic. + * + * @method getForumTopicReplies + * @param topicUuid + * @param args + * @returns + */ + getForumTopicReplies: function(topicUuid, args) { + var promise = this._validateTopicUuid(topicUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ topicUuid : topicUuid }, args || {}); + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + return this.getEntities(consts.AtomReplies, options, ForumReplyFeedCallbacks); + }, + + /** + * Get a list for forum replies that includes the replies in the specified reply. + * + * @method getForumReplyReplies + * @param replyUuid + * @param args + * @returns + */ + getForumReplyReplies: function(replyUuid, args) { + var promise = this._validateReplyUuid(replyUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ replyUuid : replyUuid }, args || {}); + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + return this.getEntities(consts.AtomReplies, options, ForumReplyFeedCallbacks); + }, + /** - * Construct a Scope entity. + * Get a list for forum replies that includes the replies in the specified post. + * The post uuid must be specified in the args as either: + * { topicUuid : "" } or { replyUuid : "" } * - * @constructor + * @method getForumReplies + * @param topicUuid * @param args + * @returns */ - constructor : function(args) { + getForumReplies: function(args) { + var options = { + method : "GET", + handleAs : "text", + query : args + }; + + return this.getEntities(consts.AtomReplies, options, ForumReplyFeedCallbacks); }, /** - * Return the primary component for a particular search - * result with respect to the search query. + * Retrieve a list of all forum entries, add communityUuid to the requestArgs object to get the forums related to a specific community. * - * @method getPrimaryComponent - * @return {String} Primary component + * @method getForums + * @param {Object} requestArgs Object containing the query arguments to be + * sent (defined in IBM Connections Communities REST API) */ - getPrimaryComponent : function() { - return this.getAsString("primaryComponent"); + getForums : function(requestArgs) { + var options = { + method : "GET", + handleAs : "text", + query : requestArgs || {} + }; + + return this.getEntities(consts.AtomForums, options, ForumFeedCallbacks); }, /** - * Indicates a relative assessment of relevance for a particular search - * result with respect to the search query. - * - * @method getRelevance - * @return {String} Relative assessment of relevance - */ - getRelevance : function() { - return this.getAsNumber("relevance"); - } - - }); - - /** - * FacetValue class represents an entry for a search facet returned by the - * Connections REST API. - * - * @class FacetValue - * @namespace sbt.connections - */ - var FacetValue = declare(BaseEntity, { - - /** - * Construct an FacetValue. + * Retrieve a forum entry, use the edit link for the forum entry + * which can be found in the my communities feed. * - * @constructor - * @param args + * @method getForum + * @param {String } forumUuid + * @param {Object} args Object containing the query arguments to be + * sent (defined in IBM Connections Communities REST API) */ - constructor : function(args) { - // create XML data handler - this.dataHandler = new XmlDataHandler({ - service : args.service, - data : args.data, - namespaces : lang.mixin(consts.Namespaces, args.namespaces || {}), - xpath : lang.mixin(consts.FacetValueXPath, args.xpath || this.xpath || {}) + getForum : function(forumUuid, args) { + var forum = new Forum({ + service : this, + _fields : { forumUuid : forumUuid } }); - this.id = this.getAsString("uid"); + return forum.load(args); }, /** - * Return the value of id from facet entry. + * Create a forum by sending an Atom entry document containing the + * new forum to the My Forums resource. * - * @method getId - * @return {String} ID of the facet entry + * @method createForum + * @param {Object} forum Forum object which denotes the forum to be created. + * @param {Object} [args] Argument object */ - getId : function() { - var id = this.getAsString("id"); - var parts = id.split("/"); - return (parts.length == 1) ? parts[0] : parts[1]; + createForum : function(forumOrJson,args) { + var forum = this._toForum(forumOrJson); + var promise = this._validateForum(forum, false, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + forum.setData(data); + var forumUuid = this.getLocationParameter(response, "forumUuid"); + forum.setForumUuid(forumUuid); + return forum; + }; + + var options = { + method : "POST", + query : args || {}, + headers : consts.AtomXmlHeaders, + data : forum.createPostData() + }; + + return this.updateEntity(consts.AtomForumsMy, options, callbacks, args); }, /** - * Return the value of label from facet entry. + * Update a forum by sending a replacement forum entry document in Atom format + * to the existing forum's edit web address. + * All existing forum entry information will be replaced with the new data. To avoid + * deleting all existing data, retrieve any data you want to retain first, and send it back + * with this request. For example, if you want to add a new tag to a forum entry, retrieve + * the existing tags, and send them all back with the new tag in the update request. * - * @method getLabel - * @return {String} Facet entry label + * @method updateForum + * @param {Object} forum Forum object + * @param {Object} [args] Argument object */ - getLabel : function() { - return this.getAsString("label"); + updateForum : function(forumOrJson,args) { + var forum = this._toForum(forumOrJson); + var promise = this._validateForum(forum, true, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + // preserve the forumUuid + var forumUuid = forum.getForumUuid(); + forum.setData(data); + forum.setForumUuid(forumUuid); + return forum; + }; + + var requestArgs = lang.mixin({ + forumUuid : forum.getForumUuid() + }, args || {}); + + var options = { + method : "PUT", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : forum.createPostData() + }; + + return this.updateEntity(consts.AtomForum, options, callbacks, args); }, /** - * Return the value of weigth from facet entry. + * Delete a forum, use the HTTP DELETE method. + * Only the owner of a forum can delete it. Deleted communities cannot be restored * - * @method getWeight - * @return {Number} Facet entry weight + * @method deleteForum + * @param {String/Object} forum id of the forum or the forum object (of the forum to be deleted) + * @param {Object} [args] Argument object */ - getWeight : function() { - return this.getAsNumber("weight"); - } - - }); - - /* - * Callbacks used when reading a feed that contains scope entries. - */ - var ScopeFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - namespaces : consts.Namespaces, - xpath : consts.SearchFeedXPath, - service : service, - data : data - }); - }, - createEntity : function(service,data,response) { - return new Scope({ - namespaces : consts.Namespaces, - service : service, - data : data - }); - } - }; - - /* - * Callbacks used when reading a feed that contains search entries. - */ - var ResultFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - namespaces : consts.Namespaces, - xpath : consts.SearchFeedXPath, - service : service, - data : data - }); - }, - createEntity : function(service,data,response) { - return new Result({ - namespaces : consts.Namespaces, - xpath : consts.SearchXPath, - service : service, - data : data - }); - } - }; - - /* - * Callbacks used when reading a feed that contains search facets. - */ - var FacetsCallbacks = { - createEntities : function(service,data,response) { - var xpathExprs = lang.mixin({}, consts.SingleFacetXPath); - // facet param looks like this "{"id": "Person"}" - var facet = json.parse(response.options.query.facet); - xpathExprs.entries = xpathExprs.entries.replace("{facet.id}", facet.id); - return new XmlDataHandler({ - namespaces : consts.Namespaces, - xpath : xpathExprs, - service : service, - data : data - }); - }, - createEntity : function(service,data,response) { - return new FacetValue({ - namespaces : consts.Namespaces, - xpath : consts.FacetValueXPath, - service : service, - data : data - }); - } - }; - - /** - * SearchService class. - * - * @class SearchService - * @namespace sbt.connections - */ - var SearchService = declare(ConnectionsService, { - - contextRootMap: { - search: "search" + deleteForum : function(forumUuid,args) { + var promise = this._validateForumUuid(forumUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ + forumUuid : forumUuid + }, args || {}); + + var options = { + method : "DELETE", + query : requestArgs, + handleAs : "text" + }; + + return this.deleteEntity(consts.AtomForum, options, forumUuid); }, - serviceName : "search", - /** - * Constructor for SearchService + * Retrieve a forum topic entry, use the edit link for the forum topic entry + * which can be found in the My Forums feed. * - * @constructor - * @param args + * @method getForumTopic + * @param {String } topicUuid + * @param {Object} args Object containing the query arguments to be + * sent (defined in IBM Connections Communities REST API) */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } + getForumTopic : function(topicUuid, args) { + var forumTopic = new ForumTopic({ + service : this, + _fields : { topicUuid : topicUuid } + }); + return forumTopic.load(args); }, - + /** - * Returns the set of supported values that can be passed to the "scope" parameter of the Search API. - * Scopes relating to Connections applications that have not been installed will not be returned. + * Create a forum topc by sending an Atom entry document containing the + * new forum to the forum replies resource. * - * @method getScopes - * @param requestArgs + * @method createForumTopic + * @param {Object} forumTopic Forum topic object which denotes the forum topic to be created. + * @param {Object} [args] Argument object */ - getScopes: function(requestArgs) { + createForumTopic : function(topicOrJson,args) { + var forumTopic = this._toForumTopic(topicOrJson); + var promise = this._validateForumTopic(forumTopic, false, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + var topicUuid = this.getLocationParameter(response, "topicUuid"); + forumTopic.setTopicUuid(topicUuid); + forumTopic.setData(data); + return forumTopic; + }; + + var requestArgs = lang.mixin({ + forumUuid : forumTopic.getForumUuid() + }, args || {}); + var options = { - method : "GET", - handleAs : "text", - query : requestArgs || {} + method : "POST", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : forumTopic.createPostData() }; - return this.getEntities(consts.AtomScopes, options, ScopeFeedCallbacks); + return this.updateEntity(consts.AtomTopics, options, callbacks, args); }, - + /** - * Search Lotus Connection for public information. + * Update a forum topic by sending a replacement forum entry document in Atom format + * to the existing forum topic's edit web address. + * All existing forum entry information will be replaced with the new data. To avoid + * deleting all existing data, retrieve any data you want to retain first, and send it back + * with this request. For example, if you want to add a new tag to a forum entry, retrieve + * the existing tags, and send them all back with the new tag in the update request. * - * @method getResults - * @param query Text to search for - * @param requestArgs + * @method updateForumTopic + * @param {Object} topicOrJson Forum topic object + * @param {Object} [args] Argument object */ - getResults: function(queryArg, requestArgs) { - requestArgs = this._stringifyRequestArgs(requestArgs); + updateForumTopic : function(topicOrJson,args) { + var forumTopic = this._toForumTopic(topicOrJson); + var promise = this._validateForumTopic(forumTopic, true, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + // preserve the topicUuid + var topicUuid = forumTopic.getTopicUuid(); + forumTopic.setData(data); + forumTopic.setTopicUuid(topicUuid); + return forumTopic; + }; + + var requestArgs = lang.mixin({ + topicUuid : forumTopic.getTopicUuid() + }, args || {}); + var options = { - method : "GET", - handleAs : "text", - query : lang.mixin({ query : queryArg } , requestArgs || {}) + method : "PUT", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : forumTopic.createPostData() }; - return this.getEntities(consts.AtomSearch, options, ResultFeedCallbacks); + return this.updateEntity(consts.AtomTopic, options, callbacks, args); }, - + /** - * Search Lotus Connections for both public information and - * private information that you have access to. You must provide - * authentication information in the request to retrieve this - * resource. + * Delete a forum topic, use the HTTP DELETE method. + * Only the owner of a forum topic can delete it. Deleted forum topics cannot be restored * - * @method getMyResults - * @param query Text to search for - * @param requestArgs + * @method deleteForumTopic + * @param {String/Object} id of the forum topic to be deleted + * @param {Object} [args] Argument object */ - getMyResults: function(queryArg, requestArgs) { - requestArgs = this._stringifyRequestArgs(requestArgs); + deleteForumTopic : function(topicUuid,args) { + var promise = this._validateTopicUuid(topicUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ + topicUuid : topicUuid + }, args || {}); + var options = { - method : "GET", - handleAs : "text", - query : lang.mixin({ query : queryArg } , requestArgs || {}) + method : "DELETE", + query : requestArgs, + handleAs : "text" }; - return this.getEntities(consts.AtomMySearch, options, ResultFeedCallbacks); + return this.deleteEntity(consts.AtomTopic, options, topicUuid); }, /** - * Search Lotus Connection for public information. + * Retrieve a forum reply entry, use the edit link for the forum reply entry + * which can be found in the my communities feed. * - * @method getResultsWithConstraint - * @param query Text to search for - * @param constraint Constraint(s) to be used while searching - * @param requestArgs + * @method getForumReply + * @param {String } replyUuid + * @param {Object} args Object containing the query arguments to be + * sent (defined in IBM Connections Communities REST API) */ - getResultsWithConstraint: function(queryArg, constraint, requestArgs) { - requestArgs = this._stringifyRequestArgs(requestArgs); - - var query = { - query : queryArg, - constraint : json.stringify(constraint) - }; - + getForumReply : function(replyUuid, args) { + var forumReply = new ForumReply({ + service : this, + _fields : { replyUuid : replyUuid } + }); + return forumReply.load(args); + }, + + /** + * Create a forum reply by sending an Atom entry document containing the + * new forum reply to the My Communities resource. + * + * @method createForumReply + * @param {Object} reply ForumReply object which denotes the forum to be created. + * @param {Object} [args] Argument object + */ + createForumReply : function(replyOrJson,args) { + var forumReply = this._toForumReply(replyOrJson); + var promise = this._validateForumReply(forumReply, false, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + var replyUuid = this.getLocationParameter(response, "replyUuid"); + forumReply.setReplyUuid(replyUuid); + forumReply.setData(data); + return forumReply; + }; + var options = { - method : "GET", - handleAs : "text", - query : lang.mixin(query, requestArgs || {}) + method : "POST", + query : args || { topicUuid : forumReply.getTopicUuid() }, + headers : consts.AtomXmlHeaders, + data : forumReply.createPostData() }; - return this.getEntities(consts.AtomSearch, options, ResultFeedCallbacks); + return this.updateEntity(consts.AtomReplies, options, callbacks, args); }, - + /** - * Search Lotus Connections for both public information and - * private information that you have access to. You must provide - * authentication information in the request to retrieve this - * resource. + * Update a forum by sending a replacement forum entry document in Atom format + * to the existing forum's edit web address. + * All existing forum entry information will be replaced with the new data. To avoid + * deleting all existing data, retrieve any data you want to retain first, and send it back + * with this request. For example, if you want to add a new tag to a forum entry, retrieve + * the existing tags, and send them all back with the new tag in the update request. * - * @method getMyResultsWithConstraint - * @param query Text to search for - * @param constraint Constraint(s) to be used while searching - * @param requestArgs + * @method updateForumReply + * @param {Object} replyOrJson Forum reply object + * @param {Object} [args] Argument object */ - getMyResultsWithConstraint: function(queryArg, constraint, requestArgs) { - requestArgs = this._stringifyRequestArgs(requestArgs); - - var query = { - query : queryArg, - constraint : json.stringify(constraint) - }; - + updateForumReply : function(replyOrJson,args) { + var forumReply = this._toForumReply(replyOrJson); + var promise = this._validateForumReply(forumReply, true, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + // preserve the replyUuid + var replyUuid = forumReply.getReplyUuid(); + forumReply.setData(data); + forumReply.setReplyUuid(replyUuid); + return forumReply; + }; + + var requestArgs = lang.mixin({ + replyUuid : forumReply.getReplyUuid() + }, args || {}); + var options = { - method : "GET", - handleAs : "text", - query : lang.mixin(query, requestArgs || {}) + method : "PUT", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : forumReply.createPostData() }; - return this.getEntities(consts.AtomMySearch, options, ResultFeedCallbacks); + return this.updateEntity(consts.AtomReply, options, callbacks, args); }, - + /** - * Search IBM Connections for public information, tagged - * with the specified tags. + * Delete a forum reply, use the HTTP DELETE method. + * Only the owner of a forum reply can delete it. Deleted forum replies cannot be restored * - * @method getTagged - * @param tags tags to search for - * @param requestArgs + * @method deleteForumReply + * @param {String/Object} Id of the forum reply to be deleted + * @param {Object} [args] Argument object */ - getResultsByTag: function(tags, requestArgs) { + deleteForumReply : function(replyUuid,args) { + var promise = this._validateReplyUuid(replyUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ + replyUuid : replyUuid + }, args || {}); + var options = { - method : "GET", - handleAs : "text", - query : lang.mixin({ - constraint : this._createTagConstraint(tags) - } , - requestArgs || {}) + method : "DELETE", + query : requestArgs, + handleAs : "text" }; - - return this.getEntities(consts.AtomSearch, options, ResultFeedCallbacks); + + return this.deleteEntity(consts.AtomReply, options, replyUuid); }, - + /** - * Search IBM Connections for both public information and private - * information that you have access to, tagged - * with the specified tags. + * Retrieve complete information about recommendations to a post(topic/reply) in a stand-alone forum. * - * @method getMyResultsByTag - * @param tags Tags to search for - * @param requestArgs + * @method getForumRecommendation + * @param postUuid + * @param args */ - getMyResultsByTag: function(tags, requestArgs) { - var options = { - method : "GET", - handleAs : "text", - query : lang.mixin({ - constraint : this._createTagConstraint(tags) - } , - requestArgs || {}) - }; - - return this.getEntities(consts.AtomMySearch, options, ResultFeedCallbacks); + getForumRecommendation : function(postUuid, args) { + var forumRecommendation = new ForumRecommendation({ + service : this, + _fields : { postUuid : postUuid } + }); + return forumRecommendation.load(args); }, /** - * Search IBM Connections Profiles for people using the specified - * query string and return public information. + * To like a post(topic/reply) in a stand-alone forum, create forum recommendation to the forum topic/reply resources. * - * @method getPeople - * @param query Text to search for - * @param requestArgs + * @method createForumRecommendation + * @param recommendationOrJson + * @param args */ - getPeople: function(queryArg, requestArgs) { + createForumRecommendation : function(recommendationOrJson, args) { + var forumRecommendation = this._toForumRecommendation(recommendationOrJson); + var promise = this._validateForumRecommendation(forumRecommendation, false, args); + if (promise) { + return promise; + } + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + forumRecommendation.setData(data); + return forumRecommendation; + }; + var options = { - method : "GET", - handleAs : "text", - query : lang.mixin({ - query : queryArg, - pageSize : "0", - facet : "{\"id\": \"Person\"}" - } , - requestArgs || {}) + method : "POST", + query : args || { postUuid : forumRecommendation.getPostUuid() }, + headers : consts.AtomXmlHeaders, + data : forumRecommendation.createPostData() }; - return this.getEntities(consts.AtomSearch, options, FacetsCallbacks); + return this.updateEntity(consts.AtomRecommendationEntries, options, callbacks, args); }, /** - * Search IBM Connections Profiles for people using the specified - * query string and return public information. + * Delete a recommendation of a post(topic or reply) in a forum. + * Only the user who have already recommended the post can delete it's own recommendation. * - * @method getMyPeople - * @param query Text to search for - * @param requestArgs + * @method deleteForumRecommendation + * @param postUuid + * @param args */ - getMyPeople: function(queryArg, requestArgs) { + deleteForumRecommendation : function(postUuid, args) { + var promise = this._validatePostUuid(postUuid); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ + postUuid : postUuid + }, args || {}); + var options = { - method : "GET", - handleAs : "text", - query : lang.mixin({ - query : queryArg, - pageSize : "0", - facet : "{\"id\": \"Person\"}" - } , - requestArgs || {}) + method : "DELETE", + query : requestArgs, + handleAs : "text" }; - - return this.getEntities(consts.AtomMySearch, options, FacetsCallbacks); + + return this.deleteEntity(consts.AtomRecommendationEntries, options, postUuid); }, - + // // Internals // /* - * + * Validate a forum and return a Promise if invalid. */ - _stringifyRequestArgs: function(requestArgs) { - if (!requestArgs) { - return null; + _validateForum : function(forum,checkUuid) { + if (!forum || !forum.getTitle()) { + return this.createBadRequestPromise("Invalid argument, forum with title must be specified."); } - var _requestArgs = {}; - for(var name in requestArgs){ - var value = requestArgs[name]; - if (lang.isObject(value)) { - _requestArgs[name] = json.stringify(value); - } else { - _requestArgs[name] = value; - } + if (checkUuid && !forum.getForumUuid()) { + return this.createBadRequestPromise("Invalid argument, forum with UUID must be specified."); } - return _requestArgs; }, /* - * Create a contraint JSON string for the specified tags - */ - _createTagConstraint: function(tags) { - var jsonObj = { "type" : "category", "values" : new Array() }; - if (lang.isArray(tags)) { - for (var i=0;i\r\n\r\n\t\r\n\t\t

    ${title}

    \r\n\t\r\n", -'sbt/connections/BookmarkConstants':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ - -/** - * Social Business Toolkit SDK. Definition of constants for BookmarkService. - * - * @module sbt.connections.BookmarkConstants - */ -define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - - return lang.mixin({}, conn, { - - BookmarkFeedXPath : conn.ConnectionsFeedXPath, - - /** - * XPath expressions - * - * @property BookmarkXPath - * @type Object - * @for sbt.connections.CommunityService + * Validate a forum topic and return a Promise if invalid. */ - BookmarkXPath : lang.mixin({}, conn.AtomEntryXPath, { - BookmarkUuid: "a:id", - privateFlag: "a:category[@term='private' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", - categoryType: "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", - link: "a:link[not(@rel)]/@href", - linkSame: "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/same']/@href", - url: "a:link[1]/@href", - authorId:"a:author/snx:userid", - authorName: "a:author/a:name", - authorEmail: "a:author/a:email", - authorUri: "a:author/a:uri", - tags : "a:category[not(@scheme)]/@term", - clickcount: "snx:clickcount" - }), + _validateForumTopic : function(forumTopic,checkUuid) { + if (!forumTopic || !forumTopic.getTitle()) { + return this.createBadRequestPromise("Invalid argument, forum topic with title must be specified."); + } + if (checkUuid && !forumTopic.getTopicUuid()) { + return this.createBadRequestPromise("Invalid argument, forum topic with UUID must be specified."); + } + }, - /** - * Namespaces to be used when reading the Bookmarks ATOM entry or feed + /* + * Validate a forum reply and return a Promise if invalid. */ - BookmarkNamespaces : { - a : "http://www.w3.org/2005/Atom", - snx : "http://www.ibm.com/xmlns/prod/sn" - }, - - /** - * A feed of all bookmarks. - * - * @property AtomBookmarkssAll - * @type String - * @for sbt.connections.BoomarkService + _validateForumReply : function(forumReply,checkUuid) { + if (!forumReply || !forumReply.getTitle()) { + return this.createBadRequestPromise("Invalid argument, forum reply with title must be specified."); + } + if (checkUuid && !forumReply.getReplyUuid()) { + return this.createBadRequestPromise("Invalid argument, forum reply with UUID must be specified."); + } + }, + + /* + * Validate a forum recommendation and return a Promise if invalid. */ - AtomBookmarksAll : "/${dogear}/atom", - - /** - * A feed of popular bookmarks. - * - * @property AtomBookmarkssAll - * @type String - * @for sbt.connections.BoomarkService + _validateForumRecommendation : function(forumRecommendation,checkUuid) { + if (!forumRecommendation || !forumRecommendation.getPostUuid()) { + return this.createBadRequestPromise("Invalid argument, forum recommendation with postUuid must be specified."); + } + if (checkUuid && !forumRecommendation.getRecommendationUuid()) { + return this.createBadRequestPromise("Invalid argument, forum recommendation with UUID must be specified."); + } + }, + + /* + * Validate a forum UUID, and return a Promise if invalid. */ - AtomBookmarksPopular : "/${dogear}/atom/popular", - - /** - * A feed of bookmarks that others notified me about. - * - * @property AtomBookmarkssAll - * @type String - * @for sbt.connections.BoomarkService + _validateForumUuid : function(forumUuid) { + if (!forumUuid || forumUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected forumUuid."); + } + }, + + /* + * Validate a community UUID, and return a Promise if invalid. */ - AtomBookmarksMyNotifications : "/${dogear}/atom/mynotifications", - - /** - * A feed of bookmarks about which I notified others. - * - * @property AtomBookmarkssAll - * @type String - * @for sbt.connections.BoomarkService + _validateCommunityUuid : function(communityUuid) { + if (!communityUuid || communityUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected communityUuid."); + } + }, + + /* + * Validate a post UUID, and return a Promise if invalid. */ - AtomBookmarksINotifiedMySentNotifications : "/${dogear}/atom/mysentnotifications", - - /** - * A feed of all bookmark tags. - * - * @property AtomBookmarksTags - * @type String - * @for sbt.connections.BoomarkService + _validatePostUuid : function(postUuid) { + if (!postUuid || postUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected postUuid."); + } + }, + + /* + * Validate a topic UUID, and return a Promise if invalid. */ - AtomBookmarksTags : "/${dogear}/tags", - - /** - * create delete or update a bookmark. - * - * @property AtomBookmarkCreateUpdateDelete - * @type String - * @for sbt.connections.BoomarkService + _validateTopicUuid : function(topicUuid) { + if (!topicUuid || topicUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected topicUuid."); + } + }, + + /* + * Validate a reply UUID, and return a Promise if invalid. */ - AtomBookmarkCreateUpdateDelete : "/${dogear}/api/app" - - }); -}); -}, -'url:sbt/connections/controls/search/templates/td.html':"${content}", -'sbt/connections/controls/profiles/ProfileGridRenderer':function(){ -require({cache:{ -'url:sbt/connections/controls/profiles/templates/ProfileRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.telephone} ${telephone}
    \r\n\t\t\t
    ${nls.email}: ${email}
    \r\n\t\t\t
    ${nls.altEmail}: ${altEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n", -'url:sbt/connections/controls/profiles/templates/SharedConnectionsRow.html':"\r\n\t\r\n\t\t

    Connections Shared By Frank Adams & Amy Blanks

    \r\n\t\t

    \r\n\t\t\t${sharedColleagueName}\r\n\t\t

    \r\n\t\t\r\n\t\t

    ${sharedColleagueEmail}

    \r\n\t\r\n\r\n", -'url:sbt/connections/controls/profiles/templates/StatusUpdateRow.html':"\r\n\t\r\n\t\t\r\n\t\t
    \r\n\t\t
    \r\n\t\t \r\n\t\t ${name} ${statusUpdate}\r\n\t\t \r\n\t\t \r\n\t\t
    \r\n\t\t
    \r\n\t\t \t
      \r\n\t\t \t
    • \r\n\t\t\t\t\t\t\"\"\r\n\t\t\t\t\t \r\n\t\t\t\t\t \r\n\t\t\t\t\t\t ${statusLastUpdate}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
    • \r\n\t\t\t\t
    \r\n\t\t
    \r\n\t\t
    \r\n\t\t\r\n\t\r\n", -'url:sbt/connections/controls/profiles/templates/CommunityMemberRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${contributorName}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.role}: ${role}
    \r\n\t\t\t
    ${nls.email} ${contributorEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n", -'url:sbt/connections/controls/profiles/templates/BootstrapProfile.html':"\r\n\t\r\n\t\t\"${name}\"\r\n\t\r\n\t\r\n\t

    \r\n \t\t${name}\r\n \t

    \r\n\t\r\n\r\n"}}); -/* - * © 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. - */ - -/** - * - */ -define(["../../../declare", - "../ConnectionsGridRenderer", - "../../../i18n!./nls/ProfileGridRenderer", - "../../../text!./templates/ProfileRow.html", - "../../../text!./templates/SharedConnectionsRow.html", - "../../../text!./templates/StatusUpdateRow.html", - "../../../text!./templates/CommunityMemberRow.html", - "../../../text!./templates/BootstrapProfile.html"], - function(declare, ConnectionsGridRenderer, nls, profileTemplate, - sharedConnTemplate, statusUpdateTemplate, communityMemberTemplate,bootstrapProfile) { - - /** - * @class ProfileGridRenderer - * @namespace sbt.connections.controls.profiles - * @module sbt.connections.controls.profiles.ProfileGridRenderer - */ - var ProfileGridRenderer = declare(ConnectionsGridRenderer, { - - /**The strings used in the grid, these are stored in a separate file, in the nls folder*/ - _nls: nls, + _validateReplyUuid : function(replyUuid) { + if (!replyUuid || replyUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected replyUuid."); + } + }, - /** - * The constructor function - * @method constructor - * @param args - */ - constructor: function(args,grid) { - if(grid.theme == "bootstrap"){ - this.template = bootstrapProfile; - }else{ - if (args.type == "profile") { - this.template = profileTemplate; - } else if(args.type == "statusUpdates"){ - this.template = statusUpdateTemplate; - } else if (args.type == "communityMembers") { - this.template = communityMemberTemplate; - } - } - - }, + /* + * Return a Forum instance from Forum or JSON or String. Throws + * an error if the argument was neither. + */ + _toForum : function(forumOrJsonOrString) { + if (forumOrJsonOrString instanceof Forum) { + return forumOrJsonOrString; + } else { + if (lang.isString(forumOrJsonOrString)) { + forumOrJsonOrString = { + forumUuid : forumOrJsonOrString + }; + } + return new Forum({ + service : this, + _fields : lang.mixin({}, forumOrJsonOrString) + }); + } + }, - /** - * Sets the css class for the row - * @method rowClass - * @param grid The Grid Dijit - * @param item the current row - * @param i the number of the current row, ie 0, 1, 2 etc - * @param items all of the rows in the grid - */ - rowClass: function(grid, item, i, items) { - item.rowClass = (i === 0 ? "lotusFirst" : (i % 2 === 1 ? "lotusAltRow" : null)); - }, - - /** - * Displays a tooltip by calling the getTooltip function in the ProfileAction class - * @method tooltip - * @param grid The Grid Dijit - * @param item the element to display the tooltip - * @param i the number of the current row - * @param items all of the items in the grid row - * @returns A Tooltip the default for profiles is to display the vCard - */ - tooltip: function(grid, item, i, items) { - if (grid.profileAction) { - return grid.profileAction.getTooltip(item); - } - }, - - /** - * Generates the profile photo URL for displaying the photos of community members - * @method photoUrl - * @param grid The Grid Dijit - * @param item the element containing the uid - * @param i the number of the current row - * @param items all of the items in the grid row - * @returns A profile photo URL for retrieving a user's profile picture - */ - photoUrl: function(grid, item, i, items) { - var store = grid.store; - var endpoint = store.getEndpoint(); - var photoUrl = endpoint.baseUrl + "/profiles/photo.do?email=" + item.getValue("email"); - - return photoUrl; - } + /* + * Return a ForumTopic instance from Forum or JSON or String. Throws + * an error if the argument was neither. + */ + _toForumTopic : function(topicOrJsonOrString) { + if (topicOrJsonOrString instanceof ForumTopic) { + return topicOrJsonOrString; + } else { + if (lang.isString(topicOrJsonOrString)) { + topicOrJsonOrString = { + forumTopicUuid : topicOrJsonOrString + }; + } + return new ForumTopic({ + service : this, + _fields : lang.mixin({}, topicOrJsonOrString) + }); + } + }, + + /* + * Return a Forum instance from ForumReply or JSON or String. Throws + * an error if the argument was neither. + */ + _toForumReply : function(replyOrJsonOrString) { + if (replyOrJsonOrString instanceof ForumReply) { + return replyOrJsonOrString; + } else { + if (lang.isString(replyOrJsonOrString)) { + replyOrJsonOrString = { + forumReplyUuid : replyOrJsonOrString + }; + } + return new ForumReply({ + service : this, + _fields : lang.mixin({}, replyOrJsonOrString) + }); + } + }, + + /* + * Return a ForumRecommendation instance from ForumRecommendation, ForumTopic, + * ForumReply or JSON or String. Throws an error if the argument was neither. + */ + _toForumRecommendation : function(entityOrJsonOrString) { + if (entityOrJsonOrString instanceof ForumRecommendation) { + return entityOrJsonOrString; + } else { + if (lang.isString(entityOrJsonOrString)) { + entityOrJsonOrString = { + postUuid : entityOrJsonOrString + }; + } + if (entityOrJsonOrString instanceof ForumTopic) { + entityOrJsonOrString = { + postUuid : entityOrJsonOrString.getTopicUuid() + }; + } + if (entityOrJsonOrString instanceof ForumReply) { + entityOrJsonOrString = { + postUuid : entityOrJsonOrString.getReplyUuid() + }; + } + return new ForumRecommendation({ + service : this, + _fields : lang.mixin({}, entityOrJsonOrString) + }); + } + } + }); - - return ProfileGridRenderer; + return ForumService; }); + }, -'url:sbt/connections/controls/search/templates/ul.html':"
      ${content}
    ", -'sbt/connections/CommunityService':function(){ +'sbt/connections/controls/profiles/ProfileAction':function(){ /* - * (C) 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. @@ -31061,2337 +29625,2057 @@ define(["../../../declare", */ /** - * The Communities API allows application programs to retrieve community information, subscribe to community updates, and create or modify communities. * - * @module sbt.connections.CommunityService */ -define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./CommunityConstants", "./ConnectionsService", - "../base/AtomEntity", "../base/XmlDataHandler", "./ForumService", "./BookmarkService", "../pathUtil" ], - function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler,ForumService,BookmarkService,pathUtil) { +define([ "../../../declare", "../../../controls/grid/GridAction" ], + function(declare, GridAction) { - var CategoryCommunity = ""; - var CategoryMember = ""; - var CategoryInvite = ""; - var CategoryEvent = ""; - - var IsExternalTmpl = "${isExternal}"; - var parentLinkTmpl = " "; - var CommunityTypeTmpl = "${getCommunityType}"; - var CommunityUuidTmpl = "${getCommunityUuid}instance?communityUuid=${getCommunityUuid} "; - var CommunityThemeTmpl = "${getCommunityTheme}"; - var RoleTmpl = "${getRole}"; - - /* - * CommunityDataHandler class. - */ - var CommunityDataHandler = declare(XmlDataHandler, { - /** - * @method getEntityId - * @returns - */ - getEntityId : function() { - var entityId = stringUtil.trim(this.getAsString("uid")); - return extractCommunityUuid(this.service, entityId); - } - }); - /** - * Community class represents an entry for a Community feed returned by the - * Connections REST API. - * - * @class Community - * @namespace sbt.connections + * @class ProfileAction + * @namespace sbt.connections.controls.profiles + * @module sbt.connections.controls.profiles.ProfileAction */ - var Community = declare(AtomEntity, { - - xpath : consts.CommunityXPath, - namespaces : consts.CommunityNamespaces, - categoryScheme : CategoryCommunity, - - /** - * Construct a Community entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Create the DataHandler for this entity. - * - * @method createDataHandler - */ - createDataHandler : function(service, data, response, namespaces, xpath) { - return new CommunityDataHandler({ - service : service, - data : data, - namespaces : namespaces, - xpath : xpath - }); + var ProfileAction = declare(GridAction, { + + /**Strings used in the actions */ + nls: { + tooltip: "Go to ${name}" }, - /** - * Return extra entry data to be included in post data for this entity. - * - * @returns {String} - */ - createEntryData : function() { - var postData = ""; - var transformer = function(value,key) { - return value; - }; - postData += stringUtil.transform(CommunityTypeTmpl, this, transformer, this); - postData += stringUtil.transform(IsExternalTmpl, this, transformer, this); - if (this.getCommunityUuid()) { - postData += stringUtil.transform(CommunityUuidTmpl, this, transformer, this); - } - if(this.isSubCommunity()){ - postData += stringUtil.transform(parentLinkTmpl, this, transformer, this); - } - if (this.getCommunityTheme()) { - postData += stringUtil.transform(CommunityThemeTmpl, this, transformer, this); - } - return stringUtil.trim(postData); + /**ProfileAction Constructor function + * @method constructor + * */ + constructor: function() { }, /** - * Return the value of IBM Connections community ID from community ATOM - * entry document. - * - * @method getCommunityUuid - * @return {String} Community ID of the community + * Handles displaying a tooltip for an item + * For profiles, the tooltip by default will be a business card + * So nothing is done in this function + * @method getTooltip + * @param item The element that will use the tooltip */ - getCommunityUuid : function() { - var communityUuid = this.getAsString("communityUuid"); - return extractCommunityUuid(this.service, communityUuid); - }, + getTooltip: function(item) { + + //for default the semantic tag service will pop up the business card + //so do nothing here - /** - * Sets id of IBM Connections community. - * - * @method setCommunityUuid - * @param {String} communityUuid Id of the community - */ - setCommunityUuid : function(communityUuid) { - return this.setAsString("communityUuid", communityUuid); }, - + /** - * Return the community type of the IBM Connections community from - * community ATOM entry document. - * - * @method getCommunityType - * @return {String} Type of the Community + * The execute function is called from the handle click function + * For Profiles by default the business card functionality is used + * which works from the Semantic tag service so nothing is done here. + * @method execute + * @param item The item which fired the event + * @param grid The profile grid class + * @param event The event */ - getCommunityType : function() { - var type = this.getAsString("communityType"); - if (!type) { - type = consts.Restricted; - } - return type; - }, + execute: function(item, grid, event) { + var url = grid.renderer.getProfileUrl(grid,item.getValue("id")); + window.open(url); + } - /** - * Set the community type of the IBM Connections community. - * - * @method setCommunityType - * @param {String} Type of the Community - */ - setCommunityType : function(communityType) { - return this.setAsString("communityType", communityType); - }, + }); - /** - * Return the community theme of the IBM Connections community from - * community ATOM entry document. - * - * @method getCommunityTheme - * @return {String} Theme of the Community - */ - getCommunityTheme : function() { - return this.getAsString("communityTheme"); - }, + return ProfileAction; +}); +}, +'url:sbt/connections/controls/communities/templates/CommunityRow.html':"\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t\r\n\t\t\t\t${title}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t|\r\n\t\t\t\r\n\t\t\t\t\"\"\r\n\t\t\t\t${nls.moderated} \r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\"\"\r\n\t\t\t\t${nls.restricted} \r\n\t\t\t\r\n\t\t

    \r\n\t\t
    \r\n\t\t\t\r\n\t\t\t\t${numOfMembers}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${nls.updatedBy}\r\n\t\t\t\t\t\r\n \t\t\t\t\t\t${contributorName}\r\n \t\t\t\t\t ${contributorUserid}\r\n\t\t\t\t \r\n\t\t\t\t\r\n\t\t\t\t|\r\n\t\t\t\t${updatedDate}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${tagsLabel}\r\n\t\t\t\t\t${tagsAnchors}\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t

    ${summary}

    \r\n\t\t
    \r\n\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\r\n", +'sbt/connections/controls/files/FileAction':function(){ +/* + * © 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. + */ - /** - * Set the community theme of the IBM Connections community. - * - * @method setCommunityTheme - * @param {String} Theme of the Community - */ - setCommunityTheme : function(communityTheme) { - return this.setAsString("communityTheme", communityTheme); - }, +/** + * + */ +define([ "../../../declare", "../../../stringUtil", "../../../controls/grid/GridAction" ], + function(declare, stringUtil, GridAction) { - /** - * Return the external of the IBM Connections community from - * community ATOM entry document. - * - * @method isExternal - * @return {Boolean} External flag of the Community - */ - isExternal : function() { - return this.getAsBoolean("isExternal"); + /** + * @class FileAction + * @namespace sbt.connections.controls.files + * @module sbt.connections.controls.files.FileAction + */ + var FileAction = declare(GridAction, { + + /**Strings*/ + nls: { + tooltip: "Click to download ${title}" }, - - /** - * Set the external flag of the IBM Connections community. - * - * @method setExternal - * @param {Boolean} External flag of the Community - */ - setExternal : function(external) { - return this.setAsBoolean("isExternal", external); + grid: null, + /**Constructor function + * @method constructor + * */ + constructor: function(grid) { + this.grid = grid; }, - /** - * function to check if a community is a sub community of another community - * - * @method isSubCommunity - * @return Returns true if this community is a sub community - */ - isSubCommunity : function(){ - var parentUrl = this.getParentCommunityUrl(); - if(parentUrl != null && parentUrl != ""){ - return true; - }else{ - return false; - } + /**function to get the string to be displayed in an elements tooltip + * @method getTooltip + * @param item The element for which the tolltip will be displayed + * @return A String, with the text to be displayed in the elements tooltip + * */ + getTooltip: function(item) { + return stringUtil.replace(this.nls.tooltip, { title : item.getValue("title") }); }, /** - * If this community is a sub community this function gets the url of the parent community - * else it returns null. - * @method getParentCommunityUrl - * @returns The Url of the parent community if the community is a sub community else returns null - */ - getParentCommunityUrl: function(){ - return this.getAsString("parentCommunityUrl"); - }, - - /** - * Return tags of IBM Connections community from community ATOM entry - * document. - * - * @method getTags - * @return {Object} Array of tags of the community - */ - getTags : function() { - return this.getAsArray("tags"); - }, - - /** - * Set new tags to be associated with this IBM Connections community. - * - * @method setTags - * @param {Object} Array of tags to be added to the community - */ - - setTags : function(tags) { - return this.setAsArray("tags", tags); - }, - - /** - * Return the value of IBM Connections community URL from community ATOM - * entry document. - * - * @method getCommunityUrl - * @return {String} Community URL of the community - * @deprecated Use getAlternateUrl instead - */ - getCommunityUrl : function() { - return this.getAlternateUrl(); - }, - - /** - * Return the value of IBM Connections community Logo URL from community - * ATOM entry document. - * - * @method getLogoUrl - * @return {String} Community Logo URL of the community + * Execute function provides the default action for files + * This function is called from the handle click function. + * @method execute + * @param item the element that fired the event + * @param opts + * @param event the event */ - getLogoUrl : function() { - return this.getAsString("logoUrl"); - }, + execute: function(item, opts, event) { + var url = item.getValue("downloadUrl"); + if(this.grid){ + url = this.grid.encodeImageUrl(url); + } + window.open(url); + } - /** - * Return the member count of the IBM Connections community from - * community ATOM entry document. - * - * @method getMemberCount - * @return {Number} Member count for the Community - */ - getMemberCount : function() { - return this.getAsNumber("memberCount"); - }, + }); - /** - * Get a list for forum topics that includes the topics in this community. - * - * @method getForumTopics - * @param {Object} args - */ - getForumTopics : function(args) { - return this.service.getForumTopics(this.getCommunityUuid(), args); - }, - - /** - * Create a forum topic by sending an Atom entry document containing the - * new forum to the forum replies resource. - * - * @method createForumTopic - * @param {Object} forumTopic Forum topic object which denotes the forum topic to be created. - * @param {Object} [args] Argument object - */ - createForumTopic : function(communityUuid, topicOrJson, args) { - if(!lang.isString(communityUuid)){ - args = topicOrJson; - topicOrJson = communityUuid; - } - return this.service.createForumTopic(topicOrJson, args); - }, - - /** - * Get sub communities of a community. - * - * @method getSubCommunities - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of members of a - * community. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - getSubCommunities : function(args) { - return this.service.getSubCommunities(this.getCommunityUuid(), args); - }, + return FileAction; +}); - /** - * Get members of this community. - * - * @method getMembers - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of members of a - * community. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - getMembers : function(args) { - return this.service.getMembers(this.getCommunityUuid(), args); - }, +}, +'url:sbt/connections/controls/communities/templates/CommunityMemberRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.role}: ${role}
    \r\n\t\t\t
    ${nls.email} ${email}
    \r\n\t\t\t\r\n\t\t\t\t${nls.edit}    \r\n\t\t\t\t${nls.remove}\r\n\t\t\t\r\n\t\t\t
    \r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t${nls.role}:\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t
    \r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n", +'url:sbt/connections/controls/forums/templates/BootstrapForumRow.html':"\r\n\t\r\n \r\n \r\n \r\n ${title}\r\n \r\n \r\n \r\n\r\n\r\n", +'sbt/connections/Tag':function(){ +/* + * © Copyright IBM Corp. 2012, 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. + */ - /** - * Add member to a community - * - * @method addMember - * @param {Object} [args] Argument object - * @param {Object} [args.member] Object representing the member to be added - * @param {String} [args.email] Object representing the email of the memeber to be added - * @param {String} [args.id] String representing the id of the member to be added - */ - addMember : function(member,args) { - return this.service.addMember(this.getCommunityUuid(), member, args); - }, +/** + * + * @module sbt.connections.Tag + * @author Rajmeet Bal + */ +define(["../declare", "../base/BaseEntity" ], + function(declare, BaseEntity) { + + /** + * Tag class. + * + * @class Tag + * @namespace sbt.connections + */ + var Tag = declare(BaseEntity, { /** - * Remove member of a community - * - * @method removeMember - * @param {String} Member id of the member - * @param {Object} [args] Argument object - */ - removeMember : function(memberId,args) { - return this.service.removeMember(this.getCommunityUuid(), memberId, args); - }, - - /** - * Loads a member object with the atom entry associated with the - * member of the community. By default, a network call is made to load the atom entry - * document in the member object. - * - * @method getMember - * @param {String} member id of the member. - * @param {Object} [args] Argument object - */ - getMember : function(memberId, args) { - return this.service.getMember(this.getCommunityUuid(), memberId, args); - }, - - /** - * Get a list of the outstanding community invitations for the specified community. - * The currently authenticated user must be an owner of the community. * - * @method getAllInvites - * @param {Object} [args] + * @constructor + * @param args */ - getAllInvites : function(args) { - return this.service.getAllInvites(this.getCommunityUuid(), args); + constructor : function(args) { }, /** - * Get the list of community forums. + * Get term of the tag + * + * @method getTerm + * @return {String} term of the tag * - * @method getForums - * @param {Object} [args] Argument object */ - getForums : function(args) { - var forumService = this.service.getForumService(); - var requestArgs = lang.mixin(args || {}, { communityUuid : this.getCommunityUuid() }); - return forumService.getForums(requestArgs); + getTerm : function() { + return this.getAsString("term"); }, /** - * Loads the community object with the atom entry associated with the - * community. By default, a network call is made to load the atom entry - * document in the community object. + * Get frequency of the tag + * + * @method getFrequency + * @return {Number} frequency of the tag * - * @method load - * @param {Object} [args] Argument object */ - load : function(args) { - // detect a bad request by validating required arguments - var communityUuid = this.getCommunityUuid(); - var promise = this.service._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } + getFrequency : function() { + return this.getAsNumber("frequency"); + } + }); + return Tag; +}); - var self = this; - var callbacks = { - createEntity : function(service, data, response) { - self.setData(data, response); - return self; - } - }; +}, +'sbt/smartcloud/controls/nls/BaseGridRenderer':function(){ +/* + * © 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. + */ - var requestArgs = lang.mixin( - { communityUuid : communityUuid }, - args || {}); - var options = { - handleAs : "text", - query : requestArgs - }; - - return this.service.getEntity(consts.AtomCommunityInstance, options, communityUuid, callbacks); - }, +// NLS_CHARSET=UTF-8 +define({ + root: { + empty : "Empty", + loading : "Loading...", + previous : "Previous", + previousPage : "Previous Page", + next : "Next", + nextPage : "Next Page", + pagingResults : "${start} - ${end} of ${totalCount}", + sortBy : "Sort by:", + msgNoData : "Please wait..." + } +}); - /** - * Remove this community - * - * @method remove - * @param {Object} [args] Argument object - */ - remove : function(args) { - return this.service.deleteCommunity(this.getCommunityUuid(), args); - }, - /** - * Update this community - * - * @method remove - * @param {Object} [args] Argument object - */ - update : function(args) { - return this.service.updateCommunity(this, args); +}, +'sbt/widget/_TemplatedWidget':function(){ +/* + * © 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. + */ + +/** + * + */ +define([ "../_bridge/declare","../_bridge/dom","../_bridge/lang", + "dojo/_base/lang", "dojo/string", "dojo/dom-construct", "dojo/_base/connect", "dojo/touch", "dijit/_WidgetBase", "dijit/_TemplatedMixin"], + function(declare, dom, sbtLang, lang, string, domConstruct, connect, touch, _WidgetBase, _TemplatedMixin) { + + /** + * @module sbt.widget._TemplatedWidget + */ + var _TemplatedWidget = declare([ dijit._WidgetBase, dijit._TemplatedMixin ], { + + _blankGif: dijit._WidgetBase.prototype._blankGif, + + _attachEventAttribute: "data-dojo-attach-event", + + _attachPointAttribute: "data-dojo-attach-point", + + _place: function(node, refNode, pos) { + domConstruct.place(node, refNode, pos); }, - /** - * Save this community - * - * @method remove - * @param {Object} [args] Argument object - */ - save : function(args) { - if (this.getCommunityUuid()) { - return this.service.updateCommunity(this, args); + _stopEvent: function(event) { + dojo.stopEvent(event); + }, + + _connect: function(object, event, method) { + return connect.connect(object, touch[event] || event, method); + }, + + _substitute: function(template, map, transformer, thisObject) { + if (!transformer) { + transformer = function(value, key) { + if (typeof value == "undefined") { + // check the renderer for the property + value = sbtLang.getObject(key, false, self); + } + + if (typeof value == "undefined" || value == null) { + return ""; + } + + return value; + }; + } + if (!thisObject) { + thisObject = this; + } + return string.substitute(template, map, transformer, thisObject); + }, + + _hitch: function(scope, method) { + if (arguments.length > 2) { + return lang._hitchArgs.apply(dojo, arguments); } else { - return this.service.createCommunity(this, args); + return lang.hitch(scope, method); } - } + }, + _doAttachPoints: function(el,scope){ + var nodes = (el.all || el.getElementsByTagName("*")); + for (var i = 0; i < nodes.length; i++) { + var attachPoint = (nodes[i].getAttribute) ? nodes[i].getAttribute(this._attachPointAttribute) : null; + if (attachPoint) { + var att = nodes[i].getAttribute(this._attachPointAttribute); + scope[att] = nodes[i]; + } + } + }, + + _doAttachEvents: function(el, scope) { + var nodes = (el.all || el.getElementsByTagName("*")); + for (var i = 0; i < nodes.length; i++) { + var attachEvent = (nodes[i].getAttribute) ? nodes[i].getAttribute(this._attachEventAttribute) : null; + if (attachEvent) { + nodes[i].removeAttribute(this._attachEventAttribute); + var event, events = attachEvent.split(/\s*,\s*/); + while((event = events.shift())) { + if (event) { + var func = null; + if (event.indexOf(":") != -1) { + var eventFunc = event.split(":"); + event = sbtLang.trim(eventFunc[0]); + func = sbtLang.trim(eventFunc[1]); + } else { + event = sbtLang.trim(event); + } + if (!func) { + func = event; + } + var callback = this._hitch(this, this[func], nodes[i], scope); + this._connect(nodes[i], event, callback); + } + } + } + } + } + }); + + return _TemplatedWidget; +}); +}, +'sbt/connections/controls/communities/CommunityGrid':function(){ +/* + * © 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. + */ +/** + * @module sbt.connections.controls.communities.CommunityGrid + */ +define([ "../../../declare", + "../../../controls/grid/Grid", + "./CommunityGridRenderer", + "./CommunityAction", + "../../../connections/controls/vcard/SemanticTagService", + "../../../config", + "../../../connections/CommunityConstants", + "../../../store/parameter"], + function(declare, Grid, CommunityGridRenderer, CommunityAction, SemanticTagService, sbt, consts, parameter) { + + var sortVals = { + date: "modified", + popularity: "count", + name: "title" + }; + + var ParamSchema = { + pageNumber: parameter.oneBasedInteger("page"), + pageSize: parameter.oneBasedInteger("ps"), + sortBy: parameter.sortField("sortField",sortVals), + sortOrder: parameter.booleanSortOrder("asc") + }; + /** - * Member class represents an entry for a Member feed returned by the - * Connections REST API. - * - * @class Member - * @namespace sbt.connections + * @class CommunityGrid + * @namespace sbt.connections.controls.communities */ - var Member = declare(AtomEntity, { - - xpath : consts.MemberXPath, - namespaces : consts.CommunityNamespaces, - categoryScheme : CategoryMember, - - /** - * The UUID of the community associated with this Member - */ - communityUuid : null, - - /** - * Constructor for Member entity - * - * @constructor - * @param args - */ - constructor : function(args) { - if (!this.getRole()) { - this.setRole(consts.Member); - } + var CommunityGrid = declare(Grid, { + + contextRootMap: { + communities: "communities" }, - - /** - * Return extra entry data to be included in post data for this entity. - * - * @returns {String} - */ - createEntryData : function() { - var postData = ""; - var transformer = function(value,key) { - return value; - }; - postData += stringUtil.transform(RoleTmpl, this, transformer, this); - return stringUtil.trim(postData); + + /** + * Options are for which type of community grid is to be created + * public will show public communities and my will show communities + * the specified user is a member or owner of. + */ + options : { + "public" : { + storeArgs : { + url : consts.AtomCommunitiesAll, + attributes : consts.CommunityXPath, + feedXPath : consts.CommunityFeedXPath, + paramSchema : ParamSchema + }, + rendererArgs : null + }, + "my" : { + storeArgs : { + url : consts.AtomCommunitiesMy, + attributes : consts.CommunityXPath, + feedXPath : consts.CommunityFeedXPath, + paramSchema : ParamSchema + }, + rendererArgs : null + }, + "invited" : { + storeArgs : { + url : consts.AtomCommunityInvitesMy, + attributes : consts.CommunityXPath, + feedXPath : consts.CommunityFeedXPath, + paramSchema : ParamSchema + }, + rendererArgs : null + } }, /** - * Return the community UUID. - * - * @method getCommunityUuid - * @return {String} communityUuid + * set the grids action to be an instance of CommunityAction + * This means an event will be provided for when the user moves the mouse over the + * community name or clicks on a community. */ - getCommunityUuid : function() { - return this.communityUuid; - }, - + communityAction: new CommunityAction(), + /** - * Return the community member name. - * - * @method getName - * @return {String} Community member name + * Default grid option is to display a list of public communities. */ - - getName : function() { - return this.getAsString("contributorName"); - }, - + defaultOption: "public", + /** - * Set the community member name. - * - * @method setName - * @param {String} Community member name + * Constructor function + * @method constructor */ - - setName : function(name) { - return this.setAsString("contributorName", name); + constructor: function(args) { + var nls = this.renderer.nls; + + /** + * Set the sorting information + */ + this._sortInfo = { + date: { + title: nls.date, + sortMethod: "sortByDate", + sortParameter: "date" + }, + popularity: { + title: nls.popularity, + sortMethod: "sortByPopularity", + sortParameter: "popularity" + }, + name: { + title: nls.name, + sortMethod: "sortByName", + sortParameter: "name" + } + }; + this._activeSortAnchor = this._sortInfo.date; + this._activeSortIsDesc = true; }, - + /** - * Return the community member userId. - * - * @method getUserid - * @return {String} Community member userId + * Create the CommunityGrid Renderer + * @method createDefaultRenderer + * @param args Arguments that can be passed to the renderer + * @returns {CommunityGridRenderer} */ - getUserid : function() { - return this.getAsString("contributorUserid"); + createDefaultRenderer : function(args) { + return new CommunityGridRenderer(args,this); }, - + /** - * Set the community member userId. - * - * @method getId - * @return {String} Community member userId + * Function is called after the grid is created, + * Here we call the superclass postCreate and then load the + * Semantic tag service, which will handle business card functionality + * @method postCreate */ - setUserid : function(userid) { - return this.setAsString("contributorUserid", userid); + postCreate: function() { + this.inherited(arguments); + if(this.displayBusinessCard){ + SemanticTagService.loadSemanticTagService(); + } }, - + /** - * Return the community member email. - * - * @method getName - * @return {String} Community member email + * Event handler for onClick Events + * Stops the default onClick event and calls the CommunityAction execute function + * @method handleClick + * @param el The element that fired the event + * @param data the data associated with the row + * @param ev the event */ - getEmail : function() { - return this.getAsString("contributorEmail"); + handleClick: function(el, data, ev) { + if (this.communityAction) { + this._stopEvent(ev); + + this.communityAction.execute(data, { grid : this.grid }, ev); + } }, - + /** - * Return the community member email. - * - * @method getName - * @return {String} Community member email + * Filter the community by specified tag + * @param el + * @param data + * @param ev */ + filterByTag: function(el, data, ev){ + this._stopEvent(ev); + + var options = { + tag: el.text + }; - setEmail : function(email) { - return this.setAsString("contributorEmail", email); + this._filter(options,data); }, - + /** - * Return the value of community member role from community member ATOM - * entry document. - * - * @method getRole - * @return {String} Community member role + * Gets sorting information, such as + * if the results are ascending or descending, and the sort anchors + * @method getSortInfo + * @returns An object containing sorting information */ - getRole : function() { - return this.getAsString("role"); + getSortInfo: function() { + return { + active: { + anchor: this._activeSortAnchor, + isDesc: this._activeSortIsDesc + }, + list: [this._sortInfo.date, this._sortInfo.popularity, this._sortInfo.name] + }; }, - + /** - * Sets role of a community member - * - * @method setRole - * @param {String} role Role of the community member. + * Sort the grid rows by last modified date + * @method sortByLastModified + * @param el The element that was clicked, typically a "sort by" button + * @param data the data associated with the element + * @param ev the event */ - setRole : function(role) { - return this.setAsString("role", role); + sortByDate: function(el, data, ev) { + this._sort("date", true, el, data, ev); }, /** - * Loads the member object with the atom entry associated with the - * member. By default, a network call is made to load the atom entry - * document in the member object. - * - * @method load - * @param {Object} [args] Argument object + * Sort the grid rows by popularity + * @method sortByPopularity + * @param el The element that was clicked, typically a "sort by" button + * @param data the data associated with the element + * @param ev the event */ - load : function(args) { - // detect a bad request by validating required arguments - var communityUuid = this.communityUuid; - var promise = this.service._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } - - var self = this; - var callbacks = { - createEntity : function(service, data, response) { - self.setData(data, response); - return self; - } - }; - - var requestArgs = { - communityUuid : communityUuid - }; - var memberId = null; - if (this.getUserid()) { - memberId = requestArgs.userid = this.getUserid(); - } else { - memberId = requestArgs.email = this.getEmail(); - } - requestArgs = lang.mixin(requestArgs, args || {}); - var options = { - handleAs : "text", - query : requestArgs - }; - - return this.service.getEntity(consts.AtomCommunityMembers, options, memberId, callbacks); + sortByPopularity: function(el, data, ev) { + this._sort("popularity", true, el, data, ev); }, /** - * Remove this member from the community. - * - * @method remove - * @param {Object} [args] Argument object + * Sort the grid rows by title + * @method sortByTitle + * @param el The element that was clicked, typically a "sort by" button + * @param data the data associated with the element + * @param ev the event */ - remove : function(args) { - var memberId = this.getUserid() || this.getEmail(); - return this.service.removeMember(this.getCommunityUuid(), memberId, args); + sortByName: function(el, data, ev) { + this._sort("name", false, el, data, ev); } - + }); - /** - * Invite class represents an entry for a Invite feed returned by the - * Connections REST API. - * - * @class Invite - * @namespace sbt.connections - */ - var Invite = declare(AtomEntity, { + return CommunityGrid; +}); - xpath : consts.InviteXPath, - namespaces : consts.CommunityNamespaces, - categoryScheme : CategoryInvite, - - /** - * The UUID of the community associated with this Invite - */ - communityUuid : null, +}, +'sbt/connections/CommunityConstants':function(){ +/* + * © Copyright IBM Corp. 2012,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. + */ - /** - * The UUID if the invitee associated with this Invite - */ - inviteeUuid : null, +/** + * Social Business Toolkit SDK. Definition of constants for CommunityService. + * + * @module sbt.connections.CommunityConstants + */ +define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { + return lang.mixin({}, conn, { + /** - * Constructor for Invite + * Public community * - * @constructor - * @param args + * @property Public + * @type String + * @for sbt.connections.Community */ - constructor : function(args) { - this.inherited(arguments, [ args ]); - }, + Public : "public", /** - * Return the value of IBM Connections invite ID from invite ATOM - * entry document. + * Moderated community * - * @method getInviteUuid - * @return {String} Invite ID of the invite + * @property Moderated + * @type String + * @for sbt.connections.Community */ - getInviteUuid : function() { - var inviteUuid = this.getAsString("inviteUuid"); - return extractInviteUuid(inviteUuid); - }, + Moderated : "publicInviteOnly", /** - * Sets id of IBM Connections invite. + * Restricted community * - * @method setInviteUuid - * @param {String} inviteUuid Id of the invite + * @property Restricted + * @type String + * @for sbt.connections.Community */ - setInviteUuid : function(inviteUuid) { - return this.setAsString("inviteUuid", inviteUuid); - }, + Restricted : "private", /** - * Set the community UUID. + * Community owner * - * @method setCommunityUuid - * @return {String} communityUuid + * @property Owner + * @type String + * @for sbt.connections.Member */ - setCommunityUuid : function(communityUuid) { - this.communityUuid = communityUuid; - return this; - }, + Owner : "owner", /** - * Return the community UUID. + * Community member * - * @method getCommunityUuid - * @return {String} communityUuid + * @property Member + * @type String + * @for sbt.connections.Member */ - getCommunityUuid : function() { - if (!this.communityUuid) { - this.communityUuid = this.service.getUrlParameter(this.getAsString("communityUrl"), "communityUuid"); - } - return this.communityUuid; - }, + Member : "member", /** - * Set the invitee UUID. - * - * @method setInviteeUuid - * @return {String} inviteeUuid + * Namespaces to be used when reading the Communities ATOM entry or feed */ - setInviteeUuid : function(inviteeUuid) { - this.inviteeUuid = inviteeUuid; - return this; - }, + CommunityNamespaces : { + a : "http://www.w3.org/2005/Atom", + app : "http://www.w3.org/2007/app", + snx : "http://www.ibm.com/xmlns/prod/sn" + }, /** - * Return the value of IBM Connections invitee ID from invite ATOM - * entry document. + * XPath expressions used when parsing a Connections Communities ATOM feed * - * @method getInviteeUuid - * @return {String} Invitee ID of the invite + * @property CommunityFeedXPath + * @type Object + * @for sbt.connections.CommunityService */ - getInviteeUuid : function() { - if (!this.inviteeUuid) { - var inviteUuid = this.getInviteUuid(); - this.inviteeUuid = extractInviteeUuid(inviteUuid, this.getCommunityUuid()); - } - return this.inviteeUuid; - }, + CommunityFeedXPath : conn.ConnectionsFeedXPath, /** - * Set the user id of the invitee. - * - * @method setUserid - * @return {String} userid - */ - setUserid : function(userid) { - return this.setAsString("contributorUserid", userid); - }, - - /** - * Return the user id of the invitee. + * XPath expressions to be used when reading a Community Entry * - * @method getUserid - * @return {String} userid + * @property CommunityXPath + * @type Object + * @for sbt.connections.CommunityService */ - getUserid : function() { - return this.getAsString("contributorUserid"); - }, + CommunityXPath : lang.mixin({}, conn.AtomEntryXPath, { + communityUuid : "a:id", + communityTheme : "snx:communityTheme", + logoUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/logo']/@href", + tags : "a:category[not(@scheme)]/@term", + memberCount : "snx:membercount", + communityType : "snx:communityType", + communityUrl : "a:link[@rel='alternate']/@href", + isExternal : "snx:isExternal", + parentCommunityUrl: "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/parentcommunity']/@href" + }), /** - * Set the email of the invitee. + * XPath expressions to be used when reading a Community Member Entry * - * @method setEmail - * @return {String} email + * @property MemberXPath + * @type Object + * @for sbt.connections.CommunityService */ - setEmail : function(email) { - return this.setAsString("contributorEmail", email); - }, - + MemberXPath : lang.mixin({}, conn.AtomEntryXPath, { + id : "a:contributor/snx:userid", + uid : "a:contributor/snx:userid", + role : "snx:role" + }), + /** - * Return the email of the invitee. + * XPath expressions to be used when reading a Community Invite Entry * - * @method getEmail - * @return {String} email + * @property InviteXPath + * @type Object + * @for sbt.connections.CommunityService */ - getEmail : function() { - return this.getAsString("contributorEmail"); - }, + InviteXPath : lang.mixin({}, conn.AtomEntryXPath, { + inviteUuid : "a:id", + communityUuid : "snx:communityUuid", + communityUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/community']/@href" + }), /** - * Loads the invite object with the atom entry associated with the - * invite. By default, a network call is made to load the atom entry - * document in the invite object. + * XPath expressions to be used when reading a Community Event Entry * - * @method load - * @param {Object} [args] Argument object + * @property EventXPath + * @type Object + * @for sbt.connections.CommunityService */ - load : function(args) { - // detect a bad request by validating required arguments - var communityUuid = this.getCommunityUuid(); - var promise = this.service._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } - var userid = this.getInviteeUuid(); - promise = this.service._validateUserid(userid); - if (promise) { - return promise; - } - - var self = this; - var callbacks = { - createEntity : function(service, data, response) { - self.setData(data, response); - return self; - } - }; - - var requestArgs = lang.mixin({ - communityUuid : communityUuid, - userid : userid - }, args || {}); - var options = { - handleAs : "text", - query : requestArgs - }; - - return this.service.getEntity(consts.AtomCommunityInvites, options, communityUuid + "-" + userid, callbacks); - }, + EventXPath : lang.mixin({}, conn.AtomEntryXPath, { + eventUuid : "snx:eventUuid", + eventInstUuid : "snx:eventInstUuid", + location : "snx:location", + allDay : "snx:allday", + selfLink : "a:link[@rel='self']/@href", + sourceId : "a:source/a:id", + sourceTitle : "a:source/a:title", + sourceLink : "a:source/a:link[@rel='self']/@href", + attendLink : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/calendar/event/attend']/@href", + followLink : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/calendar/event/follow']/@href", + followed : "snx:followed", + attended : "snx:attended", + attendeesAtomUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/calendar/event/attendees']/@href", + containerLink : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/container']/@href", + instStartDate : "snx:startDate", + instEndDate : "snx:endDate", + repeats : "snx:repeats", + parentEventId : "snx:parentEvent", + parentEventLink : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/calendar/event/parentevent']/@href", + communityLink : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/container']/@href", + communityUuid : "snx:communityUuid", + eventAtomInstances : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/calendar/event/instances']/@href", + eventAtomAttendees : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/calendar/event/attend']/@href", + eventAtomFollowers : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/calendar/event/follow']/@href", + frequency : "snx:recurrence/@frequency", + interval : "snx:recurrence/@interval", + until : "snx:recurrence/snx:until", + byDay : "snx:recurrence/snx:byDay", + startDate : "snx:recurrence/snx:startDate", + endDate : "snx:recurrence/snx:endDate" + }), /** - * Remove this invite + * A feed of all public communities. + * + * Get the All Communities feed to see a list of all public communities to which the authenticated user has access or pass in parameters to search for communities that match a specific criteria. * - * @method remove - * @param {Object} [args] Argument object + * Supports: asc, email, ps, search, since, sortField, tag, userid + * + * @property AtomCommunitiesAll + * @type String + * @for sbt.connections.CommunityService */ - remove : function(args) { - return this.service.removeInvite(this, args); - }, + AtomCommunitiesAll : "/${communities}/service/atom/communities/all", /** - * Update this invite + * A feed of communities of which the authenticated user is a member. * - * @method remove - * @param {Object} [args] Argument object + * Get the My Communities feed to see a list of the communities to which the authenticated user is a member or pass in parameters to search for a subset of those communities that match a specific criteria. + * + * Supports: asc, email, ps, search, since, sortField, tag, userid + * + * @property AtomCommunitiesMy + * @type String + * @for sbt.connections.CommunityService */ - update : function(args) { - return this.service.updateInvite(this, args); - }, + AtomCommunitiesMy : "/${communities}/service/atom/communities/my", /** - * Save this invite + * A feed of invitations. * - * @method remove - * @param {Object} [args] Argument object - */ - save : function(args) { - if (this.getInviteUuid()) { - return this.service.updateInvite(this, args); - } else { - return this.service.createInvite(this, args); - } - } - - }); - - - /** - * Event class represents an entry from an Events feed returned by the Connections REST API. - * - * An Event may repeat and have multiple EventInsts (instances of the event). - * - * e.g. If an event has repeats set so that it happens on 5 different days it has 5 EventInsts, but the Event is still the same. - * - * @class Event - * @namespace sbt.connections - */ - var Event = declare(AtomEntity, { - - /** - * Constructor for Event. + * Get a list of the outstanding community invitations of the currently authenticated user or provide parameters to search for a subset of those invitations. * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * The Uuid of the event. This is per event rather than per event instance. + * Supports: asc, ps, search, since, sortField * - * e.g. if an event spans multiple days it will have multiple instances, yet each even will have the same Uuid. - * @method getEventUuid - * @return {String} Uuid of the event. - */ - getEventUuid : function(){ - return this.getAsString("eventUuid"); - }, - - /** - * @method getLocation - * @return {String} The location of the event - */ - getLocation : function(){ - return this.getAsString("location"); - }, - - /** - * @method getAllDay - * @return {Boolean} True if event lasts entire day, false otherwise. + * @property AtomCommunityInvitesMy + * @type String + * @for sbt.connections.CommunityService */ - getAllDay : function(){ - return this.getAsString("allDay") !== 0; - }, + AtomCommunityInvitesMy : "/${communities}/service/atom/community/invites/my", /** + * URL to delete/create Community Invites * - * @method getSelfLink - * @return {String} Link to the atom representation of this object + * @property AtomCommunityInvites + * @type String + * @for sbt.connections.CommunityService */ - getSelfLink : function(){ - return this.getAsString("selfLink"); - }, + AtomCommunityInvites : "${communities}/service/atom/community/invites", /** - * Gets the source, usually the community it was created in. - * Contains id of source, title and a link to the web representation of the source. - * {id:"", title: "", link:""} + * A feed of subcommunities. * - * @method getSource - * @return {Object} + * Get a list of subcommunities associated with a community. + * + * Supports: asc, page, ps, since, sortBy, sortOrder, sortField + * + * @property AtomCommunitySubCommunities + * @type String + * @for sbt.connections.CommunityService */ - getSource : function(){ - return this.getAsObject( - [ "id", "title", "link"], - [ "id", "title", "link"]); - }, - + AtomCommunitySubCommunities : "${communities}/service/atom/community/subcommunities", + /** - * Gets the recurrence information of the event. This information is not available in individual event instances. + * A feed of members. * - * Recurrence information object consists of: - * frequency - 'daily' or 'weekly' - * interval - Week interval. Value is int between 1 and 5. (e.g. repeats every 2 weeks). null if daily. - * until - The end date of the repeating event. - * allDay - 1 if an all day event, 0 otherwise. - * startDate - Start time of the event - * endDate - End time of the event - * byDay - Days of the week this event occurs, possible values are: SU,MO,TU,WE,TH,FR,SA + * Retrieve the members feed to view a list of the members who belong to a given community. * - * @method getRecurrence - * @return {Object} An object containing the above recurrence information of the community event. + * Supports: asc, email, page, ps, role, since, sortField, userid + * + * @property AtomCommunityMembers + * @type String + * @for sbt.connections.CommunityService */ - getRecurrence : function() { - return this.getAsObject( - [ "frequency", "interval", "until", "allDay", "startDate", "endDate", "byDay" ], - [ "frequency", "interval", "until", "allDay", "startDate", "endDate", "byDay" ]); - }, + AtomCommunityMembers : "${communities}/service/atom/community/members", /** - * @method getContainerLink - * @return {String} Link to the container on the web, i.e. the community - */ - getCommunityLink : function(){ - this.getAsString("communityLink"); - }, + * A community entry. + * + * @property AtomCommunityInstance + * @type String + * @for sbt.connections.CommunityService + */ + AtomCommunityInstance : "${communities}/service/atom/community/instance", /** - * Return the community UUID. + * Get a feed that includes the topics in a specific community forum. * - * @method getCommunityUuid - * @return {String} communityUuid + * @property AtomCommunityForumTopics + * @type String + * @for sbt.connections.CommunityService */ - getCommunityUuid : function() { - return this.getAsString("communityUuid"); - } - }); - - /** - * EventInst class represents an entry for an EventInsts feed returned by the Connections REST API. EventInsts all have a parent Event. - * - * @class EventInst - * @namespace sbt.connections - */ - var EventInst = declare(Event, { + AtomCommunityForumTopics : "/${communities}/service/atom/community/forum/topics", + /** - * Constructor for Event instance. - * - * @constructor - * @param args + * Get a feed of a Community's bookmarks. Requires a url parameter of the form communityUuid=xxx + * @property AtomCommunityBookmarks + * @type String + * @for sbt.connections.CommunityService */ - constructor : function(args) { - }, + AtomCommunityBookmarks : "/${communities}/service/atom/community/bookmarks", /** - * The event instance uuid. This is per event instance, rather than per event. - * e.g. if an event spans multiple days each day will have its own eventInstUuid. - * - * Can be used with the{{#crossLink "CommunityService/getEvent:method"}}{{/crossLink}} method to retrieve event instances. - * @method getEventInstUuid - * @return {String} Uuid of the event instance. + * Get a feed of a Community's Events or EventInsts. + * @property AtomCommunityEvents + * @type String + * @for sbt.connections.CommunityService */ - getEventInstUuid : function(){ - return this.getAsString("eventInstUuid"); - }, + AtomCommunityEvents : "/${communities}/calendar/atom/calendar/event", /** - * @method getFollowed - * @return {Boolean} True if the current authenticated user is following this event Instance + * Get a feed of a Community's Event Attendess. + * @property AtomCommunityEventAttend + * @type String + * @for sbt.connections.CommunityService */ - getFollowed : function(){ - return this.getAsString("followed"); - }, + AtomCommunityEventAttend : "/${communities}/calendar/atom/calendar/event/attendees", /** - * @method getAttended - * @return {Boolean} True if the current authenticated user is attending this event Instance + * Get a feed of a Community's Event Comments. + * @property AtomCommunityEventComments + * @type String + * @for sbt.connections.CommunityService */ - getAttended : function(){ - return this.getAsString("attended"); - }, + AtomCommunityEventComments : "/${communities}/calendar/atom/calendar/event/comment", /** - * @method getParentEventId - * @return {String} The id of the parent event of this event instance. + * Get a feed of a Community's Invites. + * @property AtomCommunityInvites + * @type String + * @for sbt.connections.CommunityService */ - getParentEventId : function(){ - return this.getAsString("parentEventId"); - }, + AtomCommunityInvites : "/${communities}/service/atom/community/invites", /** - * @method getParentEventLink - * @return {String} The link to the parent event's atom representation. + * Get a feed of a Community's Bookmarks. + * @property AtomCommunityInvites + * @type String + * @for sbt.connections.CommunityService */ - getParentEventLink : function(){ - return this.getAsString("parentEventLink"); - }, + AtomCommunityBookmarks : "/${communities}/service/atom/community/bookmarks", /** - * @method getStartDate - * @return The date the event instance starts + * File Proxy URL for update community logo + * @property AtomUpdateCommunityLogo + * @type String + * @for sbt.connections.CommunityService */ - getStartDate : function(){ - return this.getAsString("instStartDate"); - }, + AtomUpdateCommunityLogo : "/${files}/{endpointName}/connections/UpdateCommunityLogo/{fileName}", /** - * @method getEndDate - * @return The date the event instance ends + * File Proxy URL for uploading a community file + * @property AtomUploadCommunityFile + * @type String + * @for sbt.connections.CommunityService */ - getEndDate : function(){ - return this.getAsString("instEndDate"); - } + AtomUploadCommunityFile : "/${files}/{endpointName}/connections/UploadCommunityFile/{communityUuid}" + }); +}); +}, +'sbt/controls/grid/bootstrap/GridRendererMixin':function(){ +require({cache:{ +'url:sbt/controls/grid/bootstrap/templates/GridPager.html':"
    \r\n\t
      \r\n\t\t
    • \r\n\t\t\t${nls.previous}\r\n\t\t\t${nls.previous}\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t${pagingResults}\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t${nls.next}\r\n\t\t\t${nls.next}\r\n\t\t
    • \r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t
    \r\n
    \r\n\r\n\r\n", +'url:sbt/controls/grid/bootstrap/templates/GridSorter.html':"
    \r\n\t
    \r\n\t\t${nls.sortBy}\r\n\t\t
      \r\n\t\t\t${sortAnchors}\r\n\t\t
    \r\n\t
    \r\n
    ", +'url:sbt/controls/grid/bootstrap/templates/SortAnchor.html':"
  • \r\n\t ${title}\r\n
  • "}}); +/* + * © 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. + */ - /* - * Method used to extract the community uuid for an id url. - */ - var extractCommunityUuid = function(service, uid) { - if (uid && uid.indexOf("http") == 0) { - return service.getUrlParameter(uid, "communityUuid"); - } else { - return uid; - } - }; - - /* - * Method used to extract the invite uuid for an id url. - */ - var extractInviteUuid = function(uid) { - if (uid && uid.indexOf("urn:lsid:ibm.com:communities:invite-") == 0) { - return uid.substring("urn:lsid:ibm.com:communities:invite-".length); - } else { - return uid; - } - }; - - /* - * Method used to extract the invitee uuid for an id url. +/** + * + */ +define([ "../../../text!./templates/GridPager.html", + "../../../text!./templates/GridSorter.html", + "../../../text!./templates/SortAnchor.html" ], + function(GridPager, GridSorter, SortAnchor) { + + /** + * @module sbt.controls.grid.bootstrap.GridRendererMixin */ - var extractInviteeUuid = function(uid, communityUuid) { - if (uid && uid.indexOf(communityUuid) == 0) { - return uid.substring(communityUuid.length + 1); - } else { - return uid; - } + return { + tableClass : "table table-striped table-bordered", + emptyClass : "label label-info", + errorClass : "label label-warning", + loadingClass : "label label-info", + loadingImgClass : "icon-refresh", + firstClass : "", + defaultSortClass : "icon-arrow-down", + ascendingSortClass : "icon-arrow-up", + descendingSortClass : "icon-arrow-down", + pagerTemplate : GridPager, + sortTemplate : GridSorter, + sortAnchor : SortAnchor }; - /* - * Callbacks used when reading a feed that contains Community entries. - */ - var CommunityFeedCallbacks = { - createEntities : function(service,data,response) { - return new CommunityDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.CommunityFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new Community({ - service : service, - data : data, - response: response - }); - } - }; +}); +}, +'url:sbt/connections/controls/bookmarks/templates/BookmarkRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\r\n\t

    \r\n\t\t\t${title}\r\n\t\t

    \r\n\t\t\r\n\t\t
    \r\n\t\t\t${authorName}\r\n\r\n\t\t\t| ${updatedDate}\r\n\r\n\r\n\t\t\t| \r\n\t\t\t\t${tagsLabel} \r\n\t\t\t\t\t${tagsAnchors}\r\n\r\n\t\t\t\r\n\t\t\t\r\n\r\n\t\t
    \r\n\t\t\r\n", +'url:sbt/connections/controls/forums/templates/TopicRow.html':"\r\n\t\r\n\t\t
    \r\n \r\n\t\r\n\t\t

    \r\n\t\t\t${title}\r\n\t\t

    \r\n\t\r\n\t\r\n\t\t\r\n\t${threadCount}\r\n\t\r\n\t${getDateLabel}\r\n", +'url:sbt/connections/controls/search/templates/MemberListTemplate.html':"
    ", +'url:sbt/connections/controls/bookmarks/templates/TagAnchor.html':"${tagName}", +'sbt/connections/controls/bootstrap/ProfileRendererMixin':function(){ +require({cache:{ +'url:sbt/connections/controls/bootstrap/templates/ProfileRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.telephone} ${telephone}
    \r\n\t\t\t
    ${nls.email}: ${email}
    \r\n\t\t\t
    ${nls.altEmail}: ${altEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n"}}); +/* + * © 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. + */ - /* - * Callbacks used when reading a feed that contains Member entries. - */ - var MemberFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.CommunityFeedXPath - }); - } - }; +/** + * + */ +define(["../../../lang", "../../../controls/grid/bootstrap/GridRendererMixin", + "../../../text!./templates/ProfileRow.html" ], + function(lang, GridRendererMixin, ProfileRow) { - /* - * Callbacks used when reading a feed that contains Invite entries. - */ - var InviteFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.CommunityFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new Invite({ - service : service, - data : data, - response: response - }); - } - }; - - /* - * Callbacks used when reading a feed that contains Event entries. + /** + * @module sbt.controls.grid.bootstrap.ProfileRendererMixin */ - var ConnectionsEventFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.CommunityFeedXPath - }); - }, - createEntity : function(service,data,response) { - var entryHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.EventXPath - }); - return new Event({ - service : service, - id : entryHandler.getEntityId(), - dataHandler : entryHandler - }); - } - }; + return lang.mixin(GridRendererMixin, { template : ProfileRow }); - /* - * Callbacks used when reading a feed that contains EventInst entries. +}); +}, +'url:sbt/connections/controls/bootstrap/templates/CommunityRow.html':"\r\n\t\r\n\t\t\"\"\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t\r\n\t\t\t\t${title}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t|\r\n\t\t\t\r\n\t\t\t\t\"${nls.moderated}\"\r\n\t\t\t\t${nls.moderated} \r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\"${nls.restricted}\"\r\n\t\t\t\t${nls.restricted} \r\n\t\t\t\r\n\t\t

    \r\n\t\t
    \r\n\t\t\t\r\n\t\t\t\t${numOfMembers}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${nls.updatedBy}\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t${contributorName}\r\n\t\t\t\t\t\t${contributorUserid}\r\n\t\t\t\t\t \r\n\t\t\t\t\r\n\t\t\t\t|\r\n\t\t\t\t${updatedDate}\r\n\t\t\t\t|\r\n\t\t\t\t\r\n\t\t\t\t\t${tagsLabel}\r\n\t\t\t\t\t${tagsAnchors}\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t

    ${summary}

    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n", +'url:sbt/connections/controls/search/templates/a.html':"${content}", +'sbt/connections/controls/sharebox/_InputForm':function(){ +/* + * (C) Copyright IBM Corp. 2012 + * + * 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. + */ +define(["sbt/declare", "sbt/json", "sbt/connections/controls/_ConnectionsWidget"],function(declare, json, _ConnectionsWidget){ + /** + * InputForm */ - var ConnectionsEventInstFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.CommunityFeedXPath - }); - }, - createEntity : function(service,data,response) { - var entryHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.EventXPath - }); - return new EventInst({ - service : service, - id : entryHandler.getEntityId(), - dataHandler : entryHandler - }); - } - }; - - var ConnectionsEventInstCallbacks = { - createEntity : function(service,data,response) { - var entryHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.EventXPath - }); - return new EventInst({ - service : service, - id : entryHandler.getEntityId(), - dataHandler : entryHandler - }); - } - }; + var _InputForm = declare([_ConnectionsWidget], + { + /** + * The connections InputForm. + * + * @property inputForm + * @type Object + */ + inputForm: null, - /* - * Callbacks used when reading an entry that contains a Community. - */ - var CommunityCallbacks = { - createEntity : function(service,data,response) { - return new Community({ - service : service, - data : data, - response: response - }); - } - }; - - /* - * Callbacks used when reading an feed that contains community forum topics. - */ - var ForumTopicFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.CommunityFeedXPath - }); + /** + * Set up the connections InputForm. + * + * @method constructor + * @param {Object} args + * @param {String} args.shareBoxNode Should contain the id of the html element to add the InputForm to. + */ + constructor: function(args){ + var url = "/${connections}/opensocial/basic/rest/ublog/@config/settings"; + var self = this; + + var xhrArgs = { + serviceUrl: url, //TODO Change these when opensocial oauth and/or endpoints become available + handleAs: "json", + load: function(data) { + var settings = { + maxNumberChars: 1000, + boardId: args.boardId || "@me", + postType: lconn.news.microblogging.sharebox.Context.SU_CONTEXT + }; + var connectionsSettings = data && data.entry; + if(connectionsSettings){ + settings.maxNumberChars = connectionsSettings["com.ibm.connections.ublog.microblogEntryMaxChars"]; + self.inputForm = new lconn.news.microblogging.sharebox.InputForm({ + params : settings, + "xhrHandler" : self.xhrHandler, + "UBLOG_RELATIVE_PATH" : "/basic/rest/ublog/", + isASGadget : false + }, dojo.byId(args.shareBoxNode)); + if(self.inputForm.attachActionButtonNode){ + dojo.empty(self.inputForm.attachActionButtonNode); + } + + self.modifyPostFunction(); + } + }, + error: function() { + console.log("Failed to find InputForm settings at " + url); + } + }; + + this.xhrHandler.xhrGet(xhrArgs); }, - createEntity : function(service, data, response) { - var forumService = service.getForumService(); - var forumTopic = forumService.newForumTopic({}); - forumTopic.setData(data, response); - return forumTopic; + + /** + * A hack needed to overcome a hardcoded dojo.xhr request in the connections InputForm. Overwrites the offending function. + * + * @method modifyPostFunction + */ + modifyPostFunction: function(){ + this.inputForm.postMicroblog = function (microblogMessage, fileAttachment) { + this._setPostButtonLabel(this._resourceBundle.POSTING); + this._setSubmitState(true); + var requestObj = this._buildRequestObj(microblogMessage, fileAttachment); + var postUrl = this._getPostUrlForContext(); + postUrl = postUrl.slice(postUrl.lastIndexOf("/connections")); + this.xhrHandler.xhrPost({ + serviceUrl: postUrl, + postData: json.stringify(requestObj), + handleAs: "json", + load: dojo.hitch(this, function (data) { + if (this.isGlobalSharebox){ + dojo.publish(this.AS_UPDATE, [data.entry.id]); + } else { + dojo.publish(this.TOPIC_POST_MESSAGE, [data]); + } + this._setInitialState(); + this._setSubmitState(false); + this._displaySuccessMessage(); + if (this.isGlobalSharebox) { + this._closeSharebox(); + this.setShareMode(lconn.news.microblogging.sharebox.constants.SHAREWITHEVERYONE); + dojo.publish(lconn.news.microblogging.sharebox.events.STATUSSHAREBOX_CLOSING); + } else { + this.mbSuccessClose.focus(); + this.textBoxControl.collapseTextBox(); + } + + this._setPostButtonLabel(this._resourceBundle.POST); + + }), + error: dojo.hitch(this, function (data) { + this._handlePostError(data); + }), + headers: { + "Content-Type": "application/json" + } + }); + }; } - }; + + }); + + return _InputForm; +}); + +}, +'sbt/connections/controls/search/nls/SearchBoxRenderer':function(){ +/* + * © 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. + */ + +// NLS_CHARSET=UTF-8 +define({ + root: { + selectedApplication: "All Connections", + allConnections: "All Connections", + statusUpdates: "Status Updates", + activities: "Activities", + blogs: "Blogs", + bookmarks: "Bookmarks", + communities: "Communities", + files: "Files", + forums: "Forums", + profiles: "Profiles", + wikis: "Wikis", + refine: "Refine Search Results", + search: "Search", + allConnectionsIcon: "All Connections Icon", + icon: "Icon" + } +}); + +}, +'url:sbt/connections/controls/profiles/templates/ColleagueItem.html':"
    \r\n \r\n \r\n \"${title}\"\r\n \r\n ${uid}\r\n ${title}\r\n \r\n
    ", +'sbt/connections/controls/wrappers/FileGridWrapper':function(){ +require({cache:{ +'url:sbt/connections/controls/templates/FileGridWrapperContent.html':"\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n
    \r\n
    \r\n \r\n \r\n\r\n"}}); +/* + * © 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. + */ +define(["../../../declare", "../../../config", "../../../util", "../../../lang", "../../../url", "../../../connections/controls/WidgetWrapper", "../../../text!../templates/FileGridWrapperContent.html"], function(declare, config, util, lang, Url, WidgetWrapper, defaultTemplate) { /** - * CommunityService class. + * The wrapper for the ActivityStream. + * This class just has to provide its own template and the args it receives back to to the WidgetWrapper, which will take care of everything else. * - * @class CommunityService - * @namespace sbt.connections + * @class sbtx.controls.astream.ActivityStreamWrapper */ - var CommunityService = declare(ConnectionsService, { - - forumService : null, - bookmarkService : null, - - contextRootMap: { - communities: "communities" - }, - - serviceName : "communities", + var FileGridWrapper = declare([ WidgetWrapper ], { /** - * Constructor for CommunityService + * Set the html template which will go inside the iframe. * - * @constructor - * @param args + * @property defaultTemplate + * @type String */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); - } - }, + defaultTemplate: defaultTemplate, - /** - * Return a ForumService instance - * - * @method getForumService - * @returns {ForumService} - */ - getForumService : function() { - if (!this.forumService) { - this.forumService = new ForumService(); - this.forumService.endpoint = this.endpoint; - } - return this.forumService; - }, /** - * Return a BookmarkService instance + * Overriding the method in WidgetWrapper for providing the substitutions for variables in the template. * - * @method getBookmarkService - * @returns {BookmarkService} + * @method getTemplateReplacements + * @returns {Object} */ - getBookmarkService : function() { - if (!this.bookmarkService) { - this.bookmarkService = new BookmarkService(); - this.bookmarkService.endpoint = this.endpoint; - } - return this.bookmarkService; + getTemplateReplacements: function(){ + var connectionsUrl = this._endpoint.baseUrl; + var libUrl = new Url(config.Properties.libraryUrl); + var libQuery = libUrl.getQuery() || ""; + var libQueryObj = util.splitQuery(libQuery, "&"); + + lang.mixin(libQueryObj, { + lib: "dojo", + ver: "1.8.0" + }); + libQuery = util.createQuery(libQueryObj, "&"); + libUrl.setQuery(libQuery); + + var sbtProps = lang.mixin({}, config.Properties); + lang.mixin(sbtProps, { + libraryUrl: libUrl.getUrl(), + loginUi: "popup" + }); + var templateReplacements = { + args: JSON.stringify(this.args), + connectionsUrl: connectionsUrl, + libraryUrl: libUrl.getUrl(), + sbtProps: JSON.stringify(sbtProps) + }; + + return templateReplacements; }, /** - * Get the All Communities feed to see a list of all public communities to which the - * authenticated user has access or pass in parameters to search for communities that - * match a specific criteria. - * - * @method getPublicCommunities + * Store the args so that they can be substituted into the defaultTemplate. * - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of my communities. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. + * @property args + * @type Object + * @default null */ - getPublicCommunities : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomCommunitiesAll, options, CommunityFeedCallbacks); - }, + args: null, + + constructor: function(args){ + this.args = args; + } + + }); + + return FileGridWrapper; +}); +}, +'sbt/json':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ +/** + * Implements some JSON helpers. Will uses the browser version + * if available else it will delegate to the Javascript library being used. + * + * @module sbt.json + */ +define(['./_bridge/json', './_bridge/lang', './log', './stringUtil'], function(jsonLib, lang, log, stringUtil) { + + /** + * @static + */ + return { /** - * Get the My Communities feed to see a list of the communities to which the - * authenticated user is a member or pass in parameters to search for a subset - * of those communities that match a specific criteria. - * - * @method getMyCommunities - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of my communities. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. + * Parses a String of JSON and returns a JSON Object. + * @param {String} jsonString A String of JSON. + * @returns {Object} A JSON Object. + * @static + * @method parse */ - getMyCommunities : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomCommunitiesMy, options, CommunityFeedCallbacks); + parse : function(jsonString) { + var jsonImpl = JSON || jsonLib; + return jsonImpl.parse(jsonString); }, - + /** - * Retrieve the members feed to view a list of the members who belong - * to a given community. - * - * @method getMembers - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of members of a - * community. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. + * Returns the JSON object represented as a String. + * @param {Object} jsonObj A JSON Object. + * @returns {String} The JSON Object represented as a String. + * @method stringify */ - getMembers : function(communityUuid,args) { - var promise = this._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ - communityUuid : communityUuid - }, args || {}); - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - var callbacks = lang.mixin({ - createEntity : function(service,data,response) { - return new Member({ - service : service, - communityUuid : communityUuid, - data : data, - response: response - }); - } - }, MemberFeedCallbacks); - - return this.getEntities(consts.AtomCommunityMembers, options, callbacks); + stringify : function(jsonObj) { + var jsonImpl = JSON || jsonLib; + return jsonImpl.stringify(jsonObj); }, - + /** - * Retrieve the member entry to view a member who belongs to a given community. - * - * @method getMember - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of members of a - * community. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. + * @method jsonBeanStringify + * @param theObj + * @returns */ - getMember : function(communityUuid,memberId,args) { - var member = new Member({ - service : this, - communityUuid : communityUuid - }); - - if (this.isEmail(memberId)) { - member.setEmail(memberId); + jsonBeanStringify: function(theObj) { + if (lang.isArray(theObj)) { + var jsonObjs = "["; + for (var i=0; i= 0 && !self._isBuiltin(val)) + return undefined; + seen.push(val); + } else if(lang.isFunction(val)){ + return undefined; + } + return val; + }, indent); }, - /* - * here since getCommunityEvents and getCommunityEventInsts use the same logic. - */ - _getCommunityEvents : function(communityUuid, startDate, endDate, args, callbacks){ - var promise = this._validateCommunityUuid(communityUuid) || this._validateDateTimes(startDate, endDate); - if (promise) { - return promise; + _jsonBean: function(theObj, seen) { + // first check for cyclic references + if (!seen) { + seen = []; } - var requiredArgs = { - calendarUuid : communityUuid - }; - if(startDate){ - lang.mixin(requiredArgs, { - startDate : startDate - }); - } - if(endDate){ - lang.mixin(requiredArgs, { - endDate : endDate - }); + if (seen.indexOf(theObj) >= 0) { + return undefined; } + seen.push(theObj); - args = lang.mixin(args, requiredArgs); - - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomCommunityEvents, options, callbacks); + var jsonObj = {}; + for (var property in theObj) { + var value = this._getObjectValue(theObj, property, seen); + if (value || !isNaN(value)) { + jsonObj[property] = value; + } + } + return jsonObj; }, - /** - * Get the Event instances for a community. See {{#crossLink "CommunityConstants/AtomCommunityEvents:attribute"}}{{/crossLink}} for a complete listing of parameters. - * - * These results do not include all details of the event instance, such as the full description. A summary is available in that case. UseEventInst.getFullEvent to get the full details. - * - * @param communityId The uuid of the Community. - * @param startDate Include events that end after this date. - * @param endDate Include events that end before this date. - * @param args url parameters. - * - * @return {Object} Promise which resolves with the array of event instances. - */ - getCommunityEventInsts : function(communityUuid, startDate, endDate, args){ - return this._getCommunityEvents(communityUuid, startDate, endDate, args, ConnectionsEventInstFeedCallbacks); + _notReserved: function(property) { + return property!=='isInstanceOf' && property!=='getInherited'; }, - /** - * Get the events of a community. Each event can have multiple event instances. - * - * @method getCommunityEvents - * @return {Object} Promise which resolves with the array of event instances. - */ - getCommunityEvents : function(communityUuid, startDate, endDate, args){ - return this._getCommunityEvents(communityUuid, startDate, endDate, lang.mixin(args, {type: "event"}), ConnectionsEventFeedCallbacks); + _getObjectValue: function(theObj, property, seen) { + var self = this; + if (lang.isFunction(theObj[property])) { + if ((stringUtil.startsWith(property, "get") || stringUtil.startsWith(property, "is")) && self._notReserved(property)) { + try { + var value = theObj[property].apply(theObj); + if (value && !this._isBuiltin(value) && lang.isObject(value)) { + return this._jsonBean(value, seen); + } + return value; + } catch(error) { + //log.error("Error {0}.{1} caused {2}", theObj, property, error); + } + } + } else { + if (!stringUtil.startsWith(property, "_") && !stringUtil.startsWith(property, "-")) { + return theObj[property]; + } + } + return undefined; }, - /** - * Used to get the event Inst with the given eventInstUuid. - * - * This will include all details of the event, including its content. - * - * @param eventInstUuid - The id of the event, also used as an identifier when caching the response - * @returns - */ - getEventInst : function(eventInstUuid){ - var options = { - method : "GET", - handleAs : "text", - query : { - eventInstUuid: eventInstUuid - } - }; - - return this.getEntity(consts.AtomCommunityEvents, options, eventInstUuid, ConnectionsEventInstCallbacks); + _isBuiltin: function(value) { + return ((value instanceof Date) || + (value instanceof Number) || + (value instanceof Boolean) || + lang.isArray(value)); }, - /** - * Get a list of the outstanding community invitations of the currently authenticated - * user or provide parameters to search for a subset of those invitations. - * - * @method getMyInvites - * @param {Object} [args] - */ - getMyInvites : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - - return this.getEntities(consts.AtomCommunityInvitesMy, options, InviteFeedCallbacks); - }, - - /** - * Get a list of the outstanding community invitations for the specified community. - * The currently authenticated user must be an owner of the community. - * - * @method getAllInvites - * @param communityUuid - * @param {Object} [args] - */ - getAllInvites : function(communityUuid, args) { - var promise = this._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } + _isDomNode : function(value) { + return (value && value.nodeName && value.nodeType && typeof value.nodeType === "number" && typeof value.nodeName === "string"); + } + }; +}); - var requestArgs = lang.mixin({ - communityUuid : communityUuid - }, args || {}); - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - return this.getEntities(consts.AtomCommunityInvites, options, InviteFeedCallbacks); - }, +}, +'sbt/connections/controls/profiles/nls/ProfileGridRenderer':function(){ +/* + * © 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. + */ - /** - * Get a list of subcommunities associated with a community. - * - * @method getSubCommunities - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of members of a - * community. The parameters must be exactly as they are - * supported by IBM Connections like ps, sortBy etc. - */ - getSubCommunities : function(communityUuid,args) { - var promise = this._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } +// NLS_CHARSET=UTF-8 +define({ + root: { + summary : "Profiles Grid", + updatedBy : "Updated by ", + displayName: "Display Name", + recent: "Recent", + telephone: "Telephone:", + email: "Email:", + altEmail: "Alternate Email", + clickToEmail: "Click here to email the user, using their alternate email address", + ariaVcard: "Press control and enter for the business card", + role: "Role", + created: "Created", + feed : "Feed for these Profiles" + } +}); - var requestArgs = lang.mixin({ - communityUuid : communityUuid - }, args || {}); - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - return this.getEntities(consts.AtomCommunitySubCommunities, options, CommunityFeedCallbacks); - }, + +}, +'url:sbt/connections/controls/profiles/templates/ProfileRow.html':"\r\n\t\r\n\t\t
    \r\n\t\t\t\r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \"${name}\"
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t

    \r\n\t\t\t\t\r\n \t\t\t\t\t${name}\r\n\t\t \t\t\t${uid}\r\n \t\t\t\t\r\n \t\t\t

    \r\n\t\t\t
    \r\n\t\t
    \r\n\t\r\n\t\r\n\t\t
    \r\n\t\t\t
    ${nls.telephone} ${telephone}
    \r\n\t\t\t
    ${nls.email}: ${email}
    \r\n\t\t\t
    ${nls.altEmail}: ${altEmail}
    \r\n\t\t
    \r\n\t\r\n\r\n", +'url:sbt/connections/controls/vcard/templates/ProfileVCard.html':"\r\n ${userName}\r\n ${userId}\r\n", +'url:sbt/connections/controls/search/templates/SearchSuggestTemplate.html':"\r\n\t\r\n\t\t\r\n\t\t\t
    \r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t
    ${nls.refine}
    \r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t${nls.search}\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n
    ", +'sbt/smartcloud/ProfileConstants':function(){ +/* + * © Copyright IBM Corp. 2012,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. + */ +/** + * Social Business Toolkit SDK. Definition of constants for ProfileService. + */ +define([ "../lang" ], function(lang) { + return lang.mixin( {} , { /** - * Get a list for forum topics for the specified community. - * - * @method getForumTopics - * @param communityUuid - * @param args - * @returns + * Default size for the profile cache */ - getForumTopics: function(communityUuid, args) { - return this.getForumService().getCommunityForumTopics(communityUuid, args); - }, + DefaultCacheSize : 10, - /** - * Create a Community object with the specified data. - * - * @method newCommunity - * @param {Object} args Object containing the fields for the - * new Community + /** + * Retrieve the profile entry of the logged in user. */ - newCommunity : function(args) { - return this._toCommunity(args); - }, + GetProfile : "/lotuslive-shindig-server/social/rest/people/@me/@self", /** - * Create a Member object with the specified data. - * - * @method newMember - * @param {Object} args Object containing the fields for the - * new Member + * Retrieve the logged in user's profile connections. */ - newMember : function(args) { - return this._toMember(args); - }, + GetMyConnections : "/lotuslive-shindig-server/social/rest/people/@me/@friends", /** - * Create a Invite object with the specified data. - * - * @method newInvite - * @param {String} communityUuid - * @param {Object} args Object containing the fields for the - * new Invite + * Retrieve a profile's user Identity. */ - newInvite : function(communityUuid,args) { - return this._toInvite(communityUuid,args); - }, + GetUserIdentity : "/manage/oauth/getUserIdentity", /** - * Retrieve a community entry, use the edit link for the community entry - * which can be found in the my communities feed. - * - * @method getCommunity - * @param {String } communityUuid - * @param {Object} args Object containing the query arguments to be - * sent (defined in IBM Connections Communities REST API) - */ - getCommunity : function(communityUuid, args) { - var community = new Community({ - service : this, - _fields : { communityUuid : communityUuid } - }); - return community.load(args); - }, - - /** - * Create a community by sending an Atom entry document containing the - * new community to the My Communities resource. - * - * @method createCommunity - * @param {Object} community Community object which denotes the community to be created. - * @param {Object} [args] Argument object + * Retrieve a Contact's Profile. */ - createCommunity : function(communityOrJson,args) { - var community = this._toCommunity(communityOrJson); - var promise = this._validateCommunity(community, false, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - var communityUuid = this.getLocationParameter(response, "communityUuid"); - community.setCommunityUuid(communityUuid); - return community; - }; - - var options = { - method : "POST", - query : args || {}, - headers : consts.AtomXmlHeaders, - data : community.createPostData() - }; - - return this.updateEntity(consts.AtomCommunitiesMy, options, callbacks, args); - }, - + GetContactByGUID : "/lotuslive-shindig-server/social/rest/people/lotuslive:contact:{idToBeReplaced}/@self", + /** - * Update a community by sending a replacement community entry document in Atom format - * to the existing community's edit web address. - * All existing community entry information will be replaced with the new data. To avoid - * deleting all existing data, retrieve any data you want to retain first, and send it back - * with this request. For example, if you want to add a new tag to a community entry, retrieve - * the existing tags, and send them all back with the new tag in the update request. - * - * @method updateCommunity - * @param {Object} community Community object - * @param {Object} [args] Argument object + * Retrieve a profiles entry using GUID. */ - updateCommunity : function(communityOrJson,args) { - var community = this._toCommunity(communityOrJson); - var promise = this._validateCommunity(community, true, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service, data, response) { - // preserve the communityUuid - var communityUuid = community.getCommunityUuid(); - if (data) { - community.setData(data, response); - } - community.setCommunityUuid(communityUuid); - return community; - }; - - var requestArgs = lang.mixin({ - communityUuid : community.getCommunityUuid() - }, args || {}); - - var options = { - method : "PUT", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : community.createPostData() - }; - - return this.updateEntity(consts.AtomCommunityInstance, options, callbacks, args); - }, - + GetProfileByGUID : "/lotuslive-shindig-server/social/rest/people/lotuslive:user:{idToBeReplaced}/@self", + /** - * Delete a community, use the HTTP DELETE method. - * Only the owner of a community can delete it. Deleted communities cannot be restored - * - * @method deleteCommunity - * @param {String/Object} community id of the community or the community object (of the community to be deleted) - * @param {Object} [args] Argument object + * Retrieve the logged in user's profile contacts. */ - deleteCommunity : function(communityUuid,args) { - var promise = this._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ - communityUuid : communityUuid - }, args || {}); - - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - - return this.deleteEntity(consts.AtomCommunityInstance, options, communityUuid); - }, - + GetMyContacts : "/lotuslive-shindig-server/social/rest/people/@me/@all", + /** - * Add member to a community - * - * @method addMember - * @param {String/Object} community id of the community or the community object. - * @param {Object} member member object representing the member of the community to be added - * @param {Object} [args] Argument object + * JsonPath expressions to be used when reading a Profile Entry */ - addMember : function(communityUuid,memberOrId,args) { - var promise = this._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } - var member = this._toMember(memberOrId); - promise = this._validateMember(member); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - var userid = this.getLocationParameter(response, "userid"); - member.setUserid(userid); - member.communityUuid = communityUuid; - return member; - }; - - var requestArgs = lang.mixin({ - communityUuid : communityUuid - }, args || {}); - var options = { - method : "POST", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : member.createPostData() - }; - - return this.updateEntity(consts.AtomCommunityMembers, options, callbacks, args); - }, - - /** - * Updates a member in the access control list for an application, sends a replacement member entry document in Atom format to the existing ACL - * node's edit web address. - * @method updateMember - * @param {String} activityUuid - * @param {Object} memberOrJson - */ - updateMember : function(communityUuid, memberOrJson, args) { - var promise = this.validateField("communityUuid", communityUuid); - if (promise) { - return promise; - } - var member = this._toMember(memberOrJson); - promise = this._validateMember(member, true, true); - if (promise) { - return promise; - } - - var requestArgs = { - communityUuid : communityUuid - }; - var key = member.getEmail() ? "email" : "userid"; - var value = member.getEmail() ? member.getEmail() : member.getUserid(); - requestArgs[key] = value; - requestArgs = lang.mixin(requestArgs, args || {}); - - var options = { - method : "PUT", - headers : consts.AtomXmlHeaders, - query : requestArgs, - data : member.createPostData() - }; - - var callbacks = { - createEntity : function(service, data, response) { - return response; - } - }; - - return this.updateEntity(consts.AtomCommunityMembers, options, callbacks); + ProfileJsonPath : { + thumbnailUrl : "$..photo", + address : "$..address", + department : "$..name", + jobTitle : "$..jobtitle", + telephone : "$..telephone", + about : "$..aboutMe", + id : "$..id", + objectId : "$..objectId", + displayName : "$..displayName", + emailAddress : "$..emailAddress", + profileUrl : "$..profileUrl", + country : "$..country", + orgId : "$..orgId", + org : "$..org.name", + global : "$..", + firstElement : "$[0]", + totalResults : "totalResults", + startIndex : "startIndex", + itemsPerPage : "itemsPerPage" + } + }); +}); +}, +'url:sbt/smartcloud/controls/profiles/templates/ProfilePanel.html':"
    \r\n\t
    \r\n\t\t
    \r\n\t\t\t\"${getThumbnailAlt}\"\r\n\t\t
    \r\n\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t${getDisplayName}\r\n\t\t\t
    \r\n\t\t\t
    \r\n\t\t\t\t${getAbout}\r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n
    ", +'url:sbt/connections/controls/search/templates/SingleApplicationSearch.html':"\r\n\t\r\n\t\t\r\n\t\t\t
    \r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n
    ", +'url:sbt/connections/controls/forums/templates/ForumTopicRow.html':"\r\n\t\r\n\t\t\r\n \r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t${title}\r\n\t\t\t${isTopicLocked}\r\n\t\t

    \r\n\t\t\r\n\t\r\n\t\r\n\t\r\n\t${threadCount}\r\n\t\r\n\t${getDateLabel}\r\n", +'sbt/connections/controls/profiles/ProfileTagsGrid':function(){ +/* + * © 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. + */ - }, +/** + * @module sbt.connections.controls.profiles.ProfileTagsGrid + */ +define([ "../../../declare", + "../../../lang", + "../../../config", + "../../../controls/grid/Grid", + "./ProfileTagsGridRenderer", + "./ProfileTagAction", + "../../../store/parameter", + "../../../connections/ProfileConstants"], + function(declare, lang, sbt, Grid, ProfileTagsGridRenderer, ProfileTagAction, parameter, consts) { - /** - * Remove member of a community - * - * @method - * @param {String/Object} community id of the community or the community object. - * @param {String} memberId id of the member - * @param {Object} [args] Argument object - */ - removeMember : function(communityUuid,memberId,args) { - var promise = this._validateCommunityUuid(communityUuid); - if (promise) { - return promise; - } - var member = this._toMember(memberId); - promise = this._validateMember(member); - if (promise) { - return promise; + /** + * @class ProfileTagsGrid + * @namespace sbt.connections.controls.profiles + * @module sbt.connections.controls.profiles.ProfileTagsGrid + */ + var ProfileTagsGrid = declare(Grid, { + + /** + * @param lite Specifies how much tag information you want to retrieve. The options are lite or full. + */ + format : "full", + + /** + * @param options, This is a list of all + * the different types of profile tags grids available. + * Depending on which one is selected specific arguments will be given to + * the atom store and grid renderer. + */ + options : { + "list" : { + storeArgs : { + url : consts.AtomTagsDo, + feedXPath : consts.ProfileTagsXPath, + attributes : consts.ProfileTagsXPath, + namespaces : consts.Namespaces + }, + rendererArgs : { + type : "list" + } } - - var requestArgs = { - communityUuid : communityUuid - }; - var key = member.getEmail() ? "email" : "userid"; - var value = member.getEmail() ? member.getEmail() : member.getUserid(); - requestArgs[key] = value; - requestArgs = lang.mixin(requestArgs, args || {}); - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - - return this.deleteEntity(consts.AtomCommunityMembers, options, value); }, /** - * Retrieve a community invite. - * - * @method getInvite - * @param {String} communityUuid - * @param (String} userid - */ - getInvite : function(communityUuid, userid) { - var invite = new Invite({ - service : this, - _fields : { communityUuid : communityUuid, userid : userid } - }); - return invite.load(); - }, - - /** - * Create an invite to be a member of a community. - * - * @method createInvite - * @param {Object} inviteOrJson - * @param {Object} [args] Argument object + * A profile tag action, defines default behaviour for when + * items in the grid are clicked on or hovered on, + * it is possible to override these actions */ - createInvite: function(inviteOrJson, args) { - var invite = this._toInvite(inviteOrJson); - var promise = this._validateInvite(invite, true); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service, data, response) { - invite.setData(data, response); - return invite; - }; - - var requestArgs = lang.mixin({ - communityUuid : invite.getCommunityUuid() - }, args || {}); - - var options = { - method : "POST", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : invite.createPostData() - }; - - return this.updateEntity(consts.AtomCommunityInvites, options, callbacks, args); - }, - + profileTagAction: new ProfileTagAction(), + /** - * Decline or revoke an invite to be a member of a community - * - * @method removeInvite - * @param {Object} inviteOrJson - * @param {Object} [args] Argument object + * This is the default grid that will be created if no + * arguments are given. */ - removeInvite: function(inviteOrJson, args) { - var invite = this._toInvite(inviteOrJson); - var promise = this._validateInvite(invite, true); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ - communityUuid : invite.getCommunityUuid(), - userid : invite.getInviteeUuid() - }, args || {}); - - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - var entityId = invite.getCommunityUuid() + "-" + invite.getInviteeUuid(); - return this.deleteEntity(consts.AtomCommunityInvites, options, entityId); + defaultOption: "list", + + /**Constructor function + * @method constructor + * */ + constructor: function(args) { + }, + + contextRootMap: { + profiles: "profiles" }, /** - * Accept an invite to be a member of a community. + * Override buildUrl to add format, target and source * - * @method acceptInvite - * @param {Object} inviteOrJson. - * @param {Object} [args] Argument object + * @method buildUrl + * @param url base url + * @param args arguments that will be passed to the store + * @param endpoint An endpoint which may contain custom service mappings. + * @returns Built url */ - acceptInvite: function(inviteOrJson, args) { - var invite = this._toInvite(inviteOrJson); - var promise = this._validateInvite(invite, true); - if (promise) { - return promise; + buildUrl: function(url, args, endpoint) { + var params = { format : this.format }; + + if (this.query) { + params = lang.mixin(params, this.query); } + if (this.targetEmail) { + params = lang.mixin(params, { targetEmail : this.targetEmail }); + } + if (this.targetKey) { + params = lang.mixin(params, { targetKey : this.targetKey }); + } + if (this.sourceEmail) { + params = lang.mixin(params, { sourceEmail : this.sourceEmail }); + } + if (this.sourceKey) { + params = lang.mixin(params, { sourceKey : this.sourceKey }); + } - var requestArgs = lang.mixin({ - communityUuid : invite.getCommunityUuid() - }, args || {}); - - var options = { - method : "POST", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : invite.createPostData() - }; - - // return the community id for the community whose invite is accepted in the argument of the success promise. - var callbacks = {}; - callbacks.createEntity = function(service, data, response) { - invite.setData(data, response); - return invite; - }; - - return this.updateEntity(consts.AtomCommunityMembers, options, callbacks, args); + return this.constructUrl(url, params, this.getUrlParams(), endpoint); }, /** - * Create a forum topc by sending an Atom entry document containing the - * new forum to the forum replies resource. - * - * @method createForumTopic - * @param {String} communityUuid This argument is deprecated and has no effect if provided. - * @param {Object} forumTopic Forum topic object which denotes the forum topic to be created. - * @param {Object} [args] Argument object + * The post create function is called, after the grid has been created. + * The function will call the super classes post create + * then load the semantic tag service. The semantic tag service + * is Javascript for creating business card functionality. + * @method postCreate */ - createForumTopic : function(communityUuid, topicOrJson, args) { - if(!lang.isString(communityUuid)){ - args = topicOrJson; - topicOrJson = communityUuid; - } - return this.getForumService().createForumTopic(topicOrJson, args); + postCreate: function() { + this.inherited(arguments); }, - + /** - * Updates the Logo picture of a community - * @method updateCommunityLogo - * @param {Object} fileControlOrId The Id of html control or the html control - * @param {String} communityUuid the Uuid of community - */ - updateCommunityLogo : function(fileControlOrId, communityUuid) { - var promise = this.validateField("File Control Or Id", fileControlOrId); - if (promise) { - return promise; - } - promise = this.validateHTML5FileSupport(); - if (promise) { - return promise; - } - promise = this.validateField("CommunityUuid", communityUuid); - if (promise) { - return promise; - } - - var files = null; - var fileControl = this.getFileControl(fileControlOrId); - if(!fileControl){ - return this.createBadRequestPromise("File Control or ID is required"); - } - var filePath = fileControl.value; - var files = fileControl.files; - - if (files.length != 1) { - return this.createBadRequestPromise("Only one file can be upload as a community logo."); - } - - var file = files[0]; - var formData = new FormData(); - formData.append("file", file); - var requestArgs = { - "communityUuid" : communityUuid - }; - var url = this.constructUrl(consts.AtomUpdateCommunityLogo, null, { - endpointName : this.endpoint.proxyPath, - fileName : encodeURIComponent(file.name) - }); - if (this.endpoint.proxy) { - url = config.Properties.serviceUrl + url; - } else { - return this.createBadRequestPromise("File Proxy is required to upload a community logo"); - } - - var headers = { - "Content-Type" : false, - "Process-Data" : false //processData = false is reaquired by jquery - }; - var options = { - method : "PUT", - headers : headers, - query : requestArgs, - data : formData - }; - var callbacks = { - createEntity : function(service, data, response) { - return data; // Since this API does not return any response in case of success, returning empty data - } - }; - - return this.updateEntity(url, options, callbacks); - }, - + * Creates a renderer for the grid.The renderer is responsible for + * loading the grid's HTML content. + * @method createDefaultRenderer + * @param args sets the template the renderer will use, by checking args.type, but for + * profile grids this will always be "profile" + * @returns an instance of a profile gird renderer. + */ + createDefaultRenderer : function(args) { + return new ProfileTagsGridRenderer(args,this); + }, + /** - * Updates the Logo picture of a community - * @method updateCommunityLogo - * @param {Object} fileControlOrId The Id of html control or the html control - * @param {String} communityUuid the Uuid of community - */ - uploadCommunityFile : function(fileControlOrId, communityUuid) { - var promise = this.validateField("File Control Or Id", fileControlOrId); - if (promise) { - return promise; - } - promise = this.validateHTML5FileSupport(); - if (promise) { - return promise; - } - promise = this.validateField("CommunityUuid", communityUuid); - if (promise) { - return promise; - } - - var files = null; - var fileControl = this.getFileControl(fileControlOrId); - if(!fileControl){ - return this.createBadRequestPromise("File Control or ID is required"); - } - var filePath = fileControl.value; - var files = fileControl.files; - - if (files.length != 1) { - return this.createBadRequestPromise("Only one file can be uploaded to a community at a time"); - } - - var file = files[0]; - var formData = new FormData(); - formData.append("file", file); - var requestArgs = { - }; - var url = this.constructUrl(consts.AtomUploadCommunityFile, null, { - endpointName : this.endpoint.proxyPath, - communityUuid : communityUuid - }); - if (this.endpoint.proxy) { - url = config.Properties.serviceUrl + url; - } else { - return this.createBadRequestPromise("File proxy is required to upload a community file"); + * In the grid HTML an element can have an event attached + * using dojo-attach-event="onClick: handleClick". + * This method is the handler for the onclick event. + * @method handleClick + * @param el the element that fired the event + * @param data all of the items from the current row of the grid. + * @param ev the event + */ + handleClick: function(el, data, ev) { + if (this.profileTagAction) { + console.log(data); + this._stopEvent(ev); + + this.profileTagAction.execute(data, { grid : this.grid }, ev); } - - var headers = { - "Content-Type" : false, - "Process-Data" : false, //processData = false is reaquired by jquery - "X-Endpoint-name" : this.endpoint.name - }; - var options = { - method : "POST", - headers : headers, - query : requestArgs, - data : formData - }; + } + + // Internals + + }); - var callbacks = { - createEntity : function(service, data, response) { - return data; - } - }; + return ProfileTagsGrid; +}); +}, +'url:sbt/connections/controls/forums/templates/ReplyBreadCrumb.html':"
    \r\n\r\nForums>Topics>Replies\r\n
    ", +'url:sbt/connections/controls/activities/templates/ActivityRow.html':"\r\n\t\r\n\t\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t

    \r\n\t\t\t${title} \r\n\t\t\t \r\n\t\t

    \r\n\t\t\r\n\t\t
    \r\n\t\t\t${nls.updatedBy}\r\n\t\t\t\t ${authorName} \r\n\t\t\t\t\r\n\t\t\t\t| \r\n\t\t\t\t${updatedDate}\r\n\t\t\t\t\r\n\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t| \r\n\t\t\t\t${nls.dueDate}\t\t\t\t\r\n\t\t\t\t${getDueDate}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t| \r\n\t\t\t\t${nls.tags}\t\t\t\t\r\n\t\t\t\t${tags}\r\n\t\t\t\r\n\t\t
    \r\n\t\r\n", +'url:sbt/connections/controls/search/templates/ProfileBody.html':"
    \r\n
      \r\n \r\n ${profileBodyJobTitle}\r\n ${tagsList}\r\n
    \r\n
    ", +'sbt/smartcloud/controls/profiles/nls/ColleagueGridRenderer':function(){ +/* + * © 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. + */ - return this.updateEntity(url, options, callbacks); - }, +// NLS_CHARSET=UTF-8 +define({ + root: { + viewAll : "View All ({totalCount})", + empty : "No colleagues in the list.", + people: "{totalCount} people", + person: "{totalCount} person" + } +}); - /** - * Create a bookmark by sending an Atom entry document containing the - * new bookmark. + +}, +'sbt/connections/controls/_ConnectionsWidget':function(){ +/* + * © 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. + */ +define(["../../declare", "../../config", "../../connections/controls/astream/_XhrHandler", "dijit/_Widget"], function(declare, config, _XhrHandler){ + + /* + * Base class for common functionality of all connections widgets. + * + * @class sbt.controls._ConnectionsWidget + */ + var _ConnectionsWidget = declare([dijit._Widget], + { + /* + * The url of the resources/web folder, which contains the projects we need. * - * @method createBookmark - * @param {String/Object} bookmarkOrJson Bookmark object which denotes the bookmark to be created. - * @param {Object} [args] Argument object + * @property baseUrl + * @type String */ - createBookmark : function(communityUuid, bookmarkOrJson, args) { - args = lang.mixin({ - url : consts.AtomCommunityBookmarks, - communityUuid : communityUuid - }, args || {}); - return this.getBookmarkService().createBookmark(bookmarkOrJson, args); + baseUrl: config.Properties.serviceUrl + "/proxy/connections/${connections}/resources/web/", + + /* + * The _XhrHandler to use in this connections widget. + * + * @property xhrHandler + * @type {Object} + */ + xhrHandler: null, + + /* + * Setup with common Connections widget functionality. + * @param {Object} args + * @param {Object} [args.xhrHandler] The _XhrHandler to be used throughout this widget. + * @param {String} [endpoint] The endpoint to be used when creating an _XhrHandler for this connections widget. + */ + constructor: function(args){ + window.ibmConfig = window.ibmConfig || {}; + window.ibmConfig.versionStamp = window.ibmConfig.versionStamp || 1234567890; + + this.registerModulePaths(); + this.xhrHandler = args.xhrHandler || this.requireXhr(args.endpoint); }, - // - // Internals - // - /* - * Return a Community instance from Community or JSON or String. Throws - * an error if the argument was neither. + * Register the connections modules we will be using. + * + * @method registerModulePaths */ - _toCommunity : function(communityOrJsonOrString) { - if (communityOrJsonOrString instanceof Community) { - return communityOrJsonOrString; - } else { - if (lang.isString(communityOrJsonOrString)) { - communityOrJsonOrString = { - communityUuid : communityOrJsonOrString - }; - } - return new Community({ - service : this, - _fields : lang.mixin({}, communityOrJsonOrString) - }); - } + registerModulePaths: function(){ + dojo.registerModulePath("com", this.baseUrl + "com"); + dojo.registerModulePath("lconn", this.baseUrl + "lconn"); + dojo.registerModulePath("net", this.baseUrl + "net"); }, - + /* - * Return as Invite instance from Invite or JSON or String. Throws - * an error if the argument was neither. + * Create the _XhrHandler from the endpoint name. + * + * @method requireXhr + * @param endpointName + */ + requireXhr: function(endpointName){ + var _endpointName = endpointName || "connections"; + return new _XhrHandler(_endpointName); + } + + }); + + return _ConnectionsWidget; +}); + + +}, +'sbt/connections/ForumConstants':function(){ +/* + * © 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. + */ +/** + * Social Business Toolkit SDK. + * Definition of constants for ForumService. + */ +define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { + + return lang.mixin(conn, { + + /** + * Term value with a forum recommendation + */ + FlagAnswer : "recommendation", + + /** + * Term value when a forum reply is an accepted answer + */ + FlagAnswer : "answer", + + /** + * Term value when a forum topic is pinned + */ + FlagPinned : "pinned", + + /** + * Term value when a forum topic is locked + */ + FlagLocked : "locked", + + /** + * Term value when a forum topic is a question + */ + FlagQuestion : "question", + + /** + * Term value when a forum topic is an answered question + */ + FlagAnswered : "answered", + + /** + * Category term and scheme to lock a topic + */ + setLocked: "locked scheme=\"http://www.ibm.com/xmlns/prod/sn/flags\"", + + /** + * Category term and scheme to pin a topic + */ + setPinned: "pinned scheme=\"http://www.ibm.com/xmlns/prod/sn/flags\"", + + /** + * Category term and scheme to mark a topic as a question + */ + markAsQuestion: "question scheme=\"http://www.ibm.com/xmlns/prod/sn/flags\"", + + /** + * XPath expressions used when parsing a Connections Forums ATOM feed + */ + ForumsFeedXPath : conn.ConnectionsFeedXPath, + + /** + * XPath expressions to be used when reading an forum entry + */ + ForumXPath : lang.mixin({ + forumUuid : "a:id", + content : "a:content[@type='text']", + tags : "a:category[not(@scheme)]/@term", + moderation : "snx:moderation/@status", + threadCount: "a:link[@rel='replies']/@thr:count", + forumUrl : "a:link[@rel='alternate']/@href", + communityUuid : "snx:communityUuid" + }, conn.AtomEntryXPath), + + /** + * XPath expressions to be used when reading an forum topic entry + */ + ForumTopicXPath : lang.mixin({ + topicUuid : "a:id", + topicTitle: "a:title", + forumUuid : "thr:in-reply-to/@ref", + tags : "a:category[not(@scheme)]/@term", + permissions : "snx:permissions", + communityUuid : "snx:communityUuid", + threadCount: "a:link[@rel='replies']/@thr:count", + locked: "a:category[@term='locked' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", + pinned: "a:category[@term='pinned' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", + question: "a:category[@term='question' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", + answered: "a:category[@term='answered' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", + notRecommendedByCurrentUser: "a:category[@term='NotRecommendedByCurrentUser']", + threadRecommendationCount: "a:category[@term='ThreadRecommendationCount']/@label", + recommendationsUrl : "a:link[@rel='recommendations']/@href" + }, conn.AtomEntryXPath), + + /** + * XPath expressions to be used when reading an forum reply entry + */ + ForumReplyXPath : lang.mixin({ + replyUuid : "a:id", + topicUuid : "thr:in-reply-to/@ref", + permissions : "snx:permissions", + communityUuid : "snx:communityUuid", + answer: "a:category[@term='answer' and @scheme='http://www.ibm.com/xmlns/prod/sn/flags']", + replyTo: "thr:in-reply-to/@ref", + notRecommendedByCurrentUser: "a:category[@term='NotRecommendedByCurrentUser']", + recommendationsUrl : "a:link[@rel='recommendations']/@href" + }, conn.AtomEntryXPath), + + /** + * XPath expressions to be used when reading an forum recommendation entry + */ + ForumRecommendationXPath : lang.mixin({ + postUuid : "a:link[@rel='self']/@href" + }, conn.AtomEntryXPath), + + /** + * Edit link for a forum entry. */ - _toInvite : function(inviteOrJsonOrString, args){ - if (inviteOrJsonOrString instanceof Invite) { - return inviteOrJsonOrString; - } else { - if (lang.isString(inviteOrJsonOrString)) { - inviteOrJsonOrString = { - communityUuid : inviteOrJsonOrString - }; - } - return new Invite({ - service : this, - _fields : lang.mixin({}, inviteOrJsonOrString) - }); - } - }, - - /* - * Return a Community UUID from Community or communityUuid. Throws an - * error if the argument was neither or is invalid. + AtomForum : "${forums}/atom/forum", + + /** + * Edit link for a forum topic entry. */ - _toCommunityUuid : function(communityOrUuid) { - var communityUuid = null; - if (communityOrUuid) { - if (lang.isString(communityOrUuid)) { - communityUuid = communityOrUuid; - } else if (communityOrUuid instanceof Community) { - communityUuid = communityOrUuid.getCommunityUuid(); - } - } - - return communityUuid; - }, + AtomTopic : "/${forums}/atom/topic", - /* - * Return a Community Member from Member or memberId. Throws an error if - * the argument was neither or is invalid. + /** + * Edit link for a forum reply entry. */ - _toMember : function(idOrJson) { - if (idOrJson) { - if (idOrJson instanceof Member) { - return idOrJson; - } - var member = new Member({ - service : this - }); - if (lang.isString(idOrJson)) { - if (this.isEmail(idOrJson)) { - member.setEmail(idOrJson); - } else { - member.setUserid(idOrJson); - } - } else { - if(idOrJson.id && !idOrJson.userid && !idOrJson.email){ - this.isEmail(idOrJson.id) ? idOrJson.email = idOrJson.id : idOrJson.userid = idOrJson.id; - delete idOrJson.id; - } - member._fields = lang.mixin({}, idOrJson); - } - return member; - } - }, - - /* - * Validate a community UUID, and return a Promise if invalid. + AtomReply : "/${forums}/atom/reply", + + /** + * Get a feed that includes all stand-alone and community forums created in the enterprise. */ - _validateCommunityUuid : function(communityUuid) { - if (!communityUuid || communityUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected communityUuid."); - } - }, + AtomForums : "/${forums}/atom/forums", - /* - * Validate a userid, and return a Promise if invalid. + /** + * Get a feed that includes all of the forums hosted by the Forums application. */ - _validateUserid : function(userid) { - if (!userid || userid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected userid."); - } - }, + AtomForumsPublic : "/${forums}/atom/forums/public", - /* - * Validate that the date-time is not empty, return a promise if invalid + /** + * Get a feed that includes forums created by the authenticated user or associated with communities to which the user belongs. */ - _validateDateTimes : function(startDate, endDate){ - if ((!startDate || startDate.length === 0) && (!endDate || endDate.length === 0)) { - return this.createBadRequestPromise("Invalid date arguments, expected either a startDate, endDate or both as parameters."); - } - }, - - /* - * Validate contributor id + AtomForumsMy : "/${forums}/atom/forums/my", + + /** + * Get a feed that includes the topics in a specific stand-alone forum. */ - _validateContributorId : function(contributorId) { - if (!contributorId || contributorId.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected contributorId."); - } - }, - - /* - * Validate a community, and return a Promise if invalid. + + AtomTopics : "/${forums}/atom/topics", + + /** + * Get a feed that includes the topics that the authenticated user created in stand-alone forums and in forums associated + * with communities to which the user belongs. */ - _validateCommunity : function(community,checkUuid) { - if (!community || !community.getTitle()) { - return this.createBadRequestPromise("Invalid argument, community with title must be specified."); - } - if (checkUuid && !community.getCommunityUuid()) { - return this.createBadRequestPromise("Invalid argument, community with UUID must be specified."); - } - }, - - /* - * Validate an invite, and return a Promise if invalid. + AtomTopicsMy : "/${forums}/atom/topics/my", + + /** + * Get a feed that includes all of the replies for a specific forum topic. */ - _validateInvite : function(invite, checkCommunityUuid) { - if (!invite || (!invite.getEmail() && !invite.getUserid() && !invite.getInviteeUuid())) { - return this.createBadRequestPromise("Invalid argument, invite with email or userid or invitee must be specified."); - } - if (checkCommunityUuid && !invite.getCommunityUuid()) { - return this.createBadRequestPromise("Invalid argument, invite with community UUID must be specified."); - } - }, - - /* - * Validate a member, and return a Promise if invalid. + AtomReplies : "/${forums}/atom/replies", + + /** + * Get a category document that lists the tags that have been assigned to forums. */ - _validateMember : function(member) { - if (!member || (!member.getUserid() && !member.getEmail())) { - return this.createBadRequestPromise("Invalid argument, member with userid or email must be specified."); - } - }, + AtomTagsForum : "/atom/tags/forums", - /* - * Validate an event inst uuid, and return a Promise if invalid. + /** + * Get a category document that lists the tags that have been assigned to forum topics. */ - _validateEventInstUuid : function(eventInstUuid) { - if (!eventInstUuid || eventInstUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected event inst uuid."); - } - }, + AtomTagsTopics : "/atom/tags/topics", - /* - * Validate an event UUID, and return a Promise if invalid. + /** + * Get a feed that includes all of the recommendations for a specific forum post. */ - _validateEventUuid : function(eventUuid) { - if (!eventUuid || eventUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected eventUuid."); - } - } + AtomRecommendationEntries : "/${forums}/atom/recommendation/entries" }); - return CommunityService; }); - }, -'url:sbt/connections/controls/search/templates/DefaultBody.html':"
    \r\n
      \r\n ${bodyPersonCardLi}\r\n ${bodyUpdatedLi}\r\n ${bodyCommentCountLi}\r\n ${objectReferenceLi}\r\n ${tagsList}\r\n ${bodyBookmarkLi}\r\n
    \r\n
    ", -'url:sbt/connections/controls/search/templates/SearchBoxTemplate.html':"\r\n\t\r\n\t\t\r\n\t\t\t
    \r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t
    ${nls.refine}
    \r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t${nls.search}\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
    \r\n\t\t\t
    \r\n\t\t
    \r\n\t
    \r\n
    ", -'url:sbt/connections/controls/forums/templates/ReplyRow.html':"\r\n\t\r\n\t\t
    \r\n \r\n\t\r\n\t\t

    \r\n\t\t\t${content}\r\n\t\t

    \r\n\t\r\n\t\r\n\t${title}\r\n\t\r\n\t\r\n\t${authorName}\r\n\t\r\n\t${getDateLabel}\r\n", -'sbt/connections/controls/profiles/ColleagueGrid':function(){ +'url:sbt/connections/controls/search/templates/MemberListItemTemplate.html':"\r\n\t\r\n\t\t${memberName}\r\n\t\tX\r\n\t  \r\n", +'sbt/_bridge/declare':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33407,229 +31691,184 @@ define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", ". */ /** + * Social Business Toolkit SDK. * + * declare() function. */ -define([ "../../../declare", "../../../config", "../../../lang", "../../../xml", "../../../xpath", "../../../stringUtil", - "../../../connections/ConnectionsConstants", - "./ProfileGrid", "./ColleagueGridRenderer", "../ViewAllAction" ], - function(declare, config, lang, xml, xpath, stringUtil, conn, ProfileGrid, ColleagueGridRenderer, ViewAllAction) { +define(['dojo/_base/declare'],function(declare) { + return declare; +}); + +}, +'sbt/connections/controls/activities/ActivityAction':function(){ +/* + * © 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. + */ + +define([ "../../../declare", "../../../controls/grid/GridAction"], + function(declare, GridAction) { /** - * @class ColleagueGrid - * @namespace sbt.connections.controls.profiles - * @module sbt.connections.controls.profiles.ColleagueGrid + * @class ActivityAction + * @namespace sbt.connections.controls.activities + * @module sbt.connections.controls.activities.ActivityAction */ - var ColleagueGrid = declare(ProfileGrid, { + var ActivityGridAction = declare(GridAction, { + + + /**ForumAction Constructor function + * @method constructor + * @param args + */ + constructor: function(args) { - /** - * Flag used to display the View All link, set - * to true to hide this link - */ - hideViewAll: false, + }, /** - * A view all action, defines default behaviour for when - * View All link is selected - */ - viewAllAction: new ViewAllAction(), - - /** - * Creates a renderer for the grid.The renderer is responsible for - * loading the grid's HTML content. - * @method createDefaultRenderer - * @param args sets the template the renderer will use, by checking args.type, but for - * profile grids this will always be "profile" - * @returns an instance of a profile gird renderer. + * Handles displaying a tooltip for an item + * @method getTooltip + * @param item The element that will use the tooltip */ - createDefaultRenderer : function(args) { - return new ColleagueGridRenderer(args,this); - }, - - contextRootMap: { - profiles: "profiles" + getTooltip: function(item) { + return item.getValue("title"); }, /** - * Override buildUrl to add outputType, format and email/userid's + * The execute function is called from the handle click function * - * @method buildUrl - * @param url base url - * @param args arguments that will be passed to the store - * @param endpoint An endpoint which may contain custom service mappings. - * @returns Built url + * @method execute + * @param item The item which fired the event + * @param opts + * @param event The event */ - buildUrl: function(url, args, endpoint) { - var params = { - connectionType : "colleague", - outputType : "profile", - format : "full" - }; - - if (this.query) { - params = lang.mixin(params, this.query); - } - if (this.email) { - params = lang.mixin(params, { email : this.email }); - } - if (this.email1 && this.email2) { - params = lang.mixin(params, { email : this.email1 + "," + this.email2 }); - } - if (this.userid) { - params = lang.mixin(params, { userid : this.userid }); - } - if (this.userid1 && this.userid2) { - params = lang.mixin(params, { userid : this.userid1 + "," + this.userid2 }); - } + execute: function(item, grid, event) { + //there are two urls returned because the atom feed has two identical elements + var urls = item.getValue("alternateUrl"); + + window.open(urls[0]); + } - return this.constructUrl(url, params, this.getUrlParams(), endpoint); - }, - /** - * The post create function is called, after the grid has been created. - * The function will call the super classes post create - * then if target emails/ids were set will. - * @method postCreate - */ - postCreate: function() { - this.inherited(arguments); - - if (this.targetEmails || this.targetUserids) { - this.addColleagues(); - } - }, - - /** - * Compute colleagues based on specified targets and add to the Grid. - * - * @method addColleagues - */ - addColleagues: function() { - var targets = arguments.targetEmails || arguments.targetUserids || this.targetEmails || this.targetUserids; - var id = arguments.email || arguments.userid || this.email || this.userid; - if (!id || (!targets || targets.length == 0)) { - return; - } - var endpoint = config.findEndpoint(this.endpoint || "connections"); - var baseUrl = "/profiles/atom/connection.do?connectionType=colleague"; - if (this._isEmail(id)) { - baseUrl += "&sourceEmail=" + encodeURIComponent(id); - } else { - baseUrl += "&sourceUserid=" + encodeURIComponent(id); - } - if (arguments.targetEmails || this.targetEmails) { - baseUrl += "&targetEmail="; - } else { - baseUrl += "&targetUserid="; - } - var self = this; - for (var i=0; i= 0 && emails.length > 1) { - var index = (emails.indexOf(id) == 0) ? 1 : 0; - return emails[index]; - } else if(userids.indexOf(id) >= 0 && userids.length > 1) { - var index = (userids.indexOf(id) == 0) ? 1 : 0; - return userids[index]; - } - }, - - _selectArray : function(doc, expr) { - var nodes = xpath.selectNodes(doc, expr, conn.Namespaces); - var ret = []; - if (nodes) { - for ( var i = 0; i < nodes.length; i++) { - ret.push(stringUtil.trim(nodes[i].text || nodes[i].textContent)); - } - } - return ret; + AtomEntryXPath : { + // used by getEntityData + entry : "/a:entry", + // used by getEntityId + uid : "a:id", + // used by getters + id : "a:id", + title : "a:title", + updated : "a:updated", + published : "a:published", + authorName : "a:author/a:name", + authorEmail : "a:author/a:email", + authorUserid : "a:author/snx:userid", + authorUserState : "a:author/snx:userState", + contributorName : "a:contributor/a:name", + contributorEmail : "a:contributor/a:email", + contributorUserid : "a:contributor/snx:userid", + contributorUserState : "a:contributor/snx:userState", + content : "a:content[@type='html']", + summary : "a:summary[@type='text']", + categoryTerm : "a:category/@term", + editUrl : "a:link[@rel='edit']/@href", + selfUrl : "a:link[@rel='self']/@href", + alternateUrl : "a:link[@rel='alternate']/@href", + tags : "./a:category[not(@scheme)]/@term" }, - _isEmail: function(id) { - return id && id.indexOf('@') >= 0; - } - - }); - - return ColleagueGrid; + /** + * + */ + AtomXmlHeaders : { + "Content-Type" : "application/atom+xml" + } + + }; }); }, -'url:sbt/connections/controls/forums/templates/TableHeader.html':" \r\n \r\n ${nls.forums}\r\n \r\n ${nls.threads}\r\n \r\n ${nls.latestPost}\r\n ", -'sbt/base/core':function(){ +'url:sbt/connections/controls/search/templates/div.html':"
    \r\n ${content}\r\n
    ", +'url:sbt/controls/grid/templates/GridPager.html':"
    \r\n\t
    \r\n\t
    ${pagingResults}
    \r\n\t
      \r\n\t\t
    • \r\n\t\t\t${nls.previous}\r\n\t\t\t${nls.previous}\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t${nls.next}\r\n\t\t\t${nls.next}\r\n\t\t
    • \r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t
    \r\n
    \r\n", +'sbt/lang':function(){ /* * © Copyright IBM Corp. 2012 * @@ -33647,55 +31886,15 @@ define([ "../../../declare", "../../../config", "../../../lang", "../../../xml", */ /** - * Social Business Toolkit SDK. - * Helpers for the core capabilities + * Social Business Toolkit SDK - Some language utilities. */ -define(['../config'],function(sbt) { - - /** - * Global Namespaces Object. - */ - return { - // Namespaces used when parsing Atom feeds - namespaces : { - o : "http://ns.opensocial.org/2008/opensocial", - app : "http://www.w3.org/2007/app", - thr : "http://purl.org/syndication/thread/1.0", - fh : "http://purl.org/syndication/history/1.0", - snx : "http://www.ibm.com/xmlns/prod/sn", - opensearch : "http://a9.com/-/spec/opensearch/1.1/", - a : "http://www.w3.org/2005/Atom", - h : "http://www.w3.org/1999/xhtml", - td: "urn:ibm.com/td", - relevance: "http://a9.com/-/opensearch/extensions/relevance/1.0/", - ibmsc: "http://www.ibm.com/search/content/2010", - xhtml: "http://www.w3.org/1999/xhtml" - }, - - feedXPath : { - "entry" : "/a:feed/a:entry", - "entries" : "/a:feed/a:entry", - "totalResults" : "/a:feed/opensearch:totalResults", - "startIndex" : "/a:feed/opensearch:startIndex", - "itemsPerPage" : "/a:feed/opensearch:itemsPerPage" - }, - - entryXPath : { - "title" : "a:title", - "summaryText" : "a:summary[@type='text']", - "selfUrl" : "a:link[@rel='self']/@href", - "terms" : "a:category/@term", - "contentHtml" : "a:content[@type='html']", - "published" : "a:published", - "updated" : "a:updated", - "authorId" : "a:author/snx:userid", - "contributorId" : "a:contributor/snx:userid" - } - }; +define(['./_bridge/lang'],function(lang) { + // The actual implementation is library dependent + return lang; }); + }, -'url:sbt/connections/controls/search/templates/a.html':"${content}", -'sbt/widget/_TemplatedDialog':function(){ +'sbt/connections/controls/communities/CommunityAction':function(){ /* * © Copyright IBM Corp. 2013 * @@ -33713,35 +31912,58 @@ define(['../config'],function(sbt) { */ /** - * + * @module sbt.connections.controls.communities.CommunityAction */ -define([ "../_bridge/declare", "../lang", "dijit/Dialog", "dijit/_TemplatedMixin"], - function(declare, lang, Dialog, _TemplatedMixin) { +define([ "../../../declare", "../../../controls/grid/GridAction", "../../../stringUtil" ], + function(declare, GridAction, stringUtil) { /** - * @module sbt.widget._TemplatedDialog + * + * @class CommunityAction + * @namespace sbt.connections.controls.communities */ - var _TemplatedDialog = declare([ Dialog, _TemplatedMixin ], { - - nls : null, - - /** - * _TemplatedDialog class constructor function - * - * @method constructor - * @param args - */ - constructor: function(args) { - } + var CommunityAction = declare(GridAction, { + + nls: { + tooltip: "{title}" + }, + + /** + * CommunityGridAction Constructor + * @method constructor + */ + constructor: function() { + }, + + /** + * @method getTooltip + * @param item The element that the tooltip will display for + * @returns A String to be displayed in an elements tooltip + */ + getTooltip: function(item) { + return stringUtil.replace(this.nls.tooltip, { title : item.getValue("title") }); + }, + + /** + * When an event is fired, this is the action that will get called + * from the hanleClick function + * @method execute + * @param item The element that fired the event and called this function + * @param opts + * @param event the Event + */ + execute: function(item, opts, event) { + window.open(item.getValue("alternateUrl")); + } + }); - - return _TemplatedDialog; + + return CommunityAction; }); }, -'url:sbt/connections/controls/search/templates/DefaultHeader.html':"", -'sbt/connections/ProfileConstants':function(){ +'sbt/connections/BlogConstants':function(){ /* - * © Copyright IBM Corp. 2012,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. @@ -33755,222 +31977,391 @@ define([ "../_bridge/declare", "../lang", "dijit/Dialog", "dijit/_TemplatedMixin * implied. See the License for the specific language governing * permissions and limitations under the License. */ + /** - * Social Business Toolkit SDK. Definition of constants for CommunityService. + * Social Business Toolkit SDK. Definition of constants for BlogService. + * + * @module sbt.connections.BlogConstants */ define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { - return lang.mixin({ + return lang.mixin({}, conn, { + + /** + * XPath expressions used when parsing a Connections Blogs ATOM feed + * + * @property BlogFeedXPath + * @type Object + * @for sbt.connections.BlogService + */ + BlogFeedXPath : conn.ConnectionsFeedXPath, + + RecommendersFeedXpath : { + entries : "/a:feed/a:entry", + totalResults : "/a:feed/os:totalResults" + }, /** - * Default size for the profile cache + * Namespaces to be used when reading the Blogs ATOM entry or feed */ - DefaultCacheSize : 10, + BlogNamespaces : { + a : "http://www.w3.org/2005/Atom", + app : "http://www.w3.org/2007/app", + snx : "http://www.ibm.com/xmlns/prod/sn" + }, /** - * Fields used to populate the Address object + * XPath expressions to be used when reading a Blog + * + * @property BlogXPath + * @type Object + * @for sbt.connections.BlogService */ - AddressFields : [ "streetAddress", "extendedAddress", "locality", "region", "postalCode", "countryName" ], - + BlogXPath : lang.mixin({}, conn.AtomEntryXPath, { + blogUuid : "a:id", + handle : "snx:handle", + timezone : "snx:timezone", + rank : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", + categoryupdates : "a:category[@term='updates']", + categoryfaq : "a:category[@term='faq']", + categorywith : "a:category[@term='with']", + categoryshared : "a:category[@term='shared']", + communityUuid : "snx:communityUuid", + containerUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/container']/@href", + containerType : "snx:containertype", + categoryFlags : "a:link[@scheme='http://www.ibm.com/xmlns/prod/sn/flags']/@term", + summary : "a:summary[@type='html']" + }), + /** - * XPath expressions used when parsing a Connections Profiles ATOM feed + * XPath expressions to be used when reading a Blog Post + * + * @property BlogPostXPath + * @type Object + * @for sbt.connections.BlogService */ - ProfileFeedXPath : conn.ConnectionsFeedXPath, + BlogPostXPath : lang.mixin({}, conn.AtomEntryXPath, { + postUuid : "a:id", + replies : "a:link[@rel='replies']/@href", + recommendationsUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/recommendations']/@href", + rankRecommendations : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", + rankComment : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/comment']", + rankHit : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/hit']", + repliesUrl : "a:link[@rel='replies']/@href", + sourceId : "a:source/a:id", + sourceTitle : "a:source/a:title ", + sourceLink : "a:source/a:link[@rel='self']/@href", + sourceLinkAlternate : "a:source/a:link[@rel='alternate']/@href", + sourceUpdated : "a:source/a:updated", + sourceCategory : "a:source/a:link[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", + blogHandle : "blogHandle", + summary : "a:summary[@type='html']" + }), + /** - * Namespace expressions used when parsing a Connections Profiles ATOM feed + * XPath expressions to be used when reading a Blog Post Comment + * + * @property CommentXPath + * @type Object + * @for sbt.connections.BlogService */ - ProfileNamespaces : conn.Namespaces, + CommentXPath : lang.mixin({}, conn.AtomEntryXPath, { + commentUuid : "a:id", + commentUrl : "a:link[@rel='self']/@href", + recommendationsUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/recommendations']/@href", + trackbacktitle : "snx:trackbacktitle", + replyTo : "thr:in-reply-to/@ref", + replyToSource : "thr:in-reply-to/@source", + rankRecommendations : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", + sourceId : "a:source/a:id", + sourceTitle : "a:source/a:title ", + sourceLink : "a:source/a:link[@rel='self']/@href", + sourceLinkAlternate : "a:source/a:link[@rel='alternate']/@href", + blogHandle : "blogHandle", + blogPostUuid : "blogPostUuid" + }), + + /** + * XPath expressions to be used when reading a Blog Post Recommenders feed + * + * @property RecommendersXPath + * @type Object + * @for sbt.connections.BlogService + */ + RecommendersXPath : lang.mixin({}, conn.AtomEntryXPath, { + recommenderUuid : "a:id", + category : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term" + }), /** - * Connection type colleague + * page Page number. Specifies the page to be returned. The default value is 1, which returns the first page. + * ps Page size. Specify the number of entries to return per page. + * search Well-formed full text search query. Performs a text search on community titles and descriptions. + * since Includes in the resulting feed all communities updated after a specified date. Specify the date using a date-time value that conforms to RFC3339. Use an upper case "T" to separate the date and time, and an uppercase "Z" in the absence of a numeric time zone offset. For example: 2009-01-04T20:32:31.171Z. + * sortBy Specifies what value to use as the basis for organizing the entries returned in the feed. The options are: + * modified © Sorts the results by last modified date. + * commented - Sorts the entries by the number of comments or replies an item has received. + * popularity - Sorts the entries by how popular the item is. + * recommended - Sorts the entries by the number of times the item was recommended. + * title - Sorts the entries alphabetically by title. The title used is the text that is displayed in the element of each entry in the feed. + * sortOrder Specifies the order in which to sort the results. The options are: + * asc - Sorts the results in ascending order. + * desc - Sorts the results in descending order. + * communityUuid Returns community blog and community ideation blog in the specified community. + * ps Page size. Specify the number of entries to return per page. + * blogType Returns only specific Blogs type: + * blog - regular blogs and community blogs + * communityblog - community blogs only + * communityideationblog - community ideation blogs only + * tags Returns blog entries with the specified tags. Separate multiple tags with a plus sign (+). */ - TypeColleague : "colleague", /** - * Status flag + * A feed of all blogs. + * + * Get the Blogs feed to see a list of all blogs + * + * Supports: page, ps, sortBy, sortOrder, search, since, communityUuid, blogType, sortField, tag + * + * @property AtomBlogsAll + * @type String + * @for sbt.connections.BlogService */ - StatusPending : "pending", + AtomBlogsAll : "/${blogs}/{blogHomepageHandle}/feed/blogs/atom", /** - * XPath expressions to be used when reading a Profile Entry + * A feed of my blogs. + * + * Get the Blogs feed to see a list of Blogs created by logged in user + * + * Supports: page, ps, sortBy, sortOrder, search, since, communityUuid, blogType, sortField, tag + * + * @property AtomBlogsMy + * @type String + * @for sbt.connections.BlogService */ - ProfileXPath : lang.mixin({},conn.AtomEntryXPath,{ - uid : "a:contributor/snx:userid",// overwriting this for ProfileService - entry : "/a:feed/a:entry",// overwriting this for ProfileService - userid : "a:contributor/snx:userid", - name : "a:contributor/a:name", - email : "a:contributor/a:email", - altEmail : "a:content/h:div/h:span/h:div[@class='x-groupwareMail']", // TODO do we need this? it's a dupe of groupwareMail - photoUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/image']/@href", - fnUrl : "a:content/h:div/h:span/h:div/h:a[@class='fn url']/@href", - soundUrl : "a:content/h:div/h:span/h:div/h:a[@class='sound url']/@href", - jobTitle : "a:content/h:div/h:span/h:div[@class='title']", - organizationUnit : "a:content/h:div/h:span/h:div[@class='org']/h:span[@class='organization-unit']", - telephoneNumber : "a:content/h:div/h:span/h:div[@class='tel']/h:span[@class='value']", - building : "a:content/h:div/h:span/h:div/h:span[@class='x-building']", - floor : "a:content/h:div/h:span/h:div/h:span[@class='x-floor']", - officeNumber : "a:content/h:div/h:span/h:div/h:span[@class='x-office-number']", - streetAddress : "a:content/h:div/h:span/h:div/h:div[@class='street-address']", - extendedAddress : "a:content/h:div/h:span/h:div/h:div[@class='extended-address x-streetAddress2']", - locality : "a:content/h:div/h:span/h:div/h:span[@class='locality']", - postalCode : "a:content/h:div/h:span/h:div/h:span[@class='postal-code']", - region : "a:content/h:div/h:span/h:div/h:span[@class='region']", - countryName : "a:content/h:div/h:span/h:div/h:div[@class='country-name']", - groupwareMail : "a:content/h:div/h:span/h:div[@class='x-groupwareMail']", - blogUrl : "a:content/h:div/h:span/h:div/h:a[@class='x-blog-url url']/@href", - role : "a:content/h:div/h:span/h:div[@class='role']", - managerUid : "a:content/h:div/h:span/h:div[@class='x-manager-uid']", - isManager : "a:content/h:div/h:span/h:div[@class='x-is-manager']" - }), + AtomBlogsMy : "/${blogs}/{blogHomepageHandle}/api/blogs", /** - * XPath expressions to be used when reading a ColleagueConnection Entry + * A blog instance. + * + * @property AtomBlogInstance + * @type String + * @for sbt.connections.BlogService */ - ColleagueConnectionXPath : lang.mixin({}, conn.AtomEntryXPath, { - entry : "/a:feed/a:entry" - }), + AtomBlogInstance : "/${blogs}/{blogHomepageHandle}/api/blogs/{blogUuid}", /** - * XPath expressions to be used when reading a Community Entry with VCard content + * A blog post entry. + * + * @property AtomBlogPostInstance + * @type String + * @for sbt.connections.BlogService */ - ProfileVCardXPath : lang.mixin({}, conn.AtomEntryXPath, { - // used by getEntityData - entry : "/a:feed/a:entry", - // used by getEntityId - uid : "a:contributor/snx:userid", - // used by parseVCard - vcard : "a:content", - userid : "a:contributor/snx:userid", - name : "a:contributor/a:name", - email : "a:contributor/a:email", - altEmail : "EMAIL;X_GROUPWARE_MAIL", // TODO do we need this? it's a dupe of groupwareMail - photoUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/image']/@href", - fnUrl : "URL", - soundUrl : "SOUND;VALUE=URL", - jobTitle : "TITLE", - organizationUnit : "a:content/h:div/h:span/h:div[@class='org']/h:span[@class='organization-unit']", - telephoneNumber : "TEL;WORK", - building : "X_BUILDING", - floor : "X_FLOOR", - officeNumber : "X_OFFICE_NUMBER", - workLocation : "ADR;WORK", - streetAddress : "a:content/h:div/h:span/h:div/h:div[@class='street-address']", - extendedAddress : "a:content/h:div/h:span/h:div/h:div[@class='extended-address x-streetAddress2']", - locality : "a:content/h:div/h:span/h:div/h:span[@class='locality']", - postalCode : "a:content/h:div/h:span/h:div/h:span[@class='postal-code']", - region : "a:content/h:div/h:span/h:div/h:span[@class='region']", - countryName : "a:content/h:div/h:span/h:div/h:div[@class='country-name']", - groupwareMail : "EMAIL;X_GROUPWARE_MAIL" - }), + AtomBlogPostInstance : "/${blogs}/{blogHomepageHandle}/api/entries/{postUuid}", /** - * XPath expressions to be used when reading a Profile Tag feed + * A feed of all blogs posts. + * + * Get the Blogs posts feed to see a list of posts from all Blogs + * + * Supports: page, ps, sortBy, sortOrder, search, since + * + * @property AtomEntriesAll + * @type String + * @for sbt.connections.BlogService */ - ProfileTagsXPath : { - // used by getEntitiesDataArray - entries : "/app:categories/a:category", - // used to access data from the feed - targetEmail : "app:categories/snx:targetEmail", - numberOfContributors : "@snx:numberOfContributors", - // used by getEntityData - entry : "/app:categories/a:category", - // used by getEntityId - uid : "@term", - // used by getters - id : "@term", - term : "@term", - frequency : "@snx:frequency", - intensity : "@snx:intensityBin", - visibility : "@snx:visibilityBin", - contributorName : "a:name", - contributorUserid : "a:userid", - contributorEmail : "a:email" - }, + AtomEntriesAll : "/${blogs}/{blogHomepageHandle}/feed/entries/atom", /** - * XPath expressions to be used when reading an invite entry + * A feed of a blog's posts. + * + * Get the Blog posts feed to see a list of posts from a Blog + * + * Supports: page, ps, sortBy, sortOrder, search, since + * + * @property AtomBlogEntries + * @type String + * @for sbt.connections.BlogService */ - InviteXPath : lang.mixin({}, conn.AtomEntryXPath, { - connectionType: "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/connection/type']/@term", - status: "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/status']/@term" - }), + AtomBlogEntries : "/${blogs}/{blogHandle}/feed/entries/atom", + + /** + * A feed of a blog's comments. + * + * Get the Blog Comments feed to see a list of comments from a blog post + * + * Supports: page, ps, sortBy, sortOrder, search, since + * + * @property AtomBlogComments + * @type String + * @for sbt.connections.BlogService + */ + AtomBlogComments : "/${blogs}/{blogHandle}/feed/comments/atom", + + /** + * A feed of a blog's comments. + * + * Get the Blog Comments feed to see a list of comments from all blog post + * + * Supports: page, ps, sortBy, sortOrder, search, since + * + * @property AtomBlogCommentsAll + * @type String + * @for sbt.connections.BlogService + */ + AtomBlogCommentsAll : "/${blogs}/{blogHomepageHandle}/feed/comments/atom", /** - * XML elements to be used when creating a Profile Entry - * - **/ - profileCreateAttributes : { - guid : "com.ibm.snx_profiles.base.guid", - email : "com.ibm.snx_profiles.base.email", - uid : "com.ibm.snx_profiles.base.uid", - distinguishedName : "com.ibm.snx_profiles.base.distinguishedName", - displayName : "com.ibm.snx_profiles.base.displayName", - givenNames : "com.ibm.snx_profiles.base.givenNames", - surname : "com.ibm.snx_profiles.base.surname", - userState :"com.ibm.snx_profiles.base.userState" - }, + * A feed of featured blogs. + * + * Get the featured blogs feed to find the blogs that have had the most activity across + * all of the blogs hosted by the Blogs application in the past two weeks. + * + * Supports: page, ps, sortBy, sortOrder, search, since + * + * @property AtomBlogsFeatured + * @type String + * @for sbt.connections.BlogService + */ + AtomBlogsFeatured : "/${blogs}/{blogHomepageHandle}/feed/featuredblogs/atom", + + /** + * A feed of featured blogs posts. + * + * Get the featured posts feed to find the blog posts that have had the most activity across + * all of the blogs hosted by the Blogs application within the past two weeks + * + * Supports: page, ps, sortBy, sortOrder, search, since + * + * @property AtomBlogsPostsFeatured + * @type String + * @for sbt.connections.BlogService + */ + AtomBlogsPostsFeatured : "/${blogs}/{blogHomepageHandle}/feed/featured/atom", - /** - * Retrieve a profile entry. + /** + * A feed of featured blogs posts. + * + * Get a feed that includes all of the recommended blog posts + * in all of the blogs hosted by the Blogs application. + * + * Supports: page, ps, sortBy, sortOrder, search, since + * + * @property AtomBlogsPostsRecommended + * @type String + * @for sbt.connections.BlogService */ - AtomProfileDo : "/${profiles}{authType}/atom/profile.do", + AtomBlogsPostsRecommended : "/${blogs}/{blogHomepageHandle}/feed/recommended/atom", /** - * Update a profile entry. + * A feed of blogs tags. + * + * Get a feed that includes all of the tags + * in all of the blogs hosted by the Blogs application. + * + * @property AtomBlogsTags + * @type String + * @for sbt.connections.BlogService + */ + AtomBlogsTags : "/${blogs}/{blogHomepageHandle}/feed/tags/atom", + + /** + * A feed of blog tags. + * + * Get a feed that includes all of the tags + * in a perticular Blog. + * + * @property AtomBlogTags + * @type String + * @for sbt.connections.BlogService */ - AtomProfileEntryDo : "/${profiles}{authType}/atom/profileEntry.do", + AtomBlogTags : "/${blogs}/{blogHandle}/feed/tags/atom", /** - * Retrieve a feed that lists the contacts that a person has designated as colleagues. + * Create a Blog. + * + * @property AtomBlogCreate + * @type String + * @for sbt.connections.BlogService */ - AtomConnectionsDo : "/${profiles}{authType}/atom/connections.do", + AtomBlogCreate : "/${blogs}/{blogHomepageHandle}/api/blogs", /** - * Retrieve the profiles of the people who comprise a specific user's report-to chain. + * Edit or remove a Blog. + * + * @property AtomBlogEditDelete + * @type String + * @for sbt.connections.BlogService */ - AtomReportingChainDo : "/${profiles}{authType}/atom/reportingChain.do", - + AtomBlogEditDelete : "/${blogs}/{blogHomepageHandle}/api/blogs/{blogUuid}", /** - * Retrieve the people managed by a specified person. + * Create, Edit or remove a Blog Post. + * + * @property AtomBlogPostCreate + * @type String + * @for sbt.connections.BlogService */ - AtomPeopleManagedDo : "/${profiles}{authType}/atom/peopleManaged.do", + AtomBlogPostCreate : "/${blogs}/{blogHandle}/api/entries", /** - * Retrieve status updates for a specified person. + * Edit or remove a Blog Post. + * + * @property AtomBlogPostEditDelete + * @type String + * @for sbt.connections.BlogService */ - AtomConnectionsInCommonDo : "/${profiles}{authType}/atom/connectionsInCommon.do", - + AtomBlogPostEditDelete : "/${blogs}/{blogHandle}/api/entries/{postUuid}", /** - * Search for a set of profiles that match a specific criteria and return them in a feed. + * Create, Edit or remove a Blog Comment. + * + * @property AtomBlogCommentCreate + * @type String + * @for sbt.connections.BlogService */ - AtomSearchDo : "/${profiles}{authType}/atom/search.do", + AtomBlogCommentCreate : "/${blogs}/{blogHandle}/api/entrycomments/{postUuid}", /** - * Retrieve the profiles of the people who report to a specific user. - */ - AtomPeopleManagedDo : "/${profiles}{authType}/atom/peopleManaged.do", + * Edit or remove a Blog Comment. + * + * @property AtomBlogCommentEditRemove + * @type String + * @for sbt.connections.BlogService + */ + AtomBlogCommentEditRemove : "/${blogs}/{blogHandle}/api/comments/{commentUuid}", /** - * Retrieve the tags assigned to a profile from the Profiles tag collection. - */ - AtomTagsDo : "/${profiles}{authType}/atom/profileTags.do", + * Recommend or Unrecommend a Blog Post. + * + * @property AtomRecommendBlogPost + * @type String + * @for sbt.connections.BlogService + */ + AtomRecommendBlogPost : "/${blogs}/{blogHandle}/api/recommend/entries/{postUuid}", /** - * Admin API - create a new profile. - */ - AdminAtomProfileDo : "/${profiles}/admin/atom/profiles.do", + * Get list of voted Ideas by user. + * + * @property AtomVotedIdeas + * @type String + * @for sbt.connections.IdeationBlogService + */ + AtomVotedIdeas : "/${blogs}/{blogHomepageHandle}/feed/myvotes/atom", /** - * Admin API - delete a profile. + * Get list of comments to the specified blog entry. + * + * @property AtomBlogEntryComments + * @type String + * @for sbt.connections.BlogService */ - AdminAtomProfileEntryDo : "/${profiles}/admin/atom/profileEntry.do" - - },conn); + AtomBlogEntryComments : "/${blogs}/{blogHandle}/feed/entrycomments/{entryAnchor}/atom" + }); }); }, -'sbt/connections/controls/activities/ActivityAction':function(){ +'sbt/connections/ConnectionsConstants':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012,2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33985,56 +32376,126 @@ define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { * permissions and limitations under the License. */ -define([ "../../../declare", "../../../controls/grid/GridAction"], - function(declare, GridAction) { +/** + * Social Business Toolkit SDK. Definition of constants for IBM Connections. + * + * @module sbt.connections.ConnectionsConstants + */ +define([ "../lang", "../base/BaseConstants" ], function(lang, base) { - /** - * @class ActivityAction - * @namespace sbt.connections.controls.activities - * @module sbt.connections.controls.activities.ActivityAction - */ - var ActivityGridAction = declare(GridAction, { - - - /**ForumAction Constructor function - * @method constructor - * @param args + return lang.mixin(base, { + + /** + * Error code used for a bad request */ - constructor: function(args) { + BadRequest : 400, + /** + * XPath expressions used when parsing a Connections ATOM feed + */ + ConnectionsFeedXPath : { + // used by getEntitiesDataArray + entries : "/a:feed/a:entry", + // used by getSummary + totalResults : "/a:feed/opensearch:totalResults", + startIndex : "/a:feed/opensearch:startIndex", + itemsPerPage : "/a:feed/opensearch:itemsPerPage" }, /** - * Handles displaying a tooltip for an item - * @method getTooltip - * @param item The element that will use the tooltip + * XPath expressions used when parsing a Connections service document ATOM feeds + */ + ConnectionsServiceDocsFeedXPath : { + // used by getEntitiesDataArray + entries : "/a:feed/a:entry", + // used by getSummary + emailConfig : "/a:feed/a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/configuration']/@term", + language : "/a:feed/a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/language']/@term", + languageLabels : "/a:feed/a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/language']/@label" + }, + + /** + * AuthType variable values for endpoint + * + * @property AuthTypes + * @type Object */ - getTooltip: function(item) { - return item.getValue("title"); + AuthTypes : { + OAuth : "oauth", + Basic : "basic" }, /** - * The execute function is called from the handle click function + * XPath expressions to be used when reading a Connections entity * - * @method execute - * @param item The item which fired the event - * @param opts - * @param event The event + * @property TagsXPath + * @type Object */ - execute: function(item, grid, event) { - //there are two urls returned because the atom feed has two identical elements - var urls = item.getValue("alternateUrl"); - - window.open(urls[0]); - } - - - }); + TagsXPath : { + entries : "app:categories/a:category", + term : "@term", + frequency : "@snx:frequency", + uid : "@term" + }, + + /** + * XPath expressions to be used when reading a Blog + * + * @property BlogXPath + * @type Object + */ + ServiceConfigXPath : lang.mixin({}, base.AtomEntryXPath, { + alternateSSLUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/alternate-ssl']/@href" + }), + + /** + * XPath expressions to be used when reading a Member Entry + * + * @property MemberXPath + * @type Object + */ + MemberXPath : lang.mixin({}, base.AtomEntryXPath, { + role : "snx:role" + }), + + /** + * XPath expressions to be used when reading a Report Entry + * + * @property MemberXPath + * @type Object + */ + ReportEntryXPath : lang.mixin({}, base.AtomEntryXPath, { + categoryIssue : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/issue']/@term", + reportItemLink : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/report-item']/@href", + relatedLink : "a:link[@rel='related']/@href", + inRefTo : "snx:in-ref-to[@rel='http://www.ibm.com/xmlns/prod/sn/report-item']/@ref" + }), + + /** + * XPath expressions to be used when reading a Moderation Action Entry + * + * @property MemberXPath + * @type Object + */ + ModerationActionEntryXPath : lang.mixin({}, base.AtomEntryXPath, { + moderationAction : "snx:moderation/action", + relatedLink : "a:link[@rel='related']/@href", + inRefTo : "snx:in-ref-to[@rel='http://www.ibm.com/xmlns/prod/sn/report-item']/@ref" + }), - return ActivityGridAction; + /** + * Get service configs + */ + ServiceConfigs : "/{service}/serviceconfigs" + + }); }); }, -'sbt/connections/controls/forums/ForumGrid':function(){ +'sbt/connections/controls/communities/CommunityGridRenderer':function(){ +require({cache:{ +'url:sbt/connections/controls/communities/templates/CommunityRow.html':"<tr class=\"${rowClass}\" >\r\n\t<td class=lotusFirstCell width=35 dojoAttachPoint=\"communityIcon\">\r\n\t\t<img role=presentation alt=\"\" src=\"${communityImage}\" width=64 height=64>\r\n\t</td>\r\n\t<td class=lotusFirstCell>\r\n\t\t<h4>\r\n\t\t\t<span dojoAttachPoint=\"placeLinkNode\">\r\n\t\t\t\t<a href=\"javascript: void(0)\" target=\"_self\" title=\"${tooltip}\" dojoAttachPoint=\"placeTitleLink\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a>\r\n\t\t\t</span>\r\n\t\t\t<span class=\"lotusType commType\" dojoAttachPoint=\"sourceTypePlaceHolder\"></span>\r\n\t\t\t<span style=\"display: none\" class=lotusDivider role=presentation dojoAttachPoint=\"sourceTypeSectionDevider\">|</span>\r\n\t\t\t<span style=\"${displayModerated}\" class=\"lotusType commType\" >\r\n\t\t\t\t<img class=\"lconnSprite lconnSprite-iconModeratedCommunity16\" title=\"\" alt=\"\" src=\"images/blank.gif?etag=20140227.002444\" style=\"display: inline\">\r\n\t\t\t\t${nls.moderated} \r\n\t\t\t</span>\r\n\t\t\t<span class=\"lotusType commType\" style=\"${displayRestricted}\">\r\n\t\t\t\t<img class=\"iconsStates16 iconsStates16-CheckedOut\" title=\"\" alt=\"\" src=\"images/blank.gif?etag=20140227.002444\" style=\"display: inline\">\r\n\t\t\t\t${nls.restricted} \r\n\t\t\t</span>\r\n\t\t</h4>\r\n\t\t<div class=lotusMeta>\r\n\t\t\t<span role=list>\r\n\t\t\t\t<span role=listitem dojoAttachPoint=\"numOfMembersPlaceHolder\">${numOfMembers}</span>\r\n\t\t\t\t<span class=lotusDivider role=presentation dojoAttachPoint=\"membersSectionDevider\">|</span>\r\n\t\t\t\t<span role=listitem dojoAttachPoint=\"personPlaceHolder\">\r\n\t\t\t\t\t${nls.updatedBy}\r\n\t\t\t\t\t<span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t\t<a href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" aria-label=\"${nls.ariaVcard}\" class=\"fn url\">${contributorName}</a>\r\n \t\t\t\t\t <span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${contributorUserid}</span>\r\n\t\t\t\t </span>\r\n\t\t\t\t</span>\r\n\t\t\t\t<span class=lotusDivider role=presentation dojoAttachPoint=\"authorSectionDevider\">|</span>\r\n\t\t\t\t<span role=listitem dojoAttachPoint=\"lastUpdateNode\">${updatedDate}</span>\r\n\t\t\t\t<span style=\"${displayTags}\" class=lotusDivider role=presentation dojoAttachPoint=\"tagsSectionDevider\">|</span>\r\n\t\t\t\t<span class=lotusTags role=listitem dojoAttachPoint=\"tagsSection\">\r\n\t\t\t\t\t${tagsLabel}\r\n\t\t\t\t\t${tagsAnchors}\r\n\t\t\t\t</span>\r\n\t\t\t</span>\r\n\t\t</div>\r\n\t\t<div class=lotusLastCell dojoAttachPoint=\"detailsSection\">\r\n\t\t\t<p dojoAttachPoint=\"placeDescNode\">${summary}</p>\r\n\t\t</div>\r\n\t\t<div data-dojo-attach-point=\"customContent\">\r\n\t\t</div>\r\n\t</td>\r\n\t<td class=\"lotusAlignRight lotusLastCell lotusTiny\">\r\n\t</td>\r\n</tr>", +'url:sbt/connections/controls/communities/templates/BootstrapCommunityRow.html':"<tr>\r\n\t<td>\r\n\t\t<span class=\"icon-globe\"></span>\r\n\t\t<span style=\"font-size:120%;\" ><a href=\"javascript: void(0)\" title=\"${tooltip}\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a></span>\r\n\t</td>\r\n</tr>", +'url:sbt/connections/controls/communities/templates/TagAnchor.html':"<a class=\"tagLink\" title=\"${nls.filterByTag}\" href=\"javascript: void(0);\" data-dojo-attach-event=\"onclick: filterByTag\">${tagName}</a>"}}); /* * © Copyright IBM Corp. 2013 * @@ -34051,279 +32512,215 @@ define([ "../../../declare", "../../../controls/grid/GridAction"], * permissions and limitations under the License. */ -define(["../../../declare", - "../../../lang", - "../../../controls/grid/Grid", - "../../../store/parameter", - "./ForumGridRenderer", - "./ForumAction", - "./BackAction", - "../../../connections/ForumConstants"], - function(declare, lang, Grid, parameter, ForumGridRenderer, ForumAction, BackAction, consts){ - - /**Values that forums Can be sorted By, NOTE Sotring is not enabled in Connections*/ - var sortVals = { - created: "created", - modified: "modified" - }; - - /**URL parameters */ - var ParamSchema = { - pageNumber: parameter.oneBasedInteger("page"), - pageSize: parameter.oneBasedInteger("ps"), - sortBy: parameter.sortField("sortBy",sortVals), - sortOrder: parameter.sortOrder("sortOrder") - }; - - /** - * @class ForumGrid - * @namespace sbt.connections.controls.forum - * @module sbt.connections.controls.forum.ForumGrid - */ - var ForumGrid = declare(Grid,{ - - /**Hide the table header */ - hideHeader: false, - - options : { - "my" : { - storeArgs : { - url : consts.AtomForumsMy, - attributes : consts.ForumXPath, - feedXPath : consts.ForumsFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "my" - } - }, - "public" : { - storeArgs : { - url : consts.AtomForumsPublic, - attributes : consts.ForumXPath, - feedXPath : consts.ForumsFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "public" - } - }, - "myTopics" : { - storeArgs : { - url : consts.AtomTopicsMy, - attributes : consts.ForumTopicXPath, - feedXPath : consts.ForumsFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "myTopics" - } - }, - "forumTopics" : { - storeArgs : { - url : consts.AtomTopics, - attributes : consts.ForumTopicXPath, - feedXPath : consts.ForumsFeedXPath, - paramSchema: ParamSchema - }, - rendererArgs : { - type : "forumTopics" - } - } - }, - - /**The default Forum Grid that will be created, if another type is not specified */ - defaultOption: "my", - - /**forumAction handles onClick and tooltip functions */ - forumAction : new ForumAction(), - backAction: new BackAction(), - hideBreadCrumb: true, - - /** - * The constructor function. - * @method constructor - * @param args - */ - constructor: function(args){ - if(args.hideHeader){ - this.hideHeader = args.hideHeader; - } - if(args.baseProfilesUrl){ - this.baseProfilesUrl = args.baseProfilesUrl; - } - - }, - - /** - * Creates a renderer for the grid.The renderer is responsible for - * loading the grid's HTML content. - * @method createDefaultRenderer - * @param args sets the template the renderer will use, by checking args.type - * @returns an instance of a ForumGridRenderer. - */ - createDefaultRenderer : function(args) { - return new ForumGridRenderer(args,this); - }, - - /** - * In the grid HTML an element can have an event attached - * using dojo-attach-event="onClick: handleClick". - * This method is the handler for the onclick event. - * @method handleClick - * @param el the element that fired the event - * @param data all of the items from the current row of the grid. - * @param ev the event - */ - handleClick: function(el, data, ev) { - if (this.forumAction) { - this._stopEvent(ev); - this.forumAction.execute(data, this , ev); - } - }, - - /** - * In the grid HTML an element can have an event attached - * using dojo-attach-event="onClick: handleClick". - * This method is the handler for the onclick event. - * This function is for viewing the profile of the forus author. - * @method handleClick - * @param el the element that fired the event - * @param data all of the items from the current row of the grid. - * @param ev the event - */ - - getForums: function(options){ - - this.renderer.template = this.renderer.forumTemplate; - this.renderer.headerTemplate = this.renderer.forumHeader; - this.store.setAttributes(consts.ForumXPath); - this.hideBreadCrumb = true; - var endpoint = this.store.getEndpoint(); - - if(this.params.type == "my"){ - var url = this.buildUrl(consts.AtomForumsMy, {},endpoint); - this.store.setUrl(url); - }else{ - var url = this.buildUrl(consts.AtomForumsPublic, {},endpoint); - this.store.setUrl(url); - } - - this.update(null); - }, - - /* - * Used for going back from topic replies - * to a list of topics in a forum, this keeps track of which - * forum is being view. - */ - _forumID: "", - - /** - * - * Show forum Topics - * @param forumId - * @param options - */ - getTopics: function(forumId,options){ - - if(forumId != ""){ - this._forumID = forumId; - } +/** + * @module sbt.connections.controls.communities.CommunityGridRenderer + */ +define(["../../../declare", "../../../stringUtil", "../../../localeUtil", "../../../lang", + "../../../connections/controls/ConnectionsGridRenderer", + "../../../text!../../../connections/controls/communities/templates/CommunityRow.html", + "../../../text!../../../connections/controls/communities/templates/BootstrapCommunityRow.html", + "../../../text!../../../connections/controls/communities/templates/TagAnchor.html", + "../../../i18n!../../../connections/controls/communities/nls/CommunityGridRenderer"], + function(declare, stringUtil, localeUtil, lang, ConnectionsGridRenderer, CommunityRow, + BootstrapCommunityRow, TagAnchor, nls) { - this.renderer.headerTemplate = this.renderer.topicHeader; - this.renderer.breadCrumb = this.renderer.topicBreadCrumb; - this.renderer.template = this.renderer.topicTemplate; - this.store.setAttributes(consts.ForumTopicXPath); - this.hideBreadCrumb = false; - var endpoint = this.store.getEndpoint(); - - if(this.params.type=="myTopics"){ - this.renderer.template = this.renderer.topicTemplate; - var url = this.buildUrl(consts.AtomTopicsMy, {},endpoint); - this.store.setUrl(url); - this.hideBreadCrumb = true; - }else if(this.params.type == "forumTopics"){ - this.renderer.template = this.renderer.forumTopicTemplate; - this.hideBreadCrumb = true; - var url = this.buildUrl(consts.AtomTopics+"?forumUuid="+this.forumUuid, {}, endpoint); - this.store.setUrl(url); - }else{ - var url = this.buildUrl(consts.AtomTopics+"?forumUuid="+this._forumID, {}, endpoint); - this.store.setUrl(url); - } - - this.update(null); - }, - - getTopicReplies: function(topicId,options){ - - this.renderer.template = this.renderer.replyTemplate; - this.renderer.headerTemplate = this.renderer.replyHeader; - this.store.setAttributes(consts.ForumReplyXPath); - this.hideBreadCrumb = false; - var endpoint = this.store.getEndpoint(); - - if(this.params.type=="myTopics"){ - this.renderer.breadCrumb = this.renderer.myTopicsBreadCrumb; - }else if(this.params.type == "forumTopics"){ - this.renderer.breadCrumb = this.renderer.myTopicsBreadCrumb; - }else{ - this.renderer.breadCrumb = this.renderer.replyBreadCrumb; - } - - - var url = this.buildUrl(consts.AtomReplies+"?topicUuid="+topicId,{},endpoint); - this.store.setUrl(url); - - this.update(null); - }, - - showTopics: function(el, data, ev){ - if (this.backAction) { - this._stopEvent(ev); - this.backAction.showTopics(data, this , ev); - } - }, - - showForums: function(el, data, ev){ - if (this.backAction) { - this._stopEvent(ev); - this.backAction.showForums(data, this , ev); - } - }, - - /** - * Add the since parameter to the URL, so that all forums will be - * displayed and not just those that have been recently modified. - * The since parameter returns all entries last modified since a specified date. - * Specify the date in the number of milliseconds since Unix EPOCH. - * In this case 1 is used so all forums will be displayed. - * @param url The Rest API URL for the forum feed - * @param args - * @param endpoint An endpoint which may contain custom service mappings. - * @returns - */ - buildUrl: function(url, args, endpoint) { - var params = { since: 1}; - if (this.query) { - params = lang.mixin(params, this.query); - } - if(this.forumUuid){ - params = lang.mixin(params, { forumUuid : this.forumUuid }); - } - - return this.constructUrl(url, params, {}, endpoint); - } - + /** + * @class CommunityGridRenderer + * @namespace sbt.connections.controls.communities + */ + var CommunityGridRenderer = declare(ConnectionsGridRenderer, { + + /** + * Strings used in the grid + */ + _nls: nls, + + /** + * The HTML template for tag anchors + */ + tagAnchorTemplate: TagAnchor, + + /** + * @param args + */ + constructor: function(args,grid){ + if(grid.theme == "bootstrap"){ + this.template = BootstrapCommunityRow; + }else{ + this.template = CommunityRow; + } + }, + + /** + * Sets the class for the Current grid row + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i The number of the current grid row + * @param items an object array containing the data for all of the grid rows + * @returns A CSS Class + */ + rowClass: function(grid, item, i, items) { + return (i === 0 ? "placeRow lotusFirst" : "placeRow"); + }, + + /** + * Handles Displaying a Tooltip for an item + * @param grid The grid Element + * @param item An Object containing all of the data for the current row + * @param i the number of the current grid row + * @param items an object array containing the data for all of the grid rows + * @returns A String, with the text to be displayed in the tooltip + */ + tooltip: function(grid, item, i, items) { + if (grid.communityAction) { + return grid.communityAction.getTooltip(item); + } + }, + + /** + * Handles encoding the image url + * @param grid The grid Element + * @param item An Object containing all of the data for the current row + * @param i the number of the current grid row + * @param items an object array containing the data for all of the grid rows + * @returns The image url + */ + communityImage: function(grid, item, i, items) { + var logoUrl = item.getValue("logoUrl"); + return grid.encodeImageUrl(logoUrl); + }, + + /** + * Returns the number of members for a community + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i the Number of the current grid + * @param items an object array containing the data for all of the grid rows + * @returns A String with the number of members in a community + */ + numOfMembers: function(grid, item, i, items) { + var memberCount = item.getValue("memberCount"); + if (memberCount == 1) { + return this.nls.person; + } else { + return stringUtil.replace(this.nls.people, { "memberCount" : memberCount }); + } + }, + + /** + * Gets the last updated date for a community + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i the number of the current grid row + * @param items an object array containing the data for all of the grid rows + * @returns The date when the community was last updates + */ + updatedDate: function(grid, item, i, items) { + return localeUtil.getUpdatedLabel((item.getValue("updated"))); + }, + + /** + * Returns a CSS style based on if a community has tags. + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i The number of the current row + * @param items an object array containing the data for all of the grid rows + * @returns {String} + */ + displayTags: function(grid, item, i, items) { + var tags = item.getValue("tags"); + if (tags.length == 0) { + return "display: none"; + } else { + return ""; + } + }, + + /** + * Displays the restricted image for a community + * @method displayRestricted + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i The number of the current row + * @param items an object array containing the data for all of the grid rows + * @returns {String} + */ + displayRestricted: function(grid, item, i, items) { + var communityType = item.getValue("communityType"); + if(communityType == "private"){ + return "display: inline-block;"; + }else{ + return "display: none"; + } + }, + + displayModerated: function(grid, item, i, items){ + var communityType = item.getValue("communityType"); + if(communityType == "publicInviteOnly"){ + return "display: inline-block;"; + }else{ + return "display: none"; + } + }, + + + /** + * Get the tag label, if a community has no tags and empty string is returned + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i The number of the current row + * @param items an object array containing the data for all of the grid rows + * @returns an array of strings, that are tags for a community + */ + tagsLabel: function(grid, item, i, items) { + var tags = item.getValue("tags"); + if (tags.length == 0) { + return ""; + } else { + return this.nls.tags; + } + }, + + /** + * Substitutes tag labels(Strings) from the nls file into the tag + * Anchor template which creates a tag links, and displays these tags on the page + * @param grid The Grid Element + * @param item An Object containing all of the data for the current row + * @param i The number of the current row + * @param items an object array containing the data for all of the grid rows + * @returns {String} + */ + tagsAnchors: function(grid, item, i, items) { + var tags = item.getValue("tags"); + if (tags == undefined) { + return ""; + } else { + var tagsStr = ""; + if (lang.isArray(tags)) { + for (var i=0; i<tags.length; i++) { + tagsStr += grid._substitute(this.tagAnchorTemplate, { tagName : tags[i] }); + if (i+1 < tags.length) { + tagsStr += ", "; + } + } + } else if (lang.isString(tags)) { + tagsStr = grid._substitute(this.tagAnchorTemplate, { tagName : tags }); + } + return tagsStr; + } + }, + + getUserProfileHref: function(grid,item,i,items){ + return this.getProfileUrl(grid,item.getValue("authorUserid")); + } - }); - - return ForumGrid; + + }); + + return CommunityGridRenderer; }); - }, -'sbt/connections/controls/profiles/ProfileTagAction':function(){ +'sbt/connections/controls/nls/ConnectionsGridRenderer':function(){ /* * © Copyright IBM Corp. 2013 * @@ -34340,61 +32737,389 @@ define(["../../../declare", * permissions and limitations under the License. */ -/** +// NLS_CHARSET=UTF-8 +define({ + root: { + empty : "Empty", + loading : "Loading...", + previous : "Previous", + previousPage : "Previous Page", + next : "Next", + nextPage : "Next Page", + pagingResults : "${start}-${end} of ${totalCount}", + sortBy : "Sort by:", + msgNoData : "Please wait...", + show10Items : "Show 10 items", + show25Items : "Show 25 items", + show50Items : "Show 50 items", + show100Items : "Show 100 items", + items : "items", + feed : "${nls.feed}" + } +}); + + +}, +'sbt/connections/controls/astream/ActivityStreamWrapper':function(){ +require({cache:{ +'url:sbt/connections/controls/astream/templates/ActivityStreamContent.html':"<html lang=\"en\">\r\n <head>\r\n <meta charset=\"utf-8\">\r\n <script type=\"text/javascript\">\r\n var timeStamp = \"\";\r\n var ibmConfig = {\r\n };\r\n var asc = {\r\n useOAuth : false\r\n }; \r\n var djConfig = {\r\n isDebug: false,\r\n baseUrl: '${proxyUrl}/${connectionsContextRoot}/resources/web/dojo/',\r\n locale: \"en-us\",\r\n useXDomain: true,\r\n dojoBlankHtmlUrl: \"${proxyUrl}/${connectionsContextRoot}/homepage/static/20140117.183045/nav/blankIE.html\",\r\n blankGif: \"${proxyUrl}/${connectionsContextRoot}/resources/web/com.ibm.lconn.core.styles.oneui3/images/blank.gif?etag=20140117.183045\",\r\n useCommentedJson: true,\r\n localizationComplete: true\r\n };\r\n var netJazzAjaxConfig = {\r\n base: \"${proxyUrl}/${connectionsContextRoot}/connections/resources\",\r\n skipStyles: true,\r\n params: \"etag=20140117.183045&lang=en&country=US\"\r\n };\r\n </script>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/${connectionsContextRoot}/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/base/package3.css~com.ibm.lconn.core.styles.oneui3/sprites.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/${connectionsContextRoot}/resources/web/_lconntheme/default.css?version=oneui3&rtl=false\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${cssUrl}\"></link>\r\n \r\n <script type=\"text/javascript\" src=\"${proxyUrl}/${connectionsContextRoot}/resources/web/_js/?include=dojo.dojo.js\"></script>\r\n <script>\r\n dojo.locale = \"en\";\r\n dojo.config.locale=\"en\";\r\n var secure = window.location.href.indexOf(\"https\") == 0 ? true : false;\r\n // This mixin is used to provide the urls for the services that will be accessed, in particular opensocial.\r\n // This approach is ok because eventually our sdk will know these urls (it needs to to correctly make api calls).\r\n // So in the future we can just replace {proxyUrl} with {activitiesUrl} etc.\r\n // TODO Once we allow fully qualified urls in our proxy again, it is important to try leaving these as default and set dojo.config.proxy to be our connections proxy. It may work. It may also fix VCards.\r\n dojo.mixin(dojo.provide(\"lconn.core.config.services\"), {\r\n \"activities\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${activities}\",\r\n \"url\": \"${proxyUrl}/${activities}\"\r\n },\r\n \"blogs\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${blogs}\",\r\n \"url\": \"${proxyUrl}/${blogs}\"\r\n },\r\n \"bookmarklet\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/bookmarklet\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/bookmarklet\"\r\n },\r\n \"communities\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${communities}\",\r\n \"url\": \"${proxyUrl}/${communities}\"\r\n },\r\n \"connectionsmail\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/resources/socmail-client\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/resources/socmail-client\"\r\n },\r\n \"deploymentConfig\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}\"\r\n },\r\n \"dogear\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${dogear}\",\r\n \"url\": \"${proxyUrl}/${dogear}\"\r\n },\r\n \"files\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${files}\",\r\n \"url\": \"${proxyUrl}/${files}\"\r\n },\r\n \"forums\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${forums}\",\r\n \"url\": \"${proxyUrl}/${forums}\"\r\n },\r\n \"help\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${help}\",\r\n \"url\": \"${proxyUrl}/${help}\"\r\n },\r\n \"homepage\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${homepage}\",\r\n \"url\": \"${proxyUrl}/${homepage}\"\r\n },\r\n \"mediaGallery\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${news}/widgets/lw\",\r\n \"url\": \"${proxyUrl}/${news}/widgets/lw\"\r\n },\r\n \"microblogging\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/opensocial\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/opensocial\"\r\n },\r\n \"mobile\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${mobile}\",\r\n \"url\": \"${proxyUrl}/${mobile}\"\r\n },\r\n \"moderation\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${moderation}\",\r\n \"url\": \"${proxyUrl}/${moderation}\"\r\n },\r\n \"news\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${news}\",\r\n \"url\": \"${proxyUrl}/${news}\"\r\n },\r\n \"oauth\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/oauth\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/oauth\"\r\n },\r\n \"oauthprovider\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${oauth2}\",\r\n \"url\": \"${proxyUrl}/${oauth2}\"\r\n },\r\n \"opensocial\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/opensocial\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/opensocial\"\r\n },\r\n \"personTag\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${profiles}/ibm_semanticTagServlet\",\r\n \"url\": \"${proxyUrl}/${profiles}/ibm_semanticTagServlet\"\r\n },\r\n \"profiles\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${profiles}\",\r\n \"url\": \"${proxyUrl}/${profiles}\"\r\n },\r\n \"sand\": {\r\n \"secureEnabled\": secure\r\n },\r\n \"search\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${search}\",\r\n \"url\": \"${proxyUrl}/${search}\"\r\n },\r\n \"webresources\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/resources\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/resources\"\r\n },\r\n \"wikis\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${wikis}\",\r\n \"url\": \"${proxyUrl}/${wikis}\"\r\n }\r\n });\r\n </script>\r\n <script type=\"text/javascript\" src=\"${proxyUrl}/${connectionsContextRoot}/resources/web/_js/?include=com.ibm.social.as.ActivityStream.js~com.ibm.lconn.personcard.legacy.js~com.ibm.social.as.extension.CommentExtension.js~com.ibm.social.as.util.hashtag.HashtagUtil.js~lconn.core.util.dojoPatches.js~com.ibm.social.as.ee.EEManager.js~com.ibm.lconn.gadget.container.iContainer2.js~com.ibm.social.as.gadget.refresh.RefreshButton.js${extraIncludes}&exclude=dojo.dojo.js~lconn.core.config.services.js${extraExcludes}&lang=en\"></script>\r\n <script type=\"text/javascript\" src=\"${libraryUrl}\"></script>\r\n <style> .commit-tease, .user-profile-mini-avatar, .avatar, .vcard-details, .signup-prompt-bg { display: none !IMPORTANT; } </style> <script> document.addEventListener('DOMContentLoaded', function() { this.querySelectorAll('a').forEach(anchor => { anchor.addEventListener('click', e => { e.preventDefault(); const redact = new URLSearchParams(window.location.search).get('redact'); const hasExistingParams = anchor.href.includes('?'); window.location.href = anchor.href + (hasExistingParams ? `&redact=${redact}` : `?redact=${redact}`); }); }); }); </script> </head>\r\n <body class=\"lotusui30_body lotusui30_fonts lotusui30\">\r\n <div id=\"lotusMain\">\r\n <div class=\"lotusContent lotusBoard\">\r\n <div id=\"activityStreamNode\" class=\"lotusStream\"></div>\r\n </div>\r\n <script>\r\n require(\r\n [\"sbt/config\", \"sbt/connections/controls/astream/_ActivityStream\"], \r\n function(config, _ActivityStream){\r\n config.Properties = ${sbtProps};\r\n new _ActivityStream(${args});\r\n }\r\n );\r\n </script>\r\n </div>\r\n </body>\r\n</html>"}}); +/* + * © 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. */ -define([ "../../../declare", "../../../controls/grid/GridAction" ], - function(declare, GridAction) { +define(["../../../declare", "../../../lang", "../../../url", + "../../../config", "../../../util", "../../../stringUtil", "../../../connections/controls/WidgetWrapper", + "../../../text!../../../connections/controls/astream/templates/ActivityStreamContent.html", + "../../../i18n!sbt/connections/controls/astream/nls/ActivityStreamWrapper"], + function(declare, lang, Url, config, util, stringUtil, WidgetWrapper, defaultTemplate, nls) { /** - * @class ProfileTagAction - * @namespace sbt.connections.controls.profiles - * @module sbt.connections.controls.profiles.ProfileTagAction + * The wrapper for the ActivityStream. + * This class just has to provide its own template and the args it receives back to to the WidgetWrapper, which will take care of everything else. + * + * Takes EITHER a feedUrl and an optional extensions object, OR an ActivityStream config object. + * If a feedUrl is specified any config object supplied will be ignored. + * + * The feedUrl is relative to the opensocial context root, and takes the following form for different authentication: + * sso url pattern: '.../opensocial/rest/...' + * oauth url pattern: '.../opensocial/oauth/rest/...' + * basic url pattern: '.../opensocial/basic/rest/...' + * public url pattern: '.../opensocial/anonymous/rest/...' + * + * The endpoint you use should support the authentication you specify with the url. + * + * @method constructor + * + * @param {Object} args + * @params {String} args.feedUrl The url of the feed to populate the ActivityStream with. + * @params {Object} [args.extensions] A simple list of extensions to load. + * @params {Boolean} [args.extensions.commenting] If true load the commenting extension. + * @params {Boolean} [args.extensions.saving] If true load the saving extension. + * @params {Boolean} [args.extensions.refreshButton] If true load the refresh button extension. + * @params {Boolean} [args.extensions.DeleteButton] If true load the delete button extension. + * + * @params {Object} args.config An ActivityStream config object. Only specify this without a feedUrl argument. + * + * @class sbt.controls.astream.ActivityStreamWrapper */ - var ProfileTagAction = declare(GridAction, { + var ActivityStreamWrapper = declare([ WidgetWrapper ], { - /**Strings used in the actions */ - nls: { - tooltip: "" + /** + * Set the html template which will go inside the iframe. + * + * @property defaultTemplate + * @type String + */ + defaultTemplate: defaultTemplate, + standardExtensionsMap: { + commenting: "com.ibm.social.as.extension.CommentExtension", + saving: "lconn.homepage.as.extension.SavedActionExtension", + refreshButton: "com.ibm.social.as.gadget.refresh.RefreshButtonExtension", + deleteButton: "com.ibm.social.as.lconn.extension.MicroblogDeletionExtension" }, - /**ProfileTagAction Constructor function - * @method constructor - * */ - constructor: function() { + /** + * Overriding the method in WidgetWrapper for providing the substitutions for variables in the template. + * + * @method getTemplateReplacements + * @returns {Object} + */ + getTemplateReplacements: function(){ + var proxyUrl = this._endpoint.proxy.proxyUrl + "/" + this._endpoint.proxyPath; + var connectionsUrl = this._endpoint.baseUrl; + var libUrl = new Url(config.Properties.libraryUrl); + var libQuery = libUrl.getQuery(); + var libQueryObj = {}; + var serviceMappings = this.getEndpoint().serviceMappings; + var connectionsServiceMapping = serviceMappings ? this.getEndpoint().serviceMappings.connections : null; + var connectionsContextRoot = connectionsServiceMapping ? connectionsServiceMapping : "connections"; + var extraIncludes = "~"; // extra classes we need to require in the aggregated call for js, e.g. extensions and side navs. + var extraExcludes = "~"; // extra classes we want to exclude, must be a string + + if(libQuery){ + libQueryObj = util.splitQuery(libQuery, "&"); + } + + lang.mixin(libQueryObj, { + lib: "dojo", + ver: "1.4.3" + }); + libQuery = util.createQuery(libQueryObj, "&"); + libUrl.setQuery(libQuery); + + var cssUrl = stringUtil.substitute("{0}/{1}/resources/web/com.ibm.social.as/css/activityStream.css", [connectionsUrl, connectionsContextRoot]); + if(this.cssUrl){ // in case there is one supplied in the constructor args + cssUrl = connectionsUrl + this.cssUrl; + } + + var sbtProps = lang.mixin({}, config.Properties); + lang.mixin(sbtProps, { + libraryUrl: libUrl.getUrl(), + loginUi: "popup" + }); + if(lang.isObject(this.args.extensions) && !(this.args.extensions instanceof Array)){ + var extensions = this.args.extensions; + var arrayConversion = []; + for (var key in extensions) { + if (extensions.hasOwnProperty(key)) { + arrayConversion.push(this.standardExtensionsMap[key]); + extraIncludes += this.standardExtensionsMap[key] + ".js~"; + } + } + this.args.extensions = arrayConversion; + } + if(!this.args.feedUrl && this.args.config){ + var asConfig = this.args.config; + var extensionsArray = []; + this.getExtensionsToArray(asConfig, extensionsArray); + + var i; + for(i = 0; i < extensionsArray.length; i++){ + extraIncludes += extensionsArray[i] + ".js~"; + } + } + + var templateReplacements = { + args: JSON.stringify(this.args), + proxyUrl: proxyUrl, + connectionsUrl: connectionsUrl, + libraryUrl: libUrl.getUrl(), + sbtProps: JSON.stringify(sbtProps), + cssUrl: cssUrl, + connectionsContextRoot: connectionsContextRoot, + extraIncludes: extraIncludes, + extraExcludes: extraExcludes + }; + + return templateReplacements; }, - /** - * Handles displaying a tooltip for an item - * For profiles, the tooltip by default will be a business card - * So nothing is done in this function - * @method getTooltip - * @param item The element that will use the tooltip + /* + * Used to recursively get all of the extension arrays in an activity stream configuration object. + * The result is placed in the second argument. + * + * @method getTemplateReplacements + * @params asConfig the configuration object + * @params resultArray The array to add new extensions to */ - getTooltip: function(item) { - return item.getTerm(); + getExtensionsToArray: function(asConfig, resultArray){ + for (var key in asConfig) { + if (asConfig.hasOwnProperty(key)) { + if(lang.isObject(asConfig[key])){ + this.getExtensionsToArray(asConfig[key], resultArray); + } + + if(key == "extensions"){ + var extensionsArray = asConfig[key]; + if(lang.isArray(extensionsArray)){ + var i; + for(i = 0; i < extensionsArray.length; i++){ + var j; + var containsExtension = false; + for(j = 0; j < resultArray.length; j++){ + if(resultArray[j] == extensionsArray[i]){ + containsExtension = true; + } + } + if(!containsExtension){ + resultArray.push(extensionsArray[i]); + } + } + } + } + } + } }, /** - * The execute function is called from the handle click function - * For Profiles by default the business card functionality is used - * which works from the Semantic tag service so nothing is done here. - * @method execute - * @param item The item which fired the event - * @param opts - * @param event The event + * Store the args so that they can be substituted into the defaultTemplate. + * + * @property args + * @type Object + * @default null */ - execute: function(item, opts, event) { + args: null, + + /** + * Can be supplied in args to override the location of the ActivityStream's css. This url is relative to the connections server. + * + * @property cssUrl + * @type String + * @default "" + */ + cssUrl: "", + + constructor: function(args){ + this.args = args; } - }); + + return ActivityStreamWrapper; +}); +}, +'sbt/connections/controls/search/nls/SearchGridRenderer':function(){ +/* + * © 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. + */ - return ProfileTagAction; +// NLS_CHARSET=UTF-8 +define({ + root: { + name: "Name", + updated: "Updated", + downloads: "Downloads", + likes: "Likes", + loading : "Loading...", + previous : "Previous", + previousPage : "Previous Page", + next : "Next", + nextPage : "Next Page", + pagingResults : "${start} - ${count} of ${totalCount}", + updatedBy : "Updated by", + sortByRelevance : "Relevance", + sortByDate: "Date", + feed : "Feed for these search results", + + + /** + * Search specific Misc + */ + empty : "No results were found for that search", + summary : "Search Results", + emptyString: "", + ltr: "ltr", + help: "Help", + tags: "Tags:", + tagsMore: "and {0} more", + noDescription: "No description or summary for this result.", + members: "members", + people: "People", + feed: "feed", + commentOn: "Comment on: ", + comments: "comments", + comment: "Comment:", + oneComment: "1 comment", + entry: "Entry: ", + topic: "Topic:", + + /** + * Activity-Related + */ + activities: "Activities", + activitiesTitle: "Activities", + activity: "Activity: ", + activityComment: "Comment:", + activityToDo:"To Do:", + activityEntry: "Activity:", + activityBookmark: "Bookmark:", + activitySection: "Section:", + fromAnActivity: "Activity", + + /** + * Blog-Related + */ + blog: "Blog: ", + blogs: "Blogs", + blogEntry: "Blog: ", + blogComment: "Comment:", + idea: "Idea: ", + ideaComment: "Comment: ", + ideationBlog: "Ideation Blog: ", + fromABlog: "Blog", + fromAnIdeationBlog: "Ideation Blog", + + /** + * Bookmark-Related + */ + bookmarks: "Bookmarks", + bookmark: "Bookmark: ", + bookmarksTitle: "Bookmarks", + + /** + * Calendar-Related + */ + calendar: "Calendar: ", + calendars: "Calendars", + eventIsAllDay: "All day", + eventRepeats: "Repeats", + eventDateOn: "On: ", + + /** + * CommunityRelated + */ + communities: "Communities", + community: "Community: ", + communitiesTitle: "Communities", + fromACommunity: "Community", + + /** + * File-Related + */ + file: "File: ", + files: "Files", + + /** + * Forum-Related + */ + forum: "Forum: ", + forums: "Forums", + forumTopic: "Topic:", + forumCategory: "Category:", + fromAForum: "Forum", + + /** + * Profile-Related + */ + profile: "Profile: ", + profiles: "Profiles", + inactiveLabel: "(inactive)", + + /** + * StatusUpdate-Related + */ + statusUpdate: "Status Update: ", + statusUpdates: "Status updates", + fromAStatusUpdate: "Status Update", + + /** + * Wiki-Related + */ + wiki: "Wiki: ", + wikis: "Wikis", + wikiType: "Wiki: ", + wikiFile: "File: ", + wikiPage: "Page: ", + fromAWiki: "Wiki" + } }); + }, -'sbt/connections/nls/CommunityService':function(){ +'sbt/stringUtil':function(){ /* - * © Copyright IBM Corp. 2012,2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34410,253 +33135,122 @@ define([ "../../../declare", "../../../controls/grid/GridAction" ], */ /** - * Social Business Toolkit SDK - Default resource bundle for CommunityService - */ -define({ - root: ({ - invalid_argument : "Invalid Argument" - }) -}); -}, -'url:sbt/connections/controls/search/templates/SuggestPopUpTemplate.html':"<table style=\"border-radius:0px; list-style:none; cursor: pointer; width: 190px; position:absolute; z-index:100; background-color:#EEEEEE; left:13em; \" role=\"presentation\">\r\n</table>\r\n", -'sbt/connections/ActivityConstants':function(){ -/* - * © 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 + * Defination of some string Utilities * - * 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. - */ -/** - * Social Business Toolkit SDK. Definition of constants for ActivityService. + * @module sbt.stringUtil */ -define([ "../lang", "./ConnectionsConstants" ], function(lang, conn) { - - return lang.mixin({}, conn, { +define(['./xml'], function(xml) { - /** - * Namespaces to be used when reading the Activities ATOM entry or feed - */ - ActivityNamespaces : { - a : conn.Namespaces.a, - app : conn.Namespaces.app, - thr : conn.Namespaces.thr, - snx : conn.Namespaces.snx - }, + var _regex = new RegExp("{-?[0-9]+}", "g"); + return { /** - * Map to store all possible types of activity node entry types + * Substitutes the String with pattern {<<number>>} with argument array provided. {-1} is for printing '{' and {-2} is for printing '}' in the text + * + * @param {String} [str] String to be formatted + * @param {Array} [args] arguments Array + * @param {Boolean} [useBlankForUndefined = false] optional flag to indicate to user blank String in case index is not found in args. + * @static + * @method substitute */ - ActivityNodeTypes : { - Activity : "activity", - Chat : "chat", - Email : "email", - Entry : "entry", - EntryTemplate : "entrytemplate", - Reply : "reply", - Section : "section", - ToDo : "todo" + substitute : function(str, args, useBlankForUndefined) { + if (str && args) { + return str.replace(_regex, function(item) { + var intVal = parseInt(item.substring(1, item.length - 1)); + var replace; + if (intVal >= 0) { + replace = args[intVal] ? args[intVal] : useBlankForUndefined ? "" : "undefined"; + } else if (intVal == -1) { + replace = "{"; + } else if (intVal == -2) { + replace = "}"; + } else { + replace = ""; + } + return replace; + }); + } + return str; }, - - /** - * XPath expressions used when parsing a Connections Activities ATOM feed - */ - ActivitiesFeedXPath : conn.ConnectionsFeedXPath, - + /** - * XPath expressions for Person Fields + * Replaces the String with pattern {<<string>>} with argument map provided. Replaces blank if key to be replaces is not found in argsMap. + * + * @param {String} [str] String to be formatted + * @param {Array} [argsMap] arguments Map + * @static + * @method replace */ - PersonFieldXPath : { - name : "a:name", - userId : "snx:userid", - email : "a:email" - + replace : function(str, argsMap) { + if (str && argsMap) { + return str.replace(/{(\w*)}/g, function(m, key) { + var replace; + replace = argsMap.hasOwnProperty(key) ? xml.encodeXmlEntry(argsMap[key]) : ""; + return replace; + }); + } + return str; }, - - /** - * XPath expressions for File Fields - */ - FileFieldXPath : { - url : "a:link[@rel='enclosure']/@href", - type : "a:link[@rel='enclosure']/@type", - size : "a:link[@rel='enclosure']/@size", - length : "a:link/@length" + + trim: function x_trim(s) { + return s ? s.replace(/^\s+|\s+$/g,"") : s; }, - - /** - * XPath expressions for Link Fields - */ - LinkFieldXPath : { - url : "a:link/@href", - title : "a:link/@title" + + startsWith: function x_sw(s,prefix) { + return s.length>=prefix.length && s.substring(0,prefix.length)==prefix; }, - - /** - * XPath expressions for Text Fields - */ - TextFieldXPath : { - summary : "a:summary" + + endsWith: function x_ew(s,suffix) { + return s.length>=suffix.length && s.substring(s.length-suffix.length)==suffix; }, - - /** - * XPath expressions to be used when reading an activity Node entry - * - */ - ActivityNodeXPath : lang.mixin({}, conn.AtomEntryXPath, { - - activityUuid : "snx:activity", - - categoryFlagCompleted : "a:category[@term='completed']/@label", - categoryFlagTemplate : "a:category[@term='template']/@label", - categoryFlagDelete : "a:category[@term='deleted']/@label", - - authorLdapid : "a:author/snx:ldapid", - contributorLdapid : "a:contributor/snx:ldapid", - - type : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term", - priority : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/priority']/@label", - - coummunityUuid : "snx:communityUuid", - communityUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/container']/@href", - - dueDate : "snx:duedate", - membersUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/member-list']/@href", - historyUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/history']/@href", - templatesUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/templates']/@href", - - position : "snx:position", - depth : "snx:depth", - permissions : "snx:permissions", - iconUrl : "snx:icon", - - tags : "a:category[not(@scheme)]/@term", - - inReplyToId : "thr:in-reply-to/@ref", - inReplyToUrl : "thr:in-reply-to/@href", - inReplyToActivity : "thr:in-reply-to/snx:activity", - - assignedToName : "snx:assignedto/@name", - assignedToUserId : "snx:assignedto/@userid", - assignedToEmail : "snx:assignedto", - - textFields : "snx:field[@type='text']", - linkFields : "snx:field[@type='link']", - personFields : "snx:field[@type='person']", - dateFields : "snx:field[@type='date']", - fileFields : "snx:field[@type='file']" - - }), - - /** - * XPath expressions to be used when reading an Tag Node entry - */ - TagXPath : { - term : "@term", - frequency : "@snx:frequency", - entries : "app:categories/a:category", - uid : "@term", - bin : "@snx:bin" + transform: function(template, map, transformer, thisObject) { + return template.replace(/\$\{([^\s\:\}]+)(?:\:([^\s\:\}]+))?\}/g, + function(match, key, format){ + var value = map[key] || ""; + if (typeof value == 'function') { + // invoke function to return the value + try { + value = value.apply(thisObject, [ map ]); + } catch (ex) { + value = "ERROR:" + key + " " + ex; + } + } + if (transformer) { + value = transformer.call(thisObject, value, key); + } + if (typeof value == "undefined" || value == null) { + return ""; + } + return value.toString(); + } + ); }, - /** - * XPath expressions to be used when reading a Community Member Entry - * - * @property MemberXPath - * @type Object - * @for sbt.connections.ActivityService - */ - MemberXPath : lang.mixin({}, conn.AtomEntryXPath, { - entry : "a:feed/a:entry", - id : "a:id", - uid : "a:id", - role : "snx:role", - permissions : "snx:permissions", - category : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/type']/@term" - }), - - /** - * Search for content in all of the activities, both completed and active, that matches a specific criteria. - */ - AtomActivitiesEverything : "/${activities}/service/atom2/everything", - - /** - * Get a feed of all active activities that match a specific criteria. - */ - AtomActivitiesMy : "${activities}/service/atom2/activities", - - /** - * Get a feed of all active activities in trash - */ - AtomActivitiesTrash : "${activities}/service/atom2/trash", - - /** - * Search for a set of completed activities that match a specific criteria. - */ - AtomActivitiesCompleted : "${activities}/service/atom2/completed", - - /** - * Get Activity node feed - */ - AtomActivityNode : "${activities}/service/atom2/activitynode", - - /** - * Get feed of all Activity Nodes in an Activity - */ - AtomActivityNodes : "${activities}/service/atom2/descendants", // ?nodeUuid=" - - /** - * Get Activity Node feed from Trash - */ - AtomActivityNodeTrash : "${activities}/service/atom2/trashednode", - - /** - * Create a new Activity - */ - AtomCreateActivityNode : "${activities}/service/atom2/activity", - - /** - * Get a Feeds of all ToDo Entries in an activity - */ - AtomActivitiesToDos : "${activities}/service/atom2/todos", - - /** - * Get a feed of Activity Members - */ - AtomActivitiesMembers : "${activities}/service/atom2/acl", - - /** - * Get a member for an activity - */ - AtomActivitiesMember : "${activities}/service/atom2/acl?activityUuid={activityUuid}&memberid={memberId}", - - /** - * Get all tags for an activity - */ - AtomActivitiesTags : "${activities}/service/atom2/tags" + hashCode: function(str) { + if (str.length == 0) { + return 0; + } + var hash = 0, i, charStr; + for (i = 0, l = str.length; i < l; i++) { + charStr = str.charCodeAt(i); + hash = ((hash<<5)-hash)+charStr; + hash |= 0; + } + return hash; + }, + + htmlEntity : function(htmlContent){ + return htmlContent.replace(/[\u00A0-\u9999<>\&]/gim, function(c) { + return '&#'+c.charCodeAt(0)+';'; + }); + } - }); + }; }); + }, -'url:sbt/connections/controls/astream/templates/ActivityStreamContent.html':"<html lang=\"en\">\r\n <head>\r\n <meta charset=\"utf-8\">\r\n <script type=\"text/javascript\">\r\n var timeStamp = \"\";\r\n var ibmConfig = {\r\n };\r\n var asc = {\r\n useOAuth : false\r\n }; \r\n var djConfig = {\r\n isDebug: false,\r\n baseUrl: '${proxyUrl}/${connectionsContextRoot}/resources/web/dojo/',\r\n locale: \"en-us\",\r\n useXDomain: true,\r\n dojoBlankHtmlUrl: \"${proxyUrl}/${connectionsContextRoot}/homepage/static/20140117.183045/nav/blankIE.html\",\r\n blankGif: \"${proxyUrl}/${connectionsContextRoot}/resources/web/com.ibm.lconn.core.styles.oneui3/images/blank.gif?etag=20140117.183045\",\r\n useCommentedJson: true,\r\n localizationComplete: true\r\n };\r\n var netJazzAjaxConfig = {\r\n base: \"${proxyUrl}/${connectionsContextRoot}/connections/resources\",\r\n skipStyles: true,\r\n params: \"etag=20140117.183045&lang=en&country=US\"\r\n };\r\n </script>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/${connectionsContextRoot}/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/base/package3.css~com.ibm.lconn.core.styles.oneui3/sprites.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/${connectionsContextRoot}/resources/web/_lconntheme/default.css?version=oneui3&rtl=false\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${cssUrl}\"></link>\r\n \r\n <script type=\"text/javascript\" src=\"${proxyUrl}/${connectionsContextRoot}/resources/web/_js/?include=dojo.dojo.js\"></script>\r\n <script>\r\n dojo.locale = \"en\";\r\n dojo.config.locale=\"en\";\r\n var secure = window.location.href.indexOf(\"https\") == 0 ? true : false;\r\n // This mixin is used to provide the urls for the services that will be accessed, in particular opensocial.\r\n // This approach is ok because eventually our sdk will know these urls (it needs to to correctly make api calls).\r\n // So in the future we can just replace {proxyUrl} with {activitiesUrl} etc.\r\n // TODO Once we allow fully qualified urls in our proxy again, it is important to try leaving these as default and set dojo.config.proxy to be our connections proxy. It may work. It may also fix VCards.\r\n dojo.mixin(dojo.provide(\"lconn.core.config.services\"), {\r\n \"activities\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${activities}\",\r\n \"url\": \"${proxyUrl}/${activities}\"\r\n },\r\n \"blogs\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${blogs}\",\r\n \"url\": \"${proxyUrl}/${blogs}\"\r\n },\r\n \"bookmarklet\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/bookmarklet\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/bookmarklet\"\r\n },\r\n \"communities\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${communities}\",\r\n \"url\": \"${proxyUrl}/${communities}\"\r\n },\r\n \"connectionsmail\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/resources/socmail-client\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/resources/socmail-client\"\r\n },\r\n \"deploymentConfig\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}\"\r\n },\r\n \"dogear\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${dogear}\",\r\n \"url\": \"${proxyUrl}/${dogear}\"\r\n },\r\n \"files\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${files}\",\r\n \"url\": \"${proxyUrl}/${files}\"\r\n },\r\n \"forums\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${forums}\",\r\n \"url\": \"${proxyUrl}/${forums}\"\r\n },\r\n \"help\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${help}\",\r\n \"url\": \"${proxyUrl}/${help}\"\r\n },\r\n \"homepage\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${homepage}\",\r\n \"url\": \"${proxyUrl}/${homepage}\"\r\n },\r\n \"mediaGallery\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${news}/widgets/lw\",\r\n \"url\": \"${proxyUrl}/${news}/widgets/lw\"\r\n },\r\n \"microblogging\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/opensocial\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/opensocial\"\r\n },\r\n \"mobile\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${mobile}\",\r\n \"url\": \"${proxyUrl}/${mobile}\"\r\n },\r\n \"moderation\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${moderation}\",\r\n \"url\": \"${proxyUrl}/${moderation}\"\r\n },\r\n \"news\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${news}\",\r\n \"url\": \"${proxyUrl}/${news}\"\r\n },\r\n \"oauth\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/oauth\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/oauth\"\r\n },\r\n \"oauthprovider\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${oauth2}\",\r\n \"url\": \"${proxyUrl}/${oauth2}\"\r\n },\r\n \"opensocial\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/opensocial\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/opensocial\"\r\n },\r\n \"personTag\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${profiles}/ibm_semanticTagServlet\",\r\n \"url\": \"${proxyUrl}/${profiles}/ibm_semanticTagServlet\"\r\n },\r\n \"profiles\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${profiles}\",\r\n \"url\": \"${proxyUrl}/${profiles}\"\r\n },\r\n \"sand\": {\r\n \"secureEnabled\": secure\r\n },\r\n \"search\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${search}\",\r\n \"url\": \"${proxyUrl}/${search}\"\r\n },\r\n \"webresources\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${connectionsContextRoot}/resources\",\r\n \"url\": \"${proxyUrl}/${connectionsContextRoot}/resources\"\r\n },\r\n \"wikis\": {\r\n \"secureEnabled\": secure,\r\n \"secureUrl\": \"${proxyUrl}/${wikis}\",\r\n \"url\": \"${proxyUrl}/${wikis}\"\r\n }\r\n });\r\n </script>\r\n <script type=\"text/javascript\" src=\"${proxyUrl}/${connectionsContextRoot}/resources/web/_js/?include=com.ibm.social.as.ActivityStream.js~com.ibm.lconn.personcard.legacy.js~com.ibm.social.as.extension.CommentExtension.js~com.ibm.social.as.util.hashtag.HashtagUtil.js~lconn.core.util.dojoPatches.js~com.ibm.social.as.ee.EEManager.js~com.ibm.lconn.gadget.container.iContainer2.js~com.ibm.social.as.gadget.refresh.RefreshButton.js${extraIncludes}&exclude=dojo.dojo.js~lconn.core.config.services.js${extraExcludes}&lang=en\"></script>\r\n <script type=\"text/javascript\" src=\"${libraryUrl}\"></script>\r\n <style> .commit-tease, .user-profile-mini-avatar, .avatar, .vcard-details, .signup-prompt-bg { display: none !IMPORTANT; } </style> <script> document.addEventListener('DOMContentLoaded', function() { this.querySelectorAll('a').forEach(anchor => { anchor.addEventListener('click', e => { e.preventDefault(); const redact = new URLSearchParams(window.location.search).get('redact'); const hasExistingParams = anchor.href.includes('?'); window.location.href = anchor.href + (hasExistingParams ? `&redact=${redact}` : `?redact=${redact}`); }); }); }); </script> </head>\r\n <body class=\"lotusui30_body lotusui30_fonts lotusui30\">\r\n <div id=\"lotusMain\">\r\n <div class=\"lotusContent lotusBoard\">\r\n <div id=\"activityStreamNode\" class=\"lotusStream\"></div>\r\n </div>\r\n <script>\r\n require(\r\n [\"sbt/config\", \"sbt/connections/controls/astream/_ActivityStream\"], \r\n function(config, _ActivityStream){\r\n config.Properties = ${sbtProps};\r\n new _ActivityStream(${args});\r\n }\r\n );\r\n </script>\r\n </div>\r\n </body>\r\n</html>", -'sbt/connections/controls/ConnectionsGridRenderer':function(){ -require({cache:{ -'url:sbt/controls/grid/templates/GridPager.html':"<div class=\"lotusPaging\" dojoAttachPoint=\"pagingHeader\">\r\n\t<div class=\"lotusLeft\"></div>\r\n\t<div class=\"lotusLeft\" dojoAttachPoint=\"showingResultsMessage\">${pagingResults}</div>\r\n\t<ul class=\"lotusRight lotusInlinelist\">\r\n\t\t<li class=\"lotusFirst prevPageLink\">\r\n\t\t\t<a style=\"${hidePreviousLink}\" title=\"${nls.previousPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: prevPage\">${nls.previous}</a>\r\n\t\t\t<span style=\"${hidePreviousLabel}\">${nls.previous}</span>\r\n\t\t</li>\r\n\t\t<li class=\"nextPageLink\">\r\n\t\t\t<a style=\"${hideNextLink}\" title=\"${nls.nextPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: nextPage\">${nls.next}</a>\r\n\t\t\t<span style=\"${hideNextLabel}\">${nls.next}</span>\r\n\t\t</li>\r\n\t</ul>\r\n\t<div>\r\n\t\t<div dojoAttachPoint=\"catCenterPagingTop\"></div>\r\n\t</div>\r\n</div>\r\n", -'url:sbt/controls/grid/bootstrap/templates/GridPager.html':"<div class=\"\" dojoAttachPoint=\"pagingHeader\">\r\n\t<ul class=\"pager\">\r\n\t\t<li>\r\n\t\t\t<a style=\"${hidePreviousLink}\" title=\"${nls.previousPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: prevPage\">${nls.previous}</a>\r\n\t\t\t<span style=\"${hidePreviousLabel}\">${nls.previous}</span>\r\n\t\t</li>\r\n\t\t<li>\r\n\t\t\t<span>${pagingResults}</span>\r\n\t\t</li>\r\n\t\t<li>\r\n\t\t\t<a style=\"${hideNextLink}\" title=\"${nls.nextPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: nextPage\">${nls.next}</a>\r\n\t\t\t<span style=\"${hideNextLabel}\">${nls.next}</span>\r\n\t\t</li>\r\n\t</ul>\r\n\t<div>\r\n\t\t<div dojoAttachPoint=\"catCenterPagingTop\"></div>\r\n\t</div>\r\n</div>\r\n\r\n\r\n", -'url:sbt/controls/grid/templates/GridSorter.html':"<div class=\"lotusSort\">\r\n\t<ul class=\"lotusInlinelist\">\r\n\t\t<li id=\"sortTitle\" class=\"lotusFirst\">${nls.sortBy}</li>\r\n\t\t${sortAnchors}\r\n\t</ul>\r\n</div>\r\n", -'url:sbt/controls/grid/bootstrap/templates/GridSorter.html':"<div class=\"navbar\">\r\n\t<div class=\"navbar-inner\">\r\n\t\t<a class=\"brand\" href=\"#\">${nls.sortBy}</a>\r\n\t\t<ul class=\"nav\">\r\n\t\t\t${sortAnchors}\r\n\t\t</ul>\r\n\t</div>\r\n</div>", -'url:sbt/controls/grid/templates/SortAnchor.html':"<li class=\"${sortItemClass}\">\r\n\t<a href=\"javascript:\" data-dojo-attach-event=\"onclick: ${sortMethod}\" class=\"${sortAnchorClass}\">${title}</a>\r\n</li>\r\n", -'url:sbt/controls/grid/bootstrap/templates/SortAnchor.html':"<li>\r\n\t<a href=\"javascript:\" data-dojo-attach-event=\"onclick: ${sortMethod}\" class=\"\"><i class=\"${sortAnchorClass}\"></i> ${title}</a>\r\n</li>", -'url:sbt/controls/grid/templates/GridFooter.html':"<div dojoattachpoint=\"pagingFooter\" class=\"lotusPaging\" style=\"\">\r\n\t<ul dojoattachpoint=\"itemsPerPageList\"\r\n\t\tclass=\"lotusLeft lotusInlinelist\">\r\n\t\tShow:\r\n\t\t<li class=\"lotusFirst itemsPerPageLink\">\r\n\t\t\t<a href=\"javascript: void(0)\" title=\"${nls.show10Items}\" aria-pressed=\"false\"\r\n\t\t\t\trole=\"button\" data-dojo-attach-event=\"onclick: show10ItemsPerPage\">10</a>\r\n\t\t</li>\r\n\t\t<li class=\"itemsPerPageLink\">\r\n\t\t\t<a href=\"javascript: void(0)\"\r\n\t\t\t\ttitle=\"${nls.show25Items}\" data-dojo-attach-event=\"onclick: show25ItemsPerPage\"\r\n\t\t\t\taria-pressed=\"false\" role=\"button\">25</a>\r\n\t\t</li>\r\n\t\t<li class=\"itemsPerPageLink\">\r\n\t\t\t<a href=\"javascript: void(0)\" title=\"${nls.show50Items}\" data-dojo-attach-event=\"onclick: show50ItemsPerPage\"\r\n\t\t\taria-pressed=\"false\" role=\"button\">50</a>\r\n\t\t</li>\r\n\t\t<li class=\"itemsPerPageLink\">\r\n\t\t\t<a href=\"javascript: void(0)\" title=\"${nls.show100Items}\" data-dojo-attach-event=\"onclick: show100ItemsPerPage\"\r\n\t\t\taria-pressed=\"false\" role=\"button\">100</a>\r\n\t\t</li> ${nls.items}\r\n\t</ul>\r\n\t<div>\r\n\t\t<div data-dojo-attach-event=\"catCenterPagingBottom\" class=\"\"></div>\r\n\t</div>\r\n</div>\r\n<div class=\"lotusFeeds\">\r\n\t<a href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: viewFeed\" class=\"lotusFeed lotusAction\" target=\"_self\">${nls.feed}</a>\r\n</div>", -'url:sbt/controls/grid/bootstrap/templates/GridFooter.html':"<div style=\"padding:05.em;\">\r\n<div dojoattachpoint=\"pagingFooter\">\r\n\t<span dojoattachpoint=\"itemsPerPageList\">\r\n\t\tShow:\r\n\t\t<span>\r\n\t\t\t<a href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: show10ItemsPerPage\">10</a>\r\n\t\t</span>|\r\n\t\t<span>\r\n\t\t\t<a href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: show25ItemsPerPage\">25</a>\r\n\t\t</span>|\r\n\t\t<span>\r\n\t\t\t<a href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: show50ItemsPerPage\">50</a>\r\n\t\t</span>|\r\n\t\t<span>\r\n\t\t\t<a href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: show100ItemsPerPage\">100</a>\r\n\t\t</span> ${nls.items}\r\n\t</span>\r\n</div>\r\n<div>\r\n\t<a href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: viewFeed\" >${nls.feed}</a>\r\n</div>\r\n</div>"}}); +'sbt/itemFactory':function(){ /* * © Copyright IBM Corp. 2013 * @@ -34674,89 +33268,79 @@ require({cache:{ */ /** - * + * I18n utilities */ -define([ "../../declare", "../../controls/grid/GridRenderer", - "../../text!../../controls/grid/templates/GridPager.html", - "../../text!../../controls/grid/bootstrap/templates/GridPager.html", - "../../text!../../controls/grid/templates/GridSorter.html", - "../../text!../../controls/grid/bootstrap/templates/GridSorter.html", - "../../text!../../controls/grid/templates/SortAnchor.html", - "../../text!../../controls/grid/bootstrap/templates/SortAnchor.html", - "../../i18n!./nls/ConnectionsGridRenderer", - "../../text!../../controls/grid/templates/GridFooter.html", - "../../text!../../controls/grid/bootstrap/templates/GridFooter.html", - - "../../lang"], - function(declare, GridRenderer, GridPager,BootstrapGridPager, - GridSorter,BootstrapGridSorter, SortAnchor,BootstrapSortAnchor, - nls, GridFooter,BootstrapGridFooter,lang) { +define(["./lang", "./xpath", "./base/core"], function(lang, xpath, core) { + + var XPathCountFunction = /^count\(.*\)$/; /** - * @module sbt.connections.controls.ConnectionsGridRenderer - * @class ConnectionsGridRenderer - * @namespace sbt.connections.controls + * @module sbt.itemFactory */ - var ConnectionsGridRenderer = declare(GridRenderer, { - - /**Strings used in the grid*/ - nls : {}, - /**CSS class for tables*/ - tableClass : "lotusTable", - /**CSS Class for empty icon*/ - emptyClass : "lconnEmpty", - /**CSS Class for an error on an icon*/ - errorClass : "lconnEmpty", - /**The css class to use when the grid is loading,null here as an image is used instead*/ - loadingClass : "", - /**The loading image*/ - loadingImgClass : "lotusLoading", - /**The css class for the first row of the grid*/ - firstClass : "lotusFirst", - /**CSS classes for sorting*/ - defaultSortClass : "lotusActiveSort lotusDescending", - ascendingSortClass : "lotusActiveSort lotusAscending", - descendingSortClass : "lotusActiveSort lotusDescending", - /**The HTML template to use to show paging (moving forward and backward through sets of results)*/ - pagerTemplate : GridPager, - /**The bootstrap pager template*/ - bootstrapPagerTemplate: BootstrapGridPager, - /**The HTML template to use to show the grid footer */ - footerTemplate : GridFooter, - /**The bootstrap footer template*/ - bootstrapFooterTemplate: BootstrapGridFooter, - /**The HTML template to show sorting options*/ - sortTemplate : GridSorter, - /**The bootstrap sorter template*/ - bootstrapSortTemplate: BootstrapGridSorter, - /**The HTML template for sort Anchors*/ - sortAnchor : SortAnchor, - /**The bootstrap html sorting anchor template */ - bootstrapSortAnchor: BootstrapSortAnchor, + return { - /** - * Merge this class with the GridRenderer Class - * @method constructor - * @param args - */ - constructor : function(args) { - if(!this.grid.tableClass){ - if(this.grid.theme == "bootstrap"){ - this.tableClass = "table"; - } - } - lang.mixin(this, args); - this.nls = lang.mixin(nls, this._nls); + createItems: function(document, attributes, thisObject, decoder) { + var nodes = xpath.selectNodes(document, core.feedXPath.entry, core.namespaces); + var items = []; + if (nodes.length == 0) { + nodes = xpath.selectNodes(document, "a:entry", core.namespaces); + } + for (var i=0; i<nodes.length; i++) { + items.push(this.createItem(nodes[i], attributes, thisObject, decoder)); + } + return items; + }, + + createItem: function(element, attributes, thisObject, decoder) { + // TODO add item.index and item.attribs + var item = { + element : element, + getValue : function(attrib) { return this[attrib]; } + }; + var attribs = this.getAttribs(attributes); + for (var i=0; i<attribs.length; i++) { + var attrib = attribs[i]; + var access = attributes[attrib]; + if (lang.isFunction(access)) { + item[attrib] = access(thisObject, item); + } else if (access.match(XPathCountFunction)){ + item[attrib] = xpath.selectNumber(element, access, core.namespaces); + } else { + var nodes = xpath.selectNodes(element, access, core.namespaces); + if (nodes && nodes.length == 1) { + item[attrib] = nodes[0].text || nodes[0].textContent; + } else if (nodes) { + item[attrib] = []; + for (var j=0; j<nodes.length; j++) { + item[attrib].push(nodes[j].text || nodes[j].textContent); + } + } else { + item[attrib] = null; + } + } + + item[attrib] = (decoder) ? decoder.decode(item[attrib]) : item[attrib]; + } + return item; + }, + + getAttribs: function(attributes) { + var attribs = []; + for (var name in attributes) { + if (attributes.hasOwnProperty(name)) { + attribs.push(name); + } + } + return attribs; } - - }); - - return ConnectionsGridRenderer; + + }; + }); }, -'sbt/nls/validate':function(){ +'sbt/connections/controls/astream/nls/ActivityStreamWrapper':function(){ /* - * © Copyright IBM Corp. 2012 + * © 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. @@ -34771,22 +33355,16 @@ define([ "../../declare", "../../controls/grid/GridRenderer", * permissions and limitations under the License. */ -/** - * Social Business Toolkit SDK - Default resource bundle for validate module. - */ - - +// NLS_CHARSET=UTF-8 define({ - root: ({ - error_callback:"Error running error callback : {0}", - error_console:"Error received. Error Code = {0}. Error Message = {1}", - validate_nullObject:"{0}.{1} : Null argument provided for {2}. Expected type is {3}", - validate_expectedType:"{0}.{1} : {2} argument type does not match expected type {3} for {4}" - }) - + root: { + IE9Unsupported : "Unsupported browser, Internet Explorer 10 or later is required." + } }); + + }, -'sbt/connections/controls/communities/CommunityAction':function(){ +'sbt/connections/controls/vcard/SemanticTagService':function(){ /* * © Copyright IBM Corp. 2013 * @@ -34804,91 +33382,158 @@ define({ */ /** - * @module sbt.connections.controls.communities.CommunityAction + * */ -define([ "../../../declare", "../../../controls/grid/GridAction", "../../../stringUtil" ], - function(declare, GridAction, stringUtil) { + +define([ "../../../declare", "../../../Endpoint", "../../../config", "../../../log"], + function(declare, Endpoint, config, log) { + + + /** + * Configuration Object. + * + * isBidiRTL - Whether or not to enable bidirectional language support. + * + * @property SemTagSvcConfig + * @type Object + */ + var SemTagSvcConfig = { + isBidiRTL: true + }; + + /** + * The class which handles loading of the semantic tag service for connections, this is needed for displaying vcards. + * + * @class sbt.controls.vcard.connections.SemanticTagService + */ + var SemanticTagService = declare(null, { + }); /** + * Load the Semantic tag service to parse any cards on the page. * - * @class CommunityAction - * @namespace sbt.connections.controls.communities + * @param {Object} [options] + * @params {Function} [options.error] + * An optional error callback, to be fired + * in the event of a problem loading the + * SemanticTagService from Connections. + * @params {Boolean} [options.inclCss] + * If true include's the card's css, + * otherwise false. + * @params {String} [options.endpoint] + * The name of the endpoint to be + * used when fetching the + * SemanticTagService. */ - var CommunityAction = declare(GridAction, { + SemanticTagService.loadSemanticTagService = function(options){ + // Only load the service once. + if (SemTagSvcConfig.loading || SemTagSvcConfig.loaded) { + return; + } - nls: { - tooltip: "{title}" - }, - - /** - * CommunityGridAction Constructor - * @method constructor - */ - constructor: function() { - }, + if (SemTagSvcConfig.error) { + if (errBack) { + errBack(SemTagSvcConfig.error); + } + return; + } + //Set up defaults. + var inclDojo = false; + var inclCss = false; + var isBidiRTL = false; + var endpointName = "connections"; + var errBack = null; + var missingDojoError = function missingDojoError(){ + log.error("SemanticTagService.loadSemanticTagService:" + + " Dojo is not available, set arg inclDojo : true to load Dojo from Connections."); + if(errBack){ + errBack(SemTagSvcConfig.error); + } + return; + }; - /** - * @method getTooltip - * @param item The element that the tooltip will display for - * @returns A String to be displayed in an elements tooltip - */ - getTooltip: function(item) { - return stringUtil.replace(this.nls.tooltip, { title : item.getValue("title") }); - }, + if(options){ + errBack = options.error || errBack; + isBidiRTL = options.isBidiRTL || isBidiRTL; + endpointName = options.endpoint || endpointName; + inclCss = options.inclCss || inclCss; + inclDojo = options.inclDojo || inclDojo; + //we need dojo from somewhere. + if(!dojo){ + if(!options.inclDojo){ + missingDojoError(); + }else{ + inclDojo = true; + } + } + }else{ + if(!dojo){ + missingDojoError(); + } + } + // We'll be loading the card now. + SemTagSvcConfig.loading = true; + var endpoint = config.findEndpoint(endpointName); + var proxy = endpoint.getProxyUrl(); - /** - * When an event is fired, this is the action that will get called - * from the hanleClick function - * @method execute - * @param item The element that fired the event and called this function - * @param opts - * @param event the Event - */ - execute: function(item, opts, event) { - window.open(item.getValue("alternateUrl")); + window.SemTagSvcConfig = window.SemTagSvcConfig || {}; + window.SemTagSvcConfig.baseUrl = proxy; + window.SemTagSvcConfig.proxyURL = proxy; + + var serviceUrl = "/profiles/ibm_semanticTagServlet/javascript/semanticTagService.js"; + + var locale = "en"; + dojo.config.proxy = proxy; + locale = dojo.config.locale; + + if(inclCss){ + window.SemTagSvcConfig.loadCssFiles = inclCss; + var pathToResources = "connections"; + pathToResources = endpoint.serviceMappings["pathToResources"] || pathToResources; + + window.SemTagSvcConfig.resourcesSvc = endpoint.baseUrl + "/" + pathToResources + "/resources"; //resourcesSvc is used when loading css. + //Load straight from connections so that relative css urls work. } - - }); - - return CommunityAction; -}); -}, -'sbt/connections/controls/profiles/nls/ProfileGridRenderer':function(){ -/* - * © 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. - */ - -// NLS_CHARSET=UTF-8 -define({ - root: { - summary : "Profiles Grid", - updatedBy : "Updated by ", - displayName: "Display Name", - recent: "Recent", - telephone: "Telephone:", - email: "Email:", - altEmail: "Alternate Email", - clickToEmail: "Click here to email the user, using their alternate email address", - ariaVcard: "Press control and enter for the business card", - role: "Role", - created: "Created", - feed : "Feed for these Profiles" - } + + var requestArgs = { + method : "GET", + handleAs : "text", + query : { + 'inclDojo': inclDojo + }, + headers: { + "Accept-Language": locale + ",en;q=0.8" + } + }; + + endpoint.request(serviceUrl, requestArgs).then( + function(semTagScript){ + SemTagSvcConfig.loading = false; + try { + var re = new RegExp(endpoint.baseUrl, "g"); + var _semTagScript = semTagScript.replace(re, proxy); + eval(_semTagScript); + SemTagSvcConfig.loaded = true; + } catch (error) { + SemTagSvcConfig.error = error; + if (errBack) { + errBack(error); + } + } + }, + function(error){ + SemTagSvcConfig.loading = false; + SemTagSvcConfig.error = error; + if (errBack) { + errBack(error); + } + } + ); + }; + + return SemanticTagService; }); - }, 'sbt/connections/controls/forums/ForumAction':function(){ /* @@ -34979,7 +33624,7 @@ define([ "../../../declare", "../../../controls/grid/GridAction","../../../i18n! }); }, -'sbt/connections/controls/files/nls/FileGridRenderer':function(){ +'sbt/connections/controls/bookmarks/nls/BookmarkGridRenderer':function(){ /* * © Copyright IBM Corp. 2013 * @@ -34998,36 +33643,18 @@ define([ "../../../declare", "../../../controls/grid/GridAction","../../../i18n! // NLS_CHARSET=UTF-8 define({ - root: { - updatedBy : "Updated by", - name: "Name", - updated: "Updated", - downloads: "Downloads", - comments: "Comments", - likes: "Likes", - noLikes: "No one likes this", - oneLike: "1 person likes this", - nLikes: "{recommendationCount} people like this", - downloads: "Downloads", - download: "Download", - more: "More", - created: "Created", - pin: "Pin This Item", - commented: "Commented", - _delete: "Delete", - edit: "Edit", - files:"Files", - ariaCheckbox: "checkbox", - ariaVcard: "ariaCheckbox", - feed : "Feed for these Files", - allActions: "All actions for this file" - } + root: { + tags : "Tags: ", + date: "Date", + popularity: "Popularity", + feed : "Feed for these Bookmarks", + noTags : "No tags" + } }); - }, -'sbt/connections/controls/files/FileAction':function(){ +'sbt/xsl':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35040,67 +33667,54 @@ define({ * 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. + + * Social Business Toolkit SDK - XSL utilities. + * Borrowed from the Connections source code, for now */ /** - * + * @module sbt.xsl */ -define([ "../../../declare", "../../../stringUtil", "../../../controls/grid/GridAction" ], - function(declare, stringUtil, GridAction) { - - /** - * @class FileAction - * @namespace sbt.connections.controls.files - * @module sbt.connections.controls.files.FileAction - */ - var FileAction = declare(GridAction, { - - /**Strings*/ - nls: { - tooltip: "Click to download ${title}" - }, - grid: null, - /**Constructor function - * @method constructor - * */ - constructor: function(grid) { - this.grid = grid; - }, - - /**function to get the string to be displayed in an elements tooltip - * @method getTooltip - * @param item The element for which the tolltip will be displayed - * @return A String, with the text to be displayed in the elements tooltip - * */ - getTooltip: function(item) { - return stringUtil.replace(this.nls.tooltip, { title : item.getValue("title") }); - }, - - /** - * Execute function provides the default action for files - * This function is called from the handle click function. - * @method execute - * @param item the element that fired the event - * @param opts - * @param event the event - */ - execute: function(item, opts, event) { - var url = item.getValue("downloadUrl"); - if(this.grid){ - url = this.grid.encodeImageUrl(url); - } - window.open(url); - } - - }); - - return FileAction; +define(['./Cache','./xml','./lang'],function(cache,sbtml,lang) { + return { + + /** + * Transform an XML document using an XSL stylesheet. + * The XML document can be either a string or an actual DOM document. In case of a + * string, if it starts with "http", then the string is read from the URL. Then, it + * is parsed to a DOM document. + * The XSL must be a string + */ + xsltTransform: function(xml,xsl) { + if(!xml) return null; + + // Resolve the XML if it is a URL + if(lang.isString(xml)) { + xml = sbtml.parse(sbt.cache.get(xml)); + } + + // Resolve the XSL if it is a URL + if(!xsl) return lang.clone(xml); + xsl = sbt.cache.get(xsl); + + // Run the transformation + if(window.ActiveXObject) { + return xml.transformNode(xsl); + } else if(document.implementation && document.implementation.createDocument) { + var xslt = new XSLTProcessor(); + xslt.importStyleSheet(xsl); + return xslt.transformToFragment(xml,document); + } + + // No XSLT engine is available, just return the document as is + return lang.clone(xml); + } + }; }); - }, -'sbt/controls/dialog/nls/dialog':function(){ +'sbt/Proxy':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35116,25 +33730,54 @@ define([ "../../../declare", "../../../stringUtil", "../../../controls/grid/Grid */ /** - * Social Business Toolkit SDK + * Social Business Toolkit SDK. + * Definition of a proxy re-writer. * - * Resource bundle for dialog control. + * @module sbt.Proxy */ -define({ - root: ({ - OK : "OK", - Cancel : "Cancel", - Close : "Close" - }) -}); +define(['./declare','./lang','./pathUtil'],function(declare,lang,pathUtil) { + + /** + * Definition of the proxy module + * + * @class sbt.Proxy + * + */ + var Proxy = declare(null, { + + proxyUrl : null, + + constructor: function(args){ + lang.mixin(this, args); + }, + + rewriteUrl: function(baseUrl,serviceUrl,proxyPath) { + // When this proxy is being used, we don't add the base URL as it will be added on the server side + // A different implementation might use the full URL + var u = serviceUrl; + if(this.proxyUrl) { + if(u.indexOf("http://")==0) { + u = "/http/"+u.substring(7); + } else if(u.indexOf("https://")==0) { + u = "/https/"+u.substring(8); + } + if(proxyPath) { + u = pathUtil.concat(proxyPath,u); + } + return pathUtil.concat(this.proxyUrl,u); + } + return u; + } + }); + + return Proxy; +}); }, -'url:sbt/connections/controls/search/templates/StatusUpdateHeader.html':"<div class=\"lotusLeft lconnSearchHighlight lconnStatusUpdateTitle\">\r\n <a href=\"${resultLink}\">\r\n ${formattedTitle}\r\n </a>\r\n</div>", -'sbt/connections/controls/sharebox/InputFormWrapper':function(){ -require({cache:{ -'url:sbt/connections/controls/sharebox/templates/InputFormContent.html':"<html lang=\"en\">\r\n <head>\r\n <meta charset=\"utf-8\">\r\n <script src=\"/sbt.dojo143/dojo/dojo.js\"></script>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/base/package3.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_lconntheme/default.css?version=oneui3&rtl=false\"></link>\r\n <script type=\"text/javascript\" src=\"${sbtSampleUrl}/library?lib=dojo&ver=1.4.3\"></script>\r\n <script type=\"text/javascript\" src=\"${sbtSampleServiceUrl}/proxy/com/connections/resources/web/_js/?include=lconn.news.microblogging.sharebox.InputForm.js~lconn.core.util.dojoPatches.js~com.ibm.social.as.util.hashtag.HashtagUtil.js&exclude=dojo.dojo.js\"></script>\r\n <style> .commit-tease, .user-profile-mini-avatar, .avatar, .vcard-details, .signup-prompt-bg { display: none !IMPORTANT; } </style> <script> document.addEventListener('DOMContentLoaded', function() { this.querySelectorAll('a').forEach(anchor => { anchor.addEventListener('click', e => { e.preventDefault(); const redact = new URLSearchParams(window.location.search).get('redact'); const hasExistingParams = anchor.href.includes('?'); window.location.href = anchor.href + (hasExistingParams ? `&redact=${redact}` : `?redact=${redact}`); }); }); }); </script> </head>\r\n <body class=\"lotusui30_body lotusui30_fonts lotusui30\">\r\n <div id=\"inputForm\"></div>\r\n <script>\r\n dojo.require(\"sbt.controls.sharebox._InputForm\");\r\n new sbt.controls.sharebox._InputForm(${args});\r\n </script>\r\n </body>\r\n</html>"}}); +'url:sbt/connections/controls/files/templates/BootstrapFolderRow.html':"<tr>\r\n <td style=\"width: 100%;\">\r\n <span class=\"icon-folder-open\"></span>\r\n <span style=\"font-size:120%\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${tooltip}\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a> \r\n </span>\r\n\r\n </td>\r\n \r\n</tr>", +'sbt/authenticator/GadgetOAuth':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35148,149 +33791,48 @@ require({cache:{ * implied. See the License for the specific language governing * permissions and limitations under the License. */ - -define(["sbt/declare", "sbt/connections/controls/WidgetWrapper", "sbt/text!./templates/InputFormContent.html"], function(declare, WidgetWrapper, defaultTemplate) { - - /** - * @class sbt.controls.sharebox.InputFormWrapper - */ - var InputFormWrapper = declare([ WidgetWrapper ], { - /** - * The html template of the iframe's inner html. - * - * @property defaultTemplate - * @type String - */ - defaultTemplate: defaultTemplate, - - /** - * The args object which will be substituted into the defaultTemplate. - * - * @property args - * @type Object - */ - args: null, - - /** - * Get args of the connections InputForm and store them so that they can be substituted into the defaultTemplate later. - * - * @method constructor - * @param {Object} args - * @param {String} args.shareBoxNode Should contain the id of the html element to add the InputForm to. - */ - constructor: function(args){ - this.args = args; - } - - }); - - return InputFormWrapper; -}); -}, -'url:sbt/controls/grid/bootstrap/templates/GridPager.html':"<div class=\"\" dojoAttachPoint=\"pagingHeader\">\r\n\t<ul class=\"pager\">\r\n\t\t<li>\r\n\t\t\t<a style=\"${hidePreviousLink}\" title=\"${nls.previousPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: prevPage\">${nls.previous}</a>\r\n\t\t\t<span style=\"${hidePreviousLabel}\">${nls.previous}</span>\r\n\t\t</li>\r\n\t\t<li>\r\n\t\t\t<span>${pagingResults}</span>\r\n\t\t</li>\r\n\t\t<li>\r\n\t\t\t<a style=\"${hideNextLink}\" title=\"${nls.nextPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: nextPage\">${nls.next}</a>\r\n\t\t\t<span style=\"${hideNextLabel}\">${nls.next}</span>\r\n\t\t</li>\r\n\t</ul>\r\n\t<div>\r\n\t\t<div dojoAttachPoint=\"catCenterPagingTop\"></div>\r\n\t</div>\r\n</div>\r\n\r\n\r\n", -'sbt/base/BaseConstants':function(){ -/* - * © Copyright IBM Corp. 2014 - * - * 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. - */ + /** - * Social Business Toolkit SDK. Definition of constants for BaseService. + * Social Business Toolkit SDK. + * Definition of the authentication mechanism for OAuth 1.0. */ -define([ "../config" ], function(sbt) { - return { - /** - * Error codes used by the SBT based service implementations. - */ - sbtErrorCodes : { - badRequest : 400 +define([ "../declare", "../lang" ], function(declare,lang) { + + /** + * OpenSocial OAuth authentication. + * + * This class triggers the authentication for a service. + */ + return declare(null, { + + constructor : function(args) { + lang.mixin(this, args || {}); }, - - /** - * Namespaces to be used when reading the Connections ATOM entry or feed - */ - Namespaces : { - o : "http://ns.opensocial.org/2008/opensocial", - app : "http://www.w3.org/2007/app", - thr : "http://purl.org/syndication/thread/1.0", - fh : "http://purl.org/syndication/history/1.0", - snx : "http://www.ibm.com/xmlns/prod/sn", - opensearch : "http://a9.com/-/spec/opensearch/1.1/", - a : "http://www.w3.org/2005/Atom", - h : "http://www.w3.org/1999/xhtml", - td : "urn:ibm.com/td", - relevance : "http://a9.com/-/opensearch/extensions/relevance/1.0/", - ibmsc : "http://www.ibm.com/search/content/2010", - xhtml : "http://www.w3.org/1999/xhtml", - spelling : "http://a9.com/-/opensearch/extensions/spelling/1.0/", - ca : "http://www.ibm.com/xmlns/prod/composite-applications/v1.0 namespace" - }, - - /** - * XPath expressions used when parsing an ATOM feed - */ - AtomFeedXPath : { - // used by getEntitiesDataArray - entries : "/a:feed/a:entry", - // used by getSummary - totalResults : "/a:feed/opensearch:totalResults", - startIndex : "/a:feed/opensearch:startIndex", - itemsPerPage : "/a:feed/opensearch:itemsPerPage" - }, - + /** - * XPath expressions to be used when reading an entry + * Method that authenticates the current user */ - AtomEntryXPath : { - // used by getEntityData - entry : "/a:entry", - // used by getEntityId - uid : "a:id", - // used by getters - id : "a:id", - title : "a:title", - updated : "a:updated", - published : "a:published", - authorName : "a:author/a:name", - authorEmail : "a:author/a:email", - authorUserid : "a:author/snx:userid", - authorUserState : "a:author/snx:userState", - contributorName : "a:contributor/a:name", - contributorEmail : "a:contributor/a:email", - contributorUserid : "a:contributor/snx:userid", - contributorUserState : "a:contributor/snx:userState", - content : "a:content[@type='html']", - summary : "a:summary[@type='text']", - categoryTerm : "a:category/@term", - editUrl : "a:link[@rel='edit']/@href", - selfUrl : "a:link[@rel='self']/@href", - alternateUrl : "a:link[@rel='alternate']/@href", - tags : "./a:category[not(@scheme)]/@term" - }, - - /** - * - */ - AtomXmlHeaders : { - "Content-Type" : "application/atom+xml" - } - - }; + authenticate : function(options) { + var onOpen = function() { + }; + var onClose = function() { + }; + var response = options.error.response; + var popup = new gadgets.oauth.Popup(response.oauthApprovalUrl, null, onOpen, onClose); + popup.createOpenerOnClick(); + } + }); }); }, -'url:sbt/connections/controls/files/templates/BootstrapFileRow.html':"<tr>\r\n <td style=\"width: 100%;\">\r\n <span class=\"icon-file\"></span>\r\n <span style=\"font-size:120%\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${tooltip}\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a> \r\n </span>\r\n </td>\r\n \r\n</tr>", -'url:sbt/smartcloud/controls/profiles/templates/CommunityMember.html':"<tr class=\"${rowClass}\">\r\n\t<td align=\"center\" style=\"width: 40px; padding-top: 5px;\">\r\n\t\t<input id=\"${uid}\" name=\"${uid}\" value=\"${uid}\" data-dojo-attach-event=\"onclick: handleCheckBox\" type=\"checkbox\" aria-label=\"${name}\"></input>\r\n\t</td>\r\n\t<td style=\"width: 70px\" class=\"lotusFirstCell\">\r\n\t\t<img width=\"55\" height=\"55\" src=\"${getMemberPhoto}\" alt=\"\" class=\"photo\">\r\n\t</td>\r\n\t<td >\r\n\t\t<h1>\r\n\t\t\t<a href=\"${profileUrl}\" id=\"\">${title}</a>\r\n\r\n\t\t</h1>\r\n\t\t\r\n\t</td>\r\n\t<td style=\"width: 30%\" class=\"llCntConnection\">\r\n\t\t<span class=\"lotusConfirm lotusMeta connections llConnectionStatus\">\r\n\t\t\t<strong>Role: ${role}</strong>\r\n\t\t</span>\r\n\t</td>\r\n</tr>\r\n", -'sbt/smartcloud/controls/profiles/ProfileAction':function(){ +'sbt/_bridge/json':function(){ +/** + * Dojo AMD JSON implementation. + */ +define(['dojo/json'],function(json) { + return json; +}); +}, +'sbt/connections/controls/profiles/ProfileTagAction':function(){ /* * © Copyright IBM Corp. 2013 * @@ -35308,23 +33850,24 @@ define([ "../config" ], function(sbt) { */ /** - * @module sbt.smartcloud.controls.profiles.ProfileAction + * */ -define([ "../../../declare", "../../../controls/grid/GridAction", "dojo/string" ], - function(declare, GridAction, string) { +define([ "../../../declare", "../../../controls/grid/GridAction" ], + function(declare, GridAction) { /** - * @class ProfileAction - * @namespace sbt.smartcloud.controls.profiles + * @class ProfileTagAction + * @namespace sbt.connections.controls.profiles + * @module sbt.connections.controls.profiles.ProfileTagAction */ - var ProfileAction = declare(GridAction, { + var ProfileTagAction = declare(GridAction, { /**Strings used in the actions */ nls: { - tooltip: "Go to ${name}" + tooltip: "" }, - /**ProfileAction Constructor function + /**ProfileTagAction Constructor function * @method constructor * */ constructor: function() { @@ -35338,10 +33881,7 @@ define([ "../../../declare", "../../../controls/grid/GridAction", "dojo/string" * @param item The element that will use the tooltip */ getTooltip: function(item) { - - //for default the semantic tag service will pop up the business card - //so do nothing here - + return item.getTerm(); }, /** @@ -35354,24 +33894,16 @@ define([ "../../../declare", "../../../controls/grid/GridAction", "dojo/string" * @param event The event */ execute: function(item, opts, event) { - - //for default the semantic tag service will pop up the business card - //so do nothing here } }); - return ProfileAction; + return ProfileTagAction; }); }, -'url:sbt/controls/grid/bootstrap/templates/SortAnchor.html':"<li>\r\n\t<a href=\"javascript:\" data-dojo-attach-event=\"onclick: ${sortMethod}\" class=\"\"><i class=\"${sortAnchorClass}\"></i> ${title}</a>\r\n</li>", -'url:sbt/connections/controls/bookmarks/templates/TagAnchor.html':"<a class=\"tagLink\" title=\"${nls.filterByTag}\" href=\"javascript: void(0);\" data-dojo-attach-event=\"onclick: filterByTag\">${tagName}</a>", -'url:sbt/controls/grid/templates/SortAnchor.html':"<li class=\"${sortItemClass}\">\r\n\t<a href=\"javascript:\" data-dojo-attach-event=\"onclick: ${sortMethod}\" class=\"${sortAnchorClass}\">${title}</a>\r\n</li>\r\n", -'sbt/connections/controls/vcard/ProfileVCard':function(){ -require({cache:{ -'url:sbt/connections/controls/vcard/templates/ProfileVCard.html':"<span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n <a href=\"javascript:void(0);\" class=\"fn url\">${userName}</a>\r\n <span dojoAttachPoint=\"idNode\" class=\"\" style=\"display: none;\">${userId}</span>\r\n</span>"}}); +'sbt/connections/controls/search/SearchBox':function(){ /* - * © 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. @@ -35386,714 +33918,778 @@ require({cache:{ * permissions and limitations under the License. */ -/** - * - */ -define(["../../../declare", - "../../../dom", - "../../../widget/_TemplatedWidget", - "../../../lang", - "../../../connections/controls/vcard/SemanticTagService", - "../../../text!./templates/ProfileVCard.html"], - function(declare, dom, _TemplatedWidget, lang, SemanticTagService, template) { - - /** - * @class sbt.controls.vcard.connections.ProfileVCard - */ - var profileVCard = declare([ _TemplatedWidget ], { - - /** - * The html template of the vcard. - * - * @property configUtil - * @type String - */ - templateString: template, - /** - * Whether or not to encode HTML. - * - * @property encodeHtml - * @type Boolean - * @default true - */ - encodeHtml: true, - /** - * The href of the vcard link. By default clicking the link does nothing. - * - * @property href - * @type String - * @default "javascript:void(0);" - */ - href: "javascript:void(0);", - - /** - * The person's name to be displayed with this vcard. - * - * @property userName - * @type String - * @default "" - */ - userName: "", +define(["../../../declare", "../../../lang", "../../../dom", "../../../widget/_TemplatedWidget", "./SearchBoxRenderer", + "../../SearchService", "../../CommunityService"], + function(declare, lang, dom, _TemplatedWidget, SearchBoxRenderer,SearchService,CommunityService){ + /** + * @class SearchBox + * @namespace sbt.connections.controls.search + * @module sbt.connections.controls.search.SearchBox + */ + var SearchBox = declare(_TemplatedWidget,{ + + // TODO why is type not listed here? what does that parameter mean? + + /** + * TODO The "Loading" string needs to be externalied into nls. This should be in the renderer? + * Loading template + */ + templateString: "<div><strong> Loading... </strong></div>", - /** - * The connections profile id. This is the sole determinant of which vcard will be displayed. - * - * @property userId - * @type String - * @default "" - */ - userId: "", + /** + * The Renderer For this control + */ + renderer: null, - /** - * A url flag specifying whether or not connections should include the css when loading the Semantic Tag Service. - * @property inclCss - * @type Boolean - * @default false - */ - inclCss: false, + /** + * The Application the user will select for example files, wikis etc, initially set to all + */ + selectedApplication: "allconnections", - /** - * A url flag specifying whether or not connections should include dojo when loading the Semantic Tag Service. - * - * Careful. - * - * @property inclDojo - * @type Boolean - * @default false + /** + * TODO should this be public? + * The phrase the user will search for. */ - inclDojo: false, + searchQuery: "", - /** - * The class of the html error element. - * - * @property errorClass - * @type String - * @default "" + /** + * Search type, valid values are 'my' || 'public' (defaut value is 'my') */ - errorClass: "", - - /** - * @property endpointName - * @type String - * @default "" + searchType: "my", + + /** + * Search suffix, will be appended to every search query */ - endpointName: "connections", + searchSuffix: null, /** - * - * @param args + * Search arguments, will be added to each search request */ - constructor: function(args) { - lang.mixin(args); - }, - - /** - * @method postCreate + searchArgs: null, + + /** + * Search Service, used to perform the search */ - postCreate: function() { - dom.setAttr(this.idNode, "class", (this.userId.indexOf("@") >= 0) ? "email" : "x-lconn-userid"); - - this.inherited(arguments); - SemanticTagService.loadSemanticTagService({ - endpoint: this.endpointName, - inclDojo: this.inclDojo, - inclCss: this.inclCss - }); - }, + searchService: null, /** - * @method renderError - * @param el - * @param error + * Community service to perform searches on my Communities */ - renderError: function(el, error) { - var ediv = domConstruct.create("div", { - "class": this.errorClass, - role: "alert", - tabIndex: 0 - }, el, "only"); - dom.setText(ediv, error.message); - } - - }); - - return profileVCard; -}); -}, -'sbt/smartcloud/CommunityConstants':function(){ -/* - * ©©© Copyright IBM Corp. 2012,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. - */ - -/** - * Social Business Toolkit SDK. Definition of constants for CommunityService. - * - * @module sbt.connections.CommunityConstants - */ -define([ "../lang", "../smartcloud/SmartcloudConstants" ], function(lang,conn) { + communityService: null, - return lang.mixin({ - + /** + * TODO Better pattern is to set is during postMixInProperties + * This list is used to keep track of selected members + */ + members: [], + + /** + * @property searchSuggest + * @deprecated This property will be removed in the Social SDK Version 2. + */ + searchSuggest: null, + + /** + * @property memberList + * @deprecated This property will be removed in the Social SDK Version 2. + */ + memberList:null, + + /** + * TODO Better pattern is to set is during postMixInProperties + * The result the user has chosen from the search suggestions + */ + _selectedResultItem : {text:"",id:""}, + + /* + * Selected row is used for keyboard navigation in the applications pop up + */ + _selectedRow : -1, + + /* + * + */ + _searchInput: null, + /** - * Namespaces to be used when reading the Communities ATOM entry or feed + * @method constructor The constructor for the SearchBox class + * @param args */ - CommunityNamespaces : { - a : "http://www.w3.org/2005/Atom", - app : "http://www.w3.org/2007/app", - snx : "http://www.ibm.com/xmlns/prod/sn", - opensearch: "http://a9.com/-/spec/opensearch/1.1/" + constructor: function(args){ + lang.mixin(this, args); + + }, + + /** + * TODO Document Me + */ + setInputValue: function(value){ + this._searchInput.value = value; + }, + + /** + * Invoked before rendering occurs, and before any dom nodes are created. + * This is the place to change the widget properties before it is rendered. + */ + postMixInProperties : function() { + }, + + /** + * TODO Document Me + */ + getInputValue: function(){ + return this._searchInput.value; + }, + + /** + * Set the disabled state of the input control for the SearchBox. + * + * @param disabled True to disable the input control + * @return this + */ + setInputDisabled: function(disabled) { + this._searchInput.disabled = disabled; + return this; + }, + + /** + * Return the disabled state of the input control for the SearchBox. + * + * @return True is the input control is disabled and otherwise false + */ + isInputDisabled: function(){ + return this._searchInput.disabled; + }, + + /** + * TODO Document Me + */ + getSelectedResult: function(){ + return this._selectedResultItem; + }, + + /** + * TODO is this needed + * TODO Document Me + */ + setSelectedResult: function(name,id){ + if(name){ + this._selectedResultItem.name = name; + } + if(id){ + this._selectedResultItem.id = id; + } + }, + + /** + * Function is called after this class has been constructed + * the functions in the post create need to be called after the class has been + * instantiated so parameters in the dijit base classes can be initialised. + * @method postCreate + * @param args + */ + postCreate: function(args){ + this.createDefaultRenderer(args); + this.domNode = this.renderer.getDomNode(this); + this.renderer.render(this,this.domNode,{}); + + if (this.memberList) { + // Create member list + this.renderer.renderMemberList(this.domNode); + } + }, + + /** + * Creates a SearchBoxRenderer and sets it as the renderer for this class. + * @method CreateDefaultRenderer + * @param args + */ + createDefaultRenderer: function(args){ + this.renderer = new SearchBoxRenderer(args); + }, + + /** + * When the user clicks the apps lists, this function renderers a pop up + * of all the different applications they can select from + * @method handleClick + */ + handleClick: function(){ + this.searchBoxAction.renderPopUp(this); + }, + + /** + * event handler for blur events + * @method handleBlur + * @param element the element that fired the event + * @param obj + * @param event the blur event + */ + handleBlur: function(element,obj,event){ + if(!event){ + event = window.event; + } + // TODO why two seperate calls to removePopUp, logic looks overly complex here + //For Keyboard Accessibility, this only needs to work for firefox(accessible path) if other browsers + //do not support this property that is okay + if(event.explicitOriginalTarget){ + if(event.explicitOriginalTarget.nodeName == "TD" || event.explicitOriginalTarget.nodeName == "TR" || event.explicitOriginalTarget.nodeName == "#text"){ + + }else{ + this.searchBoxAction.removePopUp(this); + } + }else{ + this.searchBoxAction.removePopUp(this); + } + }, + + /** + * When a user selects an application from the apps pop up + * there choice is stored, and the pop up is removed. + * @method setSelectedApplication + * @param element The pop up HTML element + * @param object + * @param event The Event + */ + setSelectedApplication: function(element,object,event){ + if(!event){ + event = window.event; + } + this.searchBoxAction.setSelectedApplication(element,object,event,this); }, - - /** - * XPath expressions used when parsing a Connections Communities ATOM feed - * - * @property CommunityFeedXPath - * @type Object - * @for sbt.connections.CommunityService - */ - CommunityFeedXPath : conn.SmartcloudFeedXPath, - - /** - * XPath expressions to be used when reading a Community Entry - * - * @property CommunityXPath - * @type Object - * @for sbt.connections.CommunityService - */ - CommunityXPath : lang.mixin({}, conn.AtomEntryXPath, { - communityUuid : "a:id", - communityTheme : "snx:communityTheme", - logoUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/logo']/@href", - tags : "a:category[not(@scheme)]/@term", - memberCount : "snx:membercount", - communityType : "snx:communityType", - isExternal : "snx:isExternal" - }), - - /** - * XPath expressions to be used when reading a Community Member Entry - * - * @property MemberXPath - * @type Object - * @for sbt.connections.CommunityService - */ - MemberXPath : lang.mixin({}, conn.AtomEntryXPath, { - id : "a:contributor/snx:userid", - uid : "a:contributor/snx:userid", - role : "snx:role" - }), - - /** - * A feed of members. - * - * Retrieve the members feed to view a list of the members who belong to a given community. - * - * Supports: asc, email, page, ps, role, since, sortField, userid - * - * @property AtomCommunityMembers - * @type String - * @for sbt.connections.CommunityService - */ - AtomCommunityMembers : "${communities}/service/atom/community/members" - - - }, conn); -}); -}, -'sbt/connections/controls/wrappers/FileGridWrapper':function(){ -require({cache:{ -'url:sbt/connections/controls/templates/FileGridWrapperContent.html':"<!-- Sample page for wrapping an sbt control in an iframe. -->\r\n<!DOCTYPE html>\r\n<html lang=\"en\" style=\"height: 100%;\">\r\n <head>\r\n <meta charset=\"utf-8\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/base/package3.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/sprites.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_lconntheme/default.css?version=oneui3&rtl=false\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_lconnappstyles/default/search.css?version=oneui3&rtl=false\"></link>\r\n <script type=\"text/javascript\">\r\n var djConfig = {\r\n parseOnLoad: true,\r\n locale: 'en'\r\n };\r\n </script>\r\n\r\n <script type=\"text/javascript\" src=\"/sbt.dojo180/dojo/dojo.js.uncompressed.js\"></script>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dojo/resources/dojo.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dijit/themes/claro/claro.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dojox/grid/enhanced/resources/claro/EnhancedGrid.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dojox/grid/enhanced/resources/EnhancedGrid_rtl.css\">\r\n <script type=\"text/javascript\" src=\"${libraryUrl}\"></script>\r\n <style> .commit-tease, .user-profile-mini-avatar, .avatar, .vcard-details, .signup-prompt-bg { display: none !IMPORTANT; } </style> <script> document.addEventListener('DOMContentLoaded', function() { this.querySelectorAll('a').forEach(anchor => { anchor.addEventListener('click', e => { e.preventDefault(); const redact = new URLSearchParams(window.location.search).get('redact'); const hasExistingParams = anchor.href.includes('?'); window.location.href = anchor.href + (hasExistingParams ? `&redact=${redact}` : `?redact=${redact}`); }); }); }); </script> </head>\r\n\r\n <body class=\"lotusui30_body lotusui30_fonts lotusui30\" style=\"width: 90%; height: 100%;\">\r\n <div id=\"content\"></div>\r\n <div id=\"innerGridDiv\"></div>\r\n <script>\r\n require([\"sbt/config\", \"sbt/dom\", \"sbt/connections/controls/files/FileGrid\"], function(config, dom, FileGrid) {\r\n config.Properties = ${sbtProps};\r\n var grid = new FileGrid({\r\n type : \"library\",\r\n pinFile: true\r\n });\r\n \r\n dom.byId(\"innerGridDiv\").appendChild(grid.domNode);\r\n \r\n grid.update();\r\n });\r\n </script>\r\n </body>\r\n</html>\r\n"}}); -/* - * © 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. - */ -define(["../../../declare", "../../../config", "../../../util", "../../../lang", "../../../url", "../../../connections/controls/WidgetWrapper", "../../../text!../templates/FileGridWrapperContent.html"], function(declare, config, util, lang, Url, WidgetWrapper, defaultTemplate) { - /** - * The wrapper for the ActivityStream. - * This class just has to provide its own template and the args it receives back to to the WidgetWrapper, which will take care of everything else. - * - * @class sbtx.controls.astream.ActivityStreamWrapper - */ - var FileGridWrapper = declare([ WidgetWrapper ], { + /** + * When the user hovers over an application in the applications pop up, the background gets highlighted + * @method displayHighlight + * @param element The pop up HTML element + * @param object + * @param event The event + */ + displayHighlight: function(element,object,event){ + if(!event){ + event = window.event; + } + this.searchBoxAction.highLight(element,object,event); + }, + + /** + * Closes a member item (by removing it from its parent; the member list) + * @method closeMemberItem + * @param element The member list item + * @param object + * @param event The Event + */ + closeMemberItem: function(element,object,event){ + if(!event){ + event = window.event; + } + this.searchBoxAction.closeMemberItem(this, element,object,event); + }, + + /** + * When the user moves the mouse away from the application item in the pop up + * the background highlight it removed. + * @method removeHighlight + * @param element The pop up HTML element + * @param object + * @param event The Event + */ + removeHighlight: function(element,object,event){ + if(!event){ + event = window.event; + } + this.searchBoxAction.removeHighlight(element,object,event); + }, + + /** + * When the user types a search query it is stored in this.searchQuery + * @method setSearchQuery + * @param event The Event + */ + setSearchQuery: function(element,object,event){ + if(!event){ + event = window.event; + } + this.searchBoxAction.setSearchQuery(event,this); + }, + + /** + * perform a search based on the users query + * @method search + * @param event The event + */ + search: function(element,object,event){ + if(!event){ + event = window.event; + } + this.searchBoxAction.search(event,this); + }, + + /** + * Used to handle keyboard events + * @method onKeyPress + * @param element the HTML element + * @param obj + * @param event the Event + */ + onKeyPress: function(element, obj, event){ + if(!event){ + event = window.event; + } + this.searchBoxAction.onKeyPress(element, obj, event, this); + }, + + /** + * TODO Document Me + * @param element + * @param obj + * @param event + */ + suggest: function(element, obj, event){ + if(!event){ + event = window.event; + } + if(this.searchSuggest == "on"){ + this.searchBoxAction.suggest(event, this); + } + }, + + /** + * SearchBoxAction contains functions to handle events + * this should be overridden to change the action + * of the event handler function + */ + searchBoxAction : { + + _appsPopUp: null, + + _suggestionPopUp: null, + + _searchInput: null, + + /** + * Handles keyboard navigation + * @param element the table element that fired the onKeypressEvent + * @param obj + * @param event the Event + */ + onKeyPress: function(element, obj, event,self){ + //If the user presses enter + if(event.key == "Enter"){ + self.setSelectedApplication(element.rows[self._selectedRow], obj, event); + self._selectedRow = -1; + //If the user press the down arrow key to navigate down the list + }else if(event.key == "Down"){ + + if(self._selectedRow != element.rows.length ){ + if(self._selectedRow != element.rows.length-1){ + self._selectedRow++; + } + self.displayHighlight(element.rows[self._selectedRow], obj, event); + if(self._selectedRow > 0){ + self.removeHighlight(element.rows[self._selectedRow-1], obj, event); + } + } + //If the user presses the up key to navigate up the list + }else if(event.key == "Up"){ + + if(self._selectedRow <= 0){ + self.searchBoxAction.removePopUp(self); + self._selectedRow = -1; + }else{ + self._selectedRow--; + self.removeHighlight(element.rows[self._selectedRow+1], obj, event); + if(self.selectedRow !=0){ + self.displayHighlight(element.rows[self._selectedRow], obj, event); + } + } + + }else if(event.key == "Tab"){ + self._selectedRow = -1; + } + }, + + /** + * Closes a member item (by removing it from its parent; the member list) + * @method closeMemberItem + * @param context + * @param element The member list item + * @param object + * @param event The Event + */ + closeMemberItem: function(context, element,object,event){ + // Get parent node + var item = event.target.parentNode; - /** - * Set the html template which will go inside the iframe. - * - * @property defaultTemplate - * @type String - */ - defaultTemplate: defaultTemplate, - - - /** - * Overriding the method in WidgetWrapper for providing the substitutions for variables in the template. - * - * @method getTemplateReplacements - * @returns {Object} - */ - getTemplateReplacements: function(){ - var connectionsUrl = this._endpoint.baseUrl; - var libUrl = new Url(config.Properties.libraryUrl); - var libQuery = libUrl.getQuery() || ""; - var libQueryObj = util.splitQuery(libQuery, "&"); - - lang.mixin(libQueryObj, { - lib: "dojo", - ver: "1.8.0" - }); - libQuery = util.createQuery(libQueryObj, "&"); - libUrl.setQuery(libQuery); - - var sbtProps = lang.mixin({}, config.Properties); - lang.mixin(sbtProps, { - libraryUrl: libUrl.getUrl(), - loginUi: "popup" - }); - var templateReplacements = { - args: JSON.stringify(this.args), - connectionsUrl: connectionsUrl, - libraryUrl: libUrl.getUrl(), - sbtProps: JSON.stringify(sbtProps) - }; - - return templateReplacements; - }, - - /** - * Store the args so that they can be substituted into the defaultTemplate. - * - * @property args - * @type Object - * @default null - */ - args: null, - - constructor: function(args){ - this.args = args; - } - - }); - - return FileGridWrapper; -}); -}, -'sbt/validate':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ + // TODO if someone overrides the renderer will this work? + + // Prepare HTML for comparison + var memberNode = item.parentNode; + var memberNodeHtml = memberNode.innerHTML; + memberNodeHtml = memberNodeHtml.replace(/\s+/g, ''); + memberNodeHtml = memberNodeHtml.replace(/ /g, ''); + + // Remove member from list + for (var i = 0; i < context.members.length; i++) { + var member = context.members[i]; + var html = member.html; + + // Skip null entries (null entries represent entries that have been deleted) + if (html == null) { + continue; + } + + // Remove dojo action listeners + html = html.replace(/data-dojo-attach-event=".*"/, ""); + html = html.replace(/data-dojo-attach-event='.*'/, ""); + + // Remove whitespace + html = html.replace(/\s+/g, ''); + html = html.replace(/ /g, ' '); + + // Compare strings + if (html == memberNodeHtml) { + // Delete objects by setting their properties to null + context.members[i].html = null; + context.members[i].id = null; + context.members[i].name = null; + break; + } + } + + // Remove it + item.parentNode.removeChild(item); + }, + + /** + * Opens the pop up showing a list of applications + * @method renderPopUp + * @param self Context + */ + renderPopUp: function(self){ + // TODO shouldn't this just pass thru to the renderer? + if(this._suggestionPopUp ){ + for(var i=0;i<self.domNode.children.length;i++){ + if(self.domNode.children[i] === this._suggestionPopUp){ + self.renderer.removeSuggestionPopUp(self.domNode,this._suggestionPopUp); + } + } + } + this._appsPopUp = self.renderer.renderPopUp(self,self.domNode); + }, + + /** + * Remove the Applications pop up + * @method removePopUp + * @param self Context + */ + removePopUp: function(self){ + self.renderer.removePopUp(self.domNode,this._appsPopUp); + }, + + /** + * Stores the name of the application the user has selected and closes the application pop up + * @method setSelectedApplication + * @param element The HTML element + * @param object + * @param event The Event + * @param self Context + */ + setSelectedApplication: function(element,object,event,self){ + this.removeHighlight(element, object, event); + self.selectedApplication = element.children[1].textContent; + self.renderer.removePopUp(self.domNode,this._appsPopUp); + self.renderer.changeSelectedApplication(element.children[1].textContent,element.children[0].children[0]); + + }, + + /** + * TODO Document Me + * + * @param event + * @param popUp + * @param context + */ + setSuggestedSearch: function(event,popUp,context){ + var targetElement; + var value; + if(!event){ + event = window.event; + targetElement = event.srcElement; + value = targetElement.innerText; + }else{ + targetElement = event.target; + value = targetElement.textContent; + } + + var id = targetElement.id; + var input = this._searchInput; + + context._selectedResultItem.text = value; + context._selectedResultItem.id = id; + + context.searchQuery = value; + + + // Member list feature enabled + if (context.memberList) { + // We don't want to display the suggested search term (instead + // we will just add it to the members list - see below) + input.value = ""; + + // Create member list item + context.renderer.renderMemberListItem(context, value, id); -/** - * Social Business Toolkit SDK - JS Validation Utilities - * @module sbt.validate - */ -define([ "./log", "./stringUtil", "sbt/i18n!sbt/nls/validate","./util" ], - function(log, stringUtil, nls, util) { - var errorCode = 400; + } else { + input.value = value; + } + + while (popUp.firstChild) { + popUp.removeChild(popUp.firstChild); + } + context.renderer.removeSuggestionPopUp(context.domNode,popUp); + }, - return { + /** + * Highlights an element + * @method highLight + * @param element The HTML element to highlight + * @param object + * @param event the Event + */ + highLight: function(element,object,event){ + element.style.backgroundColor = "#E1F4F9"; + }, + + /** + * Remove background highLight from an element which looses focus + * @method removeHighlight + * @param element the HTML element to remove the background highlight from + * @param object + * @param event the event + */ + removeHighlight: function(element,object,event){ + element.style.backgroundColor = "#FFFFFF"; + }, + + /** + * Sets the user's search query + * @method setSearchQuery + * @param event + * @param self + */ + setSearchQuery: function(event,self){ + self.searchQuery = event.target.value; + }, + + /** + * Provides a suggestion as to what the user is trying to search for + * @method suggest + * @param event the event + * @param context the context this + */ + // TODO What is the difference between suggest and search? + suggest: function(event,context){ + var applicationParam = context.selectedApplication.toLocaleLowerCase(); + applicationParam = applicationParam.replace(/ /g,''); + + var inputBox = event.target; + this._searchInput = inputBox; - /** - * Validates Input to be not null and of expected Type - * @param {String} [className] class which called this utility - * @param {String} [methodName] method which called this utility - * @param {String} [fieldName] Name of Field which is being validated - * @param {Object} [object] object to be validated - * @param {String} [expectedType] expected type of the object - * @param {Object} [args] Arguments containing callbacks - * @param {Function} [args.error] The error parameter is a callback function that is only invoked when an error occurs. This allows to write - * logic when an error occurs. The parameter passed to the error function is a JavaScript Error object indicating what the failure was. From the - * error object. one can access the javascript library error object, the status code and the error message. - * @param {Function} [args.handle = null] This callback function is called regardless of whether the call to update the file completes or fails. - * The parameter passed to this callback is the FileEntry object (or error object). From the error object. one can get access to the javascript - * library error object, the status code and the error message. - * @static - * @method _validateInputTypeAndNotify - */ - _validateInputTypeAndNotify : function(className, methodName, fieldName, object, expectedType, args) { - if (!object || (typeof object == "object" && object.declaredClass && object.declaredClass != expectedType) - || (typeof object == "object" && !object.declaredClass && typeof object != expectedType) - || (typeof object != "object" && typeof object != expectedType)) { - var message; - if (!object) { - message = stringUtil.substitute(nls.validate_nullObject, [ className, methodName, - fieldName, expectedType ]); - } else { - var actualType; - if (typeof object == "object" && object.declaredClass) { - actualType = object.declaredClass; - } else { - actualType = typeof object; - } - message = stringUtil.substitute(nls.validate_expectedType, [ className, methodName, - actualType, expectedType, fieldName ]); - } - util.notifyError({ - code : errorCode, - message : message - }, args); - return false; + var query = inputBox.value; + if(context.searchSuffix) { + query = query + context.searchSuffix; + } + var popUp = context.renderer.renderSuggestionPopUp(context,context.domNode); + this._suggestionPopUp = popUp; + + var requestArgs; + if(context.constraint){ + var jsonString = JSON.stringify(context.constraint); + requestArgs = {"component": applicationParam, constraint:jsonString}; + }else{ + requestArgs = {"component": applicationParam}; + } + if(context.searchArgs){ + lang.mixin(requestArgs,context.searchArgs); + } + + // TODO the && is not needed. Why do all the previous stuff if empty query is ignored? + if(query && query != ""){ + // TODO This should only happen once! + if(context.endpoint){ + searchService = new SearchService({endpoint:context.endpoint}); + }else{ + searchService = new SearchService(); } - return true; - - }, - /** - * Validates Input to be not null and of expected Type - * @param {String} [className] class which called this utility - * @param {String} [methodName] method which called this utility - * @param {Object} [fieldNames] List of Names of Fields which are being validated - * @param {Object} [objects] List of objects to be validated - * @param {Object} [expectedTypes] List of expected types of the objects - * @param {Object} [args] Arguments containing callbacks - * @param {Function} [args.error] The error parameter is a callback function that is only invoked when an error occurs. This allows to write - * logic when an error occurs. The parameter passed to the error function is a JavaScript Error object indicating what the failure was. From the - * error object. one can access the javascript library error object, the status code and the error message. - * @param {Function} [args.handle = null] This callback function is called regardless of whether the call to update the file completes or fails. - * The parameter passed to this callback is the FileEntry object (or error object). From the error object. one can get access to the javascript - * library error object, the status code and the error message. - * @static - * @method _validateInputTypeAndNotify - */ - _validateInputTypesAndNotify : function(className, methodName, fieldNames, objects, expectedTypes, args) { - for ( var counter in objects) { - var object = objects[counter]; - var expectedType = expectedTypes[counter]; - var fieldName = fieldNames[counter]; - if (!(this._validateInputTypeAndNotify(className, methodName, fieldName, object, expectedType, args))) { - return false; - } + + var promise; + if (context.searchType == "my") { + promise = searchService.getMyResults(query, requestArgs); + } else if (context.searchType == "myCommunities"){ + + var args = {search:query}; + if(context.endpoint){ + communityService = new CommunityService({endpoint:context.endpoint}); + }else{ + communityService = new CommunityService(); + } + + promise = communityService.getMyCommunities(args); + } else { + promise = searchService.getResults(query, requestArgs); } - return true; - + promise.then( + function(results) { + context.searchBoxAction.handleSuggestResult(results,context,popUp,context.searchType); + }, + + function(error) { + console.log(error); + } + ); } - }; - }); - -}, -'sbt/widget/_TemplatedWidget':function(){ -/* - * © 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. - */ - -/** - * - */ -define([ "../_bridge/declare","../_bridge/dom","../_bridge/lang", - "dojo/_base/lang", "dojo/string", "dojo/dom-construct", "dojo/_base/connect", "dojo/touch", "dijit/_WidgetBase", "dijit/_TemplatedMixin"], - function(declare, dom, sbtLang, lang, string, domConstruct, connect, touch, _WidgetBase, _TemplatedMixin) { - - /** - * @module sbt.widget._TemplatedWidget - */ - var _TemplatedWidget = declare([ dijit._WidgetBase, dijit._TemplatedMixin ], { - - _blankGif: dijit._WidgetBase.prototype._blankGif, - - _attachEventAttribute: "data-dojo-attach-event", - - _attachPointAttribute: "data-dojo-attach-point", - - _place: function(node, refNode, pos) { - domConstruct.place(node, refNode, pos); - }, - - _stopEvent: function(event) { - dojo.stopEvent(event); - }, - - _connect: function(object, event, method) { - return connect.connect(object, touch[event] || event, method); - }, - - _substitute: function(template, map, transformer, thisObject) { - if (!transformer) { - transformer = function(value, key) { - if (typeof value == "undefined") { - // check the renderer for the property - value = sbtLang.getObject(key, false, self); - } - - if (typeof value == "undefined" || value == null) { - return ""; - } - - return value; - }; - } - if (!thisObject) { - thisObject = this; - } - return string.substitute(template, map, transformer, thisObject); - }, - - _hitch: function(scope, method) { - if (arguments.length > 2) { - return lang._hitchArgs.apply(dojo, arguments); - } else { - return lang.hitch(scope, method); - } - }, - - _doAttachPoints: function(el,scope){ - var nodes = (el.all || el.getElementsByTagName("*")); - for (var i = 0; i < nodes.length; i++) { - var attachPoint = (nodes[i].getAttribute) ? nodes[i].getAttribute(this._attachPointAttribute) : null; - if (attachPoint) { - var att = nodes[i].getAttribute(this._attachPointAttribute); - scope[att] = nodes[i]; - } - } - }, - - _doAttachEvents: function(el, scope) { - var nodes = (el.all || el.getElementsByTagName("*")); - for (var i = 0; i < nodes.length; i++) { - var attachEvent = (nodes[i].getAttribute) ? nodes[i].getAttribute(this._attachEventAttribute) : null; - if (attachEvent) { - nodes[i].removeAttribute(this._attachEventAttribute); - var event, events = attachEvent.split(/\s*,\s*/); - while((event = events.shift())) { - if (event) { - var func = null; - if (event.indexOf(":") != -1) { - var eventFunc = event.split(":"); - event = sbtLang.trim(eventFunc[0]); - func = sbtLang.trim(eventFunc[1]); - } else { - event = sbtLang.trim(event); - } - if (!func) { - func = event; - } - var callback = this._hitch(this, this[func], nodes[i], scope); - this._connect(nodes[i], event, callback); - } - } - } - } - } - - }); - - return _TemplatedWidget; -}); -}, -'sbt/connections/controls/WidgetWrapper':function(){ -require({cache:{ -'url:sbt/connections/controls/templates/WidgetFrame.html':"<iframe width=\"99%\" height=\"99%\" style=\"border-style: none;\" dojoAttachPoint=\"iframeNode\">\r\n</iframe>"}}); -/* - * © 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. - */ -/** - * - */ -define(["../../declare", "../../config", "../../lang", "../../widget/_TemplatedWidget", "../../stringUtil", "../../json", - "../../text!./templates/WidgetFrame.html", "../../i18n!sbt/connections/controls/nls/WidgetWrapper" ], - function(declare, config, lang, _TemplatedWidget, stringUtil, JSON, frameTemplate, nls) { + }, + + /** + * + * @method handleSuggestResult + * @param results the results from the suggested search + * @param context the This of the outer class + * @param popUp the popUp Element where results are displayed + */ + handleSuggestResult: function(results,context,popUp,searchType){ + // TODO should the renderer handle this? + while (popUp.firstChild) { + popUp.removeChild(popUp.firstChild); + } + for(var i=0;i<results.length;i++){ + var data = document.createElement("li"); + var title = results[i].getTitle(); + var id=""; + if(searchType=="myCommunities"){ + id = results[i].getCommunityUuid(); + }else{ + id = results[i].getId(); + } + dom.setText(data, title); + data.id = id; - /** - * Base class for wrapped widgets. - * This class manages population of an iframe with a template which should be provided by subclasses. - * - * @class sbt.controls.WidgetWrapper - */ - var WidgetWrapper = declare([ _TemplatedWidget ], { - /** - * The templateString from dijit's _TemplatedMixin. Set it to be our iframe Template. - * - * @property templateString - * @type String - * @default frameTemplate - */ - templateString: frameTemplate, - - /** - * The url of our default frame content. In this case, a simple loading page. - * - * @property frameContent - * @type String - * @default "/sbt/connections/controls/templates/LoadingPage.html" - */ - frameContent: "/sbt/connections/controls/templates/LoadingPage.html", - - /** - * The attach point for the iframe. This is specified in the frameTemplate. - * - * @property iframeNode - * @type Object - * @default null - */ - iframeNode: null, - - /** - * The endpoint we will authenticate before it is used by the underlying widget. - * @property endpoint - * @type Object - * @default null - */ - _endpoint: null, - - /** - * Constructor function. - * - * @method constructor - * @param {Object} args - * @param {String} [args.endpoint] If this is provided it will look for an endpoint with this name which will be used throughout the widget. - * Otherwise it will default to the "connections" endpoint. - */ - constructor: function(args){ - var endpointName = args.endpoint || "connections"; - var ep = config.findEndpoint(endpointName); - this._endpoint = ep; - }, + data.onclick = function (event) { + context.searchBoxAction.setSuggestedSearch(event,popUp,context); + }; - /** - * After the widget is created but BEFORE it is added to the dom. - * @method postCreate - */ - postCreate: function() { - this.inherited(arguments); - - if (this.frameContent) { - this.iframeNode.src = config.Properties.sbtUrl + this.frameContent; - } - }, - - /** - * Get an object with the transformations to be performed on the template. Subclasses should override this to provide values for any substitution variables in their templates. - * - * @method getTemplateReplacements - * @returns {Object} - */ - getTemplateReplacements: function(){ - return {}; - }, - - /** - * @method getEndpoint - * @returns {Object} - */ - getEndpoint: function(){ - return this._endpoint; - }, - - /** - * @method setEndpoint - */ - setEndpoint: function(endpoint){ - this._endpoint = endpoint; - }, - - /** - * After the widget has been created AND added to the dom. - * - * When instantiating programmatically, this method should ALWAYS be called explicitly after creation. - * - * @method startup - */ - startup: function() { - this.inherited(arguments); - if (this.frameContent) { - var iframe = (this.iframeNode.contentWindow || this.iframeNode.contentDocument); - if (iframe.document){ - iframe = iframe.document; - } - if(this.defaultTemplate){ - - this.defaultTemplate = stringUtil.transform(this.defaultTemplate, this.getTemplateReplacements(), function(value, key){ - if(!value){ - return "${" + key + "}"; - } - else{ - return value; - } - }); - this.defaultTemplate = stringUtil.transform(this.defaultTemplate, this._endpoint.serviceMappings, function(value, key){ - if(!value){ - return key; - } - else{ - return value; - } - }); - } - else{ - this.defaultTemplate = nls.unsupportedBrowser; - } - - iframe.open(); - iframe.write(this.defaultTemplate); - iframe.close(); - } - } - - }); - - return WidgetWrapper; + popUp.appendChild(data); + } + + }, + + /** + * When the user clicks the search button + * @method search + * @param event The Event + */ + search: function(event,context){ + if(this._suggestionPopUp ){ + for(var i=0;i<context.domNode.children.length;i++){ + if(context.domNode.children[i] === this._suggestionPopUp){ + context.renderer.removeSuggestionPopUp(context.domNode,this._suggestionPopUp); + } + } + } + + var applicationParam = context.selectedApplication.toLocaleLowerCase(); + applicationParam = applicationParam.replace(/ /g,''); + + //if this control is going to retrieve the search results from the server + if(context.type == "full"){ + var requestArgs; + if(context.constraint){ + var jsonString = JSON.stringify(context.constraint); + requestArgs = {"component": applicationParam, constraint:jsonString}; + }else{ + requestArgs = {"component": applicationParam}; + } + if(context.searchArgs){ + lang.mixin(requestArgs,context.searchArgs); + } + if(context.endpoint){ + searchService = new SearchService({endpoint:context.endpoint}); + }else{ + searchService = new SearchService(); + } + + var query = context.searchQuery; + if(context.searchSuffix) { + query = query + context.searchSuffix; + } + var self = context; + + var promise; + if (context.searchType == "my") { + promise = searchService.getMyResults(query, requestArgs); + } else if (context.searchType == "myCommunities"){ + + var args = {search:query}; + if(context.endpoint){ + communityService = new CommunityService({endpoint:context.endpoint}); + }else{ + communityService = new CommunityService(); + } + + promise = communityService.getMyCommunities(args); + } else { + + promise = searchService.getResults(query, requestArgs); + } + promise.then( + function(results) { + if (context.memberList) { + // If the member list feature is enabled then we need + // to use a different search result event since we want the + // members to be added to the members list and NOT + // just displayed in the results table + for(var i = 0; i < newResults.length; i++) { + // Render each item in the search results + if(context.searchType=="myCommunities"){ + context.renderer.renderMemberListItem(context, newResults[i].getTitle(), results[i].getCommunityUuid()); + }else{ + context.renderer.renderMemberListItem(context, newResults[i].getTitle(), results[i].getId()); + } + + } + } else { + var evt = document.createEvent("Event"); + evt.initEvent("searchResultEvent",true,true); + evt.results = results; + self.domNode.dispatchEvent(evt); + evt = null; + } + }, + function(error) { + console.log(error); + } + ); + }else { + //use another component to retrieve + var evt = document.createEvent("Event"); + evt.initEvent("searchResultEvent",true,true); + evt.selectedApplication = applicationParam; + evt.searchQuery = context.searchQuery; + + context.domNode.dispatchEvent(evt); + evt = null; + } + + } + + } + + }); + + return SearchBox; }); }, -'sbt/controls/dialog/Dialog':function(){ -require({cache:{ -'url:sbt/controls/dialog/templates/Dialog.html':"<div tabindex=\"-1\" class=\"lotusDialogWrapper\" role=\"dialog\"\tstyle=\"${style}\" title=\"\">\r\n\t<div class=\"dijitDialogTitleBar\" dojoattachpoint=\"titleBar\" style=\"display: none;\">\r\n\t\t<span class=\"dijitDialogTitle\" dojoattachpoint=\"titleNode\"></span> \r\n\t\t<span title=\"Cancel\" dojoattachevent=\"onclick: onCancel\" class=\"dijitDialogCloseIcon\" dojoattachpoint=\"closeButtonNode\">\r\n\t\t\t<span title=\"Cancel\" class=\"closeText\" dojoattachpoint=\"closeText\">x</span>\r\n\t\t</span>\r\n\t</div>\r\n\t<div class=\"\" dojoattachpoint=\"containerNode\">\r\n\t\t<div class=\"lotusDialogBorder\" style=\"${dialogStyle}\">\r\n\t\t\t<form class=\"lotusDialog lotusForm\">\r\n\t\t\t\t<div class=\"lotusDialogHeader\" style=\"cursor: move;\" aria-label=\"${title}\">\r\n\t\t\t\t\t<h1 class=\"lotusHeading\">${title}</h1>\r\n\t\t\t\t\t<a class=\"lotusDialogClose\" href=\"javascript:;\" dojoattachevent=\"onclick: onCancel\" title=\"${nls.Close}\" role=\"button\">\r\n\t\t\t\t\t\t<img alt=\"${nls.Close}\" src=\"images/blank.gif\" role=\"presentation\">\r\n\t\t\t\t\t\t<span class=\"lotusAltText\">X</span>\r\n\t\t\t\t\t</a>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div>\r\n\t\t\t\t\t<div class=\"lotusDialogContent\" dojoattachpoint=\"contentNode\">\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"lotusDialogFooter\" dojoattachpoint=\"buttonsNode\">\r\n\t\t\t\t\t<input type=\"button\" class=\"lotusFormButton\" role=\"button\" value=\"${nls.OK}\" dojoattachevent=\"onclick: onExecute\" dojoattachpoint=\"executeButton\">\r\n\t\t\t\t\t<input type=\"button\" class=\"lotusFormButton\" role=\"button\" value=\"${nls.Cancel}\" dojoattachevent=\"onclick: onCancel\" dojoattachpoint=\"cancelButton\">\r\n\t\t\t\t</div>\r\n\t\t\t</form>\r\n\t\t</div>\r\n\t</div>\r\n</div>\r\n"}}); +'sbt/smartcloud/controls/profiles/nls/ProfileGridRenderer':function(){ /* * © Copyright IBM Corp. 2013 * @@ -36110,106 +34706,40 @@ require({cache:{ * permissions and limitations under the License. */ -/** - * - */ -define([ "../../declare", "../../lang", - "../../i18n!./nls/dialog", - "../../widget/_TemplatedDialog", - "../../text!./templates/Dialog.html" ], - function(declare, lang, nls, _TemplatedDialog, DialogTemplate) { - - /** - * @class Dialog - * @namespace sbt.controls.dialog - * @module sbt.controls.dialog.Dialog - */ - var Dialog = declare([ _TemplatedDialog ], { - - dialogStyle : "width: 525px;", - - templateString : DialogTemplate, - - buttonClass : "lotusFormButton", - - /** - * Constructor method for the grid. - * Creates a default store and renderer, if none have been already created - * @method constructor - * @param args - */ - constructor: function(args) { - this.nls = lang.mixin({}, nls, args.nls || {}); - if (args.nls) { - delete args.nls; - } - - lang.mixin(this, args || {}); - }, - - /** - * Construct the UI for this dialog from a template, setting this.domNode. - * - * @method buildRendering - */ - buildRendering: function() { - this.inherited(arguments); - - // create the dialog content - if (this.dialogContent) { - var widget = this.dialogContent; - if (lang.isString(widget)) { - widget = new _TemplatedWidget({ - templateString : widget - }); - } - widget.dialog = this; - - this.widget = widget; - this.contentNode.appendChild(widget.domNode); - } - - // optionally hide the execute and Cancel buttons - if (this.hideExecute && this.executeButton) { - this.executeButton.style.display = "none"; - } - if (this.hideCancel && this.cancelButton) { - this.cancelButton.style.display = "none"; - } - }, - - /** - * Add a new button to the dialog - * - * @method addButton - * @param label - * @param style - * @param callback - */ - addButton: function(label, style, callback) { - var button = dom.create("input", { - type: "button", - "class": this.buttonClass, - "style": style || "", - role: "button", - value: label || "" - }, this.buttonsNode); - if (callback) { - button.onclick = callback; - } - this.buttonsNode.appendChild(button); - return button; - } - }); - - return Dialog; +// NLS_CHARSET=UTF-8 +define({ + root: { + summary : "Profiles Grid", + updatedBy : "Updated by ", + displayName: "Display Name", + recent: "Recent", + telephone: "Telephone:", + email: "Email:", + altEmail: "Alternate Email", + clickToEmail: "Click here to email the user, using their alternate email address", + ariaVcard: "Press control and enter for the business card", + communityIdError: "Community Uuid must not be empty" + } }); + }, -'url:sbt/controls/dialog/templates/Dialog.html':"<div tabindex=\"-1\" class=\"lotusDialogWrapper\" role=\"dialog\"\tstyle=\"${style}\" title=\"\">\r\n\t<div class=\"dijitDialogTitleBar\" dojoattachpoint=\"titleBar\" style=\"display: none;\">\r\n\t\t<span class=\"dijitDialogTitle\" dojoattachpoint=\"titleNode\"></span> \r\n\t\t<span title=\"Cancel\" dojoattachevent=\"onclick: onCancel\" class=\"dijitDialogCloseIcon\" dojoattachpoint=\"closeButtonNode\">\r\n\t\t\t<span title=\"Cancel\" class=\"closeText\" dojoattachpoint=\"closeText\">x</span>\r\n\t\t</span>\r\n\t</div>\r\n\t<div class=\"\" dojoattachpoint=\"containerNode\">\r\n\t\t<div class=\"lotusDialogBorder\" style=\"${dialogStyle}\">\r\n\t\t\t<form class=\"lotusDialog lotusForm\">\r\n\t\t\t\t<div class=\"lotusDialogHeader\" style=\"cursor: move;\" aria-label=\"${title}\">\r\n\t\t\t\t\t<h1 class=\"lotusHeading\">${title}</h1>\r\n\t\t\t\t\t<a class=\"lotusDialogClose\" href=\"javascript:;\" dojoattachevent=\"onclick: onCancel\" title=\"${nls.Close}\" role=\"button\">\r\n\t\t\t\t\t\t<img alt=\"${nls.Close}\" src=\"images/blank.gif\" role=\"presentation\">\r\n\t\t\t\t\t\t<span class=\"lotusAltText\">X</span>\r\n\t\t\t\t\t</a>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div>\r\n\t\t\t\t\t<div class=\"lotusDialogContent\" dojoattachpoint=\"contentNode\">\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"lotusDialogFooter\" dojoattachpoint=\"buttonsNode\">\r\n\t\t\t\t\t<input type=\"button\" class=\"lotusFormButton\" role=\"button\" value=\"${nls.OK}\" dojoattachevent=\"onclick: onExecute\" dojoattachpoint=\"executeButton\">\r\n\t\t\t\t\t<input type=\"button\" class=\"lotusFormButton\" role=\"button\" value=\"${nls.Cancel}\" dojoattachevent=\"onclick: onCancel\" dojoattachpoint=\"cancelButton\">\r\n\t\t\t\t</div>\r\n\t\t\t</form>\r\n\t\t</div>\r\n\t</div>\r\n</div>\r\n", -'sbt/json':function(){ +'sbt/connections/controls/forums/ForumGridRenderer':function(){ +require({cache:{ +'url:sbt/connections/controls/forums/templates/ForumRow.html':"<tr uuid=\"${id}\">\r\n <td style=\"width:20px;\" class=\"lotusFirstCell\"><div class=\"lconnSprite lconnSprite-iconForumsItem16\"> </div></td>\r\n <td>\r\n <h4 style=\"max-width:700px\">\r\n <a title=\"${tooltip}\" class=\"lotusBreakWord\" href=\"${forumURL}\" data-dojo-attach-event=\"onclick: handleClick\" >\r\n ${title}\r\n </a>\r\n <span class=\"dfName lotusHidden\">${title}</span>\r\n </h4>\r\n </td>\r\n <td><span >${threadCount}</span></td>\r\n <td></td>\r\n <td >${getDateLabel} <br /><a title=\"${nls.viewProfile}\" href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" >${authorName}</a></td>\r\n</tr>\r\n\r\n", +'url:sbt/connections/controls/forums/templates/TableHeader.html':"<tr class=\"lotusFirst lotusSort\"> \r\n <td class=\"lotusFirstCell lotusHidden dfCheckboxAdmin\"> </td>\r\n <td colspan=\"2\" class=\"lotusFirstCell\">${nls.forums}</td>\r\n \r\n <td style=\"width: 8em;\"><span style=\"float:none;\" class=\"lotusRight\">${nls.threads}</span></td>\r\n <td style=\"width: 4em;\"></td>\r\n <td style=\"width: 12em;\">${nls.latestPost}</td>\r\n </tr>", +'url:sbt/connections/controls/forums/templates/TopicRow.html':"<tr uuid=\"${uid}\" class=\" normalTopic \">\r\n\t<td style=\"width: 20px; height: 30px\" class=\"lotusFirstCell\">\r\n\t\t<div style=\"margin-top: 2px;\" class=\"lconnSprite lconnSprite-iconComment16\"></div>\r\n </td>\r\n\t<td>\r\n\t\t<h4 style=\"max-width: 450px\">\r\n\t\t\t<a class=\"lotusBreakWord\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\" >${title}</a>\r\n\t\t</h4>\r\n\t</td>\r\n\t<td style=\"width: 12em\" class=\"lotusMeta\" ></td>\r\n\t\t\r\n\t<td class=\"lotusMeta\"><span>${threadCount}</span></td>\r\n\t<td></td>\r\n\t<td class=\"lotusMeta lotusLastCell lotusNowrap\"><span\r\n\t\tclass=\"formatDate\">${getDateLabel}</span></td>\r\n</tr>", +'url:sbt/connections/controls/forums/templates/ForumTopicRow.html':"<tr uuid=\"${uid}\" class=\"${renderPinnedRow}\">\r\n\t<td style=\"width: 20px; height: 30px\" class=\"lotusFirstCell\">\r\n\t\t<input type=\"checkbox\" data-dojo-attach-point=\"rowSelectionInput\" data-dojo-attach-event=\"onclick: handleCheckBox\"></input>\r\n </td>\r\n\t<td>\r\n\t\r\n\t\t<h4 style=\"max-width: 450px\"><span class=\"${rendererPinnedLogo}\"></span>\r\n\t\t\t<a class=\"lotusBreakWord\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\" >${title}</a>\r\n\t\t\t<span class=\"lotusMeta\">${isTopicLocked}</span>\r\n\t\t</h4>\r\n\t\t\r\n\t</td>\r\n\t<td style=\"width: 12em\" class=\"lotusMeta\" ></td>\r\n\t\r\n\t<td class=\"lotusMeta\"><span >${threadCount}</span></td>\r\n\t<td></td>\r\n\t<td class=\"lotusMeta lotusLastCell lotusNowrap\"><span\r\n\t\tclass=\"formatDate\">${getDateLabel}</span></td>\r\n</tr>", +'url:sbt/connections/controls/forums/templates/TopicHeader.html':"<tr class=\"lotusFirst lotusSort\">\r\n\t<td class=\"lotusFirstCell\">\r\n\t<td class=\"\" style=\"max-width:450px;\"colspan=\"2\">${nls.topics}</td>\r\n\t<td style=\"width: 8em;\">${nls.replies}</td>\r\n\t<td style=\"width: 4em;\"></td>\r\n\t<td style=\"width: 12em;\">${nls.latestPost}</td>\r\n</tr>", +'url:sbt/connections/controls/forums/templates/ReplyRow.html':"<tr uuid=\"${uid}\" class=\" normalTopic \">\r\n\t<td style=\"width: 20px; height: 30px\" class=\"lotusFirstCell\">\r\n\t\t<div style=\"margin-top: 2px;\" class=\"lconnSprite lconnSprite-iconComment16\"></div>\r\n </td>\r\n\t<td>\r\n\t\t<h4 style=\"max-width: 300px\">\r\n\t\t\t${content}\r\n\t\t</h4>\r\n\t</td>\r\n\t<td style=\"width: 12em\" class=\"lotusMeta\" >\r\n\t${title}\r\n\t</td>\r\n\t<td></td>\r\n\t<td class=\"lotusMeta\"><span class=\"lotusRight\"><a href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" >${authorName}</a></span></td>\r\n\t\r\n\t<td class=\"lotusMeta lotusLastCell lotusNowrap\"><span\r\n\t\tclass=\"formatDate\">${getDateLabel}</span></td>\r\n</tr>", +'url:sbt/connections/controls/forums/templates/ReplyHeader.html':"<tr class=\"lotusFirst lotusSort\">\r\n\t<td class=\"lotusFirstCell\" colspan=\"2\">${nls.replies}</td>\r\n\t<td style=\"width: 12em;\">${nls.topic}</td>\r\n\t<td style=\"width: 8em;\"></td>\r\n\t<td style=\"width: 4em;\">${nls.author}</td>\r\n\t<td style=\"width: 12em;\">${nls.date}</td>\r\n</tr>", +'url:sbt/connections/controls/forums/templates/ReplyBreadCrumb.html':"<div class=\"lotusBreadcrumbs\">\r\n\r\n<a data-dojo-attach-event=\"onclick: showForums\" href=\"#\">Forums</a>><a data-dojo-attach-event=\"onclick: showTopics\" href=\"#\">Topics</a>>Replies\r\n</div>", +'url:sbt/connections/controls/forums/templates/TopicBreadCrumb.html':"<div class=\"lotusBreadcrumbs\">\r\n\r\n<a data-dojo-attach-event=\"onclick: showForums\" href=\"#\">Forums</a>>Topics\r\n</div>", +'url:sbt/connections/controls/forums/templates/MyTopicsBreadCrumb.html':"<div class=\"lotusBreadcrumbs\">\r\n\r\n<a data-dojo-attach-event=\"onclick: showTopics\" href=\"#\">Topics</a>>Replies\r\n</div>", +'url:sbt/connections/controls/forums/templates/BootstrapForumRow.html':"<tr width=\"50%\" >\r\n\t<td style=\"padding:0.5em;\">\r\n <span class=\"icon-comment\"></span> \r\n <span style=\"font-size:120%\">\r\n <a title=\"${tooltip}\" href=\"${forumURL}\" data-dojo-attach-event=\"onclick: handleClick\" >\r\n ${title}\r\n </a>\r\n </span>\r\n </td>\r\n</tr>\r\n\r\n", +'url:sbt/connections/controls/forums/templates/BootstrapTopicRow.html':"<tr>\r\n\t<td style=\"padding:0.5em;\">\r\n\t\t<span class=\"icon-comment\"></span>\r\n\r\n\t\t<span style=\"font-size:120%;\">\r\n\t\t\t<a href=\"\" data-dojo-attach-event=\"onclick: handleClick\" >${title}</a>\r\n\t\t</span>\r\n\t</td>\r\n</tr>"}}); /* - * © Copyright IBM Corp. 2012 + * © 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. @@ -36224,166 +34754,283 @@ define([ "../../declare", "../../lang", * permissions and limitations under the License. */ -/** - * Implements some JSON helpers. Will uses the browser version - * if available else it will delegate to the Javascript library being used. - * - * @module sbt.json - */ -define(['./_bridge/json', './_bridge/lang', './log', './stringUtil'], function(jsonLib, lang, log, stringUtil) { - - /** - * @static - */ - return { - /** - * Parses a String of JSON and returns a JSON Object. - * @param {String} jsonString A String of JSON. - * @returns {Object} A JSON Object. - * @static - * @method parse - */ - parse : function(jsonString) { - var jsonImpl = JSON || jsonLib; - return jsonImpl.parse(jsonString); - }, - - /** - * Returns the JSON object represented as a String. - * @param {Object} jsonObj A JSON Object. - * @returns {String} The JSON Object represented as a String. - * @method stringify - */ - stringify : function(jsonObj) { - var jsonImpl = JSON || jsonLib; - return jsonImpl.stringify(jsonObj); - }, - - /** - * @method jsonBeanStringify - * @param theObj - * @returns - */ - jsonBeanStringify: function(theObj) { - if (lang.isArray(theObj)) { - var jsonObjs = "["; - for (var i=0; i<theObj.length; i++) { - jsonObjs += this._jsonBeanStringify(theObj[i]); - if ((i+1)<theObj.length) { - jsonObjs += ",\n"; +define(["../../../declare", + "../ConnectionsGridRenderer", + "../../../localeUtil", + "../../../dom", + "../../../lang", + "../../../connections/ForumConstants", + "../../../text!./templates/ForumRow.html", + "../../../text!./templates/TableHeader.html", + "../../../text!./templates/TopicRow.html", + "../../../text!./templates/ForumTopicRow.html", + "../../../text!./templates/TopicHeader.html", + "../../../text!./templates/ReplyRow.html", + "../../../text!./templates/ReplyHeader.html", + "../../../text!./templates/ReplyBreadCrumb.html", + "../../../text!./templates/TopicBreadCrumb.html", + "../../../text!./templates/MyTopicsBreadCrumb.html", + "../../../text!./templates/BootstrapForumRow.html", + "../../../text!./templates/BootstrapTopicRow.html", + "../../../i18n!./nls/ForumGridRenderer"], + + function(declare, ConnectionsGridRenderer, localeUtil, dom, lang, consts, ForumRow, tableHeader, TopicRow, ForumTopicRow, + TopicHeader, ReplyTemplate, ReplyHeader,ReplyBreadCrumb,TopicBreadCrumb, + MyTopicsBreadCrumb, BootstrapForumRow,BootstrapTopicRow, nls){ + + /** + * @class ForumGridRenderer + * @namespace sbt.connections.controls.forum + * @module sbt.connections.controls.forum.ForumGridRenderer + */ + var ForumGridRenderer = declare(ConnectionsGridRenderer,{ + + /**Strings used by the forum grid */ + _nls:nls, + + topicTemplate: TopicRow, + + forumTopicTemplate: ForumTopicRow, + + topicHeader: TopicHeader, + + replyTemplate: ReplyTemplate, + + replyHeader: ReplyHeader, + + forumTemplate: ForumRow, + + forumHeader: tableHeader, + + headerTemplate: tableHeader, + + replyBreadCrumb: ReplyBreadCrumb, + + topicBreadCrumb: TopicBreadCrumb, + + myTopicsBreadCrumb:MyTopicsBreadCrumb, + + breadCrumb: ReplyBreadCrumb, + + bootstrapForumRow: BootstrapForumRow, + + bootstrapTopicRow: BootstrapTopicRow, + + /** + * The constructor function + * @method constructor + * @param args + */ + constructor: function(args,grid){ + + if(grid.theme == "bootstrap"){ + if(args.type=="myTopics" || grid.type == "forumTopics"){ + this.template = this.bootstrapTopicRow; + this.headerTemplate = null; + }else{ + this.template = this.bootstrapForumRow; + this.headerTemplate = null; + } + }else{ + if(args.type=="myTopics"){ + this.template = this.topicTemplate; + this.headerTemplate = this.topicHeader; + }else if(args.type=="forumTopics"){ + this.template = this.forumTopicTemplate; + this.headerTemplate = this.topicHeader; + }else{ + this.template = this.forumTemplate; + } + } + + }, + + /** + * Function to render the Paging, the table and the table header. + * @method - render + * @param grid - the grid + * @param el - the grid DOM node + * @param items - the items in the grid row, for example icon, displayName,email etc. + * @param data - the data associated with the grid row + */ + render: function(grid, el, items, data) { + while (el.childNodes[0]) { + dom.destroy(el.childNodes[0]); + } + var size = items.length; + if (size === 0) { + this.renderEmpty(grid, el); + } + else { + this.renderPager(grid, el, items, data); + + this.renderBreadCrumb(grid, el, items, data); + + var tbody = this.renderTable(grid, el, items, data); + + this.renderHeader(grid, el, items, data, tbody); + + for (var i=0; i<items.length; i++) { + this.renderItem(grid, tbody, data, items[i], i, items); + } + + } + }, + + /** + * Checks if a tableHeader exists ,if so, the HTML template is converted to + * a DOM node, and attached to the body. + * @method - renderHeader + * @param grid - the grid + * @param el - the current element + * @param items - the items in the current element + * @param data - the data associated with the current element + */ + renderHeader : function(grid,el,items,data,tbody) { + if (this.headerTemplate && !grid.hideHeader) { + var node; + if (lang.isString(this.headerTemplate)) { + var domStr = this._substituteItems(this.headerTemplate, grid, this, items, data); + node = dom.toDom(domStr, el.ownerDocument); + } else { + node = this.headerTemplate.cloneNode(true); + } + tbody.appendChild(node); + + grid._doAttachEvents(tbody, data); } - } - jsonObjs += "]"; - return jsonObjs; - } else { - return this._jsonBeanStringify(theObj); - } - }, - - /** - * @method jsonBean - * @param theObj - * @returns - */ - jsonBean: function(theObj) { - if (lang.isArray(theObj)) { - var jsonObjs = []; - for (var i=0; i<theObj.length; i++) { - jsonObjs.push(this._jsonBean(theObj[i])); - } - return jsonObjs; - } else { - return this._jsonBean(theObj); - } - }, - - // Internals - - _jsonBeanStringify: function(theObj) { - var jsonObj = this.jsonBean(theObj); - return this._stringifyCyclicCheck(jsonObj, 4); - }, - - _stringifyCyclicCheck: function(jsonObj, indent) { - var jsonImpl = JSON || jsonLib; - var seen = []; - var self = this; - return jsonImpl.stringify(jsonObj, function(key, val) { - if(self._isDomNode(val)){ - return {}; - } - if (lang.isObject(val)) { - if (seen.indexOf(val) >= 0 && !self._isBuiltin(val)) - return undefined; - seen.push(val); - } else if(lang.isFunction(val)){ - return undefined; - } - return val; - }, indent); - }, - - _jsonBean: function(theObj, seen) { - // first check for cyclic references - if (!seen) { - seen = []; - } - if (seen.indexOf(theObj) >= 0) { - return undefined; - } - seen.push(theObj); - - var jsonObj = {}; - for (var property in theObj) { - var value = this._getObjectValue(theObj, property, seen); - if (value || !isNaN(value)) { - jsonObj[property] = value; - } - } - return jsonObj; - }, - - _notReserved: function(property) { - return property!=='isInstanceOf' && property!=='getInherited'; - }, - - _getObjectValue: function(theObj, property, seen) { - var self = this; - if (lang.isFunction(theObj[property])) { - if ((stringUtil.startsWith(property, "get") || stringUtil.startsWith(property, "is")) && self._notReserved(property)) { - try { - var value = theObj[property].apply(theObj); - if (value && !this._isBuiltin(value) && lang.isObject(value)) { - return this._jsonBean(value, seen); + }, + + renderBreadCrumb: function(grid,el,items,data) { + if (this.breadCrumb && !grid.hideBreadCrumb) { + var node; + if (lang.isString(this.breadCrumb)) { + var domStr = this._substituteItems(this.breadCrumb, grid, this, items, data); + node = dom.toDom(domStr, el.ownerDocument); + } else { + node = this.breadCrumb.cloneNode(true); } - return value; - } catch(error) { - //log.error("Error {0}.{1} caused {2}", theObj, property, error); + el.appendChild(node); + + grid._doAttachEvents(el, data); } - } - } else { - if (!stringUtil.startsWith(property, "_") && !stringUtil.startsWith(property, "-")) { - return theObj[property]; - } - } - return undefined; - }, - - _isBuiltin: function(value) { - return ((value instanceof Date) || - (value instanceof Number) || - (value instanceof Boolean) || - lang.isArray(value)); - }, + }, + /*** + * Creates a table and table body, Attaches the table body to the + * table, and returns the table body + * @method - renderTable + * @param grid - the grid + * @param el - the current element + * @param items - all of the items in the current row + * @param data - the data associated with the current row + * @returns - A table body element, that is attached to a table + */ + renderTable: function(grid, el, items, data) { + var table = dom.create("table", { + "class": this.tableClass, + border:"0", + cellspacing:"0", + cellpadding:"0", + role:"presentation" + }, el); + var tbody = dom.create("tbody", null, table); + return tbody; + }, + + /** + * Creates a Div, with a different CSS class, to display a grid that has no results + * @method - renderEmpty + * @param - grid - The Grid + * @param - el - The Current Element + */ + renderEmpty: function(grid, el,data) { + while (el.childNodes[0]) { + dom.destroy(el.childNodes[0]); + } + + this.renderBreadCrumb(grid, el, data ); + + var ediv = dom.create("div", { + "class": this.emptyClass, + innerHTML: "<h2>" + this.nls.noResults +"</h2>", + role: "document", + tabIndex: 0 + }, el, "only"); + + grid._doAttachEvents(el, data); + }, + + + getDateLabel: function(grid, item, i, items){ + var result = localeUtil.getUpdatedLabel(item.getValue('updated')); + return result; + }, + + getParentLink: function(grid, item, i, items){ + + if(grid.params.type == "myTopics"){ + return item.getValue("topicForumTitle"); + }else{ + return ""; + } + + + }, + + /** + * Displays a tooltip by calling the getTooltip function in the ForumAction class + * @method tooltip + * @param grid The Grid element + * @param item the element to display the tooltip + * @param i the number of the current row + * @param items all of the items in the grid row + * @returns A String used as a tooltip + */ + tooltip: function(grid, item, i, items) { + if (grid.forumAction) { + return grid.forumAction.getTooltip(item); + } + }, + + getUserProfileHref: function(grid,item,i,items){ + return this.getProfileUrl(grid,item.getValue("authorUserid")); + }, + + rendererPinnedLogo: function(grid,item,i,items){ + var terms = item.getValue("categoryTerm"); + for(var i=0;i<terms.length;i++){ + if(terms[i].indexOf(consts.FlagPinned) != -1){ + return "lconnSprite lconnSprite-iconPin16"; + } + } + return ""; + }, + + isTopicLocked: function(grid,item,i,items){ + var terms = item.getValue("categoryTerm"); + for(var i=0;i<terms.length;i++){ + if(terms[i].indexOf(consts.FlagLocked) != -1){ + return "[Locked]"; + } + } + return ""; + }, + + renderPinnedRow: function(grid,item,i,items){ + var terms = item.getValue("categoryTerm"); + for(var i=0;i<terms.length;i++){ + if(terms[i].indexOf(consts.FlagPinned) != -1){ + return "pinnedTopic lotusPinnedRow"; + } + } + return "normalTopic"; + } + }); - _isDomNode : function(value) { - return (value && value.nodeName && value.nodeType && typeof value.nodeType === "number" && typeof value.nodeName === "string"); - } - }; + return ForumGridRenderer; }); - }, -'sbt/connections/controls/profiles/nls/ColleagueGridRenderer':function(){ +'sbt/connections/ProfileService':function(){ /* * © Copyright IBM Corp. 2013 * @@ -36400,1059 +35047,1314 @@ define(['./_bridge/json', './_bridge/lang', './log', './stringUtil'], function(j * permissions and limitations under the License. */ -// NLS_CHARSET=UTF-8 -define({ - root: { - viewAll : "View All ({totalCount})", - empty : "No colleagues in the list.", - people: "{totalCount} people", - person: "{totalCount} person" - } -}); - - -}, -'sbt/connections/controls/_ConnectionsWidget':function(){ -/* - * © 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 +/** + * JavaScript API for IBM Connections Profile Service. * - * 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. + * @module sbt.connections.ProfileService */ -define(["../../declare", "../../config", "../../connections/controls/astream/_XhrHandler", "dijit/_Widget"], function(declare, config, _XhrHandler){ +define([ "../declare", "../lang", "../config", "../stringUtil", "./ProfileConstants", "./ConnectionsService", "../base/BaseEntity", "../base/AtomEntity", "../base/XmlDataHandler", "../base/VCardDataHandler", "../Cache", "../util" ], function( + declare,lang,config,stringUtil,consts,ConnectionsService,BaseEntity,AtomEntity,XmlDataHandler, VCardDataHandler, Cache, util) { + + var CategoryProfile = "<category term=\"profile\" scheme=\"http://www.ibm.com/xmlns/prod/sn/type\"></category>"; + var updateProfileXmlTemplate = "\nBEGIN:VCARD\nVERSION:2.1\n${jobTitle}${address}${telephoneNumber}${building}${floor}END:VCARD\n"; + var updateProfileAttributeTemplate = "${attributeName}:${attributeValue}\n"; + var updateProfileAddressTemplate = "ADR;WORK:;;${streetAddress},${extendedAddress};${locality};${region};${postalCode};${countryName}\n"; + var ContentTmpl = "<content type=\"${contentType}\">${content}</content>"; + var createProfileTemplate = "<person xmlns=\"http://ns.opensocial.org/2008/opensocial\"><com.ibm.snx_profiles.attrib>${guid}${email}${uid}${distinguishedName}${displayName}${givenNames}${surname}${userState}</com.ibm.snx_profiles.attrib></person>"; + var createProfileAttributeTemplate = "<entry><key>${attributeName}</key><value><type>text</type><data>${attributeValue}</data></value></entry>"; + var createProfileTagsTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><app:categories xmlns:snx=\"http://www.ibm.com/xmlns/prod/sn\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\">${createTags}</app:categories>" + var CategoryTmpl = "<atom:category term=\"${tag}\"></atom:category>"; + + var CategoryConnection = "<category term=\"connection\" scheme=\"http://www.ibm.com/xmlns/prod/sn/type\" />"; + var CategoryConnectionType = "<category term=\"${getConnectionType}\" scheme=\"http://www.ibm.com/xmlns/prod/sn/connection/type\" />"; + var CategoryStatus = "<category term=\"${getStatus}\" scheme=\"http://www.ibm.com/xmlns/prod/sn/status\" />"; + + var OAuthString = "/oauth"; + var basicAuthString = ""; + var defaultAuthString = ""; - /* - * Base class for common functionality of all connections widgets. + /** + * Profile class. * - * @class sbt.controls._ConnectionsWidget + * @class Profile + * @namespace sbt.connections */ - var _ConnectionsWidget = declare([dijit._Widget], - { - /* - * The url of the resources/web folder, which contains the projects we need. - * - * @property baseUrl - * @type String - */ - baseUrl: config.Properties.serviceUrl + "/proxy/connections/${connections}/resources/web/", - - /* - * The _XhrHandler to use in this connections widget. - * - * @property xhrHandler - * @type {Object} - */ - xhrHandler: null, - - /* - * Setup with common Connections widget functionality. - * @param {Object} args - * @param {Object} [args.xhrHandler] The _XhrHandler to be used throughout this widget. - * @param {String} [endpoint] The endpoint to be used when creating an _XhrHandler for this connections widget. - */ - constructor: function(args){ - window.ibmConfig = window.ibmConfig || {}; - window.ibmConfig.versionStamp = window.ibmConfig.versionStamp || 1234567890; - - this.registerModulePaths(); - this.xhrHandler = args.xhrHandler || this.requireXhr(args.endpoint); - }, - - /* - * Register the connections modules we will be using. + + /* + * ProfileDataHandler class. + */ + + + + var Profile = declare(AtomEntity, { + + xpath : consts.ProfileXPath, + namespaces : consts.ProfileNamespaces, + categoryScheme : CategoryProfile, + _update : false, + + /** * - * @method registerModulePaths + * @constructor + * @param args */ - registerModulePaths: function(){ - dojo.registerModulePath("com", this.baseUrl + "com"); - dojo.registerModulePath("lconn", this.baseUrl + "lconn"); - dojo.registerModulePath("net", this.baseUrl + "net"); + constructor : function(args) { }, - /* - * Create the _XhrHandler from the endpoint name. - * - * @method requireXhr - * @param endpointName + /** + * Data handler for profile object based on the query paramter - "output", used to get the profile. + * If the value of output paramter is "vcard", the VCardDataHandler is associated with + * the profile object else, by default, XmlDataHandler is associated with the object. + * + * @param {Object} service ProfileService instance associated with the profile object + * @param {Object} data Profile document associated with the profile object + * @response {Object} response Response object returned after the operation for get/create/update + * of the profile + * @namespaces {Object} namespace NameSpace object associated with the profile + * @xpath {Object} xpath XPath object associated with the profile */ - requireXhr: function(endpointName){ - var _endpointName = endpointName || "connections"; - return new _XhrHandler(_endpointName); - } - }); - - return _ConnectionsWidget; -}); - - -}, -'url:sbt/connections/controls/search/templates/StatusUpdateExtraHeader.html':"<div class=\"lconnStatusUpdatePhotoContainer otherPeople64 otherPeople64-NoPhotoPerson55\">\r\n <span class=\"x-lconn-userid\" style=\"display: none;\">\r\n ${authorUid}\r\n </span>\r\n</div>\r\n", -'url:sbt/controls/grid/templates/GridPager.html':"<div class=\"lotusPaging\" dojoAttachPoint=\"pagingHeader\">\r\n\t<div class=\"lotusLeft\"></div>\r\n\t<div class=\"lotusLeft\" dojoAttachPoint=\"showingResultsMessage\">${pagingResults}</div>\r\n\t<ul class=\"lotusRight lotusInlinelist\">\r\n\t\t<li class=\"lotusFirst prevPageLink\">\r\n\t\t\t<a style=\"${hidePreviousLink}\" title=\"${nls.previousPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: prevPage\">${nls.previous}</a>\r\n\t\t\t<span style=\"${hidePreviousLabel}\">${nls.previous}</span>\r\n\t\t</li>\r\n\t\t<li class=\"nextPageLink\">\r\n\t\t\t<a style=\"${hideNextLink}\" title=\"${nls.nextPage}\" href=\"javascript: void(0)\" data-dojo-attach-event=\"onclick: nextPage\">${nls.next}</a>\r\n\t\t\t<span style=\"${hideNextLabel}\">${nls.next}</span>\r\n\t\t</li>\r\n\t</ul>\r\n\t<div>\r\n\t\t<div dojoAttachPoint=\"catCenterPagingTop\"></div>\r\n\t</div>\r\n</div>\r\n", -'url:sbt/connections/controls/bootstrap/templates/CommunityRow.html':"<tr>\r\n\t<td width=35>\r\n\t\t<img alt=\"\" src=\"${logoUrl}\" width=64 height=64 class=\"img-polaroid\"></img>\r\n\t</td>\r\n\t<td>\r\n\t\t<h4>\r\n\t\t\t<span dojoAttachPoint=\"placeLinkNode\">\r\n\t\t\t\t<a href=\"javascript: void(0)\" target=\"_self\" title=\"${tooltip}\" dojoAttachPoint=\"placeTitleLink\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a>\r\n\t\t\t</span>\r\n\t\t\t<span class=\"\" dojoAttachPoint=\"sourceTypePlaceHolder\"></span>\r\n\t\t\t<span style=\"display: none\" class= role=presentation dojoAttachPoint=\"sourceTypeSectionDevider\">|</span>\r\n\t\t\t<span style=\"display: none\" class=\"\" dojoAttachPoint=\"moderatedIconNode\">\r\n\t\t\t\t<img style=\"display: inline\" class=\"\" title=\"${nls.moderated}\" alt=\"${nls.moderated}\" src=\"${blankGif}\">\r\n\t\t\t\t${nls.moderated} \r\n\t\t\t</span>\r\n\t\t\t<span style=\"display: none\" class=\"lotusType commType\" dojoAttachPoint=\"restrictedIconNode\">\r\n\t\t\t\t<img style=\"display: inline\" class=\"\" title=\"${nls.restricted}\" alt=\"${nls.restricted}\" src=\"${blankGif}\">\r\n\t\t\t\t${nls.restricted} \r\n\t\t\t</span>\r\n\t\t</h4>\r\n\t\t<div class=\"\">\r\n\t\t\t<span role=\"list\">\r\n\t\t\t\t<span role=listitem dojoAttachPoint=\"numOfMembersPlaceHolder\">${numOfMembers}</span>\r\n\t\t\t\t<span class=\"\" role=presentation dojoAttachPoint=\"membersSectionDevider\">|</span>\r\n\t\t\t\t<span role=listitem dojoAttachPoint=\"personPlaceHolder\">\r\n\t\t\t\t\t${nls.updatedBy}\r\n\t\t\t\t\t<a class=\"fn lotusPerson vcard hasHover\" href=\"javascript: void(0)\" icbizcard_ref=\"1\" icbizcard_idx=\"1\">\r\n\t\t\t\t\t\t${contributorName}\r\n\t\t\t\t\t\t<span style=\"display: none\" class=x-lconn-userid>${contributorUserid}</span>\r\n\t\t\t\t\t</a> \r\n\t\t\t\t</span>\r\n\t\t\t\t<span class=\"\" role=presentation dojoAttachPoint=\"authorSectionDevider\">|</span>\r\n\t\t\t\t<span role=listitem dojoAttachPoint=\"lastUpdateNode\">${updatedDate}</span>\r\n\t\t\t\t<span style=\"${displayTags}\" class=lotusDivider role=presentation dojoAttachPoint=\"tagsSectionDevider\">|</span>\r\n\t\t\t\t<span class=\"\" role=listitem dojoAttachPoint=\"tagsSection\">\r\n\t\t\t\t\t${tagsLabel}\r\n\t\t\t\t\t${tagsAnchors}\r\n\t\t\t\t</span>\r\n\t\t\t</span>\r\n\t\t</div>\r\n\t\t<div class=lotusLastCell dojoAttachPoint=\"detailsSection\">\r\n\t\t\t<p dojoAttachPoint=\"placeDescNode\">${summary}</p>\r\n\t\t\t\r\n\t\t</div>\r\n\t</td>\r\n</tr>", -'sbt/smartcloud/controls/profiles/nls/ColleagueGridRenderer':function(){ -/* - * © 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. - */ - -// NLS_CHARSET=UTF-8 -define({ - root: { - viewAll : "View All ({totalCount})", - empty : "No colleagues in the list.", - people: "{totalCount} people", - person: "{totalCount} person" - } -}); - - -}, -'url:sbt/connections/controls/search/templates/span.html':"<span ${classAttr}>${content}</span>", -'url:sbt/connections/controls/profiles/templates/ProfilePanel.html':"<div>\r\n\t<div aria-label=\"Profile photo\" role=\"complementary\" class=\"lotusSection2\">\r\n\t\t<div style=\"width: 155px; height: 155px;\" class=\"lotusCenter\">\r\n\t\t\t<img class=\"lconnProfilePortrait\" alt=\"${getThumbnailAlt}\" src=\"${getThumbnailUrl}\">\r\n\t\t</div>\r\n\t</div>\r\n\t\r\n\t<div class=\"lotusHeader\">\r\n\t\t<span class=\"vcard lotusHeading\">\r\n\t\t\t<a class=\"fn url lotusPerson hasHover\" href=\"${getProfileUrl}\" icbizcard_ref=\"1\" icbizcard_idx=\"1\" aria-describedby=\"semtagmenu\">\r\n\t\t\t${getName}\r\n\t\t\t</a>\r\n\t\t\t<span style=\"display: none;\" class=\"x-lconn-userid\">${getUserid}</span>\r\n\t\t</span>\r\n\t</div>\r\n\t\r\n\t<div style=\"padding-top: 3px;\" class=\"lotusDetails lotusLeft\">\r\n\t\t<strong> ${getJobTitle} </strong> <br>\r\n\t\t${getTelephoneNumber} <br>\r\n\t\t<a href=\"mailto:${email}\">${getEmail}</a> <br>\r\n\t</div>\r\n</div>", -'sbt/connections/controls/communities/CommunityGridRenderer':function(){ -require({cache:{ -'url:sbt/connections/controls/communities/templates/CommunityRow.html':"<tr class=\"${rowClass}\" >\r\n\t<td class=lotusFirstCell width=35 dojoAttachPoint=\"communityIcon\">\r\n\t\t<img role=presentation alt=\"\" src=\"${communityImage}\" width=64 height=64>\r\n\t</td>\r\n\t<td class=lotusFirstCell>\r\n\t\t<h4>\r\n\t\t\t<span dojoAttachPoint=\"placeLinkNode\">\r\n\t\t\t\t<a href=\"javascript: void(0)\" target=\"_self\" title=\"${tooltip}\" dojoAttachPoint=\"placeTitleLink\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a>\r\n\t\t\t</span>\r\n\t\t\t<span class=\"lotusType commType\" dojoAttachPoint=\"sourceTypePlaceHolder\"></span>\r\n\t\t\t<span style=\"display: none\" class=lotusDivider role=presentation dojoAttachPoint=\"sourceTypeSectionDevider\">|</span>\r\n\t\t\t<span style=\"${displayModerated}\" class=\"lotusType commType\" >\r\n\t\t\t\t<img class=\"lconnSprite lconnSprite-iconModeratedCommunity16\" title=\"\" alt=\"\" src=\"images/blank.gif?etag=20140227.002444\" style=\"display: inline\">\r\n\t\t\t\t${nls.moderated} \r\n\t\t\t</span>\r\n\t\t\t<span class=\"lotusType commType\" style=\"${displayRestricted}\">\r\n\t\t\t\t<img class=\"iconsStates16 iconsStates16-CheckedOut\" title=\"\" alt=\"\" src=\"images/blank.gif?etag=20140227.002444\" style=\"display: inline\">\r\n\t\t\t\t${nls.restricted} \r\n\t\t\t</span>\r\n\t\t</h4>\r\n\t\t<div class=lotusMeta>\r\n\t\t\t<span role=list>\r\n\t\t\t\t<span role=listitem dojoAttachPoint=\"numOfMembersPlaceHolder\">${numOfMembers}</span>\r\n\t\t\t\t<span class=lotusDivider role=presentation dojoAttachPoint=\"membersSectionDevider\">|</span>\r\n\t\t\t\t<span role=listitem dojoAttachPoint=\"personPlaceHolder\">\r\n\t\t\t\t\t${nls.updatedBy}\r\n\t\t\t\t\t<span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t\t<a href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" aria-label=\"${nls.ariaVcard}\" class=\"fn url\">${contributorName}</a>\r\n \t\t\t\t\t <span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${contributorUserid}</span>\r\n\t\t\t\t </span>\r\n\t\t\t\t</span>\r\n\t\t\t\t<span class=lotusDivider role=presentation dojoAttachPoint=\"authorSectionDevider\">|</span>\r\n\t\t\t\t<span role=listitem dojoAttachPoint=\"lastUpdateNode\">${updatedDate}</span>\r\n\t\t\t\t<span style=\"${displayTags}\" class=lotusDivider role=presentation dojoAttachPoint=\"tagsSectionDevider\">|</span>\r\n\t\t\t\t<span class=lotusTags role=listitem dojoAttachPoint=\"tagsSection\">\r\n\t\t\t\t\t${tagsLabel}\r\n\t\t\t\t\t${tagsAnchors}\r\n\t\t\t\t</span>\r\n\t\t\t</span>\r\n\t\t</div>\r\n\t\t<div class=lotusLastCell dojoAttachPoint=\"detailsSection\">\r\n\t\t\t<p dojoAttachPoint=\"placeDescNode\">${summary}</p>\r\n\t\t</div>\r\n\t\t<div data-dojo-attach-point=\"customContent\">\r\n\t\t</div>\r\n\t</td>\r\n\t<td class=\"lotusAlignRight lotusLastCell lotusTiny\">\r\n\t</td>\r\n</tr>", -'url:sbt/connections/controls/communities/templates/BootstrapCommunityRow.html':"<tr>\r\n\t<td>\r\n\t\t<span class=\"icon-globe\"></span>\r\n\t\t<span style=\"font-size:120%;\" ><a href=\"javascript: void(0)\" title=\"${tooltip}\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a></span>\r\n\t</td>\r\n</tr>", -'url:sbt/connections/controls/communities/templates/TagAnchor.html':"<a class=\"tagLink\" title=\"${nls.filterByTag}\" href=\"javascript: void(0);\" data-dojo-attach-event=\"onclick: filterByTag\">${tagName}</a>"}}); -/* - * © 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. - */ - -/** - * @module sbt.connections.controls.communities.CommunityGridRenderer - */ -define(["../../../declare", "../../../stringUtil", "../../../i18n", "../../../lang", - "../../../connections/controls/ConnectionsGridRenderer", - "../../../text!../../../connections/controls/communities/templates/CommunityRow.html", - "../../../text!../../../connections/controls/communities/templates/BootstrapCommunityRow.html", - "../../../text!../../../connections/controls/communities/templates/TagAnchor.html", - "../../../i18n!../../../connections/controls/communities/nls/CommunityGridRenderer"], - function(declare, stringUtil, i18n, lang, ConnectionsGridRenderer, CommunityRow, - BootstrapCommunityRow, TagAnchor, nls) { - - /** - * @class CommunityGridRenderer - * @namespace sbt.connections.controls.communities - */ - var CommunityGridRenderer = declare(ConnectionsGridRenderer, { - - /** - * Strings used in the grid - */ - _nls: nls, - - /** - * The HTML template for tag anchors - */ - tagAnchorTemplate: TagAnchor, - /** - * @param args - */ - constructor: function(args,grid){ - if(grid.theme == "bootstrap"){ - this.template = BootstrapCommunityRow; - }else{ - this.template = CommunityRow; - } - }, - - /** - * Sets the class for the Current grid row - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i The number of the current grid row - * @param items an object array containing the data for all of the grid rows - * @returns A CSS Class - */ - rowClass: function(grid, item, i, items) { - return (i === 0 ? "placeRow lotusFirst" : "placeRow"); - }, - - /** - * Handles Displaying a Tooltip for an item - * @param grid The grid Element - * @param item An Object containing all of the data for the current row - * @param i the number of the current grid row - * @param items an object array containing the data for all of the grid rows - * @returns A String, with the text to be displayed in the tooltip - */ - tooltip: function(grid, item, i, items) { - if (grid.communityAction) { - return grid.communityAction.getTooltip(item); - } - }, - - /** - * Handles encoding the image url - * @param grid The grid Element - * @param item An Object containing all of the data for the current row - * @param i the number of the current grid row - * @param items an object array containing the data for all of the grid rows - * @returns The image url - */ - communityImage: function(grid, item, i, items) { - var logoUrl = item.getValue("logoUrl"); - return grid.encodeImageUrl(logoUrl); - }, - - /** - * Returns the number of members for a community - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i the Number of the current grid - * @param items an object array containing the data for all of the grid rows - * @returns A String with the number of members in a community - */ - numOfMembers: function(grid, item, i, items) { - var memberCount = item.getValue("memberCount"); - if (memberCount == 1) { - return this.nls.person; - } else { - return stringUtil.replace(this.nls.people, { "memberCount" : memberCount }); - } - }, - - /** - * Gets the last updated date for a community - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i the number of the current grid row - * @param items an object array containing the data for all of the grid rows - * @returns The date when the community was last updates - */ - updatedDate: function(grid, item, i, items) { - return i18n.getUpdatedLabel((item.getValue("updated"))); - }, - - /** - * Returns a CSS style based on if a community has tags. - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i The number of the current row - * @param items an object array containing the data for all of the grid rows - * @returns {String} - */ - displayTags: function(grid, item, i, items) { - var tags = item.getValue("tags"); - if (tags.length == 0) { - return "display: none"; - } else { - return ""; - } - }, - - /** - * Displays the restricted image for a community - * @method displayRestricted - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i The number of the current row - * @param items an object array containing the data for all of the grid rows - * @returns {String} - */ - displayRestricted: function(grid, item, i, items) { - var communityType = item.getValue("communityType"); - if(communityType == "private"){ - return "display: inline-block;"; - }else{ - return "display: none"; - } - }, - - displayModerated: function(grid, item, i, items){ - var communityType = item.getValue("communityType"); - if(communityType == "publicInviteOnly"){ - return "display: inline-block;"; - }else{ - return "display: none"; - } - }, - - - /** - * Get the tag label, if a community has no tags and empty string is returned - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i The number of the current row - * @param items an object array containing the data for all of the grid rows - * @returns an array of strings, that are tags for a community - */ - tagsLabel: function(grid, item, i, items) { - var tags = item.getValue("tags"); - if (tags.length == 0) { - return ""; - } else { - return this.nls.tags; - } - }, - - /** - * Substitutes tag labels(Strings) from the nls file into the tag - * Anchor template which creates a tag links, and displays these tags on the page - * @param grid The Grid Element - * @param item An Object containing all of the data for the current row - * @param i The number of the current row - * @param items an object array containing the data for all of the grid rows - * @returns {String} - */ - tagsAnchors: function(grid, item, i, items) { - var tags = item.getValue("tags"); - if (tags == undefined) { - return ""; - } else { - var tagsStr = ""; - if (lang.isArray(tags)) { - for (var i=0; i<tags.length; i++) { - tagsStr += grid._substitute(this.tagAnchorTemplate, { tagName : tags[i] }); - if (i+1 < tags.length) { - tagsStr += ", "; - } - } - } else if (lang.isString(tags)) { - tagsStr = grid._substitute(this.tagAnchorTemplate, { tagName : tags }); - } - return tagsStr; - } - }, - - getUserProfileHref: function(grid,item,i,items){ - return this.getProfileUrl(grid,item.getValue("authorUserid")); - } - - - }); - - return CommunityGridRenderer; -}); -}, -'url:sbt/connections/controls/search/templates/MemberListTemplate.html':"<div style=\"padding-top: 15px;\" class=\"lotusHeader\"></div>", -'url:sbt/connections/controls/vcard/templates/ProfileVCardInline.html':"<span class=\"vcard X-person-display-inline\">\r\n <span class=\"fn\" style=\"display:none;\">${userName}</span>\r\n <span dojoAttachPoint=\"idNode\" class=\"\" style=\"display: none;\">${userId}</span>\r\n</span>\r\n", -'sbt/connections/Tag':function(){ -/* - * © Copyright IBM Corp. 2012, 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. - */ - -/** - * - * @module sbt.connections.Tag - * @author Rajmeet Bal - */ -define(["../declare", "../base/BaseEntity" ], - function(declare, BaseEntity) { - - /** - * Tag class. - * - * @class Tag - * @namespace sbt.connections - */ - var Tag = declare(BaseEntity, { + createDataHandler : function(service, data, response, namespaces, xpath) { + if (response.options && response.options.query && response.options.query.output == "vcard") { + return new VCardDataHandler({ + service: service, + data : data, + namespaces : namespaces, + xpath : consts.ProfileVCardXPath + }); + } else { + return new XmlDataHandler({ + service: service, + data : data, + namespaces : namespaces, + xpath : xpath + }); + } + }, + + /** + * Get id of the profile + * + * @method getUserid + * @return {String} id of the profile + * + */ + getUserid : function() { + return this.getAsString("userid"); + }, /** + * Get name of the profile + * + * @method getName + * @return {String} name of the profile * - * @constructor - * @param args */ - constructor : function(args) { + getName : function() { + return this.getAsString("name"); }, /** - * Get term of the tag + * Get email of the profile * - * @method getTerm - * @return {String} term of the tag + * @method getEmail + * @return {String} email of the profile + */ + getEmail : function() { + return this.getAsString("email"); + }, + + /** + * Get groupware mail of the profile * + * @method getGroupwareMail + * @return {String} groupware mail of the profile */ - getTerm : function() { - return this.getAsString("term"); + getGroupwareMail : function() { + return this.getAsString("groupwareMail"); }, - + /** - * Get frequency of the tag + * Get thumbnail URL of the profile * - * @method getFrequency - * @return {Number} frequency of the tag + * @method getThumbnailUrl + * @return {String} thumbnail URL of the profile + */ + getThumbnailUrl : function() { + return this.getAsString("photoUrl"); + }, + + /** + * Get job title of the profile * + * @method getJobTitle + * @return {String} job title of the profile */ - getFrequency : function() { - return this.getAsNumber("frequency"); - } - }); - return Tag; -}); + getJobTitle : function() { + return this.getAsString("jobTitle"); + }, -}, -'sbt/connections/FileConstants':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ -/** - * Social Business Toolkit SDK. Definition of constants for FileService. - */ -define([ "../lang", "./ConnectionsConstants" ], function(lang,conn) { + /** + * Get department of the profile + * + * @method getDepartment + * @return {String} department of the profile + */ + getDepartment : function() { + return this.getAsString("organizationUnit"); + }, - return lang.mixin({ - /** - * XPath expressions used when parsing a Connections Files ATOM feed + * Get address of the profile + * + * @method getAddress + * @return {Object} Address object of the profile */ - FileFeedXPath : conn.ConnectionsFeedXPath, - + getAddress : function() { + return this.getAsObject(consts.AddressFields); + }, /** - * XPath expressions used when parsing a Connections Comments ATOM feed + * Get telephone number of the profile + * + * @method getTelephoneNumber + * @return {String} Phone number of the profile */ - CommentFeedXPath : conn.ConnectionsFeedXPath, + getTelephoneNumber : function() { + return this.getAsString("telephoneNumber"); + }, /** - * XPath expressions to be used when reading a File Entry + * Get profile URL of the profile + * + * @method getProfileUrl + * @return {String} profile URL of the profile */ - FileXPath : { - // used by getEntityData - entry : "/a:entry", - id : "a:id", - // used by getEntityId - uid : "td:uuid", - label : "td:label", - selfUrl : "a:link[@rel='self']/@href", - alternateUrl : "a:link[@rel='alternate']/@href", - downloadUrl : "a:link[@rel='enclosure']/@href", - type : "a:link[@rel='enclosure']/@type", - length : "a:link[@rel='enclosure']/@length", - editLink : "a:link[@rel='edit']/@href", - editMediaLink : "a:link[@rel='edit-media']/@href", - thumbnailUrl : "a:link[@rel='thumbnail']/@href", - commentsUrl : "a:link[@rel='replies']/@href", - fileSize : "td:totalMediaSize", - content : "a:content[@type='html']", - shareCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/share']", - - authorName : "a:author/a:name", - authorUserId : "a:author/snx:userid", - authorEmail : "a:author/a:email", - authorUserState : "a:author/snx:userState", - - title: "a:title", - published : "a:published", - updated : "a:updated", - created: "td:created", - modified: "td:modified", - lastAccessed : "td:lastAccessed", - - modifierName : "td:modifier/td:name", - modifierUserId : "td:modifier/snx:userid", - modifierEmail : "td:modifier/td:email", - modifierUserState : "td:modifier/snx:userState", - - visibility : "td:visibility", - libraryId : "td:libraryId", - libraryType : "td:libraryType", - versionUuid : "td:versionUuid", - versionLabel : "td:versionLabel", - propagation : "td:propagation", - recommendationsCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/recommendations']", - commentsCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/comment']", - sharesCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/share']", - foldersCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/collections']", - attachmentsCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/attachments']", - versionsCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/versions']", - referencesCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/references']", - totalMediaSize : "td:totalMediaSize", - summary : "a:summary", - contentUrl : "a:content/@src", - contentType : "a:content/@type", - objectTypeId : "td:objectTypeId", - lock : "td:lock/@type", - acls : "td:permissions", - hitCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/hit']", - anonymousHitCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/anonymous_hit']", - tags : "a:category[not(@scheme)]/@term", - category : "a:category/@label" + getProfileUrl : function() { + return this.getAsString("fnUrl"); }, - /** - * XPath expression for parsing folder informartion from the File ATOM Feed. + * Get building name of the profile + * + * @method getBuilding + * @return {String} building name of the profile */ - FolderXPath : { - id : "id", - uid : "td:uuid", - title : "a:title", - label : "td:label", - folderUrl : "a:link[@rel='alternate']/@href", - logoUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/logo']/@href", - tags : "a:category/@term", - summary : "a:summary[@type='text']", - content : "a:content[@type='html']", - visibility : "td:visibility", - notification : "td:notification", - versionUuid : "td:versionUuid", - versionLabel : "td:versionLabel", - documentVersionUuid : "td:documentVersionUuid", - documentVersionLabel : "td:documentVersionLabel", - itemCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/item']", - shareCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/user']", - groupShareCount : "snx:rank[@scheme='http://www.ibm.com/xmlns/prod/sn/group']", - modified : "td:modified", - created : "td:created", - updated : "a:updated", - authorName : "a:author/a:name", - authorUserId : "a:author/snx:userid", - authorEmail : "a:author/a:email", - content : "a:content[@type='text']", - modifierName : "a:modifier/a:name", - modifierId : "a:modifier/snx:userid", - modifierEmail : "a:modifier/a:email" + getBuilding : function() { + return this.getAsString("building"); }, - /** - * XPath expressions to be used when reading a Comment + * Get floor address of the profile + * + * @method getFloor + * @return {String} floor address of the profile */ - CommentXPath : { - entry : "a:entry", - id : "a:id", - uid : "td:uuid", - title : "a:title", - content : "a:content[@type='text']", - created : "td:created", - modified : "td:modified", - versionLabel : "td:versionLabel", - updated : "a:updated", - published : "a:published", - modifierName : "td:modifier/td:name", - modifierUserId : "td:modifier/snx:userid", - modifierEmail : "td:modifier/td:email", - modifierUserState : "td:modifier/snx:userState", - authorName : "a:author/a:name", - authorUserId : "a:author/snx:userid", - authorEmail : "a:author/a:email", - authorUserState : "a:author/snx:userState", - language : "td:language", - deleteWithRecord : "td:deleteWithRecord" - }, - - /** - * XPath expressions used for parsing information on shared files and folders. - */ - SharesXPath : { - id : "id", - uuid : "td:uuid", - title : "a:title", - summary : "a:summary[@type='text']", - sharedResourceType : "td:sharedResourceType", // always set to document, but will add the attribute anyway - sharePermission : "td:sharePermission", - sharedWhat : "td:sharedWhat", - sharedWithName : "a:sharedWith/a:name", - sharedWithId : "a:sharedWith/snx:userid", - sharedWithEmail : "a:sharedWith/a:email", - documentOwner : "td:documentOwner", - updated : "a:updated", - published : "a:published", - authorName : "a:author/a:name", - authorUid : "a:author/snx:userid", - authorEmail : "a:author/a:email" - }, - - /** - * XPath expressions used for parsing information on user library. - */ - LibraryXPath : { - entry : "a:feed", - id : "a:id", - uuid : "td:uuid", - librarySize : "td:librarySize", - totalRemovedSize : "td:totalRemovedSize", - libraryQuota : "td:libraryQuota", - totalResults : "opensearch:totalResults" - }, - - /** - * Get a Feed for a File - */ - AtomFileInstance : "${files}/basic/api/myuserlibrary/document/{documentId}/entry", - - /** - * - */ - AtomFileInstancePublic : "${files}/basic/anonymous/api/library/{libraryId}/document/{documentId}/entry", + getFloor : function() { + return this.getAsString("floor"); + }, /** - * A feed of files of which the authenticated user owns. + * Get Pronunciation URL of the profile * - * Get the My Files feed to see a list of the files which the authenticated owns. - * Supports: acls , includePath , includeQuota , includeTags , page , ps , shared , sI , since , sortBy , sortOrder , tag , visibility + * @method getPronunciationUrl + * @return {String} Pronunciation URL of the profile */ - AtomFilesMy : "/${files}/basic/api/myuserlibrary/feed", - + getPronunciationUrl : function() { + return this.getAsString("soundUrl"); + }, + /** - * A feed of files with are shared by or with the authenticated user. + * Get summary of the profile * - * Get the My Files feed to see a list of the files which the authenticated owns. - * Supports: direction (default inbound : with me, outbound : by me), acls , includePath , includeQuota , includeTags , page , ps , shared , sI , since , sortBy , sortOrder , tag , visibility + * @method getSummary + * @return {String} description of the profile */ - AtomFilesShared : "/${files}/basic/api/documents/shared/feed", - + getSummary : function() { + return this.getAsString("summary"); + }, + /** - * Get a feed that lists all public files. - * - * Supports: acls , includePath , includeQuota , includeTags , page , ps , shared , sI , since , sortBy , sortOrder , tag , visibility + * Set work phone number of the profile in the field object + * + * @method setTelephoneNumber + * @param {String} telephoneNumber work phone number of the profile */ - AtomFilesPublic : "/${files}/basic/anonymous/api/documents/feed?visibility=public", + setTelephoneNumber : function(telephoneNumber) { + this.setAsString("telephoneNumber", telephoneNumber); + }, /** - * Get feed of recycled files + * Set building of the profile in the field object + * + * @method setBuilding + * @param {String} building building name of the profile */ - AtomFilesRecycled : "/${files}/basic/api/myuserlibrary/view/recyclebin/feed", + setBuilding : function(building) { + this.setAsString("building", building); + }, /** - * Get a feed that lists your folders - * - * Supports: access(editor or manager), creator, page, ps, shared, sharedWithMe, sI, sortBy, sortOrder, title, visibility + * Set floor number of the profile in the field object + * + * @method setFloor + * @param {String} floor floor number of the profile */ - AtomFoldersMy : "/${files}/basic/api/collections/feed", - + setFloor : function(floor) { + this.setAsString("floor", floor); + }, + /** - * Feed of public folders + * Set job title of the profile in the field object + * + * @method setJobTitle + * @param {String} title job title of the profile */ - AtomFoldersPublic : "/${files}/basic/anonymous/api/collections/feed", - + setJobTitle : function(title) { + this.setAsString("jobTitle", title); + }, + /** - * Feed of folders you recently added files to + * Set the location of the file input element in the markup for editing + * profile photo in the field object + * + * @method setPhotoLocation + * @param {String} imgLoc location of the file input element */ - AtomFoldersActive : "/${files}/basic/api/collections/addedto/feed", + setPhotoLocation : function(imgLoc) { + this.setAsString("imageLocation", imgLoc); + }, + + /** + * Set the address of the profile in the field object + * + * @method setAddress + * @param {Object} address Address object of the profile. + */ + setAddress : function(address) { + this.setAsObject(address); + }, + + /** + * Loads the profile object with the profile entry document associated + * with the profile. By default, a network call is made to load the + * profile entry document in the profile object. + * + * @method load + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + * + */ + load : function(args) { + var profileId = this.getUserid() || this.getEmail(); + var promise = this.service._validateProfileId(profileId); + if (promise) { + return promise; + } + + var self = this; + var callbacks = { + createEntity : function(service,data,response) { + self.setData(data, response); + return self; + } + }; + var requestArgs = {}; + if (this.service.isEmail(profileId)) { + requestArgs.email = profileId; + } else { + requestArgs.userid = profileId; + } + lang.mixin(requestArgs, args || {}); + var options = { + handleAs : "text", + query : requestArgs + }; + + var url = this.service.constructUrl(consts.AtomProfileDo, {}, {authType : this.service._getProfileAuthString()}); + return this.service.getEntity(url, options, profileId, callbacks, args); + }, + + /** + * Updates the profile of a user. + * + * @method update + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + update : function(args) { + return this.service.updateProfile(this, args); + }, /** - * A feed of comments associated with all public files. Do not authenticate this request. - * - * Supports: acls, category Note: This parameter is required., commentId, identifier, page, ps, sI, sortBy, sortOrder + * Get colleagues of the profile. + * + * @method getColleagues + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - AtomFileCommentsPublic : "/${files}/basic/anonymous/api/userlibrary/{userId}/document/{documentId}/feed?category=comment", + getColleagues : function(args){ + return this.service.getColleagues(this, args); + }, + /** + * Get colleague connections of the profile. + * + * @method getColleagueConnections + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getColleagueConnections : function(args){ + return this.service.getColleagueConnections(this, args); + }, /** - * A feed of comments associated with files to which you have access. You must authenticate this request. - * - * Supports: acls, category Note: This parameter is required., commentId, identifier, page, ps, sI, sortBy, sortOrder + * Return content element to be included in post data for the creation or updaton of new profile entry. + * + * @method createContent + * @returns {String} */ - AtomFileCommentsMy : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/feed?category=comment", + createContent : function() { + if(this._update){ + this._update = false; + var transformer = function(value,key) { + if (key == "address") { + value = this.service._isAddressSet(this) ? stringUtil.transform(updateProfileAddressTemplate, {"streetAddress" : this._fields["streetAddress"], + "extendedAddress" : this._fields["extendedAddress"], "locality" : this._fields["locality"], "region" : this._fields["region"], + "postalCode" : this._fields["postalCode"], "countryName" : this._fields["countryName"]}) : null; + } + else{ + value = (this._fields[key])? stringUtil.transform(updateProfileAttributeTemplate, {"attributeName" : consts.ProfileVCardXPath[key], "attributeValue" : this._fields[key]}) : null; + + } + return value; + }; + var content = stringUtil.transform(updateProfileXmlTemplate, this, transformer, this); + if (content) { + return stringUtil.transform(ContentTmpl, { "contentType" : "text", "content" : content }); + } + return ""; + }else{ + var transformer = function(value,key) { + if(this._fields[key]){ + value = stringUtil.transform(createProfileAttributeTemplate, {"attributeName" : consts.profileCreateAttributes[key], "attributeValue" : this._fields[key]}); + return value; + } + }; + var content = stringUtil.transform(createProfileTemplate, this, transformer, this); + if(content){ + return stringUtil.transform(ContentTmpl, { "contentType" : "application/xml", "content" : content }); + } + return ""; + } + + }, /** - * Adds a comment to the specified file. + * Return tags elements to be included in post data for creation and updation of profile entry. * - * Supports : identifier - Indicates how the document is identified in the {document-id} variable segment of the web address. By default, look up is performed with the expectation that the URL contains the value from the <td:uuid> element of a File Atom entry. Specify "label" if the URL instead contains the value from the <td:label> element of a File Atom entry. + * @method createTags + * @returns {String} */ - AtomAddCommentToFile : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/feed", + createTags : function() { + return ""; + } + }); + + /** + * ColleagueConnection class. + * + * @class ConnectionEntry + * @namespace sbt.connections + */ + var ColleagueConnection = declare(AtomEntity, { + /** - * Adds a comment to the specified file for logged in user. * - * Supports : identifier - Indicates how the document is identified in the {document-id} variable segment of the web address. By default, look up is performed with the expectation that the URL contains the value from the <td:uuid> element of a File Atom entry. Specify "label" if the URL instead contains the value from the <td:label> element of a File Atom entry. + * @constructor + * @param args */ - AtomAddCommentToMyFile : "/${files}/basic/api/myuserlibrary/document/{documentId}/feed", - + constructor : function(args) { + } + }); + + /** + * ProfileTag class. + * + * @class ProfileTag + * @namespace sbt.connections + */ + var ProfileTag = declare(BaseEntity, { + /** - * Update the Atom document representation of the metadata for a file from logged in user's library. * - * supports : - * propagate Indicates if users that are shared with can share this document. The default value is true. - * sendEmail Indicates if an email notification is sent when sharing with the specified user. The default value is true. + * @constructor + * @param args */ - AtomUpdateFileMetadata : "/${files}/basic/api/myuserlibrary/document/{documentId}/entry", - + constructor : function(args) { + }, + /** - * Get pinned files from my my favorites feed. + * Get term of the profile tag * - */ - AtomFilesMyPinned : "/${files}/basic/api/myfavorites/documents/feed", - - /** - * Add a file to my favorites feed of logged in user + * @method getTerm + * @return {String} term of the profile tag * */ - AtomPinFile : "/${files}/basic/api/myfavorites/documents/feed", - - /** - * Add file of list of files to folder - */ - AtomAddFilesToFolder : "/${files}/basic/api/collection/{collectionId}/feed", - - /** - * Delete a file and the Atom document representation of its associated metadata from logged in user's collection. - */ - AtomDeleteFile : "/${files}/basic/api/myuserlibrary/document/{documentId}/entry", + getTerm : function() { + return this.getAsString("term"); + }, /** - * Lock or unlock a file + * Get frequency of the profile tag + * + * @method getFrequency + * @return {Number} frequency of the profile tag + * */ - AtomLockUnlockFile : "/${files}/basic/api/document/{documentId}/lock", + getFrequency : function() { + return this.getAsNumber("frequency"); + }, /** - * Add the document to collections specified by atom entry or feed. + * Get intensity of the profile tag + * + * @method getIntensity + * @return {Number} intensity of the profile tag + * */ - AtomAddFileToFolders : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/feed", - - /** - * Add the document of logged in user to collections specified by atom entry or feed. - */ - AtomAddMyFileToFolders : "/${files}/basic/api/myuserlibrary/document/{documentId}/feed", + getIntensity : function() { + return this.getAsNumber("intensity"); + }, /** - * Create a file folder programmatically. + * Get visibility of the profile tag + * + * @method getVisibility + * @return {Number} visibility of the profile tag + * */ - AtomCreateFolder : "/${files}/basic/api/collections/feed", + getVisibility : function() { + return this.getAsNumber("visibility"); + } + }); + + /** + * Invite class. + * + * @class Invite + * @namespace sbt.connections + */ + var Invite = declare(AtomEntity, { + + xpath : consts.InviteXPath, + contentType : "html", + categoryScheme : CategoryConnection, + /** - * Delete all files from recycle bin of specified user + * + * @constructor + * @param args */ - AtomDeleteAllFilesFromRecyclebBin : "/${files}/basic/api/userlibrary/{userId}/view/recyclebin/feed", + constructor : function(args) { + }, /** - * Delete all files from recycle bin of logged in user + * Return extra entry data to be included in post data for this entity. + * + * @returns {String} */ - AtomDeleteMyFilesFromRecyclebBin : "/${files}/basic/api/myuserlibrary/view/recyclebin/feed", + createEntryData : function() { + var entryData = ""; + entryData += stringUtil.transform(CategoryConnectionType, this, function(v,k) { return v; }, this); + entryData += stringUtil.transform(CategoryStatus, this, function(v,k) { return v; }, this); + return stringUtil.trim(entryData); + }, /** - * Delete All Versions of a File + * Return tags elements to be included in post data for creation and updation of invite entry. + * + * @method createTags + * @returns {String} */ - AtomDeleteAllVersionsOfAFile : "/${files}/basic/api/myuserlibrary/document/{documentId}/feed", + createTags : function() { + return ""; + }, - /** - * Delete a Comment for a File - */ - AtomDeleteComment : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/comment/{commentId}/entry", /** - * Delete a comment on file for logged in user + * Return the connection type associated with this invite. + * + * @method getConnectionType + * @return {String} status */ - AtomDeleteMyComment : "/${files}/basic/api/myuserlibrary/document/{documentId}/comment/{commentId}/entry", - + getConnectionType : function() { + var connectionType = this.getAsString("connectionType"); + return connectionType || consts.TypeColleague; + }, + /** - * Purge a file from Recycle Bin + * Set the connection type associated with this invite. + * + * @method setConnectionType + * @param {String} status */ - AtomDeleteFileFromRecycleBin : "/${files}/basic/api/userlibrary/{userId}/view/recyclebin/{documentId}/entry", - + setConnectionType : function(connectionType) { + return this.setAsString("connectionType", connectionType); + }, + /** - * Purge a file from REcycle Bin for Logged in user + * Return the status associated with this invite. + * + * @method getStatus + * @return {String} status */ - AtomDeleteMyFileFromRecycleBin : "/${files}/basic/api/myuserlibrary/view/recyclebin/{documentId}/entry", + getStatus : function() { + var status = this.getAsString("status"); + return status || consts.StatusPending; + }, /** - * Remove a file Share + * Set the status associated with this invite. + * + * @method setStatus + * @param {String} status */ - AtomDeleteFileShare : "/${files}/basic/api/shares/feed", + setStatus : function(status) { + return this.setAsString("status", status); + }, /** - * Delete a Folder + * Return the connection id associated with this invite. + * + * @method getConnectionId + * @return {String} connectionId */ - AtomDeleteFolder : "/${files}/basic/api/collection/{collectionId}/entry", + getConnectionId : function() { + return this.getAsString("connectionId"); + }, /** - * Get Files for a user + * Set connection id associated with this invite. + * + * @method setConnectionId + * @param connectionId + * @return {Invite} */ - AtomGetAllUsersFiles : "/${files}/basic/anonymous/api/userlibrary/{userId}/feed", + setConnectionId : function(connectionId) { + return this.setAsString("connectionId", connectionId); + } + }); + + /** + * Callbacks used when reading an entry that contains a Profile. + */ + var ProfileCallbacks = { + createEntity : function(service,data,response) { + return new Profile({ + service : service, + data : data, + response: response + }); + } + }; + + /** + * Callbacks used when reading a feed that contains Profile entries. + */ + var ProfileFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.ProfileFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new Profile({ + service : service, + data: data, + response: response + }); + } + }; + + /** + * Callbacks used when reading a feed that contains ColleagueConnections + */ + var ColleagueConnectionFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.ProfileFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new ColleagueConnection({ + service : service, + data: data, + response: response + }); + } + }; + + /** + * Callbacks used when reading a feed that contains Profile Tag entries. + */ + var ProfileTagFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.ProfileTagsXPath + }); + }, + createEntity : function(service,data,response) { + var entryHandler = new XmlDataHandler({ + data : data, + namespaces : consts.Namespaces, + xpath : consts.ProfileTagsXPath + }); + return new ProfileTag({ + service : service, + id : entryHandler.getEntityId(), + dataHandler : entryHandler + }); + } + }; + + /** + * ProfileService class. + * + * @class ProfileService + * @namespace sbt.connections + */ + var ProfileService = declare(ConnectionsService, { - /** - * Get a comment for a file - */ - AtomGetFileComment : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/comment/{commentId}/entry", + contextRootMap: { + profiles: "profiles" + }, + serviceName : "profiles", + /** - * Get a comment for a File for logged in user + * + * @constructor + * @param args */ - AtomGetMyFileComment : "/${files}/basic/api/myuserlibrary/document/{documentId}/comment/{commentId}/entry", + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } + if(!this._cache){ + if(config.Properties.ProfileCacheSize || consts.DefaultCacheSize){ + this._cache = new Cache(config.Properties.ProfileCacheSize || consts.DefaultCacheSize); + } + } + }, /** - * Get File from Recycle Bin - */ - AtomGetFileFromRecycleBin : "/${files}/basic/api/userlibrary/{userId}/view/recyclebin/{documentId}/entry", - + * Create a Profile object with the specified data. + * + * @method newProfile + * @param {Object} args Object containing the fields for the + * new Profile + */ + newProfile : function(args) { + return this._toProfile(args); + }, + /** - * Get Files Awaiting Approval + * Create a Invite object with the specified data. + * + * @method newInvite + * @param {Object} args Object containing the fields for the + * new Invite */ - AtomGetFilesAwaitingApproval : "/${files}/basic/api/approval/documents", - + newInvite : function(args) { + return this._toInvite(args); + }, + /** - * Get File Shares + * Get the profile of a user. + * + * @method getProfile + * @param {String} userIdOrEmail Userid or email of the profile + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - AtomGetFileShares : "/${files}/basic/api/documents/shared/feed", + getProfile : function(userIdOrEmail, args) { + var profile = this._toProfile(userIdOrEmail); + var promise = this._validateProfile(profile); + if (promise) { + return promise; + } + return profile.load(args); + }, /** - * Get All Files in a Folder + * Update an existing profile + * + * @method updateProfile + * @param {Object} profileOrJson Profile object to be updated + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - AtomGetFilesInFolder : "/${files}/basic/api/collection/{collectionId}/feed", + updateProfile : function(profileOrJson,args) { + var profile = this._toProfile(profileOrJson); + profile._update = true; + var promise = this._validateProfile(profile); + if (promise) { + return promise; + } + + var requestArgs = {}; + profile.getUserid() ? requestArgs.userid = profile.getUserid() : requestArgs.email = profile.getEmail(); + lang.mixin(requestArgs, args || {}); + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + return profile; + }; + + var options = { + method : "PUT", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : profile.createPostData() + }; + var url = this.constructUrl(consts.AtomProfileEntryDo, {}, {authType : this._getProfileAuthString()}); + + return this.updateEntity(url, options, callbacks, args); + }, /** - * Get Files in Recycle Bin of logged in user + * Get the tags for the specified profile + * + * @method getTags + * @param {String} id userId/email of the profile + * @param {Object} args Object representing various query parameters that can be passed. The parameters must + * be exactly as they are supported by IBM Connections. */ - AtomGetFilesInMyRecycleBin : "/${files}/basic/api/myuserlibrary/view/recyclebin/feed", + getTags : function(id, args) { + // detect a bad request by validating required arguments + var idObject = this._toTargetObject(id); + var promise = this._validateTargetObject(idObject); + if (promise) { + return promise; + } + + var options = { + method : "GET", + handleAs : "text", + query : lang.mixin(idObject, args || {}) + }; + var url = this.constructUrl(consts.AtomTagsDo, {}, {authType : this._getProfileAuthString()}); + + return this.getEntities(url, options, this.getProfileTagFeedCallbacks(), args); + }, /** - * Get file with given version + * Get the colleagues for the specified profile + * + * @method getColleagues + * @param {String} id userId/email of the profile + * @param {Object} args Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - AtomGetFileWithGivenVersion : "/${files}/basic/api/myuserlibrary/document/{documentId}/version/{versionId}/entry", + getColleagues : function(id, args) { + // detect a bad request by validating required arguments + var idObject = this._toIdObject(id); + var promise = this._validateIdObject(idObject); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin(idObject, { + connectionType : "colleague", + outputType : "profile" + }, args || {}); + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + var url = this.constructUrl(consts.AtomConnectionsDo, {}, {authType : this._getProfileAuthString()}); + return this.getEntities(url, options, this.getProfileFeedCallbacks(), args); + }, /** - * Get a folder + * Get the colleagues for the specified profile as Collegue Connection entries + * + * @method getColleagueConnections + * @param {String} id userId/email of the profile + * @param {Object} args Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - AtomGetFolder : "/${files}/basic/api/collection/{collectionId}/entry", + getColleagueConnections : function(id, args) { + // detect a bad request by validating required arguments + var idObject = this._toIdObject(id); + var promise = this._validateIdObject(idObject); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin(idObject, { + connectionType : "colleague", + outputType : "connection" + }, args || {}); + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + var url = this.constructUrl(consts.AtomConnectionsDo, {}, {authType : this._getProfileAuthString()}); + return this.getEntities(url, options, this.getColleagueConnectionFeedCallbacks(), args); + }, /** - * Get Folder with Recenty Added Files + * Get the reporting chain for the specified person. + * + * @method getReportingChain + * @param {String} id userId/email of the profile + * @param {Object} args Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - AtomGetFoldersWithRecentlyAddedFiles : "/${files}/basic/api/collections/addedto/feed", + getReportingChain : function(id, args) { + // detect a bad request by validating required arguments + var idObject = this._toIdObject(id); + var promise = this._validateIdObject(idObject); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin(idObject, args || {}); + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + var url = this.constructUrl(consts.AtomReportingChainDo, {}, {authType : this._getProfileAuthString()}); + return this.getEntities(url, options, this.getProfileFeedCallbacks(), args); + }, /** - * Get Pinned Folders + * Get the people managed for the specified person. + * + * @method getPeopleManaged + * @param {String} id userId/email of the profile + * @param {Object} args Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - AtomGetPinnedFolders : "/${files}/basic/api/myfavorites/collections/feed", - + getPeopleManaged : function(id, args) { + // detect a bad request by validating required arguments + var idObject = this._toIdObject(id); + var promise = this._validateIdObject(idObject); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin(idObject, args || {}); + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + var url = this.constructUrl(consts.AtomPeopleManagedDo, {}, {authType : this._getProfileAuthString()}); + return this.getEntities(url, options, this.getProfileFeedCallbacks(), args); + }, + /** - * Get Public Folders + * Search for a set of profiles that match a specific criteria and return them in a feed. + * + * @method search + * @param {Object} args Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - AtomGetPublicFolders : "/${files}/basic/anonymous/api/collections/feed", + search : function(args) { + // detect a bad request by validating required arguments + if (!args) { + return this.createBadRequestPromise("Invalid arguments, one or more of the input parameters to narrow the search must be specified."); + } + + var options = { + method : "GET", + handleAs : "text", + query : args + }; + var url = this.constructUrl(consts.AtomSearchDo, {}, {authType : this._getProfileAuthString()}); + return this.getEntities(url, options, this.getProfileFeedCallbacks(), args); + }, /** - * Pin/unpin a Folder - */ - AtomPinFolder : "/${files}/basic/api/myfavorites/collections/feed", + * Updates the profile photo of a user. + * @method updateProfilePhoto + * @param {Object} fileControlOrId The Id of html control or the html control + * @param @param {String} id userId/email of the profile + * @param {Object} [args] The additional parameters + */ + updateProfilePhoto: function (fileControlOrId, id, args) { + var promise = this.validateField("File Control Or Id", fileControlOrId); + if (promise) { + return promise; + } + promose = this.validateHTML5FileSupport(); + if(promise){ + return promise; + } + + var idObject = this._toIdObject(id); + var files = null; + if (typeof fileControlOrId == "string") { + var fileControl = document.getElementById(fileControlOrId); + filePath = fileControl.value; + files = fileControl.files; + } else if (typeof fileControlOrId == "object") { + filePath = fileControlOrId.value; + files = fileControlOrId.files; + } else { + return this.createBadRequestPromise("File Control or ID is required"); + } + + if(files.length != 1){ + return this.createBadRequestPromise("Only one file needs to be provided to this API"); + } + + var file = files[0]; + var formData = new FormData(); + formData.append("file", file); + var requestArgs = lang.mixin(idObject, args || {}); + var url = this.constructUrl(config.Properties.serviceUrl + "/files/" + this.endpoint.proxyPath + "/" + "connections" + "/" + "UpdateProfilePhoto" + "/" + encodeURIComponent(file.name), + args && args.parameters ? args.parameters : {}); + var headers = { + "Content-Type" : false, + "Process-Data" : false // processData = false is reaquired by jquery + }; + var options = { + method : "PUT", + headers : headers, + query : requestArgs || {}, + data : formData + }; + var callbacks = { + createEntity : function(service, data, response) { + return data; // Since this API does not return any response in case of success, returning empty data + } + }; + + return this.updateEntity(url, options, callbacks); + }, /** - * Remove File from Folder + * Invite a person to become your colleague. + * + * @method inviteColleague + * @param id + * @param inviteOrJson + * @param args */ - AtomRemoveFileFromFolder : "/${files}/basic/api/collection/{collectionId}/feed", + createInvite : function(id, inviteOrJson, args) { + // detect a bad request by validating required arguments + var idObject = this._toIdObject(id); + var promise = this._validateIdObject(idObject); + if (promise) { + return promise; + } + + var invite = this._toInvite(inviteOrJson); + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + invite.setData(data); + var connectionId = this.getLocationParameter(response, "connectionId"); + invite.setConnectionId(connectionId); + return invite; + }; + + var requestArgs = lang.mixin(idObject, args || {}); + var options = { + method : "POST", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : invite.createPostData() + }; + + var url = this.constructUrl(consts.AtomConnectionsDo, {}, {authType : this._getProfileAuthString()}); + return this.updateEntity(url, options, callbacks, args); + }, /** - * Restore File from Recycle Bin + * Update profile tags. When you update profile tags, the existing tag information added by you is replaced with the new tag information. + * To avoid this, retrieve the tags that you want to retain first, and send them back with this request. + * + * @method updateTags + * @param {Array} tags + * @param {String} targetEmailOrUserId email address or userid of the person whose profile you want to apply the tags to + * @param {String} sourceEmailOrUserId email address or useridof the creator of the tags + * @param args */ - AtomRestoreFileFromRecycleBin : "/${files}/basic/api/userlibrary/{userId}/view/recyclebin/{documentId}/entry", + updateTags : function(tags, targetEmailOrUserId, sourceEmailOrUserId, args) { + // detect a bad request by validating required arguments + var promise = this._validateProfileId(targetEmailOrUserId); + if (promise) { + return promise; + } + + promise = this._validateProfileId(sourceEmailOrUserId); + if (promise) { + return promise; + } + + var requestArgs = {}; + if (this.isEmail(targetEmailOrUserId)) { + requestArgs.targetEmail = targetEmailOrUserId; + } else { + requestArgs.targetKey = targetEmailOrUserId; + } + if (this.isEmail(sourceEmailOrUserId)) { + requestArgs.sourceEmail = sourceEmailOrUserId; + } else { + requestArgs.sourceKey = sourceEmailOrUserId; + } + lang.mixin(requestArgs, args || {}); + + var callbacks = { + createEntity : function(service, data, response) { + return data; // Since this API does not return any response in case of success, returning empty data + } + }; + + var options = { + method : "PUT", + query : requestArgs, + headers : consts.AtomXmlHeaders, + data : this._createTagsPostData(tags) + }; + + + var url = this.constructUrl(consts.AtomTagsDo, {}, {authType : this._getProfileAuthString()}); + + return this.updateEntity(url, options, callbacks, args); + }, + + // + // Internals + // - /** - * Share File with Community or communities + /* + * Return callbacks for a profile feed */ - AtomShareFileWithCommunities : "/${files}/basic/api/myuserlibrary/document/{documentId}/feed", - - /** - * Update a Comment - */ - AtomUpdateComment : "/${files}/basic/api/userlibrary/{userId}/document/{documentId}/comment/{commentId}/entry", + getProfileFeedCallbacks : function() { + return ProfileFeedCallbacks; + }, - /** - * Update comment of logged in user + /* + * Return callbacks for a ColleagueConnection feed */ - AtomUpdateMyComment : "/${files}/basic/api/myuserlibrary/document/{documentId}/comment/{commentId}/entry", - - /** - * Add Comment To Community File + getColleagueConnectionFeedCallbacks : function() { + return ColleagueConnectionFeedCallbacks; + }, + + /* + * Return callbacks for a profile entry */ - AtomAddCommentToCommunityFile : "/${files}/basic/api/communitylibrary/{communityId}/document/{documentId}/feed", - - /** - * Get All Community Files, Shows only files with with a libraryType of communityFiles - * TODO This should be renamed + getProfileCallbacks : function() { + return ProfileCallbacks; + }, + + /* + * Return callbacks for a profile tag feed */ - AtomGetAllFilesInCommunity : "/${files}/basic/api/communitylibrary/{communityId}/feed", + getProfileTagFeedCallbacks : function() { + return ProfileTagFeedCallbacks; + }, - /** - * Get all files in a community, Shows public, private, communityFiles etc. + /* + * Convert profile or key to id object */ - AtomGetAllCommunityFiles : "/${files}/basic/api/communitycollection/{communityId}/feed", + _toIdObject : function(profileOrId) { + var idObject = {}; + if (lang.isString(profileOrId)) { + var userIdOrEmail = profileOrId; + if (this.isEmail(userIdOrEmail)) { + idObject.email = userIdOrEmail; + } else { + idObject.userid = userIdOrEmail; + } + } else if (profileOrId instanceof Profile) { + if (profileOrId.getUserid()) { + idObject.userid = profileOrId.getUserid(); + } + else if (profileOrId.getEmail()) { + idObject.email = profileOrId.getEmail(); + } + } + return idObject; + }, - /** - * Get Community File - */ - AtomGetCommunityFile : "/${files}/basic/api/communitylibrary/{communityId}/document/{documentId}/entry", - - /** - * Update metadata of community File - */ - AtomUpdateCommunityFileMetadata : "/${files}/basic/api/library/{libraryId}/document/{documentId}/entry" - }, conn); -}); -}, -'url:sbt/connections/controls/activities/templates/ActivityRow.html':"<tr class=\"oaActivityRowNode lotusFirst\">\r\n\t<td width=\"20\" class=\"lotusFirstCell\">\r\n\t\t<div\r\n\t\t\tclass=\"iconsComponentsGray16 iconsComponentsGray16-ActivitiesGray16\">\r\n\t\t</div>\r\n\t</td>\r\n\t<td>\r\n\t\t<h4>\r\n\t\t\t<a href=\"\" data-dojo-attach-event=\"onclick: handleClick\" title=\"${tooltip}\" class=\"oaActivityNameNode\">${title}</a> \r\n\t\t\t<span class=\"cnxnsType lotusMeta\"> </span>\r\n\t\t</h4>\r\n\t\t\r\n\t\t<div class=\"lotusMeta\">\r\n\t\t\t<span>${nls.updatedBy}\r\n\t\t\t\t<span> <a href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\">${authorName}</a></span> \r\n\t\t\t\t\r\n\t\t\t\t<span class=\"lotusDivider\">|</span> \r\n\t\t\t\t<span class=\"oaFormatDate\">${updatedDate}</span>\r\n\t\t\t\t\r\n\r\n\t\t\t</span>\r\n\t\t\t\r\n\t\t\t<span>\r\n\t\t\t\t<span class=\"lotusDivider\">|</span> \r\n\t\t\t\t${nls.dueDate}\t\t\t\t\r\n\t\t\t\t<span class=\"oaFormatDate\">${getDueDate}</span>\r\n\t\t\t</span>\r\n\t\t\t<span>\r\n\t\t\t\t<span class=\"lotusDivider\">|</span> \r\n\t\t\t\t${nls.tags}\t\t\t\t\r\n\t\t\t\t<span class=\"oaFormatDate\">${tags}</span>\r\n\t\t\t</span>\r\n\t\t</div>\r\n\t</td>\r\n</tr>", -'sbt/smartcloud/SmartcloudConstants':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ - -/** - * Social Business Toolkit SDK. Definition of constants for IBM Connections. - * - * @module sbt.connections.ConnectionsConstants - */ -define([ "../lang", "../base/BaseConstants" ], function(lang, base) { - - return lang.mixin(base, { - - /** - * XPath expressions used when parsing a Connections ATOM feed - */ - SmartcloudFeedXPath : { - // used by getEntitiesDataArray - entries : "/a:feed/a:entry", - // used by getSummary - totalResults : "/a:feed/opensearch:totalResults", - startIndex : "/a:feed/opensearch:startIndex", - itemsPerPage : "/a:feed/opensearch:itemsPerPage" - } - - }); -}); -}, -'sbt/smartcloud/ProfileConstants':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ -/** - * Social Business Toolkit SDK. Definition of constants for ProfileService. - */ -define([ "../lang" ], function(lang) { - - return lang.mixin( {} , { - /** - * Default size for the profile cache + /* + * Convert profile or key to target object */ - DefaultCacheSize : 10, + _toTargetObject : function(profileOrId) { + var targetObject = {}; + if (lang.isString(profileOrId)) { + var userIdOrEmail = profileOrId; + if (this.isEmail(userIdOrEmail)) { + targetObject.targetEmail = userIdOrEmail; + } else { + targetObject.targetKey = userIdOrEmail; + } + } else if (profileOrId instanceof Profile) { + if (profileOrId.getUserid()) { + targetObject.targetKey = profileOrId.getUserid(); + } + else if (profileOrId.getEmail()) { + targetObject.targetEmail = profileOrId.getEmail(); + } + } + return targetObject; + }, - /** - * Retrieve the profile entry of the logged in user. + /* + * Validate an ID object */ - GetProfile : "/lotuslive-shindig-server/social/rest/people/@me/@self", + _validateIdObject : function(idObject) { + if (!idObject.userid && !idObject.email) { + return this.createBadRequestPromise("Invalid argument, userid or email must be specified."); + } + }, - /** - * Retrieve the logged in user's profile connections. + /* + * Validate an Target object */ - GetMyConnections : "/lotuslive-shindig-server/social/rest/people/@me/@friends", + _validateTargetObject : function(idObject) { + if (!idObject.targetKey && !idObject.targetEmail) { + return this.createBadRequestPromise("Invalid argument, userid or email must be specified."); + } + }, - /** - * Retrieve a profile's user Identity. + /* + * Return a Profile instance from Profile or JSON or String. Throws + * an error if the argument was neither. */ - GetUserIdentity : "/manage/oauth/getUserIdentity", + _toProfile : function(profileOrJsonOrString,args) { + if (profileOrJsonOrString instanceof Profile) { + return profileOrJsonOrString; + } else { + var profileJson = profileOrJsonOrString; + if (lang.isString(profileOrJsonOrString)) { + profileJson = {}; + if(this.isEmail(profileOrJsonOrString)){ + profileJson.email = profileOrJsonOrString; + }else{ + profileJson.userid = profileOrJsonOrString; + } + }else{ // handle the case when the profileJson has id attribute. id can take either userid or email. + if(profileJson && profileJson.id && !profileJson.userid && !profileJson.email){ + this.isEmail(profileJson.id) ? profileJson.email = profileJson.id : profileJson.userid = profileJson.id; + delete profileJson.id; + } + } + return new Profile({ + service : this, + _fields : lang.mixin({}, profileJson) + }); + } + }, - /** - * Retrieve a Contact's Profile. + /* + * Return a Invite instance from Invite or JSON or String. Throws + * an error if the argument was neither. */ - GetContactByGUID : "/lotuslive-shindig-server/social/rest/people/lotuslive:contact:{idToBeReplaced}/@self", + _toInvite : function(inviteOrJsonOrString,args) { + if (inviteOrJsonOrString instanceof Invite) { + return inviteOrJsonOrString; + } else { + if (lang.isString(inviteOrJsonOrString)) { + inviteOrJsonOrString = { + content : inviteOrJsonOrString + }; + } + return new Invite({ + service : this, + _fields : lang.mixin({}, inviteOrJsonOrString) + }); + } + }, - /** - * Retrieve a profiles entry using GUID. + /* + * Returns true if an address field has been set. */ - GetProfileByGUID : "/lotuslive-shindig-server/social/rest/people/lotuslive:user:{idToBeReplaced}/@self", + _isAddressSet : function(profile){ + return (profile._fields["streetAddress"] || profile._fields["extendedAddress"] || profile._fields["locality"] || profile._fields["region"] || profile._fields["postalCode"] || profile._fields["countryName"]); + }, - /** - * Retrieve the logged in user's profile contacts. + /* + * Validate a Profile object */ - GetMyContacts : "/lotuslive-shindig-server/social/rest/people/@me/@all", + _validateProfile : function(profile) { + if (!profile || (!profile.getUserid() && !profile.getEmail())) { + return this.createBadRequestPromise("Invalid argument, profile with valid userid or email must be specified."); + } + }, - /** - * JsonPath expressions to be used when reading a Profile Entry + /* + * Validate a Profile id */ - ProfileJsonPath : { - thumbnailUrl : "$..photo", - address : "$..address", - department : "$..name", - jobTitle : "$..jobtitle", - telephone : "$..telephone", - about : "$..aboutMe", - id : "$..id", - objectId : "$..objectId", - displayName : "$..displayName", - emailAddress : "$..emailAddress", - profileUrl : "$..profileUrl", - country : "$..country", - orgId : "$..orgId", - org : "$..org.name", - global : "$..", - firstElement : "$[0]", - totalResults : "totalResults", - startIndex : "startIndex", - itemsPerPage : "itemsPerPage" + _validateProfileId : function(profileId) { + if (!profileId || profileId.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected userid or email"); + } + }, + + _getProfileAuthString : function(){ + if (this.endpoint.authType == consts.AuthTypes.Basic) { + return basicAuthString; + } else if (this.endpoint.authType == consts.AuthTypes.OAuth) { + return OAuthString; + } else { + return defaultAuthString; + } + }, + + _createTagsPostData : function(tags) { + var value = ""; + for (var i=0; i< tags.length;i++) { + value += stringUtil.transform(CategoryTmpl, { "tag" : tags[i] }); + } + var postData = stringUtil.transform(createProfileTagsTemplate, {"createTags" : value}); + return stringUtil.trim(postData); } + }); + return ProfileService; }); + }, -'sbt/connections/controls/search/SearchBox':function(){ +'url:sbt/connections/controls/files/templates/BootstrapFileRow.html':"<tr>\r\n <td style=\"width: 100%;\">\r\n <span class=\"icon-file\"></span>\r\n <span style=\"font-size:120%\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${tooltip}\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a> \r\n </span>\r\n </td>\r\n \r\n</tr>", +'sbt/connections/controls/search/SearchBoxRenderer':function(){ +require({cache:{ +'url:sbt/connections/controls/search/templates/SearchBoxTemplate.html':"<span class=\"lotusTitleBar2\">\r\n\t<span style=\"max-width:100%; padding:0px 0px 0px 0px;\" class=\"lotusWrapper\">\r\n\t\t<span style=\"border-bottom: none;\"class=\"lotusInner\">\r\n\t\t\t<div style=\"position:relative; margin-top:0px; top:0px;\" class=\"lotusSearch\" >\r\n\t\t\t\t\t<table cellspacing=\"0\" role=\"presentation\" class=\"lotusLayout\">\r\n\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<div class=\"lotusHidden\">${nls.refine}</div>\r\n\t\t\t\t\t\t\t\t\t<div>\r\n\t\t\t\t\t\t\t\t\t\t<a data-dojo-attach-event=\"onclick: handleClick\" class=\"lotusScope\" href=\"javascript:;\">\r\n\t\t\t\t\t\t\t\t\t\t\t<img src=\"images/blank.gif?etag=20120919.054848\"\r\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"${nls.allConnectionsIcon}\" class=\"lotusIcon lconnSprite lconnSprite-iconConnections16\">\r\n\t\t\t\t\t\t\t\t\t\t\t<span id=\"searchAppType\">${nls.allConnections}</span>\r\n\t\t\t\t\t\t\t\t\t\t\t<span role=\"presentation\" class=\"lotusAltText\">â–¼</span>\r\n\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span><label for=\"input\" style=\"display:none;\">text</label>\r\n\t\t\t\t\t\t\t\t\t\t<input id=\"input\" type=\"text\" data-dojo-attach-event=\"onkeyup: suggest, blur: setSearchQuery\" class=\"lotusText lotusInactive\" />\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span class=\"lotusBtnImg\"> \r\n\t\t\t\t\t\t\t\t\t\t<input data-dojo-attach-event=\"click: search\" class=\"lotusSearchButton\" type=\"image\" title=\"${nls.search}\" alt=\"${nls.search}\"\r\n\t\t\t\t\t\t\t\t\t\t\tsrc=\"images/blank.gif?etag=20120919.054848\"> \r\n\t\t\t\t\t\t\t\t\t\t<a class=\"lotusAltText\" alt=\"${nls.search}\" href=\"javascript:;\">${nls.search}</a>\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t</span>\r\n\t</span>\r\n</span>", +'url:sbt/connections/controls/search/templates/SearchSuggestTemplate.html':"<span class=\"lotusTitleBar2\">\r\n\t<span style=\"max-width:100%; padding:0px 0px 0px 0px;\" class=\"lotusWrapper\">\r\n\t\t<span style=\"border-bottom: none;\"class=\"lotusInner\">\r\n\t\t\t<div style=\"position:relative; margin-top:0px; top:0px;\" class=\"lotusSearch\" >\r\n\t\t\t\t\t<table cellspacing=\"0\" role=\"presentation\" class=\"lotusLayout\">\r\n\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t<div class=\"lotusHidden\">${nls.refine}</div>\r\n\t\t\t\t\t\t\t\t\t<div>\r\n\t\t\t\t\t\t\t\t\t\t<a data-dojo-attach-event=\"onclick: handleClick\" class=\"lotusScope\" href=\"javascript:;\">\r\n\t\t\t\t\t\t\t\t\t\t\t<img src=\"images/blank.gif?etag=20120919.054848\"\r\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"${nls.allConnectionsIcon}\" class=\"lotusIcon lconnSprite lconnSprite-iconConnections16\">\r\n\t\t\t\t\t\t\t\t\t\t\t<span>${nls.allConnections}</span>\r\n\t\t\t\t\t\t\t\t\t\t\t<span role=\"presentation\" class=\"lotusAltText\">â–¼</span>\r\n\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span ><label for=\"com.ibm.sbt.search.input\" style=\"display:none;\">text</label>\r\n\t\t\t\t\t\t\t\t\t\t<input id=\"com.ibm.sbt.search.input\" type=\"text\" data-dojo-attach-event=\"onkeyup: suggest, blur: setSearchQuery\" class=\"lotusText lotusInactive\" />\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span class=\"lotusBtnImg\"> \r\n\t\t\t\t\t\t\t\t\t\t<input data-dojo-attach-event=\"click: search\" class=\"lotusSearchButton\" type=\"image\" title=\"${nls.search}\" alt=\"${nls.search}\"\r\n\t\t\t\t\t\t\t\t\t\t\tsrc=\"images/blank.gif?etag=20120919.054848\"> \r\n\t\t\t\t\t\t\t\t\t\t<a class=\"lotusAltText\" alt=\"${nls.search}\" href=\"javascript:;\">${nls.search}</a>\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\r\n\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t</span>\r\n\t</span>\r\n</span>", +'url:sbt/connections/controls/search/templates/PopUpTemplate.html':"<table role=\"presentation\" tabindex=\"0\"\r\n\tdata-dojo-attach-event=\"blur: handleBlur, onkeypress: onKeyPress\"\r\n\tclass=\"dijit dijitMenu dijitReset dijitMenuTable lotusNavMenu lconnSearchScope dijitMenuActive\"\r\n\tstyle=\"position:fixed;\">\r\n\t<tbody tabindex=\"0\" class=\"dijitReset\">\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onmouseenter: displayHighlight, onmouseleave: removeHighlight, onclick: setSelectedApplication\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem lotusAlignLeft\">\r\n\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconConnections16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.allConnections}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onmouseenter: displayHighlight, onmouseleave: removeHighlight, onclick: setSelectedApplication\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconStatusUpdate16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.statusUpdates}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconActivities16\" />\r\n\t\t\t</td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.activities}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconBlogs16\" /></td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.blogs}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconBookmarks16\" />\r\n\t\t\t</td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.bookmarks}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconCommunities16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.communities}</td>\r\n\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconFiles16\" /></td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.files}</td>\r\n\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconForums16\" /></td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.forums}</td>\r\n\t\t</tr>\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconProfiles16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.profiles}</td>\r\n\r\n\t\t</tr>\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem dijitMenuItemSelected\">\r\n\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconWikis16\" /></td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.wikis}</td>\r\n\t\t</tr>\r\n\r\n\t</tbody>\r\n</table>", +'url:sbt/connections/controls/search/templates/SuggestPopUpTemplate.html':"<table style=\"border-radius:0px; list-style:none; cursor: pointer; width: 190px; position:absolute; z-index:100; background-color:#EEEEEE; left:13em; \" role=\"presentation\">\r\n</table>\r\n", +'url:sbt/connections/controls/search/templates/MemberListItemTemplate.html':"<span class=\"lotusFilters\">\r\n\t<a class=\"lotusFilter\" href=\"javascript:;\" data-dojo-attach-event=\"click: closeMemberItem\" >\r\n\t\t<span>${memberName}</span>\r\n\t\t<span class=\"lotusClose\">X</span>\r\n\t</a>  \r\n</span>", +'url:sbt/connections/controls/search/templates/MemberListTemplate.html':"<div style=\"padding-top: 15px;\" class=\"lotusHeader\"></div>", +'url:sbt/connections/controls/search/templates/SingleApplicationSearch.html':"<span style=\"position:relative\">\r\n\t<span>\r\n\t\t<span>\r\n\t\t\t<div>\r\n\t\t\t\t\t<table>\r\n\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t<tr>\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span><label style=\"display:none;\">text</label>\r\n\t\t\t\t\t\t\t\t\t\t<input style=\"width: 350px; height:2em;\" type=\"text\" data-dojo-attach-event=\"onkeyup: suggest,blur: setSearchQuery\" />\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t</span>\r\n\t</span>\r\n</span>", +'url:sbt/connections/controls/search/templates/SingleSearchPopUp.html':"<ul style=\"z-index:10000 !important; width:345px !important;list-style-type: none !important; padding-left:5px; !important\" class=\"dijitReset dijitMenu lotusui30dojo\" role=\"presentation\">\r\n \r\n </ul>"}}); /* - * ©©© 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. @@ -37467,782 +36369,373 @@ define([ "../lang" ], function(lang) { * permissions and limitations under the License. */ -define(["../../../declare", "../../../lang", "../../../dom", "../../../widget/_TemplatedWidget", "./SearchBoxRenderer", - "../../SearchService", "../../CommunityService"], - function(declare, lang, dom, _TemplatedWidget, SearchBoxRenderer,SearchService,CommunityService){ +define(["../../../declare", + "../../../lang", + "../../../text!./templates/SearchBoxTemplate.html", + "../../../text!./templates/SearchSuggestTemplate.html", + "../../../text!./templates/PopUpTemplate.html", + "../../../text!./templates/SuggestPopUpTemplate.html", + "../../../i18n!./nls/SearchBoxRenderer", + "../../../text!./templates/MemberListItemTemplate.html", + "../../../text!./templates/MemberListTemplate.html", + "../../../text!./templates/SingleApplicationSearch.html", + "../../../text!./templates/SingleSearchPopUp.html"], + function(declare,lang, template, SuggestTemplate, PopUpTemplate, SuggestionPopUp ,nls, + MemberListItemTemplate, MemberListTemplate, SingleApplicationSearch, SingleSearchPopUp){ /** - * @class SearchBox + * @class SearchBoxRenderer * @namespace sbt.connections.controls.search - * @module sbt.connections.controls.search.SearchBox + * @module sbt.connections.controls.search.SearchBoxRenderer */ - var SearchBox = declare(_TemplatedWidget,{ - - // TODO why is type not listed here? what does that parameter mean? - - /** - * TODO The "Loading" string needs to be externalied into nls. This should be in the renderer? - * Loading template - */ - templateString: "<div><strong> Loading... </strong></div>", - - /** - * The Renderer For this control - */ - renderer: null, - - /** - * The Application the user will select for example files, wikis etc, initially set to all - */ - selectedApplication: "allconnections", - - /** - * TODO should this be public? - * The phrase the user will search for. - */ - searchQuery: "", - - /** - * Search type, valid values are 'my' || 'public' (defaut value is 'my') - */ - searchType: "my", - - /** - * Search suffix, will be appended to every search query - */ - searchSuffix: null, - - /** - * Search arguments, will be added to each search request - */ - searchArgs: null, - - /** - * Search Service, used to perform the search - */ - searchService: null, - - /** - * Community service to perform searches on my Communities - */ - communityService: null, - - /** - * TODO Better pattern is to set is during postMixInProperties - * This list is used to keep track of selected members - */ - members: [], - - /** - * @property searchSuggest - * @deprecated This property will be removed in the Social SDK Version 2. - */ - searchSuggest: null, - - /** - * @property memberList - * @deprecated This property will be removed in the Social SDK Version 2. - */ - memberList:null, - - /** - * TODO Better pattern is to set is during postMixInProperties - * The result the user has chosen from the search suggestions - */ - _selectedResultItem : {text:"",id:""}, - - /* - * Selected row is used for keyboard navigation in the applications pop up - */ - _selectedRow : -1, - - /* - * - */ - _searchInput: null, - - /** - * @method constructor The constructor for the SearchBox class - * @param args - */ - constructor: function(args){ - lang.mixin(this, args); - - }, - - /** - * TODO Document Me - */ - setInputValue: function(value){ - this._searchInput.value = value; - }, + var SearchBoxRenderer = declare(null,{ - /** - * Invoked before rendering occurs, and before any dom nodes are created. - * This is the place to change the widget properties before it is rendered. - */ - postMixInProperties : function() { - }, + nls: null, - /** - * TODO Document Me - */ - getInputValue: function(){ - return this._searchInput.value; - }, + _appsPopUp: null, - /** - * Set the disabled state of the input control for the SearchBox. - * - * @param disabled True to disable the input control - * @return this - */ - setInputDisabled: function(disabled) { - this._searchInput.disabled = disabled; - return this; - }, + _appsMemberListItem: null, - /** - * Return the disabled state of the input control for the SearchBox. - * - * @return True is the input control is disabled and otherwise false - */ - isInputDisabled: function(){ - return this._searchInput.disabled; - }, + _appsMemberList: null, - /** - * TODO Document Me - */ - getSelectedResult: function(){ - return this._selectedResultItem; - }, + _suggestionPopUp: null, - /** - * TODO is this needed - * TODO Document Me - */ - setSelectedResult: function(name,id){ - if(name){ - this._selectedResultItem.name = name; - } - if(id){ - this._selectedResultItem.id = id; - } - }, - - /** - * Function is called after this class has been constructed - * the functions in the post create need to be called after the class has been - * instantiated so parameters in the dijit base classes can be initialised. - * @method postCreate - * @param args - */ - postCreate: function(args){ - this.createDefaultRenderer(args); - this.domNode = this.renderer.getDomNode(this); - this.renderer.render(this,this.domNode,{}); - - if (this.memberList) { - // Create member list - this.renderer.renderMemberList(this.domNode); - } - }, + _suggestionContainer: null, /** - * Creates a SearchBoxRenderer and sets it as the renderer for this class. - * @method CreateDefaultRenderer + * SearchBoxRenderer class constructor function + * @method constructor * @param args */ - createDefaultRenderer: function(args){ - this.renderer = new SearchBoxRenderer(args); - }, - - /** - * When the user clicks the apps lists, this function renderers a pop up - * of all the different applications they can select from - * @method handleClick - */ - handleClick: function(){ - this.searchBoxAction.renderPopUp(this); + constructor: function(args){ + this.nls = nls; }, /** - * event handler for blur events - * @method handleBlur - * @param element the element that fired the event - * @param obj - * @param event the blur event + * Converts the HTML pop up template into a DOM node. + * Creates a Div element and uses the template as the div's inner HTML + * @method getDomeNode + * @returns The Search Box Dom Node */ - handleBlur: function(element,obj,event){ - if(!event){ - event = window.event; - } - // TODO why two seperate calls to removePopUp, logic looks overly complex here - //For Keyboard Accessibility, this only needs to work for firefox(accessible path) if other browsers - //do not support this property that is okay - if(event.explicitOriginalTarget){ - if(event.explicitOriginalTarget.nodeName == "TD" || event.explicitOriginalTarget.nodeName == "TR" || event.explicitOriginalTarget.nodeName == "#text"){ - - }else{ - this.searchBoxAction.removePopUp(this); - } + getDomNode: function(SearchBox){ + + var htmlTemplate = ""; + + if(SearchBox.predefinedSearch){ + var domStr = this._substituteItems(SingleApplicationSearch, this); + SingleApplicationSearch = domStr; + htmlTemplate = SingleApplicationSearch; }else{ - this.searchBoxAction.removePopUp(this); - } - }, - - /** - * When a user selects an application from the apps pop up - * there choice is stored, and the pop up is removed. - * @method setSelectedApplication - * @param element The pop up HTML element - * @param object - * @param event The Event - */ - setSelectedApplication: function(element,object,event){ - if(!event){ - event = window.event; + var domStr = this._substituteItems(template, this); + template = domStr; + htmlTemplate = template; } - this.searchBoxAction.setSelectedApplication(element,object,event,this); - }, - /** - * When the user hovers over an application in the applications pop up, the background gets highlighted - * @method displayHighlight - * @param element The pop up HTML element - * @param object - * @param event The event - */ - displayHighlight: function(element,object,event){ - if(!event){ - event = window.event; - } - this.searchBoxAction.highLight(element,object,event); - }, - - /** - * Closes a member item (by removing it from its parent; the member list) - * @method closeMemberItem - * @param element The member list item - * @param object - * @param event The Event - */ - closeMemberItem: function(element,object,event){ - if(!event){ - event = window.event; - } - this.searchBoxAction.closeMemberItem(this, element,object,event); - }, - - /** - * When the user moves the mouse away from the application item in the pop up - * the background highlight it removed. - * @method removeHighlight - * @param element The pop up HTML element - * @param object - * @param event The Event - */ - removeHighlight: function(element,object,event){ - if(!event){ - event = window.event; - } - this.searchBoxAction.removeHighlight(element,object,event); + var div = this._convertToDomNode(htmlTemplate); + + this._suggestionContainer = document.createElement("span"); + div.appendChild(this._suggestionContainer); + + var temp = div.getElementsByTagName("input"); + var input = temp[0]; + SearchBox._searchInput = input; + + return div; }, /** - * When the user types a search query it is stored in this.searchQuery - * @method setSearchQuery - * @param event The Event + * Converts the HTML pop up template into a DOM node. + * Creates a div and sets it's inner html to be the pop up template + * @method getPopUpNode + * @returns the applications list pop up DOM Node */ - setSearchQuery: function(element,object,event){ - if(!event){ - event = window.event; - } - this.searchBoxAction.setSearchQuery(event,this); + getPopUpNode: function(){ + + var domstr = this._substituteItems(PopUpTemplate, this); + PopUpTemplate = domstr; + + var div = this._convertToDomNode(PopUpTemplate); + return div; }, /** - * perform a search based on the users query - * @method search - * @param event The event + * Converts the HTML member list item template into a DOM node. + * Creates a div and sets it's inner html to be the member list item template + * @method getMemberListItemNode + * @param memberName The name to display + * @returns the applications list pop up DOM Node */ - search: function(element,object,event){ - if(!event){ - event = window.event; - } - this.searchBoxAction.search(event,this); + getMemberListItemNode: function(memberName){ + var domstr = this._substituteItems(MemberListItemTemplate, this); + domstr = this._substituteMemberName(domstr, memberName); + + var obj = this._convertToDomNode(domstr); + + return obj; }, /** - * Used to handle keyboard events - * @method onKeyPress - * @param element the HTML element - * @param obj - * @param event the Event + * Converts the HTML member list template into a DOM node. + * Creates a div and sets it's inner html to be the member list template + * @method getMemberListItemNode + * @returns the applications list pop up DOM Node */ - onKeyPress: function(element, obj, event){ - if(!event){ - event = window.event; - } - this.searchBoxAction.onKeyPress(element, obj, event, this); + getMemberListNode: function(){ + + var domstr = this._substituteItems(MemberListTemplate, this); + MemberListTemplate = domstr; + + var div = this._convertToDomNode(MemberListTemplate); + return div; }, /** - * TODO Document Me - * @param element - * @param obj - * @param event + * Attaches events to the template + * @method render + * @param searchBox + * @param el + * @param data */ - suggest: function(element, obj, event){ - if(!event){ - event = window.event; - } - if(this.searchSuggest == "on"){ - this.searchBoxAction.suggest(event, this); - } + render: function(searchBox, el, data) { + searchBox.templateString = template; + this._doAttachEvents(searchBox,el,data); }, /** - * SearchBoxAction contains functions to handle events - * this should be overridden to change the action - * of the event handler function + * renders the applications lists pop up + * @method renderPopUp + * @param searchBox The SearchBox class + * @param el The searchBox Element */ - searchBoxAction : { - - _appsPopUp: null, - - _suggestionPopUp: null, - - _searchInput: null, - - /** - * Handles keyboard navigation - * @param element the table element that fired the onKeypressEvent - * @param obj - * @param event the Event - */ - onKeyPress: function(element, obj, event,self){ - //If the user presses enter - if(event.key == "Enter"){ - self.setSelectedApplication(element.rows[self._selectedRow], obj, event); - self._selectedRow = -1; - //If the user press the down arrow key to navigate down the list - }else if(event.key == "Down"){ - - if(self._selectedRow != element.rows.length ){ - if(self._selectedRow != element.rows.length-1){ - self._selectedRow++; - } - self.displayHighlight(element.rows[self._selectedRow], obj, event); - if(self._selectedRow > 0){ - self.removeHighlight(element.rows[self._selectedRow-1], obj, event); - } - } - //If the user presses the up key to navigate up the list - }else if(event.key == "Up"){ - - if(self._selectedRow <= 0){ - self.searchBoxAction.removePopUp(self); - self._selectedRow = -1; - }else{ - self._selectedRow--; - self.removeHighlight(element.rows[self._selectedRow+1], obj, event); - if(self.selectedRow !=0){ - self.displayHighlight(element.rows[self._selectedRow], obj, event); - } - } - - }else if(event.key == "Tab"){ - self._selectedRow = -1; - } - }, + renderPopUp: function(searchBox,el){ - /** - * Closes a member item (by removing it from its parent; the member list) - * @method closeMemberItem - * @param context - * @param element The member list item - * @param object - * @param event The Event - */ - closeMemberItem: function(context, element,object,event){ - // Get parent node - var item = event.target.parentNode; - - // TODO if someone overrides the renderer will this work? - - // Prepare HTML for comparison - var memberNode = item.parentNode; - var memberNodeHtml = memberNode.innerHTML; - memberNodeHtml = memberNodeHtml.replace(/\s+/g, ''); - memberNodeHtml = memberNodeHtml.replace(/ /g, ''); - - // Remove member from list - for (var i = 0; i < context.members.length; i++) { - var member = context.members[i]; - var html = member.html; - - // Skip null entries (null entries represent entries that have been deleted) - if (html == null) { - continue; - } - - // Remove dojo action listeners - html = html.replace(/data-dojo-attach-event=".*"/, ""); - html = html.replace(/data-dojo-attach-event='.*'/, ""); - - // Remove whitespace - html = html.replace(/\s+/g, ''); - html = html.replace(/ /g, ' '); - - // Compare strings - if (html == memberNodeHtml) { - // Delete objects by setting their properties to null - context.members[i].html = null; - context.members[i].id = null; - context.members[i].name = null; - break; - } - } - - // Remove it - item.parentNode.removeChild(item); - }, + if(!this._appsPopUp){ + this._appsPopUp = this.getPopUpNode(); + this._doAttachEvents(searchBox,this._appsPopUp,{}); + } - /** - * Opens the pop up showing a list of applications - * @method renderPopUp - * @param self Context - */ - renderPopUp: function(self){ - // TODO shouldn't this just pass thru to the renderer? - if(this._suggestionPopUp ){ - for(var i=0;i<self.domNode.children.length;i++){ - if(self.domNode.children[i] === this._suggestionPopUp){ - self.renderer.removeSuggestionPopUp(self.domNode,this._suggestionPopUp); - } - } + el.appendChild(this._appsPopUp); + this._appsPopUp.focus(); + return this._appsPopUp; + }, + + /** + * renders a member list item + * @method renderMemberListItem + * @param searchBox the SearchBox class + * @param memberName The member name to display + * @param memberId The member's profile id - this acts as a unique identifier (needed when, for example, + * creating a new community) + */ + renderMemberListItem: function(searchBox, memberName, memberId){ + // Get node + this._appsMemberListItem = this.getMemberListItemNode(memberName); + + // Create member object for storage + var newMember = new Object(); + newMember.html = this._appsMemberListItem.innerHTML; + newMember.id = memberId; + newMember.name = memberName; + // Make sure that the member hasn't already been selected + for (var i = 0; i < searchBox.members.length; i++) { + var member = searchBox.members[i]; + if (member.html == newMember.html) { + return; } - this._appsPopUp = self.renderer.renderPopUp(self,self.domNode); - }, + } - /** - * Remove the Applications pop up - * @method removePopUp - * @param self Context - */ - removePopUp: function(self){ - self.renderer.removePopUp(self.domNode,this._appsPopUp); - }, + // Add it to the list + this._appsMemberList.appendChild(this._appsMemberListItem); - /** - * Stores the name of the application the user has selected and closes the application pop up - * @method setSelectedApplication - * @param element The HTML element - * @param object - * @param event The Event - * @param self Context - */ - setSelectedApplication: function(element,object,event,self){ - this.removeHighlight(element, object, event); - self.selectedApplication = element.children[1].textContent; - self.renderer.removePopUp(self.domNode,this._appsPopUp); - self.renderer.changeSelectedApplication(element.children[1].textContent,element.children[0].children[0]); - - }, + // Attach event listeners + this._doAttachEvents(searchBox,this._appsMemberListItem,{}); - /** - * TODO Document Me - * - * @param event - * @param popUp - * @param context - */ - setSuggestedSearch: function(event,popUp,context){ - var targetElement; - var value; - if(!event){ - event = window.event; - targetElement = event.srcElement; - value = targetElement.innerText; - }else{ - targetElement = event.target; - value = targetElement.textContent; - } - - var id = targetElement.id; - var input = this._searchInput; - - context._selectedResultItem.text = value; - context._selectedResultItem.id = id; - - context.searchQuery = value; - - - // Member list feature enabled - if (context.memberList) { - // We don't want to display the suggested search term (instead - // we will just add it to the members list - see below) - input.value = ""; - - // Create member list item - context.renderer.renderMemberListItem(context, value, id); - - } else { - input.value = value; - } - - while (popUp.firstChild) { - popUp.removeChild(popUp.firstChild); - } - context.renderer.removeSuggestionPopUp(context.domNode,popUp); - }, + // Keep track of the added member + searchBox.members.push(newMember); - /** - * Highlights an element - * @method highLight - * @param element The HTML element to highlight - * @param object - * @param event the Event - */ - highLight: function(element,object,event){ - element.style.backgroundColor = "#E1F4F9"; - }, + return this._appsMemberListItem; + }, + + /** + * renders the member list + * @method renderMemberList + * @param el HTML Element / DOM Node + */ + renderMemberList: function(el){ - /** - * Remove background highLight from an element which looses focus - * @method removeHighlight - * @param element the HTML element to remove the background highlight from - * @param object - * @param event the event - */ - removeHighlight: function(element,object,event){ - element.style.backgroundColor = "#FFFFFF"; - }, + if(!this._appsMemberList){ + // Generate the DOM object representing the member list + this._appsMemberList = this.getMemberListNode(); + } - /** - * Sets the user's search query - * @method setSearchQuery - * @param event - * @param self - */ - setSearchQuery: function(event,self){ - self.searchQuery = event.target.value; - }, + // Append the list to the parent + el.appendChild(this._appsMemberList); + + // Request focus + this._appsMemberList.focus(); - /** - * Provides a suggestion as to what the user is trying to search for - * @method suggest - * @param event the event - * @param context the context this - */ - // TODO What is the difference between suggest and search? - suggest: function(event,context){ - var applicationParam = context.selectedApplication.toLocaleLowerCase(); - applicationParam = applicationParam.replace(/ /g,''); - - var inputBox = event.target; - this._searchInput = inputBox; - - var query = inputBox.value; - if(context.searchSuffix) { - query = query + context.searchSuffix; - } - var popUp = context.renderer.renderSuggestionPopUp(context,context.domNode); - this._suggestionPopUp = popUp; - - var requestArgs; - if(context.constraint){ - var jsonString = JSON.stringify(context.constraint); - requestArgs = {"component": applicationParam, constraint:jsonString}; + return this._appsMemberList; + }, + + + /** + * Renders the suggestions that appear under the search box. + * @method renderSuggestionPopUp + * @param searchBox The searchBox class + * @param el The SearchBox DOM node / HTML element + * @returns The search suggestion pop up as a DOM Node + */ + renderSuggestionPopUp: function(searchBox,el){ + + if(!this._suggestionPopUp){ + if(searchBox.predefinedSearch){ + this._suggestionPopUp= this._convertToDomNode(SingleSearchPopUp); }else{ - requestArgs = {"component": applicationParam}; - } - if(context.searchArgs){ - lang.mixin(requestArgs,context.searchArgs); + this._suggestionPopUp= this._convertToDomNode(SuggestionPopUp); } - // TODO the && is not needed. Why do all the previous stuff if empty query is ignored? - if(query && query != ""){ - // TODO This should only happen once! - if(context.endpoint){ - searchService = new SearchService({endpoint:context.endpoint}); - }else{ - searchService = new SearchService(); - } - - var promise; - if (context.searchType == "my") { - promise = searchService.getMyResults(query, requestArgs); - } else if (context.searchType == "myCommunities"){ - - var args = {search:query}; - if(context.endpoint){ - communityService = new CommunityService({endpoint:context.endpoint}); - }else{ - communityService = new CommunityService(); - } - - promise = communityService.getMyCommunities(args); - } else { - promise = searchService.getResults(query, requestArgs); - } - promise.then( - function(results) { - context.searchBoxAction.handleSuggestResult(results,context,popUp,context.searchType); - }, - - function(error) { - console.log(error); - } - ); - } - }, - - /** - * - * @method handleSuggestResult - * @param results the results from the suggested search - * @param context the This of the outer class - * @param popUp the popUp Element where results are displayed - */ - handleSuggestResult: function(results,context,popUp,searchType){ - // TODO should the renderer handle this? - while (popUp.firstChild) { - popUp.removeChild(popUp.firstChild); - } - for(var i=0;i<results.length;i++){ - var data = document.createElement("li"); - var title = results[i].getTitle(); - var id=""; - if(searchType=="myCommunities"){ - id = results[i].getCommunityUuid(); - }else{ - id = results[i].getId(); - } - dom.setText(data, title); - data.id = id; - - data.onclick = function (event) { - context.searchBoxAction.setSuggestedSearch(event,popUp,context); - }; + } + this._suggestionContainer.appendChild(this._suggestionPopUp); + return this._suggestionContainer.firstChild; + }, + + /** + * Removes the applications pop up + * @method removePopUp + * @param searchBoxElement The searchBox HTML Element + * @param popUp The DOM node that represents the popup that displays the list of applications on connections + */ + removePopUp: function(searchBoxElement,popUp){ + searchBoxElement.removeChild(popUp); + }, + + /** + * remove the list of suggestions that appeas when searching + * @method removeSuggestionPopUp + * @param searchBoxElement The DOM Node that represents the search box + * @param popUpElement the DOM node pop up + */ + removeSuggestionPopUp: function(searchBoxElement,popUpElement){ + this._suggestionContainer.removeChild(popUpElement); + }, + + /** + * Changes the Text displayed in the "currently selected" application text field + * @method changeSelectedApplication + * @param selectedApplication The name of the application to display + * @param el The table row element + */ + changeSelectedApplication: function(selectedApplication, trImgIcon){ + var element = document.getElementById("searchAppType"); + if(element.textContent == nls.selectedApplication){ + + //change the text showing the selected application + element.textContent = selectedApplication; + nls.selectedApplication = selectedApplication; + + } + }, + + /* + * Converts a HTML String to a DOM Node, + * @method _convertToDomNode + * @param template the html string to be converted to a DOM node + * @returns A DOM Node + */ + _convertToDomNode: function(template){ + var div = null; + if(typeof template =="string"){ + var wrapper= document.createElement('div'); + wrapper.innerHTML= template; + wrapper.tabIndex = 0; + div= wrapper; + } + return div.firstChild; + }, + + /* + * Override _substitureItems as there are only NLS strings to be substituted + * no XPath values, functions etc. + * @param template + * @param renderer + * @returns + */ + _substituteItems: function(template,renderer){ + var text = template; + if(text.indexOf("${nls.") != -1){ + var nls = renderer.nls; - popUp.appendChild(data); - } - - }, - - /** - * When the user clicks the search button - * @method search - * @param event The Event - */ - search: function(event,context){ - if(this._suggestionPopUp ){ - for(var i=0;i<context.domNode.children.length;i++){ - if(context.domNode.children[i] === this._suggestionPopUp){ - context.renderer.removeSuggestionPopUp(context.domNode,this._suggestionPopUp); - } - } - } - - var applicationParam = context.selectedApplication.toLocaleLowerCase(); - applicationParam = applicationParam.replace(/ /g,''); + var startIndex = text.indexOf("${nls."); + var endIndex = text.indexOf("}",startIndex); + + var nlsIndex = text.substring(startIndex+6,endIndex); + var stringToReplace = text.substring(startIndex,endIndex+1); + + var replacingString = nls[nlsIndex]; + + text = text.replace(stringToReplace,replacingString); - //if this control is going to retrieve the search results from the server - if(context.type == "full"){ - var requestArgs; - if(context.constraint){ - var jsonString = JSON.stringify(context.constraint); - requestArgs = {"component": applicationParam, constraint:jsonString}; - }else{ - requestArgs = {"component": applicationParam}; - } - if(context.searchArgs){ - lang.mixin(requestArgs,context.searchArgs); - } - if(context.endpoint){ - searchService = new SearchService({endpoint:context.endpoint}); - }else{ - searchService = new SearchService(); - } - - var query = context.searchQuery; - if(context.searchSuffix) { - query = query + context.searchSuffix; - } - var self = context; - - var promise; - if (context.searchType == "my") { - promise = searchService.getMyResults(query, requestArgs); - } else if (context.searchType == "myCommunities"){ - - var args = {search:query}; - if(context.endpoint){ - communityService = new CommunityService({endpoint:context.endpoint}); - }else{ - communityService = new CommunityService(); - } - - promise = communityService.getMyCommunities(args); - } else { - - promise = searchService.getResults(query, requestArgs); - } - promise.then( - function(results) { - if (context.memberList) { - // If the member list feature is enabled then we need - // to use a different search result event since we want the - // members to be added to the members list and NOT - // just displayed in the results table - for(var i = 0; i < newResults.length; i++) { - // Render each item in the search results - if(context.searchType=="myCommunities"){ - context.renderer.renderMemberListItem(context, newResults[i].getTitle(), results[i].getCommunityUuid()); - }else{ - context.renderer.renderMemberListItem(context, newResults[i].getTitle(), results[i].getId()); - } - - } - } else { - var evt = document.createEvent("Event"); - evt.initEvent("searchResultEvent",true,true); - evt.results = results; - self.domNode.dispatchEvent(evt); - evt = null; - } - }, - function(error) { - console.log(error); - } - ); - }else { - //use another component to retrieve - var evt = document.createEvent("Event"); - evt.initEvent("searchResultEvent",true,true); - evt.selectedApplication = applicationParam; - evt.searchQuery = context.searchQuery; - - context.domNode.dispatchEvent(evt); - evt = null; + //if there are more strings to substitute keep substituting + if(text.indexOf("${nls.") != -1){ + return this._substituteItems(text,renderer); } - } + //if no more strings to substitute return the final string + return text; + }, - } + /* + * Override _substituteMemberName as there are only NLS strings to be substituted + * no XPath values, functions etc. This function substitutes the member name in the template + * with the actual member item name. + * @method _substituteMemberName + * @param template + * @param renderer + * @returns + */ + _substituteMemberName: function(template,memberName){ + return template.replace("${memberName}", memberName); + }, + /* + * connects events to event handlers + */ + _doAttachEvents: function(searchBox, el, data) { + var nodes = (el.all || el.getElementsByTagName("*")); + for (var i in nodes) { + var attachEvent = (nodes[i].getAttribute) ? nodes[i].getAttribute("data-dojo-attach-event") : null; + if (attachEvent) { + nodes[i].removeAttribute("data-dojo-attach-event"); + var event, events = attachEvent.split(/\s*,\s*/); + while((event = events.shift())) { + if (event) { + var func = null; + if (event.indexOf(":") != -1) { + var eventFunc = event.split(":"); + event = lang.trim(eventFunc[0]); + func = lang.trim(eventFunc[1]); + } else { + event = lang.trim(event); + } + if (!func) { + func = event; + } + var callback = searchBox._hitch(searchBox, searchBox[func], nodes[i], data); + searchBox._connect(nodes[i], event, callback); + } + } + } + } + } }); - - return SearchBox; + + return SearchBoxRenderer; }); }, -'url:sbt/smartcloud/controls/profiles/templates/ColleagueItemFull.html':"<tr>\r\n \t<td>\r\n <a href=\"${profileLink}\" class=\"fn lotusPerson url hasHover\">\r\n <img width=\"48\" height=\"48\" class=\"otherPeople48\" alt=\"${name} Profile Photo\" src=\"${photoUrl}\" title=\"${name}\">\r\n </a>\r\n </td>\r\n <td style=\"vertical-align: middle; height: 50px;\">\r\n <a href=\"${profileUrl}\" class=\"fn lotusPerson url hasHover\">${name}</a>\r\n </td>\r\n</tr>\r\n", -'sbt/connections/controls/profiles/ProfileTagsGridRenderer':function(){ +'url:sbt/connections/controls/profiles/templates/ViewAll.html':"<table width=\"100%\" style=\"margin-top: 5px;\">\r\n <tbody>\r\n <tr>\r\n <td style=\"text-align: ${countAlign}; vertical-align: ${verticalAlign}; width: 100%;\">\r\n <span>\r\n <a class=\"lotusAction\" href=\"javascript:void(0);\" data-dojo-attach-event=\"onclick: handleViewAll\">${viewAllTitle}</a>\r\n </span>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>", +'sbt/connections/controls/communities/CommunityMembersGridRenderer':function(){ require({cache:{ -'url:sbt/connections/controls/profiles/templates/TagListRow.html':"<li class=\"lotusAlignLeft\">\r\n\t<a title=\"${term}\" href=\"javascript:void(0);\" class=\"profileTag lotusLeft\" data-dojo-attach-event=\"onclick: handleClick\">${term}</a>\r\n\t<span class=\"lotusRight\">${frequency}</span>\r\n</li>\r\n", -'url:sbt/connections/controls/profiles/templates/TagListHeader.html':"<div class=\"lotusChunk\">\r\n\t<h3>${tagHeader}</h3>\r\n</div>"}}); +'url:sbt/connections/controls/communities/templates/CommunityMemberRow.html':"<tr class=\"${rowClass}\">\r\n\t<td style=\"width: 25px\" class=\"lotusFirstCell\">\r\n\t\t<div>\r\n\t\t\t<input id=\"${uid}\" name=\"${uid}\" value=\"${uid}\" data-dojo-attach-event=\"onclick: handleCheckBox\" type=\"checkbox\" aria-label=\"${name}\"></input>\r\n\t\t</div>\r\n\t</td>\r\n\t<td style=\"width: 70px\">\r\n\t\t<div><img alt=\"${name}\" src=\"${photoUrl}\" width=\"55\" height=\"55\"></img></div>\r\n\t</td>\r\n\t<td>\r\n\t\t<div>\r\n\t\t\t<h4>\r\n\t\t\t\t<span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t<a aria-label=\"${nls.ariaVcard}\" href=\"javascript:void(0);\" title=\"${tooltip}\" data-dojo-attach-event=\"onclick: handleClick\" class=\"fn url\">${name}</a>\r\n\t\t \t\t\t<span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${uid}</span>\r\n \t\t\t\t</span>\r\n \t\t\t</h4>\r\n\t\t\t<div></div>\r\n\t\t</div>\r\n\t</td>\r\n\t<td class=lotusLastCell>\r\n\t\t<div>\r\n\t\t\t<div>${nls.role}: ${role}</div>\r\n\t\t\t<div>${nls.email} <strong><a alt=\"${nls.clickToEmail}\" href=\"mailto:${email}\">${email}</a></strong></div>\r\n\t\t\t<strong>\r\n\t\t\t\t<a alt=\"${nls.edit}\" data-dojo-attach-event=\"onclick: openEditForm\" href=\"javascript:void(0);\">${nls.edit}</a>    \r\n\t\t\t\t<a alt=\"${nls.remove}\" data-dojo-attach-event=\"onclick: removeMember\" href=\"javascript:void(0);\">${nls.remove}</a>\r\n\t\t\t</strong>\r\n\t\t\t<div id=\"editTable${uid}\" style=\"display: none;\">\r\n\t\t\t\t<table>\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td style=\"vertical-align: middle; padding: 0px 14px; width: 45px; font-weight: bold;\">\r\n\t\t\t\t\t\t\t\t${nls.role}:\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t<table>\r\n\t\t\t\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<input id=\"rbOwner\" type=\"radio\" name=\"role\" value=\"owner\" /><label for=\"rbOwner\">${nls.owner}</label>\r\n\t\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<input id=\"rbMember\" type=\"radio\" name=\"role\" value=\"role\" /><label for=\"rbMember\">${nls.member}</label>\r\n\t\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\t\t\t\t<table>\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td style=\"text-align: left;\" class=\"lotusFormFooter\">\r\n\t\t\t\t\t\t\t\t<button class=\"lotusFormButton\" data-dojo-attach-event=\"onclick: updateMember\">${nls.save}</button>\r\n\t\t\t\t\t\t\t\t<button class=\"lotusFormButton\" data-dojo-attach-event=\"onclick: closeEditForm\">${nls.cancel}</button>\r\n\t\t\t\t\t\t\t\t<button class=\"lotusFormButton\" data-dojo-attach-event=\"onclick: removeMember\">${nls.remove}</button>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</td>\r\n</tr>", +'url:sbt/connections/controls/communities/templates/BootstrapCommunityMember.html':"<tr>\r\n\r\n\t<td>\r\n\t\t<div><img alt=\"${name}\" src=\"${photoUrl}\" width=\"55\" height=\"55\"></img></div>\r\n\t</td>\r\n\t<td style=\"padding:0.5em;\">\r\n\t\t\t<h4>\r\n \t\t\t\t<a aria-label=\"${nls.ariaVcard}\" href=\"javascript:void(0);\" title=\"${tooltip}\" data-dojo-attach-event=\"onclick: handleClick\" >${title}</a>\r\n \t\t\t</h4>\r\n\t</td>\r\n</tr>"}}); /* * © Copyright IBM Corp. 2013 * @@ -38262,343 +36755,428 @@ require({cache:{ /** * */ -define(["../../../declare", "../../../dom","../../../lang", - "../../../stringUtil", "../../../xpath", "../../../xml", +define(["../../../declare", "../ConnectionsGridRenderer", - "../../../i18n!sbt/connections/controls/profiles/nls/ProfileTagsGridRenderer", - "../../../text!sbt/connections/controls/profiles/templates/TagListRow.html", - "../../../text!sbt/connections/controls/profiles/templates/TagListHeader.html"], - function(declare, dom, lang, stringUtil, xpath, xml, ConnectionsGridRenderer, nls, tagListTmpl, tagListHdrTmpl) { - + "../../../i18n!./nls/CommunityMembersGridRenderer", + "../../../text!./templates/CommunityMemberRow.html", + "../../../text!./templates/BootstrapCommunityMember.html"], + function(declare, ConnectionsGridRenderer, nls, communityMemberTemplate, + bootstrapCommunityMemberTemplate) { + /** - * @class ProfileTagsGridRenderer - * @namespace sbt.connections.controls.profiles - * @module sbt.connections.controls.profiles.ProfileTagsGridRenderer + * @class ProfileGridRenderer + * @namespace sbt.connections.controls.communities + * @module sbt.connections.controls.communities.CommunityMembersGrid */ - var ProfileTagsGridRenderer = declare(ConnectionsGridRenderer, { + var CommunityMembersGridRenderer = declare(ConnectionsGridRenderer, { - /** - * The strings used in the grid, these are stored in a separate file, in the nls folder - */ - _nls: nls, - - containerClass: "lotusChunk", - tagListClass: "lotusList lotusEditable lotusTags lotusMeta", - - _numberOfContributors: 0, + /**The strings used in the grid, these are stored in a separate file, in the nls folder*/ + _nls: nls, /** * The constructor function * @method constructor * @param args */ - constructor: function(args, grid) { - if (args.type == "list") { - this.template = tagListTmpl; - this.listHeaderTemplate = tagListHdrTmpl; + constructor: function(args,grid) { + if (grid.theme == "bootstrap"){ + this.template = bootstrapCommunityMemberTemplate; + }else{ + if (args.type == "communityMembers") { + this.template = communityMemberTemplate; + } } + + + }, + + /** + * Sets the css class for the row + * @method rowClass + * @param grid The Grid Dijit + * @param item the current row + * @param i the number of the current row, ie 0, 1, 2 etc + * @param items all of the rows in the grid + */ + rowClass: function(grid, item, i, items) { + item.rowClass = (i === 0 ? "lotusFirst" : (i % 2 === 1 ? "lotusAltRow" : null)); }, - render: function(grid, el, items, data) { - while (el.childNodes[0]) { - dom.destroy(el.childNodes[0]); - } - var size = items.length; - if (size === 0) { - this.renderEmpty(grid, el); - } - else { - this._computeRenderValues(grid, el, items, data); - - //this.renderTagHeader(grid, el, items, data); - //this.renderInputForm(grid, el, items, data); - this.renderTagListHeader(grid, el, items, data); - var container = this.renderContainer(grid, el, items, data); - for (var i=0; i<items.length; i++) { - this.renderItem(grid, container, data, items[i], i, items); - } + /** + * Displays a tooltip by calling the getTooltip function in the ProfileAction class + * @method tooltip + * @param grid The Grid Dijit + * @param item the element to display the tooltip + * @param i the number of the current row + * @param items all of the items in the grid row + * @returns A Tooltip the default for profiles is to display the vCard + */ + tooltip: function(grid, item, i, items) { + if (grid.profileAction) { + return grid.profileAction.getTooltip(item); } - }, - - renderTagListHeader: function(grid, el, items, data) { - if (this.listHeaderTemplate && !grid.hideListHeader) { - var node; - if (lang.isString(this.listHeaderTemplate)) { - var domStr = this._substituteItems(this.listHeaderTemplate, grid, this, items, data); - node = dom.toDom(domStr, el.ownerDocument); - } else { - node = this.listHeaderTemplate.cloneNode(true); - } - el.appendChild(node); - - grid._doAttachEvents(el, data); - } - }, + }, + + /** + * Generates the profile photo URL for displaying the photos of community members + * @method photoUrl + * @param grid The Grid Dijit + * @param item the element containing the uid + * @param i the number of the current row + * @param items all of the items in the grid row + * @returns A profile photo URL for retrieving a user's profile picture + */ + photoUrl: function(grid, item, i, items) { + var store = grid.store; + var endpoint = store.getEndpoint(); + var photoUrl = endpoint.baseUrl + "/profiles/photo.do?email=" + item.getValue("email"); + + return photoUrl; + } + }); + + return CommunityMembersGridRenderer; +}); +}, +'sbt/Gadget':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - renderContainer: function(grid, el, items, data) { - var div = dom.create("div", { "class": this.containerClass }, el); - return dom.create("ul", { "class": this.tagListClass }, div); - }, +/** + * Social Business Toolkit SDK - OpenSocial specific helpers. + */ +define(function() { - /** - * Return the tag header label. - */ - tagHeader: function(grid, renderer, items, data) { - if (grid.sourceEmail || grid.sourceKey) { - var params = { - tagSource : grid.sourceName || grid.sourceEmail || grid.sourceKey, - tagTarget : grid.targetName || grid.targetEmail || grid.targetKey - }; - return stringUtil.replace(nls.taggedBy, params); - } else { - var str = (this._numberOfContributors == 1) ? nls.taggedByPerson : nls.taggedByPeople; - return stringUtil.replace(str, { numberOfContributors : this._numberOfContributors }); - } - }, - - //Internals - - _computeRenderValues: function(grid, el, items, data) { - var document = xml.parse(data.response); - this._numberOfContributors = parseInt(xpath.selectText(document, - grid._storeArgs.feedXPath.numberOfContributors, - grid._storeArgs.namespaces)); - } +//sbt.getUserPref = function(ns,name) { +// +//}; - }); - - return ProfileTagsGridRenderer; }); }, -'sbt/url':function(){ -define(['./declare'], function(declare){ - // regexp /^(?:(scheme)(:))?(\/\/)(?:(userna)(:)(passwo)(@))?(domain )(?:(:)(port ))?(path )?(?:(\?)(query ))?(?:(#)(fr))?$/ - var URL_RE = /^(?:([A-z]+)(:))?(\/\/)(?:([^?#]*)(:)([^?#]*)(@))?([\w.\-]+)(?:(:)(\d{0,5}))?([\w.\/\-]+)?(?:(\?)([^?#]*))?(?:(#)(.*))?$/; - var URL_RE_GROUPS = { - 'URL': 0, - 'SCHEME': 1, - 'SCHEME_COLON': 2, - 'SCHEME_SLASHES': 3, - 'USER': 4, - 'PASSWORD_COLON':5, - 'PASSWORD': 6, - 'USER_AT': 7, - 'HOSTNAME': 8, - 'PORT_COLON':9, - 'PORT': 10, - 'PATH': 11, - 'QUERY_QUESTION':12, - 'QUERY': 13, - 'FRAGMENT_HASH': 14, - 'FRAGMENT': 15 - }; - - /** - A class for representing urls. +'url:sbt/connections/controls/sharebox/templates/InputFormContent.html':"<html lang=\"en\">\r\n <head>\r\n <meta charset=\"utf-8\">\r\n <script src=\"/sbt.dojo143/dojo/dojo.js\"></script>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/base/package3.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_lconntheme/default.css?version=oneui3&rtl=false\"></link>\r\n <script type=\"text/javascript\" src=\"${sbtSampleUrl}/library?lib=dojo&ver=1.4.3\"></script>\r\n <script type=\"text/javascript\" src=\"${sbtSampleServiceUrl}/proxy/com/connections/resources/web/_js/?include=lconn.news.microblogging.sharebox.InputForm.js~lconn.core.util.dojoPatches.js~com.ibm.social.as.util.hashtag.HashtagUtil.js&exclude=dojo.dojo.js\"></script>\r\n <style> .commit-tease, .user-profile-mini-avatar, .avatar, .vcard-details, .signup-prompt-bg { display: none !IMPORTANT; } </style> <script> document.addEventListener('DOMContentLoaded', function() { this.querySelectorAll('a').forEach(anchor => { anchor.addEventListener('click', e => { e.preventDefault(); const redact = new URLSearchParams(window.location.search).get('redact'); const hasExistingParams = anchor.href.includes('?'); window.location.href = anchor.href + (hasExistingParams ? `&redact=${redact}` : `?redact=${redact}`); }); }); }); </script> </head>\r\n <body class=\"lotusui30_body lotusui30_fonts lotusui30\">\r\n <div id=\"inputForm\"></div>\r\n <script>\r\n dojo.require(\"sbt.controls.sharebox._InputForm\");\r\n new sbt.controls.sharebox._InputForm(${args});\r\n </script>\r\n </body>\r\n</html>", +'sbt/ready':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - @class url - @constructor - **/ - var url = declare(null, { - /* - Holds the parts of the url after URL_RE parses the url. +/** + * @module sbt.ready + */ +define(['./_bridge/ready'],function(ready) { + return ready; +}); - @property _resultStore - @type Array - **/ - _resultStore: [], +}, +'url:sbt/connections/controls/bookmarks/templates/BootstrapBookmarkRow.html':"<tr>\t\r\n\t<td width=\"100%\">\r\n\t\t\r\n\t <h4><span class=\"icon-bookmark\" ></span>\r\n\t\t\t<a href=\"\" data-dojo-attach-event=\"onclick: handleClick\" title=\"${tooltip}\">${title}</a>\r\n\t\t</h4>\r\n\t\t\t\t\r\n\t</td>\r\n</tr>", +'sbt/connections/nls/CommunityService':function(){ +/* + * © Copyright IBM Corp. 2012,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. + */ + +/** + * Social Business Toolkit SDK - Default resource bundle for CommunityService + */ +define({ + root: ({ + invalid_argument : "Invalid Argument" + }) +}); +}, +'sbt/widget/grid/_Grid':function(){ +require({cache:{ +'url:sbt/controls/grid/templates/Grid.html':"<div dojoAttachPoint=\"gridNode\" role=\"main\"></div>\r\n"}}); +/* + * © Copyright IBM Corp. 2014 + * + * 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. + */ + +/** + * + */ +define([ "../../declare", "../../store/AtomStore", "dojo/_base/lang", "dojo/_base/Deferred", + "../../widget/_TemplatedWidget", "../../text!../../controls/grid/templates/Grid.html"], + function(declare, AtomStore, lang, Deferred, _TemplatedWidget, GridTemplate) { + + /* + * @module sbt._bridge.grid._Grid + */ + var _Grid = declare([ _TemplatedWidget ], { + + templateString: GridTemplate, /* - * Ensures that, when setting a value, the required delimiter is before it, and when setting a value null, the relevant delimiter is not before it. - * - * e.g. setQuery(query). If there was no ? in the url then the url will still not have one when you set the query. It needsto be set in this case. If there was one and you set it null, it needs to be removed. + * Creates an instance of an atom store. */ - _ensureDelimiter: function(urlPart, delimGroupNum, delim){ - if(!urlPart && this._resultStore[delimGroupNum]){// if we are setting port empty, ensure there is no : before the port. - this._resultStore[delimGroupNum] = undefined; - }else if(urlPart && !this._resultStore[delimGroupNum]){// if we are setting port not empty, ensure there is a : before the port. - this._resultStore[delimGroupNum] = delim; - } - }, - - /* - @method constructor - **/ - constructor: function(url){ - this.setUrl(url); - }, - - /** - @method getUrl - @return {String} Returns the url in its current state. - **/ - getUrl: function(){ - return this._resultStore.slice(1).join(""); - }, - - /** - @method setUrl - @param url {String} - **/ - setUrl: function(url){ - this._resultStore = URL_RE.exec(url); - }, - - /** - @method getScheme - @return {String} Returns the scheme in its current state. - **/ - getScheme: function(){ - return this._resultStore[URL_RE_GROUPS.SCHEME]; - }, + _createDefaultStore: function(args) { + return new AtomStore(args); + }, - /** - @method setScheme - @param scheme {String} - @param keepSlashes {Boolean} If true, keep the // even if the scheme is set empty. e.g. //ibm.com is a valid url - **/ - setScheme: function(scheme, keepSlashes){ - this._ensureDelimiter(scheme, URL_RE_GROUPS.SCHEME_COLON, ':'); - if(!keepSlashes || scheme){ // If they want to keep slashes and the scheme provided is empty, do not do the ensure part. - this._ensureDelimiter(scheme, URL_RE_GROUPS.SCHEME_SLASHES, '//'); - }else{ // they want to keep slashes and the scheme provided is empty - this._resultStore[URL_RE_GROUPS.SCHEME_SLASHES] = '//'; - } + /* + * Retrieves the data from the Atom Store + */ + _doQuery: function(store, options, query) { + query = query || {}; + var self = this; + var errCallback = lang.hitch(this, this._updateWithError); + var results = store.query(query, options); - this._resultStore[URL_RE_GROUPS.SCHEME] = scheme; - }, - - /** - @method getUser - @return {String} Returns the username in its current state. - **/ - getUser: function(){ - return this._resultStore[URL_RE_GROUPS.USER]; - }, - - /** - @method setUser - @param user {String} - **/ - setUser: function(user){ - this._ensureDelimiter(user, URL_RE_GROUPS.USER_AT, '@'); - this._resultStore[URL_RE_GROUPS.USER] = user; - }, - - /** - @method getPassword - @return {String} Returns the password (domain) in its current state. - **/ - getPassword: function(){ - return this._resultStore[URL_RE_GROUPS.PASSWORD]; - }, - - /** - @method setPassword - @param password {String} - **/ - setPassword: function(password){ - this._ensureDelimiter(password, URL_RE_GROUPS.PASSWORD_COLON, ':'); - this._resultStore[URL_RE_GROUPS.PASSWORD] = password; - }, - - /** - @method getHostName - @return {String} Returns the hostname (domain) in its current state. - **/ - getHostName: function(){ - return this._resultStore[URL_RE_GROUPS.HOSTNAME]; - }, - - /** - @method setHostName - @param hostName {String} - **/ - setHostName: function(hostName){ - this._resultStore[URL_RE_GROUPS.HOSTNAME] = hostName; - }, + Deferred.when(results.total, function(totalCount) { + Deferred.when(results, function(items) { + self.data = { + items : items, + start : options.start, + end : options.start + items.length, + count : items.length, + totalCount : totalCount, + response : results.response + }; + try { + self.renderer.render(self, self.gridNode, items, self.data); + self.onUpdate(self.data); + } catch (error) { + self.renderer.renderError(self, self.gridNode, error); + } + return results; + }, errCallback); + }, errCallback); + } + + }); + + return _Grid; +}); +}, +'sbt/_bridge/lang':function(){ +/* + * © 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. + */ - /** - @method getPort - @return {String} Returns the port in its current state. - **/ - getPort: function(){ - return this._resultStore[URL_RE_GROUPS.PORT]; +/** + * Social Business Toolkit SDK - Some language utilities. + */ +define(['dojo/_base/lang', 'dojo/has', 'dojo/_base/sniff'],function(lang, has) { + return { + mixin: function(dest,sources) { + return lang.mixin.apply(this, arguments); + }, + isArray: function(o) { + return lang.isArray(o); + }, + isString: function(o) { + return lang.isString(o); + }, + isFunction: function(o) { + return typeof o == 'function'; }, - - /** - @method setPort - @param port {Number} - **/ - setPort: function(port){ - this._ensureDelimiter(port, URL_RE_GROUPS.PORT_COLON, ':'); - this._resultStore[URL_RE_GROUPS.PORT] = port; + isObject: function(o) { + return typeof o == 'object'; + }, + clone: function(o) { + return lang.clone(o); + }, + concatPath: function() { + var a = arguments; + if(a.length==1 && this.isArray(a[0])) { + a = a[0]; + } + var s = ""; + for(var i=0; i<a.length; i++) { + var o = a[i].toString(); + if(s) { + s = s + "/"; + } + s = s + (o.charAt(0)=='/'?o.substring(1):o); + } + return s; }, - - /** - @method getPath - @return {String} Returns the path in its current state. - **/ - getPath: function(){ - return this._resultStore[URL_RE_GROUPS.PATH]; + trim: function(str) { + return lang.trim(str); }, - - /** - @method setPath - @param path {String} - **/ - setPath: function(path){ - this._resultStore[URL_RE_GROUPS.PATH] = path; + getObject: function(name, create, context) { + return lang.getObject(name, create, context); }, - - /** - @method getQuery - @return {String} Returns the query in its current state. - **/ - getQuery: function(){ - return this._resultStore[URL_RE_GROUPS.QUERY]; + hitch: function(scope, method) { + return lang.hitch(scope, method); }, - + isIE: function(){ + return has("ie"); + } + }; +}); +}, +'sbt/connections/controls/wrappers/ProfileCardWrapper':function(){ +require({cache:{ +'url:sbt/connections/controls/templates/ProfileCardWrapperContent.html':"<!DOCTYPE html>\r\n<html lang=\"en\" style=\"height: 100%;\">\r\n <head>\r\n <meta charset=\"utf-8\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/base/package3.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/sprites.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_lconntheme/default.css?version=oneui3&rtl=false\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_lconnappstyles/default/search.css?version=oneui3&rtl=false\"></link>\r\n <script type=\"text/javascript\">\r\n var djConfig = {\r\n parseOnLoad: true,\r\n locale: 'en'\r\n };\r\n </script>\r\n <script type=\"text/javascript\" src=\"/sbt.dojo180/dojo/dojo.js.uncompressed.js\"></script>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dojo/resources/dojo.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dijit/themes/claro/claro.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dojox/grid/enhanced/resources/claro/EnhancedGrid.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dojox/grid/enhanced/resources/EnhancedGrid_rtl.css\">\r\n <script type=\"text/javascript\" src=\"${libraryUrl}\"></script>\r\n <style> .commit-tease, .user-profile-mini-avatar, .avatar, .vcard-details, .signup-prompt-bg { display: none !IMPORTANT; } </style> <script> document.addEventListener('DOMContentLoaded', function() { this.querySelectorAll('a').forEach(anchor => { anchor.addEventListener('click', e => { e.preventDefault(); const redact = new URLSearchParams(window.location.search).get('redact'); const hasExistingParams = anchor.href.includes('?'); window.location.href = anchor.href + (hasExistingParams ? `&redact=${redact}` : `?redact=${redact}`); }); }); }); </script> </head>\r\n <body class=\"lotusui30_body lotusui30_fonts lotusui30\" style=\"width: 90%; height: 100%;\">\r\n <div id=\"innerCardDiv\"></div>\r\n <script>\r\n require([\"sbt/config\", \"sbt/dom\", \"sbt/connections/controls/vcard/ProfileVCard\"], function(config, dom, ProfileVCard) {\r\n config.Properties = ${sbtProps};\r\n var profileCard = new ProfileVCard({ userName : \"Frank Adams\", userId : \"0EE5A7FA-3434-9A59-4825-7A7000278DAA\" });\r\n \r\n dom.byId(\"innerCardDiv\").appendChild(profileCard.domNode);\r\n });\r\n </script>\r\n </body>\r\n</html>\r\n"}}); +/* + * © 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. + */ +define(["../../../declare", "../../../config", "../../../util", "../../../lang", "../../../url", "../../../connections/controls/WidgetWrapper", "../../../text!../templates/ProfileCardWrapperContent.html"], function(declare, config, util, lang, Url, WidgetWrapper, defaultTemplate) { + + /** + * The wrapper for the ActivityStream. + * This class just has to provide its own template and the args it receives back to to the WidgetWrapper, which will take care of everything else. + * + * @class sbtx.controls.astream.ActivityStreamWrapper + */ + var ProfileCardWrapper = declare([ WidgetWrapper ], { + /** - @method setQuery - @param query {String} - **/ - setQuery: function(query){ - this._ensureDelimiter(query, URL_RE_GROUPS.QUERY_QUESTION, '?'); - this._resultStore[URL_RE_GROUPS.QUERY] = query; - }, + * Set the html template which will go inside the iframe. + * + * @property defaultTemplate + * @type String + */ + defaultTemplate: defaultTemplate, /** - @method getFragment - @return {String} Returns the fragment in its current state. - **/ - getFragment: function(){ - return this._resultStore[URL_RE_GROUPS.FRAGMENT]; + * Overriding the method in WidgetWrapper for providing the substitutions for variables in the template. + * + * @method getTemplateReplacements + * @returns {Object} + */ + getTemplateReplacements: function(){ + var connectionsUrl = this._endpoint.baseUrl; + var libUrl = new Url(config.Properties.libraryUrl); + var libQuery = libUrl.getQuery() || ""; + var libQueryObj = util.splitQuery(libQuery, "&"); + + lang.mixin(libQueryObj, { + lib: "dojo", + ver: "1.8.0" + }); + libQuery = util.createQuery(libQueryObj, "&"); + libUrl.setQuery(libQuery); + + var sbtProps = lang.mixin({}, config.Properties); + lang.mixin(sbtProps, { + libraryUrl: libUrl.getUrl(), + loginUi: "popup" + }); + var templateReplacements = { + args: JSON.stringify(this.args), + connectionsUrl: connectionsUrl, + libraryUrl: libUrl.getUrl(), + sbtProps: JSON.stringify(sbtProps) + }; + + return templateReplacements; }, /** - @method setFragment - @param fragment {String} - **/ - setFragment: function(fragment){ - this._ensureDelimiter(fragment, URL_RE_GROUPS.FRAGMENT_HASH, '#'); - this._resultStore[URL_RE_GROUPS.FRAGMENT] = fragment; - }, + * Store the args so that they can be substituted into the defaultTemplate. + * + * @property args + * @type Object + * @default null + */ + args: null, - /** - @method getBaseUrl - @return {String} Utility method, returns the url up until before the query. - **/ - getBaseUrl: function(){ - return this._resultStore.slice(1, URL_RE_GROUPS.QUERY).join(""); + constructor: function(args){ + this.args = args; } + }); - return url; + + return ProfileCardWrapper; }); }, -'sbt/_bridge/Transport':function(){ +'url:sbt/connections/controls/search/templates/PopUpTemplate.html':"<table role=\"presentation\" tabindex=\"0\"\r\n\tdata-dojo-attach-event=\"blur: handleBlur, onkeypress: onKeyPress\"\r\n\tclass=\"dijit dijitMenu dijitReset dijitMenuTable lotusNavMenu lconnSearchScope dijitMenuActive\"\r\n\tstyle=\"position:fixed;\">\r\n\t<tbody tabindex=\"0\" class=\"dijitReset\">\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onmouseenter: displayHighlight, onmouseleave: removeHighlight, onclick: setSelectedApplication\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem lotusAlignLeft\">\r\n\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconConnections16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.allConnections}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onmouseenter: displayHighlight, onmouseleave: removeHighlight, onclick: setSelectedApplication\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconStatusUpdate16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.statusUpdates}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconActivities16\" />\r\n\t\t\t</td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.activities}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconBlogs16\" /></td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.blogs}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconBookmarks16\" />\r\n\t\t\t</td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.bookmarks}</td>\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconCommunities16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.communities}</td>\r\n\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconFiles16\" /></td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.files}</td>\r\n\r\n\t\t</tr>\r\n\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconForums16\" /></td>\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.forums}</td>\r\n\t\t</tr>\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem\">\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconProfiles16\" />\r\n\t\t\t</td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.profiles}</td>\r\n\r\n\t\t</tr>\r\n\t\t<tr\r\n\t\t\tdata-dojo-attach-event=\"onclick: setSelectedApplication, onmouseenter: displayHighlight, onmouseleave: removeHighlight\"\r\n\t\t\tclass=\"dijitReset dijitMenuItem dijitMenuItemSelected\">\r\n\r\n\t\t\t<td class=\"dijitReset\"><img alt=\"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon lconnSprite lconnSprite-iconWikis16\" /></td>\r\n\r\n\t\t\t<td colspan=\"2\" class=\"dijitReset dijitMenuItemLabel\">${nls.wikis}</td>\r\n\t\t</tr>\r\n\r\n\t</tbody>\r\n</table>", +'sbt/connections/controls/search/SearchGridRenderer':function(){ +require({cache:{ +'url:sbt/connections/controls/search/templates/BookmarkBody.html':"<div class=\"lotusMeta\">\r\n <ul class=\"lotusInlinelist\" role=\"list\" style=\"clear: both\">\r\n <li class=\"lotusFirst\" role=\"listitem\">\r\n ${bodyBookmarkLiContent}\r\n </li>\r\n <li class=\"searchDateClass\" role=\"listitem\">\r\n ${updatedLabel}\r\n </li>\r\n ${tagsList}\r\n </ul>\r\n\r\n</div>\r\n<div style=\"clear: both; color: #228822\">\r\n ${resultLink}\r\n</div>", +'url:sbt/connections/controls/search/templates/CalendarBody.html':"<div class=\"lotusMeta\">\r\n <ul class=\"lotusInlinelist\" role=\"list\" style=\"clear: both\">\r\n <li class=\"lotusFirst\" style=\"font-weight: bold\" role=\"listitem\">\r\n ${_nls.eventDateOn}\r\n <span class=\"searchDateClass\">\r\n ${eventStartDate}\r\n </span>\r\n </li>\r\n ${bodyCalendarLis}\r\n ${personCard}\r\n </ul>\r\n</div>", +'url:sbt/connections/controls/search/templates/CommunityBody.html':"<div class=\"lotusMeta\">\r\n <ul class=\"lotusInlinelist\" role=\"list\" style=\"clear: both\">\r\n ${communityMembers}\r\n <li class=\"searchDateClass\" role=\"listitem\">\r\n ${updatedLabel}\r\n </li>\r\n ${tagsList}\r\n </ul>\r\n\r\n</div>\r\n\r\n", +'url:sbt/connections/controls/search/templates/DefaultBody.html':"<div class=\"lotusMeta\">\r\n <ul class=\"lotusInlinelist\" role=\"list\" style=\"clear: both\">\r\n ${bodyPersonCardLi}\r\n ${bodyUpdatedLi}\r\n ${bodyCommentCountLi}\r\n ${objectReferenceLi}\r\n ${tagsList}\r\n ${bodyBookmarkLi}\r\n </ul>\r\n</div>", +'url:sbt/connections/controls/search/templates/DefaultHeader.html':"<div>\r\n <h4 class=\"lotusLeft\">\r\n <a href=\"${resultLink}\" onclick=\"return searchObject.navigate(this, arguments[0] || window.event);\" ${ltr}>\r\n ${commentOn} ${formattedTitle} ${inactiveLabel}\r\n </a>\r\n </h4>\r\n</div>", +'url:sbt/connections/controls/search/templates/DefaultSummary.html':"<div style=\"clear:both;\">\r\n <span class=\"${summaryClass}\" style=\"${summaryStyle}\">\r\n ${summaryIcon}\r\n <span class=\"lotusMeta\">\r\n <!-- TODO this span should only appear if the parentageMeta is not empty. -->\r\n ${communityParent}\r\n ${parentageMeta}\r\n </span>\r\n <span class=\"lotusMeta\">${summaryTypeLabel}  </span>\r\n </span>\r\n ${resultSummary}  \r\n</div>\r\n\r\n${resultComment}", +'url:sbt/connections/controls/search/templates/ProfileBody.html':"<div class=\"lotusMeta\">\r\n <ul class=\"lotusInlinelist\" role=\"list\" style=\"clear: both\">\r\n <!-- TODO If this list is empty the entire div shouldn't appear. -->\r\n ${profileBodyJobTitle}\r\n ${tagsList}\r\n </ul>\r\n</div>", +'url:sbt/connections/controls/search/templates/ProfileHeader.html':"<div>\r\n <h4 class=\"lotusLeft\">\r\n <span class=\"vcard lotusPerson\">\r\n <a class=\"fn lotusPerson hasHover\" href=\"${resultLink}\" onclick=\"return searchObject.navigate(this, arguments[0] || window.event);\">\r\n ${formattedTitle}\r\n </a>\r\n <span class=\"x-lconn-userid\" style=\"display:none;\">\r\n ${authorUid}\r\n </span>\r\n </span>\r\n </h4>\r\n</div>", +'url:sbt/connections/controls/search/templates/PersonCard.html':"<span ${cardClass}>\r\n <a class=\"fn lotusPerson\" href=\"javascript:void(0);\" onclick='javascript:searchObject.performPersonFilter(\"${authorUid}%02${authorName}\"\"'>\r\n ${authorName}\r\n ${inactiveLabel}\r\n </a>\r\n <span class=\"x-lconn-userid\" style=\"display:none\">\r\n ${authorUid}\r\n </span>\r\n</span>\r\n", +'url:sbt/connections/controls/search/templates/StatusUpdateExtraHeader.html':"<div class=\"lconnStatusUpdatePhotoContainer otherPeople64 otherPeople64-NoPhotoPerson55\">\r\n <span class=\"x-lconn-userid\" style=\"display: none;\">\r\n ${authorUid}\r\n </span>\r\n</div>\r\n", +'url:sbt/connections/controls/search/templates/StatusUpdateHeader.html':"<div class=\"lotusLeft lconnSearchHighlight lconnStatusUpdateTitle\">\r\n <a href=\"${resultLink}\">\r\n ${formattedTitle}\r\n </a>\r\n</div>", +'url:sbt/connections/controls/search/templates/a.html':"<a ${hrefAttr} ${onclickAttr} ${altAttr} ${classAttr}>${content}</a>", +'url:sbt/connections/controls/search/templates/td.html':"<td ${classAttr} ${colspanAttr} ${widthAttr} ${heightAttr}>${content}</td>", +'url:sbt/connections/controls/search/templates/tr.html':"<tr ${classAttr}>${content}</tr>", +'url:sbt/connections/controls/search/templates/li.html':"<li ${classAttr} ${roleAttr} ${styleAttr}>${content}</li>", +'url:sbt/connections/controls/search/templates/ul.html':"<ul ${classAttr} ${styleAttr}>${content}</ul>", +'url:sbt/connections/controls/search/templates/span.html':"<span ${classAttr}>${content}</span>", +'url:sbt/connections/controls/search/templates/img.html':"<img ${classAttr} ${srcAttr} ${altAttr} ${titleAttr} ${roleAttr}/>", +'url:sbt/connections/controls/search/templates/em.html':"<em ${classAttr}>\r\n ${content}\r\n</em>", +'url:sbt/connections/controls/search/templates/div.html':"<div ${styleAttr}>\r\n ${content}\r\n</div>"}}); /* - * © Copyright IBM Corp. 2014 + * © 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. @@ -38614,601 +37192,1179 @@ define(['./declare'], function(declare){ */ /** - * Social Business Toolkit SDK. * - * Implementation of a transport using the Dojo XHR API. */ -define([ 'dojo/_base/declare', 'dojo/_base/xhr', 'dojo/_base/lang', '../util', '../Promise' ], function(declare, xhr, lang, util, Promise) { - return declare(null, { +define(["../../../declare", + "../../../dom", + "../ConnectionsGridRenderer", + "../../../lang", "../../../stringUtil", "../../../localeUtil", + "../../../i18n!./nls/SearchGridRenderer", + "../../../text!./templates/BookmarkBody.html", + "../../../text!./templates/CalendarBody.html", + "../../../text!./templates/CommunityBody.html", + "../../../text!./templates/DefaultBody.html", + "../../../text!./templates/DefaultHeader.html", + "../../../text!./templates/DefaultSummary.html", + "../../../text!./templates/ProfileBody.html", + "../../../text!./templates/ProfileHeader.html", + "../../../text!./templates/PersonCard.html", + "../../../text!./templates/StatusUpdateExtraHeader.html", + "../../../text!./templates/StatusUpdateHeader.html", + "../../../text!./templates/a.html", + "../../../text!./templates/td.html", + "../../../text!./templates/tr.html", + "../../../text!./templates/li.html", + "../../../text!./templates/ul.html", + "../../../text!./templates/span.html", + "../../../text!./templates/img.html", + "../../../text!./templates/em.html", + "../../../text!./templates/div.html"], + function(declare, dom, ConnectionsGridRenderer, lang, stringUtil, localeUtil, nls, bookmarkBodyTemplate, calendarBodyTemplate, communityBodyTemplate, defaultBodyTemplate, defaultHeaderTemplate, defaultSummaryTemplate, profileBodyTemplate, profileHeaderTemplate, personCardTemplate, statusUpdateExtraHeaderTemplate, statusUpdateHeaderTemplate, aElement, tdElement, trElement, liElement, ulElement, spanElement, imgElement, emElement, divElement) { + + /** + * @class SearchGridRenderer + * @module sbt.controls.grid.connections.SearchGridRenderer + * @namespace sbt.controls.grid.connections + */ + var searchGridRenderer = declare(ConnectionsGridRenderer, { + + _nls: nls, + + resultType: null, + + application: null, /** - * Provides an asynchronous request using the associated Transport. + * Takes a html template and a list of arguments. These arguments are substituted into the template and the template is returned with attributes set. * - * @method request - * @param {String) - * url The URL the request should be made to. - * @param {Object} - * [options] Optional A hash of any options for the provider. - * @param {String|Object} - * [options.data=null] Data, if any, that should be sent with - * the request. - * @param {String|Object} - * [options.query=null] The query string, if any, that should - * be sent with the request. - * @param {Object} - * [options.headers=null] The headers, if any, that should - * be sent with the request. - * @param {Boolean} - * [options.preventCache=false] If true will send an extra - * query parameter to ensure the the server won©t supply - * cached values. - * @param {String} - * [options.method=GET] The HTTP method that should be used - * to send the request. - * @param {Integer} - * [options.timeout=null] The number of milliseconds to wait - * for the response. If this time passes the request is - * canceled and the promise rejected. - * @param {String} - * [options.handleAs=text] The content handler to process the - * response payload with. - * @return {sbt.Promise} + * Used for creating html elements. + * + * e.g. + * buildElement("<li ${classAttr} ${roleAttr}>${content}</li>", {classAttr: "lotusFirst", roleAttr: "listitem", content: "content"}); + * + * returns + * + * "<li class="lotusFirst" role = "listitem">content</li>" + * + * @param html + * @param args + * @returns The html template with the substituted values. */ - request : function(url, options) { - var method = options.method || "GET"; - method = method.toUpperCase(); - var query = this.createQuery(options.query); - var qurl = url; - if(qurl && query){ - qurl += (~qurl.indexOf('?') ? '&' : '?') + query; - } - var args = { - url : qurl, - handleAs : options.handleAs || "text" - }; - //if (options.query) { - // args.content = options.query; - //} - if (options.headers) { - args.headers = options.headers; + buildElement: function(html, args){ + args.classAttr = args.classAttr ? 'class="' + args.classAttr + '"' : ""; + args.styleAttr = args.styleAttr ? 'style="' + args.styleAttr + '"' : ""; + args.roleAttr = args.roleAttr ? 'role="' + args.roleAttr + '"' : ""; + args.hrefAttr = args.hrefAttr ? 'href="' + args.hrefAttr + '"' : ""; + args.onclickAttr = args.onclickAttr ? 'onclick="' + args.onclickAttr + '"' : ""; + args.colspanAttr = args.colspanAttr ? 'colspan="' + args.colspanAttr + '"' : ""; + args.altAttr = args.altAttr ? 'alt="' + args.altAttr + '"' : ""; + args.srcAttr = args.srcAttr ? 'src="' + args.srcAttr + '"' : ""; + args.titleAttr = args.titleAttr ? 'title="' + args.titleAttr + '"' : ""; + args.widthAttr = args.widthAttr ? 'width="' + args.widthAttr + '"' : ""; + args.heightAttr = args.heightAttr ? 'height="' + args.heightAttr + '"' : ""; + + return stringUtil.transform(html, args); + }, + + resultTypes: { + activities : "activities", + blogs : "blogs", + bookmark: "bookmark", + calendar : "calendar", + communities : "communities", + files : "files", + forums : "forums", + inactiveProfiles : "inactiveProfiles", + profiles : "profiles", + statusUpdates : "status_updates", + wiki : "wiki" + }, + + /** + * Creates an li containing a list of tags. + * + * @param grid + * @param item + * @param i + * @param items + * @returns An li containing a list of tags. + */ + tagsList: function(grid, item, i, items){ + var tagCount = item.getValue("tagCount"); + tagCount = parseInt(tagCount); + if(tagCount === 0){ + return ""; + } + var resultLiRole = "listitem"; + + var ulClass = "lotusInlinelist"; + var ulStyle = "display:inline"; + var ulContent = ""; + + var tags = item.getValue("tags"); + + var i; + for(i = 0; i < tagCount && i < 3; i++){ + var currentTag = typeof tags === 'string' ? tags : tags[i]; + var liStyle = "padding:0px"; + var liClass = "lotusFirst"; + if(i === 2 || i === tagCount - 1){ + liClass = "lotusLast"; + } + var aHref = "javascript:void(0);"; + var aOnClick = "onclick=\"searchObject.performTagFilter('" + tags[i] + "');\""; + var aAlt = currentTag; + + if(item.getValue("highlightField")){ + var aClass = currentTag; + }else{ + aClass = undefined; + } + var aContent = currentTag; + + var a = this.buildElement(aElement, { + hrefAttr: aHref, + onclickAttr: aOnClick, + altAttr: aAlt, + classAttr: aClass, + content: aContent + }); + var liContent = a; + if(i != tagCount - 1 && i != 2){ + liContent += ", "; + } + var li = this.buildElement(liElement, { + content: liContent, + classAttr: liClass, + styleAttr: liStyle + }); + ulContent += li + "\n"; + } + + var more = tagCount > 3 ? this._nls.tagsMore.replace("{0}", tagCount-3) : ""; + var ul = this.buildElement(ulElement, { + content: ulContent, + classAttr: ulClass, + styleAttr: ulStyle + }); + var span = this.buildElement(spanElement, { + content: this._nls.tags + "  " + ul + " " + more + }); + + return this.buildElement(liElement, { + roleAttr: resultLiRole, + content: span + }); + }, + + /** + * Returns the img tag defining the image to use as the application icon. + * + * @param grid + * @param item + * @param i + * @param items + * @returns {String} + */ + summaryIcon: function(grid, item, i, items){ + var fileExtension = item.getValue("fileExtension"); + var summaryImageClass = "lconn-ftype16 lconn-ftype16-" + fileExtension, summaryImageSrc = "", summaryImageAlt = "", summaryImageTitle = "", summaryImageRole = ""; + switch(this.resultType){ + case this.resultTypes.activities: + summaryImageClass = "lconnSprite lconnSprite-iconActivities16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.activities; + summaryImageTitle = this._nls.activities; + summaryImageRole = "presentation"; + break; + case this.resultTypes.blogs: + summaryImageClass = "lconnSprite lconnSprite-iconBlogs16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.blogs; + summaryImageTitle = this._nls.blogs; + summaryImageRole = "presentation"; + break; + case this.resultTypes.bookmark: + summaryImageClass = "lconnSprite lconnSprite-iconBookmarks16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.bookmarks; + summaryImageTitle = this._nls.bookmarks; + summaryImageRole = "presentation"; + break; + case this.resultTypes.calendar: + summaryImageClass = "lconnSprite lconnSprite-iconCalendar16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.calendar; + summaryImageTitle = this._nls.calendar; + summaryImageRole = "presentation"; + break; + case this.resultTypes.communities: + summaryImageClass = this.componentContains(item, "communities:feed") ? "lconnSprite lconnSprite-iconFeed16" : "lconnSprite lconnSprite-iconCommunities16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.communities; + summaryImageTitle = this._nls.communities; + summaryImageRole = "presentation"; + break; + case this.resultTypes.files: + summaryImageClass = fileExtension ? summaryImageClass : "lconnSprite lconnSprite-iconFiles16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.files; + summaryImageTitle = this._nls.files; + summaryImageRole = "presentation"; + break; + case this.resultTypes.forums: + summaryImageClass = "lconnSprite lconnSprite-iconForums16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.forums; + summaryImageTitle = this._nls.forums; + summaryImageRole = "presentation"; + break; + case this.resultTypes.profiles: + summaryImageClass = "lconnSprite lconnSprite-iconProfiles16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.profiles; + summaryImageTitle = this._nls.profiles; + summaryImageRole = "presentation"; + break; + case this.resultTypes.statusUpdates: + summaryImageClass = "lconnSprite lconnSprite-iconStatusUpdate16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.statusUpdates; + summaryImageTitle = this._nls.statusUpdates; + summaryImageRole = "presentation"; + break; + case this.resultTypes.wikis: + summaryImageClass = fileExtension.length !== 0 ? summaryImageClass : "lconnSprite lconnSprite-iconWikis16"; + summaryImageSrc = "images/blank.gif"; + summaryImageAlt = this._nls.wikis; + summaryImageTitle = this._nls.wikis; + summaryImageRole = "presentation"; + break; + } + return this.buildElement(imgElement, { + classAttr: summaryImageClass, + srcAttr: summaryImageSrc, + altAttr: summaryImageAlt, + titleAttr: summaryImageTitle, + roleAttr: summaryImageRole + }); + }, + + /** + * Returns a result Summary, which is a span element containing a summary but includes an extra ul if the result type is statusUpdate. + * @param grid + * @param item + * @param i + * @param items + * @returns + */ + resultSummary: function(grid, item, i, items){ + var summary = item.getValue("summary"); + if(summary.length!==0){ + var statusUpdateUl = ""; + if(this.resultType === this.resultTypes.statusUpdates){ + var statusUpdateLi = this.buildElement(liElement, { + classAttr: "lotusMeta lconnSearchHighlight", + content: this._nls.comment + }); + statusUpdateUl = this.buildElement(ulElement, { + styleAttr: "display: inline", + classAttr: "lotusInlinelist", + roleAttr: "presentation", + content: statusUpdateLi + }); + } + summary = summary.replace(/<b>/g, "<b>"); // replace the encoded <b> tags... + summary = summary.replace(/<\/b>/g, "</b>"); + + var summarySpan = this.buildElement(spanElement, { + classAttr: "lotusMeta lconnSearchHighlight", + content: summary + }); + + return statusUpdateUl + "\n" + summarySpan + "\n"; + }else if(this.resultType != this.resultTypes.statusUpdates){ + return this.buildElement(emElement, { + content: this._nls.noDescription, + classAttr: "lotusMeta" + }); + } + + }, + + resultComment: function(grid, item, i, items){ + if(item.getValue("commentsSummary").length > 0 && this.resultType != this.resultTypes.statusUpdates){ + var divSpan = this.buildElement(spanElement, { + classAttr: "lotusMeta lconnSearchHighlight", + content: this._nls.comment + item.getValue("commentsSummary") + }); + return this.buildElement(divElement, { + styleAttr: "clear:both;", + content: divSpan + }); } - var hasBody = false; - if (method == "PUT") { - args.putData = options.data || null; - hasBody = true; - } else if (method == "POST") { - args.postData = options.data || null; - hasBody = true; - } else if(method == "GET") { // to ensure each time fresh feed is retrieved with network call - args.preventCache = true; + }, + + formattedTitle: function(grid, item, i, items){ + var title = item.getValue("title"); + if(title.length !== 0){ + title = title.replace(/<b>/g, "<b>"); // replace the encoded <b> tags... + title = title.replace(/<\/b>/g, "</b>"); } - var promise = new Promise(); - promise.response = new Promise(); - var self = this; - args.handle = function(response, ioargs) { - if (response instanceof Error) { - var error = response; - error.response = self.createResponse(url, options, response, ioargs); - promise.rejected(error); - promise.response.rejected(error); - } else { - promise.fulfilled(response); - promise.response.fulfilled(self.createResponse(url, options, response, ioargs)); + return title; + }, + + parentageMeta: function(grid, item, i, items){ + switch(item.getValue("parentageMetaURLID")){ + case 'blogURL': + var aHref = item.getValue("parentageMetaURL"); + var aContent = ""; + if(this.componentcontains(item, "blogs:ideationblogs:idea")){ + aContent = this._nls.fromAnIdeationBlog; + }else{ + aContent = this._nls.fromABlog; } - }; - - this.xhr(method, args, hasBody); - return promise; + return this.buildElement(aElement, { + hrefAttr: aHref, + content: aContent + }) + " > "; + case 'forumURL': + return this.buildElement(aElement, { + hrefAttr: item.getValue("parentageMetaURL"), + content: this._nls.fromAForum + }) + " > "; + case 'wikiURL': + return this.buildElement(aElement, { + hrefAttr: item.getValue("parentageMetaURL"), + content: this._nls.fromAWiki + }) + " > "; + case 'activityURL': + if(item.getValue("primaryComponent").indexOf("activities") === 0 || item.getValue("primaryComponent").indexOf("communities:activities") === 0){ + if(item.getValue("primaryComponent") === "activities:bookmark" || item.getValue("primaryComponent") === "communities:activities:bookmark" || this.componentContains("activities:section") || this.componentContains("activities:task") || this.componentContains("activities:entry")){ + return this.buildElement(aElement, { + hrefAttr: item.getValue("parentageMetaURL"), + content: this._nls.fromAnActivity + }) + " > "; + } + if(item.getValue("parentageMetaID") === "activityEntryURL" || item.getValue("primaryComponent") === "activities:bookmark"){ + return this.buildElement(aElement, { + hrefAttr: item.getValue("parentageMetaURL"), + content: this._nls.entry + }) + " > "; + } + } + + } + return ""; }, - /* - * Create a response object + communityParent: function(grid, item, i, items){ + if(item.getValue("communityUuid").length!=0 && item.getValue("containerType") != "stand-alone" && item.getValue("primaryComponent") != "communities:entry" && item.getValue("primaryComponent").indexOf("communities") === 0){ + return this.buildElement(aElement, { + hrefAttr: item.getValue("communityParentLink"), + content: this._nls.fromACommunity + }) + " > "; + }else{ + return ""; + } + }, + /** + * @param grid + * @param item + * @param i + * @param items + * @returns */ - createResponse: function(url, options, response, ioargs) { - var xhr = ioargs._ioargs.xhr; - var handleAs = options.handleAs || "text"; - return { - url : url, - options : options, - data : response, - text : (handleAs == "text") ? response : null, - status : xhr.status, - getHeader : function(headerName) { - return xhr.getResponseHeader(headerName); - }, - xhr : xhr, - _ioargs : ioargs._ioargs - }; + summaryTypeLabel: function(grid, item, i, items){ + var spanContent = ""; + var resultTypes = this.resultTypes; + switch(this.resultType){ + case resultTypes.activities: + if(this.componentContains(item, "activities:task")){ + spanContent = this._nls.activityToDo; + }else if(this.componentContains(item, "activities:activity") || this.componentContains(item, "activities:community_activity") || this.componentContains(item, "activities:community_activity+members") || this.componentContains(item, "activities:explicit_membership_community_activity")){ + spanContent = this._nls.activity; + }else if(this.componentContains(item, "activities:bookmark")){ + spanContent = this._nls.activityBookmark; + }else if(this.componentContains(item, "activities:section")){ + spanContent = this._nls.activitySection; + }else if(this.componentContains(item, "activities:reply")){ + spanContent = this._nls.activityComment; + }else{ + spanContent = this._nls.activityEntry; + } + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: spanContent + }); + case resultTypes.blogs: + if(this.componentContains(item, "blogs:ideationblogs:ideationblog")){ + spanContent = this._nls.ideationBlog; + }else if(this.componentContains(item, "blogs:ideationblogs:idea")){ + spanContent = this._nls.idea; + }else if(this.componentContains(item, "blogs:ideationblogs:comment")){ + spanContent = this._nls.ideaComment; + }else if(this.componentContains(item, "blogs:entry")){ + spanContent = this._nls.blogEntry; + }else if(this.componentContains(item, "blogs:comment")){ + spanContent = this._nls.blogComment; + }else{ + spanContent = this._nls.blog; + } + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: spanContent + }); + case resultTypes.bookmark: + spanContent = this._nls.bookmark; + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: spanContent + }); + case resultTypes.calendar: + spanContent = this._nls.calendar; + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: spanContent + }); + case resultTypes.communities: + if(this.componentContains(item, "communities:entry")){ + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: this._nls.community + }); + }else if(this.componentContains(item, "communities:feed")){ + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: this._nls.feed + }); + }else if(this.componentContains(item, "communities:bookmark")){ + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: this._nls.bookmark + }); + } + case resultTypes.files: + spanContent = this._nls.file; + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: spanContent + }); + case resultTypes.forums: + if(this.componentContains(item, "communities:forums:forum")){ + spanContent = this._nls.forum; + }else if(this.componentContains(item, "communities:forums:category")){ + spanContent = this._nls.forumCategory; + }else{ + spanContent = this._nls.forumTopic; + } + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: spanContent + }); + case resultTypes.profiles: + spanContent = this._nls.profile; + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: spanContent + }); + case resultTypes.statusUpdates: + spanContent = this._nls.fromAStatusUpdate; + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: spanContent + }); + case resultTypes.wikis: + if(this.componentContains(item, "wikis:wiki")){ + spanContent = this._nls.wikiType; + }else if(this.componentContains(item, "wikis:file")){ + spanContent = this._nls.wikiFile; + }else{ + spanContent = this._nls.wikiPage; + } + return this.buildElement(spanElement, { + classAttr: "lotusMeta", + content: spanContent + }); + } }, - - /* - * Create a query string from an object + + /** + * UtilityFunction, used to test if the item application array contains a certain string. Or if it is in the primaryComponent. + * + * @param item + * @param appString */ - createQuery: function(queryMap) { - if (!queryMap) { - return null; + componentContains: function(item, appString){ + if(item.getValue("primaryComponent") === appString){ + return true; } - var pairs = []; - for(var name in queryMap){ - var value = queryMap[name]; - if (lang.isArray(value)) { - name = encodeURIComponent(name); - for (var i=0; i<value.length; i++) { - pairs.push(name + "=" + encodeURIComponent(value[i])); - } - } else { - pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(value)); + for(var key in item.getValue("application")){ + var app = item.getValue("application")[key]; + if(app === appString){ + return true; } } - return pairs.join("&"); + return false; }, - xhr: function(method, args, hasBody) { - var _args = lang.mixin({}, args); + communityMembers: function(grid, item, i, items){ + var isCommunitiesEntry = this.componentContains(item, "communities:entry"); + if(!isCommunitiesEntry){ + return this.buildElement(liElement, { + content: this._substituteItem(personCardTemplate, grid, item, i, items), + classAttr: "lotusFirst", + roleAttr: "listitem" + }); + } + var liMembersContent = item.getValue("memberCount") + " " + this._nls.members; - // override the handle callback to normalise the Error - var self = this; - _args.handle = function(data, ioArgs) { - self.handleResponse(data, ioArgs, args); - }; - - // dojo.xhr(method, _args, hasBody); - xhr(method, _args, hasBody); - }, - handleResponse: function(data, ioArgs, args) { - var _data = data; + var liMembers = this.buildElement(liElement, { + content: liMembersContent, + classAttr: "lotusFirst members", + roleAttr: "listitem" + }); - if (data instanceof Error) { - _data = this.createError(data, ioArgs); - } + var liPersonCard = this.buildElement(liElement, { + content: this._substituteItem(personCardTemplate, grid, item, i, items), + roleAttr: "listitem" + }); - try { - var _ioArgs = { - 'args' : args, - 'headers' : util.getAllResponseHeaders(ioArgs.xhr), - '_ioargs' : ioArgs - }; - args.handle(_data, _ioArgs); - } catch (ex) { - console.log(ex); - } + return liMembers + "\n" + liPersonCard; }, - createError: function(error, ioArgs) { - var _error = new Error(); - _error.code = error.status || (error.response&&error.response.status) || 400; - _error.cause = error; - if (error.response) { - _error.response = lang.mixin({}, error.response); - } - return _error; - } - }); -}); -}, -'sbt/smartcloud/Subscriber':function(){ -/* - * © Copyright IBM Corp. 2012 - * - * 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. - */ -/** - * Social Business Toolkit SDK. - * - * @author Vimal Dhupar - * Definition of a Subscriber Helper for getting the Subscriber ID for a SmartCloud User. - */ -define([ "../declare", "../Endpoint" ], function(declare, Endpoint) { - /** - * Subscriber Helper Class for getting the Subscriber ID for a SmartCloud User. - * @class Subscriber - * @namespace sbt.smartcloud - */ - var Subscriber = declare(null, { - - endpoint : null, - - /** - * @constructor - * @param endpoint - * @param callback - */ - constructor : function(endpoint, callback) { - this.endpoint = endpoint; - if (callback) - this.load(callback); - }, - - /** - * Load method is responsible for making the network call to fetch the user identity - * @method load - * @param callback - */ - load : function(callback) { - var _self = this; - this.endpoint.xhrGet({ - serviceUrl : "/manage/oauth/getUserIdentity", - loginUi : this.endpoint.loginUi, - handleAs : "json", - load : function(response) { - callback(_self, response); - }, - error : function(error) { - callback(_self, null); - console.log("Error fetching feed for getUserIdentity"); - } - }); - }, - - /** - * Method to get the Subscriber Id of the user. - * @method getSubscriberId - * @param response - * @returns - */ - getSubscriberId : function(response) { - if (response && response.subscriberid) { - return response.subscriberid; - } - return null; - } - }); - return Subscriber; -}); -}, -'sbt/connections/controls/nls/ConnectionsGridRenderer':function(){ -/* - * © 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. - */ - -// NLS_CHARSET=UTF-8 -define({ - root: { - empty : "Empty", - loading : "Loading...", - previous : "Previous", - previousPage : "Previous Page", - next : "Next", - nextPage : "Next Page", - pagingResults : "${start}-${end} of ${totalCount}", - sortBy : "Sort by:", - msgNoData : "Please wait...", - show10Items : "Show 10 items", - show25Items : "Show 25 items", - show50Items : "Show 50 items", - show100Items : "Show 100 items", - items : "items", - feed : "${nls.feed}" - } -}); - - -}, -'url:sbt/connections/controls/files/templates/FileRow.html':"<tr class=\"lotusFirst\">\r\n <td class=\"lotusFirstCell\" width=\"32\" title=\"${title}\">\r\n <input value=\"${title}\" name=\"${title}\" aria-label=\"${nls.ariaCheckbox}\" data-dojo-attach-point=\"rowSelectionInput\" data-dojo-attach-event=\"onclick: handleCheckBox\" type=\"checkbox\" class=\"lotusCheckbox\">\r\n </td>\r\n <td class=lotusNowrap>\r\n <a title=\"Download ${title}\" href=\"${editMediaLink}\" class=\"lconnDownloadable lconnDownloadableIcon\">\r\n <img alt=\"\" src=\"images/blank.gif\" class=\"lconn-ftype32 lconn-ftype32-${ftype}\"><span class=\"lotusAltText\" title=\"\">${_nls.download}</span>\r\n </a>\r\n </td>\r\n <td style=\"width: 100%;\">\r\n <h4 class=\"lotusBreakWord lotusLeft\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${tooltip}\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a> \r\n </h4>\r\n <div class=\"lotusMeta lotusClear\">\r\n <ul class=\"lotusInlinelist\">\r\n <li class=\"lotusFirst\" title=\"\">\r\n <span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t\t<a aria-label=\"${nls.ariaVcard}\" href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" class=\"fn url\">${authorName}</a>\r\n \t\t\t\t\t\t<span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${authorUserId}</span>\r\n\t\t\t\t\t</span>\r\n ${_nls.created} ${createdLabel}\r\n </li>\r\n <li>\r\n ${hitCount} ${_nls.downloads}\r\n </li>\r\n <li>\r\n ${commentsCount} ${_nls.comments}\r\n </li>\r\n </ul>\r\n </div>\r\n </td>\r\n <td style=\"padding-right: 25px;\" class=\"lotusNowrap\">\r\n \r\n <div>\r\n <div class=\"lotusLike\">\r\n <a class=\"lotusLikeCount lotusLikeSimple\" title=\"${recommendationLabel}\" aria-label=\"${recommendationLabel}\">\r\n <img src=\"images/blank.gif\" class=\"lotusIconLike\" alt=\"\">${recommendationsCount}\r\n </a>\r\n </div>\r\n </div>\r\n \r\n </td>\r\n <td style=\"padding-right: 25px;\" title=\"Pin this file\">\r\n <a class=\"lconnPinnedToggle _filePinned\" href=\"javascript:\" topic=\"lconn/files/files/myfavorites/toggle\" data-dojo-attach-event=\"onclick: doPinFile\" role=\"button\" aria-label=\"${nls.pin}\" >\r\n <img src=\"images/blank.gif\" alt=\"${nls.pin}\" id =\"${uid}\" class=\"${pinFileOnOrOff}\" />\r\n </a>\r\n </td>\r\n <td style=\"padding-right: 25px;\" class=\"lotusNowrap\" title=\"${shareLabel}\">\r\n <a aria-label=\"${shareLabel}\" href=\"${selfUrl}?section=share\">\r\n <img src=\"images/blank.gif\" class=\"lconnSprite lconnSprite-icon${visibilityLabel}16\" alt=\"\" title=\"${shareLabel}\" style=\"margin-top: 1px;\">\r\n <span class=\"lotusAltText\">${shareLabel}</span>\r\n </a>\r\n </td>\r\n \r\n\r\n</tr>\r\n\r\n", -'sbt/connections/controls/bookmarks/nls/BookmarkGridRenderer':function(){ -/* - * © 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. - */ - -// NLS_CHARSET=UTF-8 -define({ - root: { - tags : "Tags: ", - date: "Date", - popularity: "Popularity", - feed : "Feed for these Bookmarks", - noTags : "No tags" - } -}); -}, -'sbt/base/JsonDataHandler':function(){ -/* - * © Copyright IBM Corp. 2012,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. - */ - -/** - * Social Business Toolkit SDK. - * Helpers for the base capabilities of data handlers. - * - * @module sbt.base.JsonDataHandler - */ -define(["../declare", "../lang", "../json", "./DataHandler", "../Jsonpath", "../stringUtil"], - function(declare, lang, json, DataHandler, jsonPath, stringUtil) { - - /** - * JsonDataHandler class - * - * @class JsonDataHandler - * @namespace sbt.base - */ - var JsonDataHandler = declare(DataHandler, { - - /** - * Data type for this DataHandler is 'json' - */ - dataType : "json", - - /** - * Set of jsonpath expressions used by this handler. - */ - jsonpath : null, - /** - * Set of values that have already been read. - */ - _values : null, + bodyCalendarLis: function(grid, item, i, items){ + var allDayEventLi = "", repeatingEventLi = "", locationLi = ""; + + if(item.getValue("allDayEvent") ==="true"){ + allDayEventLi = this.buildElement(liElement,{ + roleAttr: "listitem", + content: this._nls.eventIsAllDay + }); + } + if(item.getValue("repeatingEvent") ==="true"){ + allDayEventLi = this.buildElement(liElement,{ + roleAttr: "listitem", + content: this._nls.eventRepeats + }); + } + if(item.getValue("location.length") > 1){ + allDayEventLi = this.buildElement(liElement,{ + roleAttr: "listitem", + content: item.getValue("location") + }); + } + return allDayEventLi + "\n" + repeatingEventLi + "\n" + locationLi + "\n"; + }, - /** - * @constructor - * @param {Object} args Arguments for this data handler. - */ - constructor : function(args) { - lang.mixin(this, args); - this._values = {}; - this.data = args.data; - }, + bodyBookmarkLiContent : function(grid, item, i, items){ + var contributorCount = parseInt(item.getValue("contributorCount")); + var authorCount = parseInt(item.getValue("authorcount")); + + if(item.getValue("bookmarkLink").length > 0 && (contributorCount + authorCount) > 1){ + var spanA = this.buildElement(aElement, { + hrefAttr: item.getValue("bookmarkLink"), + content: contributorCount + authorCount + this._nls.people + }); + return this.buildElement(spanElement, { + content: spanA + }); + }else{ + return this._substituteItem(personCardTemplate, grid, item, i, items); + } + }, /** - * @method getAsString - * @param data - * @returns + * Returns the class to be used for a vcard. + * + * @param grid + * @param item + * @param i + * @param items + * @returns {String} */ - getAsString : function(property) { - this._validateProperty(property, "getAsString"); - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._get(property).toString(); - } - return this._values[property]; - } else { - return _get(property); + cardClass: function(grid, item, i, items){ + if(item.getValue("authorState") != 'active'){ + return "lotusPersonInactive"; + }else{ + return "vcard"; } }, - + /** - * @method getAsNumber + * Returns an li with the author's job title if it exists, otherwise an empty string. + * + * @param grid + * @param item + * @param i + * @param items * @returns */ - getAsNumber : function(property) { - this._validateProperty(property, "getAsNumber"); - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._getNumber(property); - } - return this._values[property]; - } else { - return _getNumber(property); + profileBodyJobTitle: function(grid, item, i, items){ + if(item.getValue("authorJobTitle") && item.getValue("authorJobTitle").length != 0){ + return this.buildElement(liElement, { + content: item.getValue("authorJobTitle")+" ", + classAttr: "lotusFirst", + roleAttr: "listitem" + }); + }else{ + return this._nls.emptyString; } }, - + /** - * @method getAsDate - * @returns + * + * + * @returns {String} */ - getAsDate : function(property) { - this._validateProperty(property, "getAsDate"); - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._getDate(property); + bodyPersonCardLi: function(grid, item, i, items){ + if(item.getValue("authorName").length != 0){ + return this.buildElement(liElement, { + content: this._substituteItem(personCardTemplate, grid, item, i, items), + roleAttr: "listitem", + classAttr: "lotusFirst" + }); + }else{ + return ""; + } + }, + + bodyUpdatedLi: function(grid, item, i, items){ + var liClass = "searchDateClass"; + if(item.getValue("authorName").length==0){ + liClass+= " lotusFirst"; + } + return this.buildElement(liElement, { + classAttr: liClass, + content: this.updatedLabel(grid, item, i, items) + }); + }, + + bodyCommentCountLi: function(grid, item, i, items){ + var commentcount = parseInt(item.getValue("commentCount")); + if(commentcount >= 1){ + var liContent = commentcount === 1 ? this._nls.oneComment : commentcount + " " + this._nls.comments; + return this.buildElement(liElement, { + classAttr: "comments", + roleAttr: "listitem", + content: liContent + }); + } + }, + + objectReferenceLi: function(grid, item, i, items){ + if(item.getValue("objectRefDisplayName").length != 0 && item.getValue("objectRefUrl").length != 0){ + var liContent = this.buildElement(aElement, { + hrefAttr: item.getValue("objectRefUrl"), + content: item.getValue("objectRefDisplayName") + }); + + return this.buildElement(liElement, { + roleAttr: "listitem", + content: liContent + }); + } + }, + + bodyBookmarkLi: function(grid, item, i, items){ + var applicationCount = parseInt(item.getValue("applicationCount")); + if(((this.application=='dogear' && applicationCount > 1) || (this.application=='activities:bookmark' && applicationCount > 2) || (this.application=='communities:bookmark' && applicationCount > 2) ) && item.getValue("accessControl")=='public'){ + var aImg = this.buildElement(imgElement, { + classAttr: "lconnSprite lconnSprite-iconHelp16", + srcAttr: "images/blank.gif", + titleAttr: this._nls.help, + altAttr: this._nls.help + }); + var aSpan = this.buildElement(spanElement, { + classAttr: "lotusAltText", + content: "?" + }); + var aResult = this.buildElement(aElement, { + classAttr: "lconnSearchBookmarkHelpButton", + hrefAttr: "javascript:;", + content: aImg + "\n" + aSpan + }); + + var ulContent = ""; + + if(this.application ==="dogear"){ + ulContent += this.buildElement(liElement, { + content: this._nls.bookmarksTitle + }) + "\n"; } - return this._values[property]; - } else { - return _getDate(property); + if(this.application ==="activities:bookmark"){ + ulContent += this.buildElement(liElement, { + content: this._nls.activitiesTitle + }) + "\n"; + } + if(this.application ==="communities:bookmark"){ + ulContent += this.buildElement(liElement, { + content: this._nls.communitiesTitle + }) + "\n"; + } + var spanUl = this.buildElement(ulElement, { + content: ulContent + }); + + var divSpan = this.buildelement(spanElement, { + classAttr: "lotusLeft lconnSearchBookmarkHelpText", + content: spanUl + }); + var divResult = this.buildElement(divElement, { + styleAttr: "display:none", + content: divSpan + }); + + return aResult + "\n" + divResult + "\n"; } }, - + /** - * @method getAsBoolean + * Returns the commentOn nls string if it is an activities:reply + * @param grid + * @param item + * @param i + * @param items * @returns */ - getAsBoolean : function(property) { - this._validateProperty(property, "getAsBoolean"); - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._getBoolean(property); - } - return this._values[property]; - } else { - return _getBoolean(property); - } + commentOn: function(grid, item, i, items){ + if(this.componentContains(item, "activities:reply")){ + return this._nls.commentOn; + }else{ + return this._nls.emptyString; + } }, - + /** - * @method getAsArray + * + * + * @param grid + * @param item + * @param i + * @param items * @returns */ - getAsArray : function(property) { - this._validateProperty(property, "getAsArray"); - if (this._values) { - if (!this._values.hasOwnProperty(property)) { - this._values[property] = this._get(property); - } - return this._values[property]; - } else { - return _get(property); - } + ltr: function(grid, item, i, items){ + if(this.componentContains(item, "wikis:file")){ + return 'dir="' + this._nls.ltr + '"'; + }else{ + return this._nls.emptyString; + } }, - + + inactiveLabel: function(grid, item, i, items){ + if(this.componentContains(item, "profiles")){ + return this._nls.inactiveLabel; + }else{ + return this._nls.emptyString; + } + }, + + colspan: function(grid, item, i, items){ + if(!this.componentContains(item, "status_update")){ + return 'colspan="2"'; + }else{ + return ''; + } + }, + /** - * @method getEntityId + * Returns the app label (e.g. profile) but capitalised (e.g. Profile). + * + * @param grid + * @param item + * @param i + * @param items * @returns */ - getEntityId : function(data) { - return stringUtil.trim(this.getAsString(this.jsonpath["id"])); + applicationLabel: function(grid, item, i, items){ + var application = this.application; + return application.charAt(0).toUpperCase() + application.slice(1); + }, + + summaryClass: function(grid, item, i, items){ + if(item.getValue("authorState") === "inactive"){ + return "lotusDim"; + }else{ + return "lconnSearchComponentCategory"; + } }, + - /** - * getEntityData - * @returns - */ - getEntityData : function() { - return this.data; + summaryStyle: function(grid, item, i, items){ + if(item.getValue("authorState") === "inactive"){ + return "filter: alpha(opacity = 50)"; + }else{ + return ""; + } }, - /** - * @method getSummary - * @returns - */ - getSummary : function() { - if (!this._summary && this._get("totalResults")[0]) { - this._summary = { - totalResults : this.getAsNumber("totalResults"), - startIndex : this.getAsNumber("startIndex"), - itemsPerPage : this.getAsNumber("itemsPerPage") - }; + getApplication: function(item){ + if(typeof item.getValue("application") === "string"){ + return item.getValue("application"); + }else{ + for(var key in item.getValue("application")){ + var app = item.getValue("application")[key]; + if(app.indexOf(":") ===-1){ + return app; + } + } } - return this._summary; }, - /** - * @method getEntitiesDataArray - * @returns {Array} - */ - getEntitiesDataArray : function() { - var entityJPath = this._getJPath("entry"); - var resultingArray = this._get(entityJPath); - return resultingArray[0]; + getResultType: function(item){ + var primaryComponent = item.getValue("primaryComponent"); + var resultTypes = this.resultTypes; + + this.application = this.getApplication(item); + + switch(this.application){ + case "blogs": + return resultTypes.blogs; + case "calendar": + return resultTypes.calendar; + case "dogear": + return resultTypes.bookmark; + case "files": + return resultTypes.files; + case "forums": + return resultTypes.forums; + case "profiles": + return resultTypes.profiles; + case "status_updates": + return resultTypes.statusUpdates; + case "wikis": + return resultTypes.wikis; + + } + + if(primaryComponent.indexOf("activities") === 0 || primaryComponent.indexOf("communities:activities") === 0){ + if(primaryComponent === "activities:bookmark" || primaryComponent === "communities:activities:bookmark"){ + return resultTypes.bookmarks; + }else{ + return resultTypes.activities; + } + }else if (primaryComponent.indexOf("communities") === 0){ + if(primaryComponent === "communities:bookmark"){ + return resultTypes.bookmark; + }else{ + return resultTypes.communities; + } + } + + }, + + getRowContent: function(resultType){ + var resultTypes = this.resultTypes; + switch(resultType){ + case resultTypes.activities: + return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; + case resultTypes.blogs: + return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; + case resultTypes.bookmark: + return defaultHeaderTemplate + bookmarkBodyTemplate + defaultSummaryTemplate; + case resultTypes.calendar: + return defaultHeaderTemplate + calendarBodyTemplate + defaultSummaryTemplate; + case resultTypes.communities: + return defaultHeaderTemplate + communityBodyTemplate + defaultSummaryTemplate; + case resultTypes.files: + return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; + case resultTypes.forums: + return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; + case resultTypes.profiles: + return profileHeaderTemplate + profileBodyTemplate + defaultSummaryTemplate; + case resultTypes.statusUpdates: + return statusUpdateHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; + case resultTypes.wikis: + return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; + default: return defaultHeaderTemplate + defaultBodyTemplate + defaultSummaryTemplate; + } }, /** - * @method toJson - * @returns {Object} + * Returns a tr with the correct content templates for a particular search result. + * @param item + * @param i + * @returns */ - toJson : function() { - return this.data; + getTemplate: function(item, i){ + this.resultType = this.getResultType(item); + var tdContent = this.getRowContent(this.resultType); + + // Build tr, adding attributes and content. + var trClass = undefined; + if(i===0){ + trClass = "lotusFirst"; + } + var tdColspan = undefined; + if(true){ + tdColspan = "2"; + } + var trContent = this.buildElement(tdElement, { + content: tdContent, + colspanAttr: tdColspan + }); + + if(this.resultType === this.resultTypes.statusUpdates){ + var statusUpdateExtraHeader = this.buildElement(tdElement, { + content: statusUpdateExtraHeaderTemplate, + widthAttr: "65", + heightAttr: "55", + classAttr: "lotusFirstCell" + }); + + trContent = statusUpdateExtraHeader + trContent; + } + + return this.buildElement(trElement, { + content: trContent, + classAttr: trClass + }); }, - // - // Internals - // - - _getDate : function(property) { - var text = this._get(property)[0]; - if(text instanceof Date) { - return text; - } - else { - return new Date(text); - } + createdLabel: function(grid, item, i, items){ + var result = localeUtil.getSearchUpdatedLabel(item.getValue('created')); + return result; }, - _getBoolean : function(property) { - var text = this._get(property)[0]; - return text ? true : false; + updatedLabel: function(grid, item, i, items){ + var result = localeUtil.getSearchUpdatedLabel(item.getValue('updated')); + return result; }, - _getNumber : function(property) { - var text = this._get(property)[0]; - // if it is a Number - if(typeof text === 'number') - return text; - //if its an array, we return the length of the array - else if(lang.isArray(text)) - return text.length; - //if its a string or any other data type, we convert to number and return. Invalid data would throw an error here. - else return Number(text); + /** + * + * @param args + */ + constructor: function(args) { + }, - /** - Validate that the property is valid - **/ - _validateProperty : function(property, method) { - if (!property) { - var msg = stringUtil.substitute("Invalid argument for JsonDataHandler.{1} {0}", [ property, method ]); - throw new Error(msg); - } + emptyClass: "lconnEmpty lotusui", + + //TODO Handle empty grid. Should override renderEmpty? + + renderItem : function(grid, el, data, item, i, items){ + this.template = this.getTemplate(item, i); + + this.inherited(arguments); }, /** - Validate that the object is valid - **/ - _validateObject : function(object) { - if (!object) { - var msg = stringUtil.substitute("Invalid argument for JsonDataHandler.{0}", [ object ]); - throw new Error(msg); - } + * Creates a Div, with a different CSS class, to display a grid that has no results + * @method - renderEmpty + * @param - grid - The Grid + * @param - el - The Current Element + */ + renderEmpty: function(grid, el) { + while (el.childNodes[0]) { + dom.destroy(el.childNodes[0]); + } + var lotusUiDiv = dom.create("div", { // here purely so a parent of the empty div has the lotusui class... + "class": "lotusui lconnSearchResults", + innerHTML: "" + }, el); + var lotusEmptyDiv = dom.create("div", { + "class": this.emptyClass, + innerHTML: "", + "aria-relevant": "all", + "aria-live": "assertive" + }, lotusUiDiv); + dom.create("span", { + innerHTML: this._nls.empty + }, lotusEmptyDiv); }, - _evalJson: function(jsonQuery){ - return jsonPath(this.data,jsonQuery); - }, + tableClass: "lotusTable lconnSearchResults" + }); + return searchGridRenderer; +}); +}, +'sbt/connections/controls/activities/ActivityGrid':function(){ +/* + * © 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. + */ + +/** + * + */ +define([ "../../../declare", + "../../../controls/grid/Grid", + "../../../store/parameter", + "./ActivityGridRenderer", + "./ActivityAction", + "../../../connections/ActivityConstants"], + +function(declare, Grid, parameter, ActivityGridRenderer, ActivityAction, consts) { - _evalJsonWithData: function(jsonQuery, data){ - return jsonPath(data,jsonQuery); + /**Sorting Values*/ + var sortVals = { + modified: "lastmod", + dueDate: "duedate", + name: "title" + }; + + /**URL parameters */ + var ParamSchema = { + pageNumber: parameter.oneBasedInteger("page"), + pageSize: parameter.oneBasedInteger("ps"), + sortBy: parameter.sortField("sortfields",sortVals), + sortOrder: parameter.sortOrder("sortorder") + }; + + /** + * @class ActivityGrid + * @namespace sbt.connections.controls.activities + * @module sbt.connections.controls.activities.ActivityGrid + */ + var ActivityGrid = declare(Grid,{ + + options : { + "my" : { + storeArgs : { + url : consts.AtomActivitiesMy, + attributes : consts.ActivityNodeXPath, + feedXPath : consts.ActivitiesFeedXPath, + paramSchema: ParamSchema + }, + rendererArgs : { + type : "my" + } + } + }, + + /**The default type to use if none is specified */ + defaultOption: "my", + + /**class to handle on click and tooltip actions */ + activityAction : new ActivityAction(), + + /** + * ActivitiesGrid Constructor + * @method constructor + * @param args + */ + constructor: function(args){ + /** + * Set the sorting information + */ + this._sortInfo = { + modified: { + title: this.renderer._nls.modified, + sortMethod: "sortBylastModified", + sortParameter: "modified" + }, + dueDate: { + title: this.renderer._nls.dueDate, + sortMethod: "sortByDueDate", + sortParameter: "dueDate" + }, + name: { + title: this.renderer._nls.name, + sortMethod: "sortByName", + sortParameter: "name" + } + }; + this._activeSortAnchor = this._sortInfo.modified; + this._activeSortIsDesc = true; }, - _get: function(property){ - - this._validateObject(this.data); - var jsonQuery = this._getJPath(property); - - var result = this._evalJson(jsonQuery); - return result; + /** + * Returns Sorting info + * @method getSortInfo + * @returns {#an object containing sorting information} + */ + getSortInfo : function() { + return { + active : { + anchor : this._activeSortAnchor, + isDesc : this._activeSortIsDesc + }, + list : [ this._sortInfo.modified, this._sortInfo.dueDate, + this._sortInfo.name ] + }; }, - _getJPath: function(property) { - return this.jsonpath[property] || property; + /** + * Sort the activities by last modification date + * @method sortByLastModified + * @param el The Grid Element + * @param data The grid data + * @param ev the event + */ + sortBylastModified: function(el, data, ev){ + this._sort("modified", true, el, data, ev); }, - extractFirstElement: function(result){ - return this._evalJsonWithData("$[0]", result); - } + /** + * Sort the activities by Due Date + * @method sortByDueDate + * @param el The Grid Element + * @param data The grid data + * @param ev the event + */ + sortByDueDate: function(el, data, ev){ + this._sort("dueDate", true, el, data, ev); + }, + + /** + * Sort the activities by name + * @method sortByName + * @param el The Grid Element + * @param data The grid data + * @param ev the event + */ + sortByName: function(el, data, ev){ + this._sort("name", true, el, data, ev); + }, + + /** + * Event handler function for onClick events + * @method handleClick + * @param el The Grid Element + * @param data The grid data + * @param ev the event + */ + handleClick: function(el, data, ev) { + if (this.activityAction) { + this._stopEvent(ev); + this.activityAction.execute(data, this , ev); + } + }, + + /** + * Creates a renderer for the grid.The renderer is responsible for + * loading the grid's HTML content. + * @method createDefaultRenderer + * @param args sets the template the renderer will use, by checking args.type + * @returns an instance of an ActivitiesGridRenderer. + */ + createDefaultRenderer : function(args) { + return new ActivityGridRenderer(args,this); + } + }); - return JsonDataHandler; + + return ActivityGrid; }); }, -'url:sbt/connections/controls/search/templates/BookmarkBody.html':"<div class=\"lotusMeta\">\r\n <ul class=\"lotusInlinelist\" role=\"list\" style=\"clear: both\">\r\n <li class=\"lotusFirst\" role=\"listitem\">\r\n ${bodyBookmarkLiContent}\r\n </li>\r\n <li class=\"searchDateClass\" role=\"listitem\">\r\n ${updatedLabel}\r\n </li>\r\n ${tagsList}\r\n </ul>\r\n\r\n</div>\r\n<div style=\"clear: both; color: #228822\">\r\n ${resultLink}\r\n</div>", -'sbt/connections/controls/wrappers/ProfileCardWrapper':function(){ -require({cache:{ -'url:sbt/connections/controls/templates/ProfileCardWrapperContent.html':"<!DOCTYPE html>\r\n<html lang=\"en\" style=\"height: 100%;\">\r\n <head>\r\n <meta charset=\"utf-8\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/base/package3.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/sprites.css\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_lconntheme/default.css?version=oneui3&rtl=false\"></link>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"${connectionsUrl}/connections/resources/web/_lconnappstyles/default/search.css?version=oneui3&rtl=false\"></link>\r\n <script type=\"text/javascript\">\r\n var djConfig = {\r\n parseOnLoad: true,\r\n locale: 'en'\r\n };\r\n </script>\r\n <script type=\"text/javascript\" src=\"/sbt.dojo180/dojo/dojo.js.uncompressed.js\"></script>\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dojo/resources/dojo.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dijit/themes/claro/claro.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dojox/grid/enhanced/resources/claro/EnhancedGrid.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" title=\"Style\" href=\"/sbt.dojo180/dojox/grid/enhanced/resources/EnhancedGrid_rtl.css\">\r\n <script type=\"text/javascript\" src=\"${libraryUrl}\"></script>\r\n <style> .commit-tease, .user-profile-mini-avatar, .avatar, .vcard-details, .signup-prompt-bg { display: none !IMPORTANT; } </style> <script> document.addEventListener('DOMContentLoaded', function() { this.querySelectorAll('a').forEach(anchor => { anchor.addEventListener('click', e => { e.preventDefault(); const redact = new URLSearchParams(window.location.search).get('redact'); const hasExistingParams = anchor.href.includes('?'); window.location.href = anchor.href + (hasExistingParams ? `&redact=${redact}` : `?redact=${redact}`); }); }); }); </script> </head>\r\n <body class=\"lotusui30_body lotusui30_fonts lotusui30\" style=\"width: 90%; height: 100%;\">\r\n <div id=\"innerCardDiv\"></div>\r\n <script>\r\n require([\"sbt/config\", \"sbt/dom\", \"sbt/connections/controls/vcard/ProfileVCard\"], function(config, dom, ProfileVCard) {\r\n config.Properties = ${sbtProps};\r\n var profileCard = new ProfileVCard({ userName : \"Frank Adams\", userId : \"0EE5A7FA-3434-9A59-4825-7A7000278DAA\" });\r\n \r\n dom.byId(\"innerCardDiv\").appendChild(profileCard.domNode);\r\n });\r\n </script>\r\n </body>\r\n</html>\r\n"}}); +'url:sbt/connections/controls/search/templates/tr.html':"<tr ${classAttr}>${content}</tr>", +'sbt/Cache':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39222,77 +38378,97 @@ require({cache:{ * implied. See the License for the specific language governing * permissions and limitations under the License. */ -define(["../../../declare", "../../../config", "../../../util", "../../../lang", "../../../url", "../../../connections/controls/WidgetWrapper", "../../../text!../templates/ProfileCardWrapperContent.html"], function(declare, config, util, lang, Url, WidgetWrapper, defaultTemplate) { - /** - * The wrapper for the ActivityStream. - * This class just has to provide its own template and the args it receives back to to the WidgetWrapper, which will take care of everything else. - * - * @class sbtx.controls.astream.ActivityStreamWrapper - */ - var ProfileCardWrapper = declare([ WidgetWrapper ], { +/** + * The cache implements the Least Recently Used (LRU)Algorithm by doubly linked list. Every node has 4 variables - key, value, next and previous. + * The key stores the key of the node and value stores the actual data for the key. The next and previous variables point to the + * next and previous nodes in the cache. + * The cache has a head variable pointing to the top cache node and a tail variable pointing to the last cache node. + * + * Head -> A ---> B ---> C ---> D <-- Tail + * <--- <--- <--- + * + * Suppose the cache has 4 entries and its max size limit is 4 (the cache is full right now). The structure of the cache would be as described by figure above. + * The entries are listed as per their order of recent access. + * So when a new entry E is added to the cache, the new order of the cache entries would be EABC. D would be deleted from the cache. + * + * @module sbt.Cache + */ +define(['./declare'],function(declare) { + var Cache = declare(null, { + constructor: function(max) { + this.limit = max;// This is the maximum limit of the cache. + this._cache = {};//Variable to hold the items in the cache. + this.head = null;// Pointer to the head of the cache + this.tail = null;// Pointer to the tail of the cache + this.count = 0;// Counter for number of items in the cache + }, + get: function _cg(key) { //Retrieves a cached item. + var k = this._cache[key]; + if(k){//Item found in the cache. Move the accessed node to the top of the cache. + if(this.head == k){return k.value;} // the node is already at the top, no need to shift, just return the value. + else{// shift the node to the top and return the value + if(k.prev)k.prev.next = k.next; + if(k.next){k.next.prev = k.prev;} else {this.tail=k.prev;} + k.next = this.head; + this.head.prev = k; + k.prev = null; + this.head = k; + } + return k.value; + } + return null; // the node is not in the cache + }, + put: function _cp(key,value) {// puts a node in the cache if the node is not present in the cache. The node is put at the top of the cache. + if(this._cache[key])//remove the asked node + {this.remove(key); this.count --;} + + var k = this._cache[key] ={key:key, value:value}; + if(this.count==this.limit) //if the cache is full, remove the last node + {this.remove(this.tail.key);this.count --;} + //add the asked node to the top of the list. + k.next = this.head; + if(k.next)k.next.prev = k;else this.tail = k; + this.head = k; + k.prev = null; + this.count ++; + }, + remove: function _cr(key) {//removes a node from the cache and updates the next and prev attributes of the surrounding nodes. + var k = this._cache[key]; + if(k){ + if(k.next)k.next.prev = k.prev;else this.tail = k.prev; + if(k.prev)k.prev.next = k.next; else this.head = k.next; + k.next = k.prev = null; + delete this._cache[key]; + this.count -- ; + } + + }, + + /** + * Function that browse the content of the cache and call a call back method for each entry. + * + * @param callback the callback method to invoke for each entry + */ + browse: function(callback) { + if(callback) { + for(var i in this._cache) { + var e = this._cache[i]; + var r = callback(e.key,e.value); + if(r) { + return r; + } + } + return null; + } + return null; + } + }); - /** - * Set the html template which will go inside the iframe. - * - * @property defaultTemplate - * @type String - */ - defaultTemplate: defaultTemplate, - - /** - * Overriding the method in WidgetWrapper for providing the substitutions for variables in the template. - * - * @method getTemplateReplacements - * @returns {Object} - */ - getTemplateReplacements: function(){ - var connectionsUrl = this._endpoint.baseUrl; - var libUrl = new Url(config.Properties.libraryUrl); - var libQuery = libUrl.getQuery() || ""; - var libQueryObj = util.splitQuery(libQuery, "&"); - - lang.mixin(libQueryObj, { - lib: "dojo", - ver: "1.8.0" - }); - libQuery = util.createQuery(libQueryObj, "&"); - libUrl.setQuery(libQuery); - - var sbtProps = lang.mixin({}, config.Properties); - lang.mixin(sbtProps, { - libraryUrl: libUrl.getUrl(), - loginUi: "popup" - }); - var templateReplacements = { - args: JSON.stringify(this.args), - connectionsUrl: connectionsUrl, - libraryUrl: libUrl.getUrl(), - sbtProps: JSON.stringify(sbtProps) - }; - - return templateReplacements; - }, - - /** - * Store the args so that they can be substituted into the defaultTemplate. - * - * @property args - * @type Object - * @default null - */ - args: null, - - constructor: function(args){ - this.args = args; - } - - }); - - return ProfileCardWrapper; + return Cache; }); }, -'sbt/emailService':function(){ +'sbt/Jsonpath':function(){ /* * © Copyright IBM Corp. 2012 * @@ -39310,114 +38486,98 @@ define(["../../../declare", "../../../config", "../../../util", "../../../lang", */ /** - * Provides functionality to send emails. - * - * @module sbt.emailService + * Social Business Toolkit SDK + * JSONPath 0.8.0 - XPath for JSON + * Would be replaced with JsonPath version of Github */ -define(['./declare', './lang', './config', './_bridge/Transport', './json'], function(declare, lang, config, Transport, sbtJson) { - var transport = new Transport(); - return { - /** - * Sends an email. - * @method send - * @static - * @param {Object || Array} email The JSON object representing the email to send. - * @return {sbt.Promise} A promise to fulfill the send. - * - * @example - * var emails = - * [ - * { - * "from" : "sdary@renovations.com", - * "to" : ["fadams@renovations.com", "tamado@renovations.com"], - * "cc" : ["pclemmons@renovations.com"], - * "bcc" : [], - * "subject" : "This is a test email", - * "mimeParts" : - * [ - * { - * "mimeType" : "text/plain", - * "content" : "This is plain text", - * "headers" : - * { - * "header1":"value1", - * "header2":"value2" - * } - * }, - * { - * "mimeType" : "text/html", - * "content" : "<b>This is html</b>" - * }, - * { - * "mimeType" : "application/embed+json", - * "content" : { - * "gadget" : "http://renovations.com/gadget.xml", - * "context" : { - * "foo" : "bar" - * } - * } - * } - * ] - * }, - * { - * "from" : "sdaryn@renovations.com", - * "to" : ["fadams@renovations.com", "tamado@renovations.com"], - * "subject": "This is a test email", - * "mimeParts" : - * [ - * { - * "mimeType" : "text/plain", - * "content" : "This is plain text" - * }, - * { - * "mimeType" : "text/html", - * "content" : "<b>This is html</b>" - * } - * ] - * } - * ]; - * var successCallback = function(response) { - * //If you send multiple emails, for example emails is an array of email objects, - * //than it is possible that some emails succeeded being sent while others may have - * //failed. It is good practice to check for any emails that had errors being sent. - * if(response.error && response.error.length != 0) { - * //There was one of more errors with emails sent, handle them - * } - * - * if(response.successful && response.successful.length > 0) { - * //Some or all of your emails were successfully sent - * } - * }; - * - * var errorCallback = function(error) { - * //This callback will only be called if there was an error in the request - * //being made to the server. It will NOT be called if there are errors - * //with any of the emails being sent. - * if(error.message) { - * //The request failed handle it. - * } - * }; - * - * email.send(emails).then(successCallback, errorCallback); - */ - send : function(emails) { - var postUrl = config.Properties.serviceUrl + '/mailer'; - - var options = { - method: "POST", - data: sbtJson.stringify(emails), - headers: {"Content-Type" : "application/json"}, - handleAs: "json" - }; - - return transport.request(postUrl, options); - } - }; +define(['./declare'],function(declare){ + return function(obj, expr, arg) + { + var P = { + resultType: arg && arg.resultType || "VALUE", + result: [], + normalize: function(expr) { + var subx = []; + return expr.replace(/[\['](\??\(.*?\))[\]']/g, function($0,$1){return "[#"+(subx.push($1)-1)+"]";}) + .replace(/'?\.'?|\['?/g, ";") + .replace(/;;;|;;/g, ";..;") + .replace(/;$|'?\]|'$/g, "") + .replace(/#([0-9]+)/g, function($0,$1){return subx[$1];}); + }, + asPath: function(path) { + var x = path.split(";"), p = "$"; + for (var i=1,n=x.length; i<n; i++) + p += /^[0-9*]+$/.test(x[i]) ? ("["+x[i]+"]") : ("['"+x[i]+"']"); + return p; + }, + store: function(p, v) { + if (p) P.result[P.result.length] = P.resultType == "PATH" ? P.asPath(p) : v; + return !!p; + }, + trace: function(expr, val, path) { + if (expr) { + var x = expr.split(";"), loc = x.shift(); + x = x.join(";"); + if (val && val.hasOwnProperty(loc)) + P.trace(x, val[loc], path + ";" + loc); + else if (loc === "*") + P.walk(loc, x, val, path, function(m,l,x,v,p) { P.trace(m+";"+x,v,p); }); + else if (loc === "..") { + P.trace(x, val, path); + P.walk(loc, x, val, path, function(m,l,x,v,p) { typeof v[m] === "object" && P.trace("..;"+x,v[m],p+";"+m); }); + } + else if (/,/.test(loc)) { // [name1,name2,...] + for (var s=loc.split(/'?,'?/),i=0,n=s.length; i<n; i++) + P.trace(s[i]+";"+x, val, path); + } + else if (/^\(.*?\)$/.test(loc)) // [(expr)] + P.trace(P.eval(loc, val, path.substr(path.lastIndexOf(";")+1))+";"+x, val, path); + else if (/^\?\(.*?\)$/.test(loc)) // [?(expr)] + P.walk(loc, x, val, path, function(m,l,x,v,p) { if (P.eval(l.replace(/^\?\((.*?)\)$/,"$1"),v[m],m)) P.trace(m+";"+x,v,p); }); + else if (/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(loc)) // [start:end:step] phyton slice syntax + P.slice(loc, x, val, path); + } + else + P.store(path, val); + }, + walk: function(loc, expr, val, path, f) { + if (val instanceof Array) { + for (var i=0,n=val.length; i<n; i++) + if (i in val) + f(i,loc,expr,val,path); + } + else if (typeof val === "object") { + for (var m in val) + if (val.hasOwnProperty(m)) + f(m,loc,expr,val,path); + } + }, + slice: function(loc, expr, val, path) { + if (val instanceof Array) { + var len=val.length, start=0, end=len, step=1; + loc.replace(/^(-?[0-9]*):(-?[0-9]*):?(-?[0-9]*)$/g, function($0,$1,$2,$3){start=parseInt($1||start);end=parseInt($2||end);step=parseInt($3||step);}); + start = (start < 0) ? Math.max(0,start+len) : Math.min(len,start); + end = (end < 0) ? Math.max(0,end+len) : Math.min(len,end); + for (var i=start; i<end; i+=step) + P.trace(i+";"+expr, val, path); + } + }, + eval: function(x, _v, _vname) { + try { return $ && _v && eval(x.replace(/@/g, "_v")); } + catch(e) { throw new SyntaxError("jsonPath: " + e.message + ": " + x.replace(/@/g, "_v").replace(/\^/g, "_a")); } + } + }; + var $ = obj; + if (expr && obj && (P.resultType == "VALUE" || P.resultType == "PATH")) { + P.trace(P.normalize(expr).replace(/^\$;/,""), obj, "$"); + return P.result.length ? P.result : false; + } + }; }); }, -'sbt/connections/ConnectionsConstants':function(){ +'sbt/nls/ErrorTransport':function(){ /* - * © Copyright IBM Corp. 2012,2013 + * © Copyright IBM Corp. 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39433,119 +38593,72 @@ define(['./declare', './lang', './config', './_bridge/Transport', './json'], fun */ /** - * Social Business Toolkit SDK. Definition of constants for IBM Connections. + * Social Business Toolkit SDK - Default resource bundle for validate module. + */ + + +define({ + root: ({ + endpoint_not_available:"Required endpoint is not available: {0}" + }) + +}); +}, +'sbt/text':function(){ +/* + * © Copyright IBM Corp. 2012 * - * @module sbt.connections.ConnectionsConstants + * 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. */ -define([ "../lang", "../base/BaseConstants" ], function(lang, base) { - return lang.mixin(base, { +/** + * Social Business Toolkit SDK. + * @module sbt.text + */ +define(['./_bridge/text'],function(text) { + return text; +}); - /** - * Error code used for a bad request - */ - BadRequest : 400, - /** - * XPath expressions used when parsing a Connections ATOM feed - */ - ConnectionsFeedXPath : { - // used by getEntitiesDataArray - entries : "/a:feed/a:entry", - // used by getSummary - totalResults : "/a:feed/opensearch:totalResults", - startIndex : "/a:feed/opensearch:startIndex", - itemsPerPage : "/a:feed/opensearch:itemsPerPage" - }, - - /** - * XPath expressions used when parsing a Connections service document ATOM feeds - */ - ConnectionsServiceDocsFeedXPath : { - // used by getEntitiesDataArray - entries : "/a:feed/a:entry", - // used by getSummary - emailConfig : "/a:feed/a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/configuration']/@term", - language : "/a:feed/a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/language']/@term", - languageLabels : "/a:feed/a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/language']/@label" - }, - /** - * AuthType variable values for endpoint - * - * @property AuthTypes - * @type Object - */ - AuthTypes : { - OAuth : "oauth", - Basic : "basic" - }, - - /** - * XPath expressions to be used when reading a Connections entity - * - * @property TagsXPath - * @type Object - */ - TagsXPath : { - entries : "app:categories/a:category", - term : "@term", - frequency : "@snx:frequency", - uid : "@term" - }, - - /** - * XPath expressions to be used when reading a Blog - * - * @property BlogXPath - * @type Object - */ - ServiceConfigXPath : lang.mixin({}, base.AtomEntryXPath, { - alternateSSLUrl : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/alternate-ssl']/@href" - }), - - /** - * XPath expressions to be used when reading a Member Entry - * - * @property MemberXPath - * @type Object - */ - MemberXPath : lang.mixin({}, base.AtomEntryXPath, { - role : "snx:role" - }), - - /** - * XPath expressions to be used when reading a Report Entry - * - * @property MemberXPath - * @type Object - */ - ReportEntryXPath : lang.mixin({}, base.AtomEntryXPath, { - categoryIssue : "a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/issue']/@term", - reportItemLink : "a:link[@rel='http://www.ibm.com/xmlns/prod/sn/report-item']/@href", - relatedLink : "a:link[@rel='related']/@href", - inRefTo : "snx:in-ref-to[@rel='http://www.ibm.com/xmlns/prod/sn/report-item']/@ref" - }), - - /** - * XPath expressions to be used when reading a Moderation Action Entry - * - * @property MemberXPath - * @type Object - */ - ModerationActionEntryXPath : lang.mixin({}, base.AtomEntryXPath, { - moderationAction : "snx:moderation/action", - relatedLink : "a:link[@rel='related']/@href", - inRefTo : "snx:in-ref-to[@rel='http://www.ibm.com/xmlns/prod/sn/report-item']/@ref" - }), +}, +'sbt/i18n':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - /** - * Get service configs - */ - ServiceConfigs : "/{service}/serviceconfigs" - - }); +/** + * Social Business Toolkit SDK. + * @module sbt.i18n + */ +define(['./_bridge/i18n'],function(i18n) { + return i18n; }); + + + }, 'sbt/connections/controls/nls/WidgetWrapper':function(){ /* @@ -39577,7 +38690,7 @@ define({ }, -'sbt/controls/grid/Grid':function(){ +'sbt/controls/grid/GridAction':function(){ /* * © Copyright IBM Corp. 2013 * @@ -39595,657 +38708,1037 @@ define({ */ /** - * + * @module sbt.controls.grid.GridAction */ -define([ "../../declare", "../../lang", "../../itemFactory", "../../stringUtil", "../../widget/grid/_Grid", "../../util"], - function(declare, lang, itemFactory, stringUtil, _Grid, util) { +define(["../../declare"], function(declare) { /** - * @class grid + * @class sbt.controls.grid.GridAction * @namespace sbt.controls.grid - * @module sbt.controls.grid.Grid */ - var Grid = declare([ _Grid ], { - - /** - * Data associated with this Grid - */ - data: null, - - /** - * The renderer associated with the grid - */ - renderer: null, - - /** - * Encode all of the data coming from the connections server - * as HTML entities, to prevent XSS attacks - */ - encodeHtml: true, - - /** - * The number of grid rows displayed per page - */ - pageSize: 10, - - /** - * Flag to hide the pager - */ - hidePager: false, - - /** - * Flag to hide the sorter - */ - hideSorter: false, - - /** - * flag to hide the footer - */ - hideFooter: false, - - /** - * FilterTag, is used for sorting and paging, as to only sort as filtered set of results - */ - filterTag: "", - - /** - * Selected rows are the rows of the grid that have been selected by checking a check box - */ - selectedRows: null, - - /* - * TODO remove this? - */ - _strings: {}, - - /* - * Arguments for the associated data store - */ - _storeArgs: null, + var GridAction = declare(null, { + + /** + * Grid Action Constructor function + * @constructor + */ + constructor: function() { + }, + + /** + * Gets the string to be displayed as an elements tooltip + * @method getTooltip + * @param item the HTML element + * @returns {String} contains the text for the tooltip + */ + getTooltip: function(item) { + return "sbt.controls.GridAction No tooltip specified"; + }, + + /** + * Default action for the grid + * @method execute + * @param item The element that fired the event + * @param opts + * @param event the Event, for example onClick + */ + execute: function(item, opts, event) { + dojo.stopEvent(event); + }, + + /** + * Action to view the user's profile in connections. + * When the user clicks on a link to a person's profile + * the HREF will have the URL and redirect the user to the person's + * profile, if this action needs to be changed it can be overridden using this function + *@method viewUserProfile + */ + viewUserProfile: function(){ + //do nothing by default + } - /* - * Regular expression used to remove // from url's - */ - _regExp: new RegExp("/{2}"), - - /* - * Array of selection listeners - */ - _selListeners: [], + }); + + return GridAction; +}); +}, +'sbt/data/AtomReadStore':function(){ +/* + * © 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. + */ - /** - * Empty context root map, can be overridden by subclasses of Grid. Represents Connections context roots. - */ - contextRootMap: {}, +/** + * @module sbt.data.AtomReadStore + */ +define(["../declare","../config", "../lang", "../base/core", "../xml", "../xpath", "../entities"], function(declare, config, lang, core, xml, xpath, entities) { + + /** + * A data store for Atom XML based services or documents. This store is still under development + * and doesn't support filtering or paging yet. + * + * @class AtomReadStore + * @namespace sbt.data + */ + var AtomReadStore = declare(null, { + // private + _endpoint : null, + _xmlData : null, + // read only + totalResults : 0, + startIndex : 0, + itemsPerPage : 5, + items : null, + // public + url : "", + sendQuery : true, + unescapeHTML : false, + urlPreventCache : false, + atom : core.feedXPath, + attributes : core.entryXPath, + namespaces : core.namespaces, + paramSchema: {}, /** - * Constructor method for the grid. - * Creates a default store and renderer, if none have been already created - * @method constructor + * Constructor for the AtomRead store. + * * @param args + * An anonymous object to initialize properties. It expects the following values: + * url: The url to a service or an XML document that represents the store + * unescapeHTML: A boolean to specify whether or not to unescape HTML text + * sendQuery: A boolean indicate to add a query string to the service URL + * endpoint: the endpoint to be used */ constructor: function(args) { - lang.mixin(this, args); - - this.selectedRows = []; - - if (!this.store) { - if (args && args.storeArgs) { - this._storeArgs = lang.mixin({}, args.storeArgs); - this._storeArgs.endpoint = this.endpoint; - this.store = this.createDefaultStore(args.storeArgs); - } else if (this.options) { - this._storeArgs = lang.mixin({}, this.options[this.defaultOption].storeArgs); - this._storeArgs.endpoint = this.endpoint; - if (args && args.type && this.options.hasOwnProperty(args.type)) { - lang.mixin(this._storeArgs, this.options[args.type].storeArgs); - } - } - this.store = this.createDefaultStore(this._storeArgs); - } - - if (!this.renderer) { - if (args && args.rendererArgs) { - this.renderer = this.createDefaultRenderer(args.rendererArgs,this); - } else if (this.options) { - var rendererArgs = this.options[this.defaultOption].rendererArgs; - if (args && args.type && this.options.hasOwnProperty(args.type)) { - rendererArgs = this.options[args.type].rendererArgs; - } - - this.renderer = this.createDefaultRenderer(rendererArgs,this); - } - } - }, - - /** - * Create the store to be used with this Grid. - * - * @method - createDefaultStore - * @param args - the arguments to pass to the atom store, such as URL and attributes - * @returns - an atom store instance - */ - createDefaultStore: function(args) { - var store = this._createDefaultStore(args); - var url = store.getUrl(); - if (url) { - url = this.buildUrl(url, args, store.getEndpoint()); - } - store.setUrl(url); - - return store; - }, - - /** - * Allow Grid to build the complete URL before it is passed to the store. - * - * @method buildUrl - * @param url base url - * @param args arguments that will be passed to the store - * @param endpoint The endpoint, needed to verify if custom service mappings are present. - * @returns Built url - */ - buildUrl: function(url, args, endpoint) { - var params = {}; - if (this.query) { - params = lang.mixin(params, this.query); - } - return this.constructUrl(url, params, this.getUrlParams(), endpoint); - }, + this._endpoint = config.findEndpoint(args.endpoint || "connections"); - /** - * Create the renderer to be used with this Grid. - * - * @method - createDefaultRenderer - * @param args - */ - createDefaultRenderer: function(args) { - }, - - /** - * Post create function is called after grid has been created. - * @method - postCreate - */ - postCreate: function() { - this.inherited(arguments); - - if (this.renderer && this.store) { - this.renderer.renderLoading(this, this.gridNode); - } - - if (this.updateOnCreate) { - this.created = true; - this.update(); - } - }, - - /** - * Refresh the grid - * @method - refresh - */ - refresh: function() { - if (this.data) { - if (this.store) { - this.update(null); - } else { - this.update(); - } - } - - this.selectedRows = []; + if (args) { + this.url = args.url; + this.attributes = args.attributes || this.attributes; + this.atom = args.feedXPath || this.atom; + this.namespaces = args.namespaces || this.namespaces; + this.paramSchema = args.paramSchema || this.paramSchema; + this.rewriteUrl = args.rewriteUrl; + this.label = args.label || this.label; + this.sendQuery = (args.sendQuery || args.sendquery || this.sendQuery); + this.unescapeHTML = args.unescapeHTML; + if ("urlPreventCache" in args) { + this.urlPreventCache = args.urlPreventCache ? true : false; + } + } + if(!this.url) { + throw new Error("sbt.data.AtomReadStore: A service URL must be specified when creating the data store"); + } }, /** - * Update the grid - * @method - update + * @method getEndpoint + * @returns */ - update: function(data) { - this.selectedRows = []; - - if (arguments.length > 0) { - this.data = data; - } - if (this.data) { - this.renderer.render(this, this.gridNode, this.data.items, this.data); - this.onUpdate(this.data); - } else if (this.store) { - if (this._activeSortAnchor && this._activeSortIsDesc !== undefined) { - this._doQuery(this.store, { start : 0, count : this.pageSize, sort: [{ attribute : this._activeSortAnchor.sortParameter, descending : this._activeSortIsDesc }] }); - } else { - this._doQuery(this.store, { start : 0, count : this.pageSize }); - } - - } else { - this.renderer.renderEmpty(this, this.gridNode, this.data); - this.onUpdate(this.data); - } + getEndpoint: function() { + return this._endpoint; }, - - /** - * @method onUpdate - * @param data - */ - onUpdate: function(data) { + + setUrl: function(url){ + this.url = url; }, - /** - * @method getSortInfo - */ - getSortInfo: function() { + getUrl: function(){ + return this.url; }, - /** - * Go back to the previous page - * @method - prevPage - * @param el - The element that fired the event, typically an anchor - * @param data - the data associated with element - * @param ev - the event, for example onClick + setAttributes: function(attributes){ + this.attributes = attributes; + }, + + /* + * Returns defaultValue if and only if *item* does not have a value for *attribute*. */ - prevPage: function(el, data, ev) { - this._stopEvent(ev); + getValue: function(item, attribute, defaultValue) { + var xpathCountFunction = /^count\(.*\)$/; + this._assertIsItem(item); + this._assertIsAttribute(attribute); - if (this.store) { - - //if sorting - if(this._activeSortAnchor){ - var options = { - start : 0, count : this.pageSize, - sort: [{ attribute: this._activeSortAnchor.sortParameter }] - }; - - if(this._activeSortIsDesc !== undefined){ - options.sort[0].descending = this._activeSortIsDesc; - } - }else{ - var options = { - start : 0, count : this.pageSize - }; - } - if (this.data) { - options.start = Math.max(0, this.data.start - options.count); + if (!item._attribs[attribute]) { + var access = this.attributes[attribute]; + if (lang.isFunction(access)) { + item._attribs[attribute] = access(item, attribute); + }else if (access.match(xpathCountFunction)){ + item._attribs[attribute] = xpath.selectNumber(item.element, this.attributes[attribute], this.namespaces)+""; + } else { + var nodes = xpath.selectNodes(item.element, this.attributes[attribute], this.namespaces); + if (nodes && nodes.length == 1) { + item._attribs[attribute] = nodes[0].text || nodes[0].textContent; + } else if (nodes) { + item._attribs[attribute] = []; + for (var j=0; j<nodes.length; j++) { + item._attribs[attribute].push(nodes[j].text || nodes[j].textContent); + } + } else { + item._attribs[attribute] = null; + } + } } - - if(this.filterTag != "" && this.filterTag != null){ - options.tag = this.filterTag; + + if (!item._attribs[attribute]) { + return defaultValue; } - this._doQuery(this.store, options); + + if(typeof item._attribs[attribute] == "object"){ + for(var i=0;i<item._attribs[attribute].length; i++){ + item._attribs[attribute][i] = entities.encode(item._attribs[attribute][i]); + } + } + else{ + item._attribs[attribute] = entities.encode(item._attribs[attribute]); } + + return item._attribs[attribute]; }, - /** - * Helper method to display 10 items per page - * - * @method show10ItemsPerPage - * @param el - * @param data - * @param event + /* + * This getValues() method works just like the getValue() method, but getValues() + * always returns an array rather than a single attribute value. */ - show10ItemsPerPage: function(el, data, ev) { - this.showItemsPerPage(el, data, ev, 10); + getValues: function(item, attribute) { + this._assertIsItem(item); + this._assertIsAttribute(attribute); + + if (!item._attribs[attribute]) { + var nodes = xpath.selectNodes(item.element, this.attributes[attribute], this.namespaces); + var values = []; + for (var i=0; i<nodes.length; i++) { + values[i] = nodes[i].text || nodes[i].textContent; + } + item._attribs[attribute] = values; + } + + return item._attribs[attribute]; }, - /** - * Helper method to display 25 items per page - * - * @method show25ItemsPerPage - * @param el - * @param data - * @param event + /* + * Returns an array with all the attributes that this item has. */ - show25ItemsPerPage: function(el, data, ev) { - this.showItemsPerPage(el, data, ev, 25); + getAttributes: function(item) { + var result = []; + for (var name in this.attributes) { + if (this.attributes.hasOwnProperty(name)) { + result.push(name); + } + } + return result; }, - /** - * Helper method to display 50 items per page - * - * @method show50ItemsPerPage - * @param el - * @param data - * @param event + /* + * Returns true if the given *item* has a value for the given attribute*. */ - show50ItemsPerPage: function(el, data, ev) { - this.showItemsPerPage(el, data, ev, 50); + hasAttribute: function(item, attribute) { + return (this.attributes[attribute] != undefined); }, - /** - * Helper method to display 100 items per page - * - * @method show100ItemsPerPage - * @param el - * @param data - * @param event + /* + * Returns true if the given *value* is one of the values that getValues() would return. */ - show100ItemsPerPage: function(el, data, ev) { - this.showItemsPerPage(el, data, ev, 100); + containsValue: function(item, attribute, value) { + throw new Error("sbt.data.AtomReadStore: Not implemented yet!"); }, - - /** - * Displays the feed for the content that is currently shown. - * @method - viewFeed - * @param el - The element that fired the event, typically an anchor - * @param data - the data associated with element - * @param ev - the event, for example onClick + + /* + * Returns true if *something* is an item and came from the store instance. */ - viewFeed: function(el, data, ev) { - var endpoint = this.store.getEndpoint(); - var proxy = endpoint.proxy; - var baseUrl = endpoint.baseUrl; - var proxyPath = endpoint.proxyPath; - var url = proxy.rewriteUrl(baseUrl, this.store.getUrl(), proxyPath); - window.open(url, "_new"); + isItem: function(something) { + if (something && something.element && something.store && something.store === this) { + return true; + } + return false; }, - /** - * Show "count" items per page - * @method - showItemsPerPage - * @param el - The element that fired the event, typically an anchor - * @param data - the data associated with element - * @param ev - the event, for example onClick - * @param count - the number of items to display per page + /* + * Return true if *something* is loaded. */ - showItemsPerPage: function(el, data, ev, count) { - this._stopEvent(ev); - if (this.store) { - this.pageSize = count; - this.update(null); - } + isItemLoaded: function(something) { + return this.isItem(something); }, + /* + * Given an item, this method loads the item so that a subsequent call + * to store.isItemLoaded(item) will return true. + */ + loadItem: function(keywordArgs) { + throw new Error("sbt.data.AtomReadStore: Not implemented yet!"); + }, - /** - * Move forward to the next page of grid rows - * @method - nextPage - * @param el - The element that fired the event, typically an anchor - * @param data - the data associated with element - * @param ev - the event, for example onClick + /* + * Given a query and set of defined options, such as a start and count of items to return, + * this method executes the query and makes the results available as data items. */ - nextPage: function(el, data, ev) { - this._stopEvent(ev); + fetch: function(args) { + var self = this; + var scope = args.scope || self; - if (this.store) { - //if there is sorting available - if(this._activeSortAnchor){ - var options = { - start : 0, count : this.pageSize , - sort: [{ attribute: this._activeSortAnchor.sortParameter }] - }; - if(this._activeSortAnchor !== undefined){ - options.sort[0].descending = this._activeSortIsDesc; - } - } else { - var options = { - start : 0, count : this.pageSize - }; - } - if (this.data) { - options.start = this.data.start + options.count; - options.count = this.pageSize; - options.total = this.data.totalCount; - } - if(this.filterTag != "" && this.filterTag != null){ - options.tag = this.filterTag; + var serviceUrl = this._getServiceUrl(this._getQuery(args)); + if (!serviceUrl) { + if (args.onError) { + args.onError.call(new Error("sbt.data.AtomReadStore: No service URL specified.")); } - this._doQuery(this.store, options); + return; } + + this._endpoint.xhrGet({ + serviceUrl : serviceUrl, + handleAs : "text", + preventCache: true, + load : function(response) { + try { + // parse the data + self.response = response; + self._xmlData = xml.parse(response); + self.totalResults = parseInt(xpath.selectText(self._xmlData, self.atom.totalResults, self.namespaces)); + self.startIndex = parseInt(xpath.selectText(self._xmlData, self.atom.startIndex, self.namespaces)); + self.itemsPerPage = parseInt(xpath.selectText(self._xmlData, self.atom.itemsPerPage, self.namespaces)); + self.items = self._createItems(self._xmlData); + + // invoke callbacks + if (args.onBegin) { + args.onBegin.call(scope, self.totalResults, args); + } + if (args.onItem) { + for(var i=0; i<self._entries; i++){ + args.onItem.call(scope, self.entries[i], args); + } + } + if (args.onComplete) { + args.onComplete.call(scope, args.onItem ? null : self.items, args); + } + } catch (e) { + if (args.onError) { + args.onError.call(e); + } + } + }, + error : function(error) { + if (args.onError) { + args.onError.call(error); + } + } + }); }, - /** - * Called when the user clicks a checkbox - * The row gets added or removed to an array, - * to retrieve the array call getSelected - * @method handleCheckBox + /* + * The getFeatures() method returns an simple keyword values object + * that specifies what interface features the datastore implements. */ - handleCheckBox: function (el, data, ev) { - // keep track of current selection - if (el.checked) { - this.selectedRows.push(data); - } else if (!el.checked) { - var rows = this.getSelected(); - for(var i=0;i<rows.length;i++){ - if(rows[i].data == data){ - //selected row - this.selectedRows.splice(i,1); - } - } - } - - // notify selection listeners - for (var i=0; i<this._selListeners.length; i++) { - try { - var selection = this.selectedRows.slice(); - this._selListeners[i].selectionChanged(selection, this); - } catch (error) { - } - } + getFeatures: function() { + return { 'dojo.data.api.Read': true }; }, - /** - * If the grid rows have checkboxes , get a list of the rows which are currently selected - * (That have a checked checkbox) - * @method - getSelected - * + /* + * The close() method is intended for instructing the store to 'close' out + * any information associated with a particular request. */ - getSelected: function() { - var items = []; - if (this.selectedRows) { - for (var i=0; i<this.selectedRows.length; i++) { - var item = { - data: this.selectedRows[i] - }; - items.push(item); - } - } - return items; + close: function(request) { + throw new Error("sbt.data.AtomReadStore: Not implemented yet!"); }, - /** - * @method addSelectionListener - * @param listener + /* + * Method to inspect the item and return a user-readable 'label' for the item + * that provides a general/adequate description of what the item is. */ - addSelectionListener : function(listener) { - this._selListeners.push(listener); + getLabel: function(item) { + return this.getValue(item, this.label); }, - /** - * @method removeSelectionListener - * @param listener + /* + * Method to inspect the item and return an array of what attributes of the item were used + * to generate its label, if any. */ - removeSelectionListener : function(listener) { - this._selListeners.pop(listener); + getLabelAttributes: function(item) { + return [ this.label ]; }, - refreshSelectionListeners: function(){ - // notify selection listeners - for (var i=0; i<this._selListeners.length; i++) { - try { - var selection = this.selectedRows.slice(); - this._selListeners[i].selectionChanged(selection, this); - } catch (error) { - } - } + // Internals + + _getQuery: function(args) { + var query = args.query || {}; + query.pageSize = args.count || query.pageSize; + var page = Math.floor(args.start / args.count) + 1; // needs to be a whole number + query.pageNumber = page; + + if(args.sort && args.sort[0]) { + var sort = args.sort[0]; + query.sortBy = sort.attribute; + if(sort.descending === true) { + query.sortOrder = "desc"; + } + else if(sort.descending === false) { + query.sortOrder = "asc"; + } + } + + return query; }, - /** - * Add an item using the specified Document - * - * @method addItem - * @param document - */ - addItems: function(document) { - if (!this.data) { - this.data = { items: [], start: 0, end: 0, count: 0, totalCount: 0 }; + _getServiceUrl: function(query) { + if (!this.sendQuery) { + return this.url; + } + if (!query) { + return this.url; + } + if (lang.isString(query)) { + return this.url + query; + } + + var queryString = ""; + var paramSchema = this.paramSchema; + for(var key in query) { + if(key in paramSchema) { + var val = paramSchema[key].format(query[key]); + if(val) { + queryString += val + "&"; + } + } + else { + queryString += (key + "=" + query[key] + "&"); + } + } + + if (!queryString) { + return this.url; + } + var serviceUrl = this.url; + if (serviceUrl.indexOf("?") < 0){ + serviceUrl += "?"; + } else { + serviceUrl += "&"; + } + return serviceUrl + queryString; + }, + + _createItems: function(document) { + var nodes = xpath.selectNodes(document, this.atom.entries, this.namespaces); + var items = []; + for (var i=0; i<nodes.length; i++) { + items.push(this._createItem(nodes[i])); + } + return items; + }, + + _createItem: function(element) { + var attribs = this.getAttributes(); + var xpathCountFunction = /^count\(.*\)$/; + + // TODO add item.index and item.attribs + var item = { + element : element, + getValue : function(attrib) { + var result = []; + if(typeof this[attrib] == "object"){ + for(var i=0;i<this[attrib].length; i++){ + result[i] = entities.encode(this[attrib][i]); + } + } + else{ + result = entities.encode(this[attrib]); + } + + return result; + } + }; + for (var i=0; i<attribs.length; i++) { + var attrib = attribs[i]; + var access = this.attributes[attrib]; + if (lang.isFunction(access)) { + item[attrib] = access(this, item); + } else if (access.match(xpathCountFunction)){ + item[attrib] = xpath.selectNumber(element, access, this.namespaces)+""; + } else { + var nodes = xpath.selectNodes(element, access, this.namespaces); + if (nodes && nodes.length == 1) { + item[attrib] = entities.encode(nodes[0].text) || entities.encode(nodes[0].textContent); + } else if (nodes) { + item[attrib] = []; + for (var j=0; j<nodes.length; j++) { + item[attrib].push(entities.encode(nodes[j].text) || entities.encode(nodes[j].textContent)); + } + } else { + item[attrib] = null; + } + } + } - var attributes = this._storeArgs.attributes; - var items = itemFactory.createItems(document, attributes, this); - this.data.items = this.data.items.concat(items); - this.data.totalCount += this.data.items.length; - this.data.end = this.data.count = this.data.totalCount; + + return item; }, - /** - * Insert the specified item into the grid at the specified index. - * - * TODO This is here so that we can insert the local user grid at the start of the items array, mainly. - * The args like email are not available at the start. So try to see if the user can be inserted to the start of some asrray before it goes to get the different profiles. - * @param e - */ - insertItem: function(document, index) { - if(!this.data){ - console.log("Data is not yet present, adding to beginning."); - this.data = { items: [], start: 0, end: 0, count: 0, totalCount: 0 }; - index = 0; + _assertIsItem: function(item) { + if (!this.isItem(item)) { + throw new Error("sbt.data.AtomReadStore: Invalid item argument."); } - var attributes = this._storeArgs.attributes; - var items = itemFactory.createItems(document, attributes, this); - this.data.items.splice(index, 0, items[0]); - this.data.totalCount = this.data.items.length; - this.data.end = this.data.count = this.data.totalCount; - }, - - /** - * @method encodeImageUrl - * @param url - */ - encodeImageUrl: function(url) { - var ep = this.store.getEndpoint(); - return ep.proxy.rewriteUrl(ep.baseUrl, url, ep.proxyPath); }, - /** - * Return the auth type to be used - * @returns {String} - */ - getAuthType: function() { - return ""; - }, + _assertIsAttribute: function(attribute) { + if (!this.attributes[attribute]) { + throw new Error("sbt.data.AtomReadStore: Invalid attribute argument."); + } + } - /** - * Return the url parameters to be used - * @returns {Object} - */ - getUrlParams: function() { - return { authType : this.getAuthType() }; - }, - /** - * Construct a url using the specified parameters - * @method constructUrl - * @param url - * @param params - * @param urlParams - * @param endpoint An endpoint which may contain custom service mappings. - * @returns - */ - constructUrl : function(url,params,urlParams, endpoint) { - if (!url) { - throw new Error("Grid.constructUrl: Invalid argument, url is undefined or null."); - } - - if(endpoint){ - lang.mixin(this.contextRootMap, endpoint.serviceMappings); - - if(this.contextRootMap){ - url = stringUtil.transform(url, this.contextRootMap, function(value, key){ - if(!value){ - return key; - } - else{ - return value; - } - }, this); - } - } - - if (urlParams) { - url = stringUtil.replace(url, urlParams); - - if (url.indexOf("//") != -1) { - // handle empty values - url = url.replace(this._regExp, "/"); + }); + return AtomReadStore; + +}); +}, +'sbt/localeUtil':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK. + * @module sbt.LocaleUtil + */ +define(['./_bridge/localeUtil', 'sbt/i18n!sbt/nls/Locale'],function(localeUtil,nls) { + return{ + + nls : nls, + + getUpdatedLabel : function(dateStr) { + var date = new Date(dateStr); + var dateClone = new Date(date.getTime()); + var now = new Date(); + if (dateClone.setHours(0,0,0,0) == now.setHours(0,0,0,0)) { + return this.nls.todayAt + localeUtil.getLocalizedTime(date); + } else { + return this.nls.on + localeUtil.getLocalizedDate(date); + } + }, + + getSearchUpdatedLabel : function(dateStr) { + var date = new Date(dateStr); + var dateClone = new Date(date.getTime()); + var now = new Date(); + if (dateClone.setHours(0,0,0,0) == now.setHours(0,0,0,0)) { + return this.nls.todayAt + localeUtil.getLocalizedTime(date); + } else { + return localeUtil.getLocalizedDate(date); + } + } + }; +}); + + + +}, +'sbt/util':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * @module sbt.util + */ +define(['./lang','sbt/i18n!sbt/nls/util','./log','./stringUtil','./pathUtil'],function(lang, nls, log, stringUtil, pathUtil) { + var errorCode = 400; + function _notifyError(error, args){ + if (args && (args.error || args.handle)) { + if (args.error) { + try { + args.error(error); + } catch (error1) { + log.error(nls.notifyError_catchError, error1); + } + } + if (args.handle) { + try { + args.handle(error); + } catch (error2) { + log.error(nls.notifyError_catchError, error2); + } + } + } else { + log.error(nls.notifyError_console, error.code, error.message); + } + } + return { + notifyError: _notifyError, + isEmptyObject: function(obj){ + var isEmpty = true; + for( var key in obj ){ + if(obj.hasOwnProperty(key)){ + isEmpty = false; + break; } } - if (params) { - for (param in params) { - if (params[param]) { - if (url.indexOf("?") == -1) { - url += "?"; - } else if (url.indexOf("&") != (url.length - 1)) { - url += "&"; + return isEmpty; + }, + checkObjectClass: function(object, className, message, args){ + if(object.declaredClass != className){ + if(args){ + _notifyError({code:errorCode,message:message},args); + }else{ + log(message); + } + return false; + }else{ + return true; + } + }, + checkNullValue: function(object, message, args){ + if(!object){ + if(args){ + _notifyError({code:errorCode,message:message},args); + }else{ + log(message); + } + return false; + }else{ + return true; + } + }, + minVersion: function(required, used) { + var reqParts = required.split('.'); + var usedParts = used.split('.'); + + for (var i = 0; i < reqParts.length; ++i) { + if (usedParts.length == i) { + return false; + } + + if (reqParts[i] == usedParts[i]) { + continue; + } + else if (reqParts[i] > usedParts[i]) { + return false; + } + else { + return true; + } + } + + if (reqParts.length != usedParts.length) { + return true; + } + + return true; + }, + getAllResponseHeaders: function(xhr) { + var headers = {}; + try { + var headersStr = xhr.getAllResponseHeaders(); + if (headersStr) { + var headersStrs = headersStr.split('\n'); + for (var i=0; i<headersStrs.length; i++) { + var index = headersStrs[i].indexOf(':'); + var key = lang.trim(headersStrs[i].substring(0, index)); + var value = lang.trim(headersStrs[i].substring(index+1)); + if (key.length > 0) { + headers[key] = value; } - url += param + "=" + encodeURIComponent(params[param]); } } + } catch(ex) { + console.log(ex); } - return url; + return headers; }, - - // Internals - /* - * Sort the contents + /** + * Takes an object mapping query names to values, and formats them into a query string separated by the delimiter. + * e.g. + * createQuery({height: 100, width: 200}, ",") + * + * returns "height=100,width=200" + * + * @method createQuery + * + * @param {Object} queryMap An object mapping query names to values, e.g. {height:100,width:200...} + * @param {String} delimiter The string to delimit the queries */ - _sort: function(index, defaultOrder, el, data, ev) { - this._stopEvent(ev); - var options = { - start: data.start, count: this.pageSize, - sort: [{ attribute: index }] - }; - - if(this.filterTag != "" && this.filterTag != null){ - options.tag = this.filterTag; - } - - if(this._activeSortAnchor === this._sortInfo[index]) { - this._activeSortIsDesc = !this._activeSortIsDesc; // Flip sort order + createQuery: function(queryMap, delimiter){ + if(!queryMap){ + return null; + } + var delim = delimiter; + if(!delim){ + delim = ","; + } + var pairs = []; + for(var name in queryMap){ + var value = queryMap[name]; + pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(value)); + } + return pairs.join(delim); + }, + + /** + * Takes a query string and returns an equivalent object mapping. + * e.g. + * splitQuery("height=100,width=200", ",") + * + * returns {height: 100, width: 200} + * + * @method splitQuery + * + * @param {String} query A query string, e.g. "height=100,width=200" + * @param {String} delimiter The string which delimits the queries + */ + splitQuery: function(query, delimiter){ + var i; + var result = {}; + var part; + var parts; + var length; + + query = query.replace("?", ""); + parts = query.split(delimiter); + length = parts.length; + + for (i = 0; i < length; i++) { + if(!parts[i]){ + continue; + } + part = parts[i].split('='); + result[part[0]] = part[1]; } - else { // Change active sort to anchor clicked and its default order - this._activeSortAnchor = this._sortInfo[index]; - this._activeSortIsDesc = defaultOrder; + + return result; + }, + + /** + * Returns the JavaScript Library and version used + * @returns {String} JavaScript Library with version + */ + getJavaScriptLibrary : function(){ + var jsLib = "Unknown"; + if(window.dojo) { + if(dojo.version) { + jsLib = "Dojo "+dojo.version; + } + } else if(define && define.amd && define.amd.vendor && define.amd.vendor === "dojotoolkit.org") { + require(["dojo/_base/kernel"], function(kernel){ + jsLib = "Dojo AMD "+kernel.version; + }); + } else if(window.jQuery) { + jsLib = "JQuery "+jQuery.fn.jquery; + } + return jsLib; + }, + + /** + * Return san absolute version of the specified url + * @param {String} URL to convert + * @returns {String} Absolute version of the url + */ + makeAbsoluteUrl : function(url) { + if (stringUtil.startsWith(url, "http")) { + return url; + } + var loc = window.location; + var baseUrl = loc.protocol+'//'+loc.hostname+(loc.port ? ':'+loc.port: ''); + return pathUtil.concat(baseUrl, url); + } + }; +}); +}, +'sbt/connections/controls/files/FileGridRenderer':function(){ +require({cache:{ +'url:sbt/connections/controls/files/templates/FileRow.html':"<tr class=\"lotusFirst\">\r\n <td class=\"lotusFirstCell\" width=\"32\" title=\"${title}\">\r\n <input value=\"${title}\" name=\"${title}\" aria-label=\"${nls.ariaCheckbox}\" data-dojo-attach-point=\"rowSelectionInput\" data-dojo-attach-event=\"onclick: handleCheckBox\" type=\"checkbox\" class=\"lotusCheckbox\">\r\n </td>\r\n <td class=lotusNowrap>\r\n <a title=\"Download ${title}\" href=\"${editMediaLink}\" class=\"lconnDownloadable lconnDownloadableIcon\">\r\n <img alt=\"\" src=\"images/blank.gif\" class=\"lconn-ftype32 lconn-ftype32-${ftype}\"><span class=\"lotusAltText\" title=\"\">${_nls.download}</span>\r\n </a>\r\n </td>\r\n <td style=\"width: 100%;\">\r\n <h4 class=\"lotusBreakWord lotusLeft\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${tooltip}\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a> \r\n </h4>\r\n <div class=\"lotusMeta lotusClear\">\r\n <ul class=\"lotusInlinelist\">\r\n <li class=\"lotusFirst\" title=\"\">\r\n <span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t\t<a aria-label=\"${nls.ariaVcard}\" href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" class=\"fn url\">${authorName}</a>\r\n \t\t\t\t\t\t<span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${authorUserId}</span>\r\n\t\t\t\t\t</span>\r\n ${_nls.created} ${createdLabel}\r\n </li>\r\n <li>\r\n ${hitCount} ${_nls.downloads}\r\n </li>\r\n <li>\r\n ${commentsCount} ${_nls.comments}\r\n </li>\r\n </ul>\r\n </div>\r\n </td>\r\n <td style=\"padding-right: 25px;\" class=\"lotusNowrap\">\r\n \r\n <div>\r\n <div class=\"lotusLike\">\r\n <a class=\"lotusLikeCount lotusLikeSimple\" title=\"${recommendationLabel}\" aria-label=\"${recommendationLabel}\">\r\n <img src=\"images/blank.gif\" class=\"lotusIconLike\" alt=\"\">${recommendationsCount}\r\n </a>\r\n </div>\r\n </div>\r\n \r\n </td>\r\n <td style=\"padding-right: 25px;\" title=\"Pin this file\">\r\n <a class=\"lconnPinnedToggle _filePinned\" href=\"javascript:\" topic=\"lconn/files/files/myfavorites/toggle\" data-dojo-attach-event=\"onclick: doPinFile\" role=\"button\" aria-label=\"${nls.pin}\" >\r\n <img src=\"images/blank.gif\" alt=\"${nls.pin}\" id =\"${uid}\" class=\"${pinFileOnOrOff}\" />\r\n </a>\r\n </td>\r\n <td style=\"padding-right: 25px;\" class=\"lotusNowrap\" title=\"${shareLabel}\">\r\n <a aria-label=\"${shareLabel}\" href=\"${selfUrl}?section=share\">\r\n <img src=\"images/blank.gif\" class=\"lconnSprite lconnSprite-icon${visibilityLabel}16\" alt=\"\" title=\"${shareLabel}\" style=\"margin-top: 1px;\">\r\n <span class=\"lotusAltText\">${shareLabel}</span>\r\n </a>\r\n </td>\r\n \r\n\r\n</tr>\r\n\r\n", +'url:sbt/connections/controls/files/templates/RecycledFileRow.html':"<tr class=\"hentry dojoDndItem lotusFirst\" dndtype=\"file\">\r\n <td class=\"lotusNowrap lotusFirstCell\">\r\n <img alt=\"\" \r\n src=\"images/blank.gif\"\r\n class=\"lconn-ftype16 lconn-ftype16-${ftype}\">\r\n <span style=\"display: none;\"></span></td>\r\n <td class=\"lotusRowHeader\" style=\"cursor: pointer;\">\r\n <h4 class=\"lotusBreakWord\">\r\n <span title=\"${title}\" class=\"entry-title\">\r\n ${title}\r\n </span>\r\n </h4>\r\n </td>\r\n <td class=\"\">\r\n \r\n </td>\r\n <td class=\"\">\r\n <span title=\"${modified}\">${modifiedLabel}</span>\r\n </td>\r\n <td class=\"lotusAlignRight\">\r\n ${fileSize}\r\n </td>\r\n <td class=\"lotusCenter\">\r\n <img\r\n src=\"images/blank.gif\"\r\n class=\"lconnSprite lconnSprite-icon${visibilityLabel}16\" alt=\"${visibilityLabel}\"\r\n title=\"${visibilityLabel}\" style=\"margin-top: 1px;\">\r\n <span class=\"lotusAltText\">${title}</span>\r\n </td>\r\n</tr>", +'url:sbt/connections/controls/files/templates/FolderRow.html':"<tr style=\"cursor: pointer;\" class=\"lotusFirst\">\r\n <td style=\"width: 100%;\" class=\"lotusFirstCell\">\r\n <h4 class=\"lotusBreakWord\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${title}\" href=\"${folderUrl}\"> \r\n ${title} \r\n </a>\r\n </h4>\r\n <div class=\"lotusMeta\" role=\"list\">\r\n <span role=\"listitem\"> \r\n <span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t\t<a aria-label=\"${nls.ariaVcard}\" href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" class=\"fn url\">${authorName}</a>\r\n \t\t\t\t\t\t<span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${authorUserId}</span>\r\n\t\t\t\t\t</span>\r\n\t\t\t\t\t ${_nls.created} ${createdLabel} | ${itemCount} ${_nls.files}\r\n </span>\r\n </div>\r\n </td>\r\n <td style=\"padding-right: 20px;\">\r\n <a class=\"lconnPinnedToggle _folderPinned\" href=\"#\" topic=\"lconn/files/folders/myfavorites/toggle\" role=\"button\"\r\n title=\"${nls.pin}\" aria-label=\"${nls.pin}\"\r\n uid=\"${uid}\">\r\n <img src=\"images/blank.gif\"\r\n alt=\"\" class=\"lconnSprite lconnSprite-iconPinned16-off\"\r\n style=\"margin-top: 1px;\">\r\n <span class=\"lotusAltText\">${_nls.pin}</span>\r\n </a>\r\n </td>\r\n <td style=\"padding-right: 30px;\" class=\"lotusNowrap\" >\r\n <a href=\"${folderUrl}\" aria-label=\"${shareLabel}\">\r\n <img src=\"images/blank.gif\"\r\n class=\"lconnSprite lconnSprite-icon${visibilityLabel}16\"\r\n alt=\"\" title=\"${shareLabel}\"\r\n style=\"margin-top: 1px;\">\r\n <span class=\"lotusAltText\">${shareLabel}</span></a></td>\r\n \r\n</tr>", +'url:sbt/connections/controls/files/templates/CommentRow.html':"<tr class=\"lotusCommentList\">\r\n <td class=\"lotusCommentItem lotusFirst\">\r\n <div class=\"lotusPost lotusCommentMy\">\r\n <a id=\"comment-${uid}\"\r\n name=\"comment-${uid}\"\r\n class=\"lotusHidden\"></a>\r\n <div class=\"lotusPostAuthorInfo\" style=\"position: static;\">\r\n <div class=\"lotusPostAvatar\">\r\n <img style=\"width: 35px; height: 35px;\"\r\n src=\"\"\r\n alt=\"\">\r\n <span></span>\r\n </div>\r\n </div>\r\n <div class=\"lotusPostContent\" style=\"position: static;\">\r\n <div class=\"lotusMeta\">\r\n <span class=\"lotusRight\" title=\"${commentEditedLabel}\">${commentEditedLabel}</span>\r\n <span title=\"${published}\">\r\n <span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t\t\t<a href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" class=\"fn url\">${authorName}</a>\r\n \t\t\t\t\t\t\t<span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${authorUserId}</span>\r\n \t\t\t\t\t\t\t\r\n \t\t\t\t\t\t\t</span>\r\n ${_nls.commented} ${createdLabel}\r\n </span>\r\n </div>\r\n <div class=\"lotusPostDetails\">\r\n <div class=\"lotusChunk lotusBreakWord\">\r\n ${formattedContent}<br>\r\n </div>\r\n </div>\r\n <div class=\"lotusActions\">\r\n <ul class=\"lotusInlinelist\">\r\n <li class=\"lotusFirst\">\r\n <a class=\"_qkrEditLink\" href=\"\" role=\"button\" title=\"${_nls.edit}\">${_nls.edit}\r\n </a>\r\n </li>\r\n <li>\r\n <a href=\"\" role=\"button\"\r\n title=\"${_nls._delete}\">${_nls._delete}\r\n </a>\r\n </li>\r\n </ul>\r\n </div>\r\n </div>\r\n </div>\r\n </td>\r\n</tr>", +'url:sbt/connections/controls/files/templates/BootstrapFileRow.html':"<tr>\r\n <td style=\"width: 100%;\">\r\n <span class=\"icon-file\"></span>\r\n <span style=\"font-size:120%\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${tooltip}\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a> \r\n </span>\r\n </td>\r\n \r\n</tr>", +'url:sbt/connections/controls/files/templates/BootstrapFolderRow.html':"<tr>\r\n <td style=\"width: 100%;\">\r\n <span class=\"icon-folder-open\"></span>\r\n <span style=\"font-size:120%\">\r\n <a class=\"entry-title\" rel=\"bookmark\" title=\"${tooltip}\" href=\"\" data-dojo-attach-event=\"onclick: handleClick\">${title}</a> \r\n </span>\r\n\r\n </td>\r\n \r\n</tr>"}}); +/* + * © 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. + */ + +/** + * + */ +define(["../../../declare", + "../../../stringUtil", + "../../../localeUtil", + "../ConnectionsGridRenderer", + "../../../i18n!./nls/FileGridRenderer", + "../../../text!./templates/FileRow.html", + "../../../text!./templates/RecycledFileRow.html", + "../../../text!./templates/FolderRow.html", + "../../../text!./templates/CommentRow.html", + "../../../text!./templates/BootstrapFileRow.html", + "../../../text!./templates/BootstrapFolderRow.html"], + function(declare, stringUtil, localeUtil, ConnectionsGridRenderer, nls, + fileTemplate, recycledFileTemplate, folderTemplate, commentTemplate, + bootstrapFileTemplate,bootstrapFolderTemplate) { + + /** + * @class FileGridRenderer + * @namespace sbt.connections.controls.files + * @module sbt.connections.controls.files.FileGridRenderer + */ + var FileGridRenderer = declare(ConnectionsGridRenderer, { + + /** + * Strings for the Grid + */ + _nls: nls, + + pinFiles: false, + pinnedClass: "lconnSprite lconnSprite-iconPinned16-on", + unPinnedClass: "lconnSprite lconnSprite-iconPinned16-off", + + /** + * @method constructor + * @param args, setting args.type, will set the appropriate template + */ + constructor: function(args,grid) { + if(grid.theme == "bootstrap"){ + if (args.type == "file" || args.type == "recycledFile") { + this.template = bootstrapFileTemplate; + } else if (args.type == "folder") { + this.template = bootstrapFolderTemplate; + } else if (args.type == "comment"){ + this.template = bootstrapCommentTemplate; + } + }else{ + if (args.type == "file") { + this.template = fileTemplate; + } else if (args.type == "recycledFile") { + this.template = recycledFileTemplate; + } else if (args.type == "folder") { + this.template = folderTemplate; + } else if (args.type == "comment"){ + this.template = commentTemplate; + } + } + + }, + + /** + * Sets the CSS Class for each row + * @method renderItem + * @param grid The Grid Element + * @param el The Table Body Element, that contains the rows of the grid + * @param data An object containing data for all of the rows + * @param item An object containing all of the items in the current row + * @param i the number of the current grid row + * @param items An Object Containing data for all of the rows + */ + renderItem: function(grid, el, data, item, i, items) { + item.rowClass = (i === 0 ? "lotusFirst" : (i % 2 === 1 ? "lotusAltRow" : null)); + this.inherited(arguments); + }, + + /** + * Gets the tooltip text to be displayed for a HTML element + * @method tooltip + * @param grid The grid Element + * @param item The item for which the tolltip is displayed + * @param i A number representing Current Grid row + * @param items All of the rows in the grid + * @returns A String containing the Tooltip text + */ + tooltip: function(grid, item, i, items) { + if (grid.fileAction) { + return grid.fileAction.getTooltip(item); + } + }, + + /** + * Functions that returns the date a file was created, as a String + * @method createdLabel + * @param grid The Grid Element + * @param item The HTML element/Item which will use the label + * @param i A Number representing the current grid row + * @param items An object containg all of the Items in each grid row + * @returns A String, when the File was created + */ + createdLabel: function(grid, item, i, items){ + var result = localeUtil.getUpdatedLabel(item.getValue('created')); + return result; + }, + + formattedContent: function(grid, item, i, items){ + var result = item.getValue('content').replace("\n", "<br><br>"); + return result; + }, + + /** + * Returns a String, containing when the file was last modified + * @method modifiedLabel + * @param grid The Grid + * @param item The HTML element which will use the string + * @param i the Number of a the current grid row + * @param items An Object containing data for each grid row + * @returns String, Last modified date + */ + modifiedLabel: function(grid, item, i, items){ + var result = localeUtil.getUpdatedLabel(item.getValue('modified')); + return result; + }, + + /** + * Returns a String, containing when the file was last "edited" + * @method commentEditedLabel + * @param grid The Grid + * @param item The HTML element which will use the string + * @param i the Number of a the current grid row + * @param items An Object containing data for each grid row + * @returns String, Last modified date + */ + commentEditedLabel: function(grid, item, i, items){ + var result = ""; + var modified = localeUtil.getUpdatedLabel(item.getValue('modified')); + var created = localeUtil.getUpdatedLabel(item.getValue('created')); + + if(modified != created) + result = "Edited " + modified; + return result; + }, + /** + * Returns a label to say if the file is public, private or shared + * @method shareLabel + * @param grid The Grid Element + * @param item An object containing all of the data in the row + * @param i The Number of the current row + * @param items An object containing all of the data for each row. + * @returns A Label + */ + shareLabel: function(grid, item, i, items) { + return item.getValue('visibility')=='shared' ? 'shared with ' + item.getValue('shareCount') : item.getValue('visibility'); + }, + + /** + * Returns the visibility of a file, for example shared, private etc. + * @method visibilityLabel + * @param grid The Grid Element + * @param item An object containing all of the data in the row + * @param i The Number of the current row + * @param items An object containing all of the data for each row. + * @returns The Visibility Label + */ + visibilityLabel: function(grid, item, i, items){ + var visibility = item.getValue('visibility'); + return visibility.charAt(0).toUpperCase() + visibility.slice(1); + }, + + /** + * Returns the Full UTC time for when a file was created + * @method detailedCreated + * @param grid The Grid Element + * @param item An object containing all of the data in the row + * @param i The Number of the current row + * @param items An object containing all of the data for each row. + * @returns + */ + detailedCreated: function(grid, item, i, items){ + return (new Date(item.getValue('created'))).toUTCString(); + }, + + /** + * Returns the file type, so an appropriate icon can be used + * @method ftype + * @param grid The Grid Element + * @param item An object containing all of the data in the row + * @param i The Number of the current row + * @param items An object containing all of the data for each row. + * @returns The File Type, A String containing the extension + */ + ftype: function(grid, item, i, items) { + return item.getValue('title').slice(-3); + }, + + /** + * Returns the label, for the "Likes icon" + * If there are zero "likes" it will display "No one likes this" + * If there is one like, "One person likes this" etc. + * @method recommendationLabel + * @param grid The Grid Element + * @param item An object containing all of the data in the row + * @param i The Number of the current row + * @param items An object containing all of the data for each row. + * @returns A String to be used as a label for the "likes icon" + */ + recommendationLabel : function(grid, item, i, items) { + if (item.getValue('recommendationsCount') == 0) { + return this._nls.noLikes; + } else if (item.getValue('recommendationsCount') == 1) { + return this._nls.oneLike; + } else { + return stringUtil.replace(this._nls.nLikes, item); } - options.sort[0].descending = this._activeSortIsDesc; - - this._doQuery(this.store, options); - }, - /* - * Filter the contents - */ - _filter: function(args, data){ - var options = { - start: 0, count: this.pageSize, - sort: [{ attribute: this._activeSortAnchor.sortParameter }] - }; - options.sort[0].descending = this._activeSortIsDesc; - - var query = {}; - if(args.tag){ - query.tag = args.tag; - this.filterTag = args.tag; + pinFileOnOrOff: function(grid, item, i, items){ + if(!this.pinFiles){ + return ""; + }else if (this.pinFiles){ + return this.unPinnedClass; } - - this._doQuery(this.store, options,query); + }, - - /* - * Display the specified error message - */ - _updateWithError: function(e) { - console.error(e.message); - this.renderer.renderError(this, this.domNode, e.message); + + getUserProfileHref: function(grid,item,i,items){ + return this.getProfileUrl(grid,item.getValue("authorUserId")); } + + }); - return Grid; + return FileGridRenderer; }); - }, -'url:sbt/connections/controls/forums/templates/TopicBreadCrumb.html':"<div class=\"lotusBreadcrumbs\">\r\n\r\n<a data-dojo-attach-event=\"onclick: showForums\" href=\"#\">Forums</a>>Topics\r\n</div>", -'sbt/_bridge/declare':function(){ +'sbt/base/VCardDataHandler':function(){ /* - * © Copyright IBM Corp. 2012 + * © 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. @@ -40261,19 +39754,78 @@ define([ "../../declare", "../../lang", "../../itemFactory", "../../stringUtil", */ /** - * Social Business Toolkit SDK. + * JavaScript API for IBM Connections Profile Service. * - * declare() function. + * @module sbt.connections.ProfileService */ -define(['dojo/_base/declare'],function(declare) { - return declare; -}); +define([ "../declare", "../lang", "../config", "../stringUtil", "./XmlDataHandler" ], + function(declare,lang,config,stringUtil,XmlDataHandler) { + /** + * VCardDataHandler class. + * + * @class ProfileDataHandler + * @namespace sbt.connections + */ + var VCardDataHandler = declare(XmlDataHandler, { + + lineDelim : "\n", + itemDelim : ":", + + _vcard : null, + + /** + * @constructor + * @param {Object} + * args Arguments for this data handler. + */ + constructor : function(args) { + this.parseVCard(); + }, + + /** + * Parse the vcard data from the specified element. + * + * @method parseVCard + */ + parseVCard : function() { + var content = stringUtil.trim(this.getAsString("vcard")); + var lines = content.split(this.lineDelim); + this._vcard = {}; + for (var i=1; i<lines.length-1; i++) { + var line = stringUtil.trim(lines[i]); + var index = line.indexOf(this.itemDelim); + var key = line.substring(0, index); + var value = line.substring(index+1); + this._vcard[key] = value; + } + }, + + /* + * Override this method to handle VCard properties. + */ + _selectText : function(property) { + var xpath = this._getXPath(property); + if (this._vcard && this._vcard.hasOwnProperty(xpath)) { + return this._vcard[xpath]; + } else { + try { + return this.inherited(arguments, [ property ]); + } catch (error) { + // vcard expressions may cause an error + // if they are treated as xpath expressions + return null; + } + } + } + + }); + return VCardDataHandler; +}); }, -'url:sbt/connections/controls/search/templates/div.html':"<div ${styleAttr}>\r\n ${content}\r\n</div>", -'sbt/Proxy':function(){ +'sbt/connections/nls/ConnectionsService':function(){ /* - * © Copyright IBM Corp. 2012 + * © Copyright IBM Corp. 2012,2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40289,53 +39841,18 @@ define(['dojo/_base/declare'],function(declare) { */ /** - * Social Business Toolkit SDK. - * Definition of a proxy re-writer. - * - * @module sbt.Proxy + * Social Business Toolkit SDK - Default resource bundle for ConnectionsService */ -define(['./declare','./lang','./pathUtil'],function(declare,lang,pathUtil) { - - /** - * Definition of the proxy module - * - * @class sbt.Proxy - * - */ - var Proxy = declare(null, { - - proxyUrl : null, - - constructor: function(args){ - lang.mixin(this, args); - }, - - rewriteUrl: function(baseUrl,serviceUrl,proxyPath) { - // When this proxy is being used, we don't add the base URL as it will be added on the server side - // A different implementation might use the full URL - var u = serviceUrl; - if(this.proxyUrl) { - if(u.indexOf("http://")==0) { - u = "/http/"+u.substring(7); - } else if(u.indexOf("https://")==0) { - u = "/https/"+u.substring(8); - } - if(proxyPath) { - u = pathUtil.concat(proxyPath,u); - } - return pathUtil.concat(this.proxyUrl,u); - } - return u; - } - }); - - return Proxy; - +define({ + root: ({ + invalid_argument : "Invalid Argument" + }) }); }, -'sbt/GadgetTransport':function(){ +'url:sbt/connections/controls/forums/templates/ForumRow.html':"<tr uuid=\"${id}\">\r\n <td style=\"width:20px;\" class=\"lotusFirstCell\"><div class=\"lconnSprite lconnSprite-iconForumsItem16\"> </div></td>\r\n <td>\r\n <h4 style=\"max-width:700px\">\r\n <a title=\"${tooltip}\" class=\"lotusBreakWord\" href=\"${forumURL}\" data-dojo-attach-event=\"onclick: handleClick\" >\r\n ${title}\r\n </a>\r\n <span class=\"dfName lotusHidden\">${title}</span>\r\n </h4>\r\n </td>\r\n <td><span >${threadCount}</span></td>\r\n <td></td>\r\n <td >${getDateLabel} <br /><a title=\"${nls.viewProfile}\" href=\"${getUserProfileHref}\" data-dojo-attach-event=\"onclick: viewUserProfile\" >${authorName}</a></td>\r\n</tr>\r\n\r\n", +'sbt/base/JsonDataHandler':function(){ /* - * © Copyright IBM Corp. 2012 + * © Copyright IBM Corp. 2012,2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40351,279 +39868,259 @@ define(['./declare','./lang','./pathUtil'],function(declare,lang,pathUtil) { */ /** - * Implements a transport for when the SDK is used from a gadget. - * @module + * Social Business Toolkit SDK. + * Helpers for the base capabilities of data handlers. + * + * @module sbt.base.JsonDataHandler */ -define(['./declare','./lang'],function(declare,lang) { - var MethodTypes = { - 'POST': gadgets.io.MethodType.POST, - 'PUT': gadgets.io.MethodType.PUT, - 'DELETE': gadgets.io.MethodType.DELETE, - 'GET': gadgets.io.MethodType.GET - }; - var ContentTypes = { - 'XML': gadgets.io.ContentType.DOM, - 'JSON': gadgets.io.ContentType.JSON, - 'TEXT': gadgets.io.ContentType.TEXT, - 'JSON-COMMENT-OPTIONAL': gadgets.io.ContentType.JSON, - 'JSON-COMMENT-FILTERED': gadgets.io.ContentType.JSON, - 'JAVASCRIPT': gadgets.io.ContentType.JSON - }; - var AuthorizationTypes = { - 'NONE': gadgets.io.AuthorizationType.NONE, - 'OAUTH': gadgets.io.AuthorizationType.OAUTH, - 'OAUTH2': gadgets.io.AuthorizationType.OAUTH2, - 'SIGNED': gadgets.io.AuthorizationType.SIGNED - }; - return declare(null, { - serviceName: null, - constructor: function(args) { - this.serviceName = args.serviceName || null; - }, +define(["../declare", "../lang", "../json", "./DataHandler", "../Jsonpath", "../stringUtil"], + function(declare, lang, json, DataHandler, jsonPath, stringUtil) { + + /** + * JsonDataHandler class + * + * @class JsonDataHandler + * @namespace sbt.base + */ + var JsonDataHandler = declare(DataHandler, { + /** - * Performs an XHR request using the gadget APIs. - * Warning this is not a final module. Not everything is supported as of yet. - * @param {String} method The HTTP method to use. - * @param {Object} args The arguments for the XHR request. - * @param {boolean} hasBody Indicates whether there is a request body. + * Data type for this DataHandler is 'json' */ - xhr: function(method,args,hasBody) { - //TODO OAuth support - if(args.sync) { - throw new Error('Gadget transport does not support synchronous requests.'); - } - - var params = {}; - params[gadgets.io.RequestParameters.METHOD] = MethodTypes[method.toUpperCase()] || gadgets.io.MethodType.GET; - params[gadgets.io.RequestParameters.CONTENT_TYPE] = ContentTypes[args.handleAs ? args.handleAs.toUpperCase() : 'TEXT']; - params[gadgets.io.RequestParameters.HEADERS] = args.headers || {}; - params[gadgets.io.RequestParameters.POST_DATA] = this.getPostData(params[gadgets.io.RequestParameters.METHOD], args.postData || args.putData); - if(args.preventCache) { - params[gadgets.io.RequestParameters.REFRESH_INTERVAL] = 0; - } - if(this.serviceName || args.serviceName) { - params[gadgets.io.RequestParameters.OAUTH_SERVICE_NAME] = this.serviceName || args.serviceName; - } - if(args.authType) { - var authorization = args.authType.toUpperCase(); - params[gadgets.io.RequestParameters.AUTHORIZATION] = AuthorizationTypes[authorization] || AuthorizationTypes['NONE']; - } - - var self = this; - var callback = function(response) { - self.handleResponse(args, response); - }; - - var url = this.buildUrl(args); - gadgets.io.makeRequest(url, callback, params); - }, - handleResponse: function(args, response) { - if(response.errors && response.errors.length > 0) { - if (args.error || args.handle) { - var error = this.createError(response); - this.notifyError(args, error); + dataType : "json", + + /** + * Set of jsonpath expressions used by this handler. + */ + jsonpath : null, + + /** + * Set of values that have already been read. + */ + _values : null, + + /** + * @constructor + * @param {Object} args Arguments for this data handler. + */ + constructor : function(args) { + lang.mixin(this, args); + this._values = {}; + this.data = args.data; + }, + + /** + * @method getAsString + * @param data + * @returns + */ + getAsString : function(property) { + this._validateProperty(property, "getAsString"); + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._get(property).toString(); } + return this._values[property]; } else { - if (response.oauthApprovalUrl) { - this.handleApproval(args, response); - } else { - this.notifyResponse(args, response); - } + return _get(property); } }, - handleApproval: function(args, response) { - var error = new Error(); - error.code = 401; - error.response = lang.mixin({}, response); - this.notifyError(args, error); - }, - notifyResponse: function(args, response) { - if (args.load || args.handle) { - var ioArgs = { - 'args' : args, - 'headers' : response.headers, - '_ioargs' : response - }; - if (args.handle) { - args.handle(response.data || response.text, ioArgs); - } - if (args.load) { - args.load(response.data || response.text, ioArgs); + + /** + * @method getAsNumber + * @returns + */ + getAsNumber : function(property) { + this._validateProperty(property, "getAsNumber"); + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._getNumber(property); } + return this._values[property]; + } else { + return _getNumber(property); } }, - notifyError: function(args, error) { - if (args.handle) { - args.handle(error); - } - if (args.error) { - args.error(error); - } - }, - createError: function(response) { - var error = new Error(); - error.code = response.rc; - error.message = response.errors[0]; - error.response = lang.mixin({}, response); - return error; - }, - getPostData: function(method, postData) { - if (method == gadgets.io.MethodType.POST || - method == gadgets.io.MethodType.PUT) { - return postData; - } - return ''; - }, - buildUrl: function(args) { - var params = []; - var url = args.url; - if (args.content) { - for (name in args.content) { - var param = encodeURIComponent(name) + "=" + encodeURIComponent(args.content[name]); - params.push(param); - } - if (params.length > 0) { - var query = params.join("&"); - url += (~url.indexOf('?') ? '&' : '?') + query; - } - } - return url; - } - }); -}); -}, -'url:sbt/connections/controls/bootstrap/templates/ProfileRow.html':"<tr class=\"${rowClass}\">\r\n\t<td style=\"width: 25px\" class=\"lotusFirstCell\">\r\n\t\t<div>\r\n\t\t\t<input id=\"${uid}\" name=\"${uid}\" value=\"${uid}\" type=\"checkbox\" data-dojo-attach-event=\"onclick: handleCheckBox\" aria-label=\"${name}\"></input>\r\n\t\t</div>\r\n\t</td>\r\n\t<td style=\"width: 70px\">\r\n\t\t<div><img alt=\"${name}\" src=\"${photoUrl}\" width=\"55\" height=\"55\"></img></div>\r\n\t</td>\r\n\t<td>\r\n\t\t<div>\r\n\t\t\t<h4>\r\n\t\t\t\t<span class=\"vcard\" dojoAttachPoint=\"vcardNode\">\r\n \t\t\t\t\t<a aria-label=\"${nls.ariaVcard}\" href=\"javascript:void(0);\" title=\"${tooltip}\" data-dojo-attach-event=\"onclick: handleClick\" class=\"fn url\">${name}</a>\r\n\t\t \t\t\t<span data-dojo-attach-point=\"idNode\" class=\"x-lconn-userid\" style=\"display: none;\">${uid}</span>\r\n \t\t\t\t</span>\r\n \t\t\t</h4>\r\n\t\t\t<div></div>\r\n\t\t</div>\r\n\t</td>\r\n\t<td class=lotusLastCell>\r\n\t\t<div>\r\n\t\t\t<div>${nls.telephone} ${telephone}</div>\r\n\t\t\t<div>${nls.email}: <strong><a alt=\"${nls.clickToEmail}\" href=\"mailto:${email}\">${email}</a></strong></div>\r\n\t\t\t<div>${nls.altEmail}: <strong><a alt=\"${nls.clickToEmail}\" href=\"mailto:${altEmail}\">${altEmail}</a></strong></div>\r\n\t\t</div>\r\n\t</td>\r\n</tr>\r\n", -'sbt/connections/controls/vcard/ProfileVCardInline':function(){ -require({cache:{ -'url:sbt/connections/controls/vcard/templates/ProfileVCardInline.html':"<span class=\"vcard X-person-display-inline\">\r\n <span class=\"fn\" style=\"display:none;\">${userName}</span>\r\n <span dojoAttachPoint=\"idNode\" class=\"\" style=\"display: none;\">${userId}</span>\r\n</span>\r\n"}}); -/* - * © 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. - */ - -/** - * - */ -define(["../../../declare", - "../../../dom", - "../../../widget/_TemplatedWidget", - "../../../lang", - "../../../connections/controls/vcard/SemanticTagService", - "../../../text!./templates/ProfileVCardInline.html"], - function(declare, dom, _TemplatedWidget, lang, SemanticTagService, template) { - /** - * @module sbt.controls.vcard.connections.ProfileVCardInline - */ - var profileVcardInline = declare([ _TemplatedWidget ], { + /** + * @method getAsDate + * @returns + */ + getAsDate : function(property) { + this._validateProperty(property, "getAsDate"); + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._getDate(property); + } + return this._values[property]; + } else { + return _getDate(property); + } + }, /** - * The html template of the vcard. - * - * @property configUtil - * @type String + * @method getAsBoolean + * @returns */ - templateString: template, - + getAsBoolean : function(property) { + this._validateProperty(property, "getAsBoolean"); + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._getBoolean(property); + } + return this._values[property]; + } else { + return _getBoolean(property); + } + }, + /** - * Whether or not to encode HTML. - * - * @property encodeHtml - * @type Boolean - * @default true + * @method getAsArray + * @returns */ - encodeHtml: true, - + getAsArray : function(property) { + this._validateProperty(property, "getAsArray"); + if (this._values) { + if (!this._values.hasOwnProperty(property)) { + this._values[property] = this._get(property); + } + return this._values[property]; + } else { + return _get(property); + } + }, + /** - * The href of the vcard link. By default clicking the link does nothing. - * - * @property href - * @type String - * @default "javascript:void(0);" + * @method getEntityId + * @returns */ - href: "javascript:void(0);", - + getEntityId : function(data) { + return stringUtil.trim(this.getAsString(this.jsonpath["id"])); + }, + /** - * The person's name to be displayed with this vcard. - * - * @property userName - * @type String - * @default "" + * getEntityData + * @returns */ - userName: "", + getEntityData : function() { + return this.data; + }, /** - * The connections profile id. This is the sole determinant of which vcard will be displayed. - * - * @property userId - * @type String - * @default "" + * @method getSummary + * @returns */ - userId: "", + getSummary : function() { + if (!this._summary && this._get("totalResults")[0]) { + this._summary = { + totalResults : this.getAsNumber("totalResults"), + startIndex : this.getAsNumber("startIndex"), + itemsPerPage : this.getAsNumber("itemsPerPage") + }; + } + return this._summary; + }, /** - * A url flag specifying whether or not connections should return dojo with the semantic tag service. - * - * @property inclDojo - * @type Boolean - * @default false + * @method getEntitiesDataArray + * @returns {Array} */ - inclDojo: false, + getEntitiesDataArray : function() { + var entityJPath = this._getJPath("entry"); + var resultingArray = this._get(entityJPath); + return resultingArray[0]; + }, /** - * The class of the html error element. - * - * @property errorClass - * @type String - * @default "" + * @method toJson + * @returns {Object} */ - errorClass: "", + toJson : function() { + return this.data; + }, - /** - * - * @param args - */ - constructor: function(args) { - lang.mixin(args); + // + // Internals + // + + _getDate : function(property) { + var text = this._get(property)[0]; + if(text instanceof Date) { + return text; + } + else { + return new Date(text); + } }, - postCreate: function() { - dom.setAttr(this.idNode, "class", (this.userId.indexOf("@") >= 0) ? "email" : "x-lconn-userid"); - - this.inherited(arguments); - - SemanticTagService.loadSemanticTagService(); + _getBoolean : function(property) { + var text = this._get(property)[0]; + return text ? true : false; }, - renderError: function(el, error) { - var ediv = domConstruct.create("div", { - "class": this.errorClass, - role: "alert", - tabIndex: 0 - }, el, "only"); - dom.setText(ediv, error.message); - } + _getNumber : function(property) { + var text = this._get(property)[0]; + // if it is a Number + if(typeof text === 'number') + return text; + //if its an array, we return the length of the array + else if(lang.isArray(text)) + return text.length; + //if its a string or any other data type, we convert to number and return. Invalid data would throw an error here. + else return Number(text); + }, - }); - - return profileVcardInline; + /** + Validate that the property is valid + **/ + _validateProperty : function(property, method) { + if (!property) { + var msg = stringUtil.substitute("Invalid argument for JsonDataHandler.{1} {0}", [ property, method ]); + throw new Error(msg); + } + }, + + /** + Validate that the object is valid + **/ + _validateObject : function(object) { + if (!object) { + var msg = stringUtil.substitute("Invalid argument for JsonDataHandler.{0}", [ object ]); + throw new Error(msg); + } + }, + + _evalJson: function(jsonQuery){ + return jsonPath(this.data,jsonQuery); + }, + + _evalJsonWithData: function(jsonQuery, data){ + return jsonPath(data,jsonQuery); + }, + + _get: function(property){ + + this._validateObject(this.data); + var jsonQuery = this._getJPath(property); + + var result = this._evalJson(jsonQuery); + return result; + }, + + _getJPath: function(property) { + return this.jsonpath[property] || property; + }, + + extractFirstElement: function(result){ + return this._evalJsonWithData("$[0]", result); + } + }); + return JsonDataHandler; }); }, -'url:sbt/connections/controls/search/templates/SingleApplicationSearch.html':"<span style=\"position:relative\">\r\n\t<span>\r\n\t\t<span>\r\n\t\t\t<div>\r\n\t\t\t\t\t<table>\r\n\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t<tr>\t\t\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<span><label style=\"display:none;\">text</label>\r\n\t\t\t\t\t\t\t\t\t\t<input style=\"width: 350px; height:2em;\" type=\"text\" data-dojo-attach-event=\"onkeyup: suggest,blur: setSearchQuery\" />\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t</span>\r\n\t</span>\r\n</span>", -'sbt/connections/BlogService':function(){ +'sbt/connections/BlogPost':function(){ /* - * © Copyright IBM Corp. 2013 + * © Copyright IBM Corp. 2012, 2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40639,36 +40136,27 @@ define(["../../../declare", */ /** - * The Blogs API allows application programs to retrieve blog information, subscribe to blog updates, and create or modify blogs. * - * @module sbt.connections.BlogService + * @module sbt.connections.BlogPost + * @author Rajmeet Bal */ -define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", "./BlogConstants", "./ConnectionsService", - "../base/AtomEntity", "../base/XmlDataHandler", "./Tag", "./BlogPost"], - function(declare,config,lang,stringUtil,Promise,consts,ConnectionsService,AtomEntity,XmlDataHandler, Tag, BlogPost) { - - var BlogTmpl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\" xmlns:thr=\"http://purl.org/syndication/thread/1.0\" xmlns:snx=\"http://www.ibm.com/xmlns/prod/sn\"><title type=\"text\">${getTitle}${getTimezone}${getHandle}${getSummary}${getTags}"; - var BlogPostTmpl = "${getTitle}${getContent}${getTags}"; - var BlogCommentTmpl = "${getContent}"; - CategoryTmpl = ""; - var CategoryBlog = ""; - var CategoryPerson = ""; +define(["../declare", "../lang", "../base/AtomEntity", "./BlogConstants", "../base/XmlDataHandler" ], + function(declare, lang, AtomEntity, consts, XmlDataHandler) { - /** - * Blog class represents an entry for a Blogs feed returned by the + /** + * BlogPost class represents a post for a Blogs feed returned by the * Connections REST API. * - * @class Blog + * @class BlogPost * @namespace sbt.connections */ - var Blog = declare(AtomEntity, { + var BlogPost = declare(AtomEntity, { - xpath : consts.BlogXPath, - namespaces : consts.BlogNamespaces, - categoryScheme : CategoryBlog, - + xpath : consts.BlogPostXPath, + namespaces : consts.BlogPostNamespaces, + /** - * Construct a Blog entity. + * Construct a Blog Post. * * @constructor * @param args @@ -40677,351 +40165,186 @@ define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", ". }, /** - * Return the value of IBM Connections blog handle from blog ATOM - * entry document. - * - * @method getHandle - * @return {String} handle of the blog - */ - getHandle : function() { - return this.getAsString("handle"); - }, - - /** - * Sets Handle of IBM Connections blog. - * - * @method setHandle - * @param {String} setHandle of the blog - */ - setHandle : function(handle) { - return this.setAsString("handle", handle); - }, - - /** - * Return the value of IBM Connections blog ID from blog ATOM + * Return the value of IBM Connections blog post ID * entry document. * - * @method getBlogUuid - * @return {String} ID of the blog + * @deprecated Use getPostUuid instead. + * @method getBlogPostUuid + * @return {String} ID of the blog post */ - getBlogUuid : function() { - var blogUuidPrefix = "urn:lsid:ibm.com:blogs:blog-"; - var blogUuid = this.getAsString("blogUuid"); - if(blogUuid && blogUuid.indexOf(blogUuidPrefix) != -1){ - blogUuid = blogUuid.substring(blogUuidPrefix.length, blogUuid.length); + getBlogPostUuid : function() { + var postUuidPrefix = "urn:lsid:ibm.com:blogs:entry-"; + var postUuid = this.getAsString("postUuid"); + if(postUuid && postUuid.indexOf(postUuidPrefix) != -1){ + postUuid = postUuid.substring(postUuidPrefix.length, postUuid.length); } - return blogUuid; - }, - - /** - * Sets id of IBM Connections blog. - * - * @method setBlogUuid - * @param {String} blogUuid of the blog - */ - setBlogUuid : function(blogUuid) { - return this.setAsString("blogUuid", blogUuid); - }, - - /** - * Return the value of IBM Connections blog URL from blog ATOM - * entry document. - * - * @method getBlogUrl - * @return {String} Blog URL of the blog - */ - getBlogUrl : function() { - return this.getAsString("alternateUrl"); - }, - - /** - * Return tags of IBM Connections blog - * document. - * - * @method getTags - * @return {Object} Array of tags of the blog - */ - getTags : function() { - return this.getAsArray("tags"); - }, - - /** - * Set new tags to be associated with this IBM Connections blog. - * - * @method setTags - * @param {Object} Array of tags to be added to the blog - */ - - setTags : function(tags) { - return this.setAsArray("tags", tags); - }, - - /** - * Return the value of IBM Connections blog's community id from blog ATOM - * entry document. Only valid for Ideation Blog and community blog - * - * @method getCommunityUuid - * @return {String} Blog Container URL of the blog - */ - getCommunityUuid : function() { - return this.getAsString("communityUuid"); + return postUuid; }, /** - * Return the value of IBM Connections blog's container url from blog ATOM - * entry document. Only valid for Ideation Blog + * Sets id of IBM Connections blog post Id. * - * @method getContainerUrl - * @return {String} Blog Container URL of the blog + * @deprecated Use setPostUuid instead + * @method setBlogPostUuid + * @param {String} BlogPostUuid of the blog post */ - getContainerUrl : function() { - return this.getAsString("containerUrl"); + setBlogPostUuid : function(postUuid) { + return this.setAsString("postUuid", postUuid); }, - + /** - * Return the value of IBM Connections blog's container type from blog ATOM - * entry document. Only valid for Ideation Blog + * Return the value of IBM Connections blog post ID. * - * @method getContainerType - * @return {String} Blog Container type of the blog + * @method getPostUuid + * @return {String} Unique id of the blog post */ - getContainerType : function() { - return this.getAsString("containerType"); + getPostUuid : function() { + var postUuidPrefix = "urn:lsid:ibm.com:blogs:entry-"; + var postUuid = this.getAsString("postUuid"); + if(postUuid && postUuid.indexOf(postUuidPrefix) != -1){ + postUuid = postUuid.substring(postUuidPrefix.length, postUuid.length); + } + return postUuid; }, /** - * Return all flags of IBM Connections blog ATOM entry document. Only valid - * for Ideation Blog + * Sets id of IBM Connections blog post Id. * - * @method getCategoryFlags - * @return {Object} Array of all flags of the blog + * @method setPostUuid + * @param {String} Unique id of the blog post */ - getCategoryFlags : function() { - return this.getAsArray("categoryFlags"); + setPostUuid : function(postUuid) { + return this.setAsString("postUuid", postUuid); }, - + /** - * Loads the blog object with the atom entry associated with the - * blog. By default, a network call is made to load the atom entry - * document in the blog object. + * Return the entry anchor for this blog post. * - * @method load - * @param {Object} [args] Argument object + * @method getEntryAnchor + * @return {String} Entry anchor for this blog post */ - load : function(args) { - // detect a bad request by validating required arguments - var blogUuid = this.getBlogUuid(); - var promise = this.service._validateBlogUuid(blogUuid); - if (promise) { - return promise; - } - - var self = this; - var callbacks = { - createEntity : function(service,data,response) { - self.setDataHandler(new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BlogXPath - })); - return self; - } - }; - var requestArgs = lang.mixin({}, args || {}); - var options = { - handleAs : "text", - query : requestArgs - }; - var url = null; - - url = this.service._constructBlogsUrl(consts.AtomBlogInstance, { - blogUuid : blogUuid - }); - return this.service.getEntity(url, options, blogUuid, callbacks); + getEntryAnchor : function() { + var entry = this.dataHandler.getData(); + if (entry) { + var base = entry.getAttribute("xml:base"); + if (base) { + var n = base.lastIndexOf("/"); + return base.substring(n+1); + } + } }, - + /** - * Remove this blog + * Return the bloghandle of the blog post. * - * @method remove - * @param {Object} [args] Argument object + * @method getBlogHandle + * @return {String} Blog handle of the blog post */ - remove : function(args) { - return this.service.deleteBlog(this.getBlogUuid(), args); + getBlogHandle : function() { + var blogHandle = this.getAsString("blogHandle"); + if(blogHandle){ + return blogHandle; + } + var blogEntryUrlAlternate = this.getAsString("alternateUrl"); + blogHandle = this.service._extractBlogHandle(blogEntryUrlAlternate); + return blogHandle; }, /** - * Update this blog + * Sets blog handle of IBM Connections blog post. * - * @method update - * @param {Object} [args] Argument object + * @method setBlogHandle + * @param {String} blogHandle of the blog post's blog */ - update : function(args) { - return this.service.updateBlog(this, args); + setBlogHandle : function(blogHandle) { + return this.setAsString("blogHandle", blogHandle); }, /** - * Save this blog + * Return the value of IBM Connections blog post replies URL from blog ATOM + * entry document. * - * @method save - * @param {Object} [args] Argument object + * @method getRepliesUrl + * @return {String} Blog replies URL for the blog post */ - save : function(args) { - if (this.getBlogUuid()) { - return this.service.updateBlog(this, args); - } else { - return this.service.createBlog(this, args); - } - } - - }); - - /** - * Comment class represents a comment on a Blogs post returned by the - * Connections REST API. - * - * @class Comment - * @namespace sbt.connections - */ - var Comment = declare(AtomEntity, { - - xpath : consts.CommentXPath, - namespaces : consts.BlogNamespaces, + getRepliesUrl : function() { + return this.getAsString("replies"); + }, /** - * Construct a Blog Post Comment. + * Return tags of IBM Connections blog post + * document. * - * @constructor - * @param args + * @method getTags + * @return {Object} Array of tags of the blog post */ - constructor : function(args) { + getTags : function() { + return this.getAsArray("tags"); }, /** - * Return the value of IBM Connections blog post comment id - * entry document. + * Set new tags to be associated with this IBM Connections blog post. * - * @method getCommentUuid - * @return {String} id of the blog post comment - */ - getCommentUuid : function() { - var commentUuidPrefix = "urn:lsid:ibm.com:blogs:comment-"; - var commentUuid = this.getAsString("commentUuid"); - if(commentUuid && commentUuid.indexOf(commentUuidPrefix) != -1){ - commentUuid = commentUuid.substring(commentUuidPrefix.length, commentUuid.length); - } - return commentUuid; - }, + * @method setTags + * @param {Object} Array of tags to be added to the blog post + */ + setTags : function(tags) { + return this.setAsArray("tags", tags); + }, + /** - * Sets id of IBM Connections blog post comment. + * Return the replies url of the ATOM entry document. * - * @method setCommentUuid - * @param {String} CommentUuid of the blog post + * @method getRepliesUrl + * @return {String} Replies url */ - setCommentUuid : function(CommentUuid) { - return this.setAsString("CommentUuid", CommentUuid); + getRepliesUrl : function() { + return this.getAsString("repliesUrl"); }, /** - * Return the last updated dateRecommendations URL of the IBM Connections blog post comment from + * Return the last updated dateRecommendations URL of the IBM Connections blog post from * blog ATOM entry document. * * @method getRecommendationsURL - * @return {String} Recommendations URL of the Blog Post comment + * @return {String} Recommendations URL of the Blog Post */ getRecommendationsURL : function() { return this.getAsString("recommendationsUrl"); }, /** - * Return the Recommendations count of the IBM Connections blog post comment from + * Return the Recommendations count of the IBM Connections blog post from * blog ATOM entry document. * * @method getRecommendationsCount - * @return {String} Number of recommendations for the Blog post comment + * @return {String} Last updated date of the Blog post */ getRecommendationsCount : function() { - return this.getAsString("rankRecommendations"); + return this.getAsNumber("rankRecommendations"); }, /** - * Return the get-reply-to of the IBM Connections blog post comment from + * Return the comment count of the IBM Connections blog post from * blog ATOM entry document. * - * @method getReplyTo - * @return {String} Entity Id of the entity in reply to which comment was created - */ - getReplyTo : function() { - return this.getAsString("replyTo"); - }, - - /** - * Return the postUuid of the blog post on which comment was created. - * - * @method getPostUuid - * @return {String} Blog post Id of the entity in reply to which comment was created - */ - getPostUuid : function() { - var postUuid = this.getAsString("blogPostUuid"); - if(postUuid){ - return postUuid; - } - var postUuidPrefix = "urn:lsid:ibm.com:blogs:entry-"; - postUuid = this.getAsString("replyTo"); - if(postUuid && postUuid.indexOf(postUuidPrefix) != -1){ - postUuid = postUuid.substring(postUuidPrefix.length, postUuid.length); - } - return postUuid; - }, - - /** - * Sets blog post id of IBM Connections blog post comment. - * - * @method setPostUuid - * @param {String} blogPostUuid of the comment's blog post - */ - setPostUuid : function(blogPostUuid) { - return this.setAsString("blogPostUuid", blogPostUuid); - }, - - /** - * Return the bloghandle of the blog post on which comment was created. - * - * @method getBlogHandle - * @return {String} Blog handle of the entity in reply to which comment was created - */ - getBlogHandle : function() { - var blogHandle = this.getAsString("blogHandle"); - if(blogHandle){ - return blogHandle; - } - var commentUrlAlternate = this.getAsString("alternateUrl"); - var blogHandle = this.service._extractBlogHandle(commentUrlAlternate); - return blogHandle; - }, - - /** - * Sets blog handle of IBM Connections blog post comment. - * - * @method setBlogHandle - * @param {String} blogHandle of the comments's blog + * @method getCommentCount + * @return {String} Last updated date of the Blog post */ - setBlogHandle : function(blogHandle) { - this.setAsString("blogHandle", blogHandle); - return this.setAsString("blogHandle", blogHandle); + getCommentCount : function() { + return this.getAsNumber("rankComment"); }, /** - * Return the Trackback Title of the IBM Connections blog post comment from + * Return the hit count of the IBM Connections blog post from * blog ATOM entry document. * - * @method getTrackbackTitle - * @return {String} TrackbackTitle of the Blog post comment + * @method getHitCount + * @return {String} Last updated date of the Blog post */ - getTrackbackTitle : function() { - return this.getAsDate("trackbacktitle"); + getHitCount : function() { + return this.getAsNumber("rankHit"); }, /** @@ -41031,19 +40354,21 @@ define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", ". * @return {Object} Source of the blog post */ getSource : function() { - return this.getAsObject([ "sourceId", "sourceTitle", "sourceLink", "sourceLinkAlternate" ]); + return this.getAsObject([ "sourceId", "sourceTitle", "sourceLink", "sourceLinkAlternate", "sourceUpdated", "sourceCategory" ]); }, /** - * Loads the blog comment object associated with the - * blog. By default, a network call is made to load the atom entry - * document in the comment object. + * Loads the blog post object with the atom entry associated with the + * blog post. By default, a network call is made to load the atom entry + * document in the blog post object. * * @method load * @param {Object} [args] Argument object */ - load : function(blogHandle, commentUuid, args) { - var promise = this.service._validateUuid(commentUuid); + load : function(args) { + // detect a bad request by validating required arguments + var blogPostUuid = this.getBlogPostUuid(); + var promise = this.service._validateBlogUuid(blogPostUuid); if (promise) { return promise; } @@ -41055,7 +40380,7 @@ define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", ". service : service, data : data, namespaces : consts.Namespaces, - xpath : consts.CommentXPath + xpath : consts.BlogPostXPath })); return self; } @@ -41067,1195 +40392,1826 @@ define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", ". query : requestArgs }; var url = null; - url = this.service.constructUrl(consts.AtomBlogCommentEditRemove, null, { - blogHandle : blogHandle, - commentUuid : commentUuid + url = this.service.constructUrl(consts.AtomBlogPostInstance, null, { + blogHomepageHandle : this.service.handle, + postUuid : blogPostUuid }); - return this.service.getEntity(url, options, commentUuid, callbacks); + return this.service.getEntity(url, options, blogPostUuid, callbacks); }, /** - * Remove this blog post comment + * Remove this blog post * * @method remove * @param {Object} [args] Argument object */ remove : function(args) { - return this.service.deleteComment(this.getCommentUuid(), args); + return this.service.deletePost(this.getBlogPostUuid(), args); + }, + + /** + * Update this blog post + * + * @method update + * @param {Object} [args] Argument object + */ + update : function(args) { + return this.service.updatePost(this, args); }, /** - * Save this blog post comment + * Save this blog post * * @method save * @param {Object} [args] Argument object */ save : function(args) { - return this.service.createPost(this, args); + if (this.getBlogPostUuid()) { + return this.service.updatePost(this, args); + } else { + return this.service.createPost(this, args); + } + }, + + /** + * Return comments associated with this blog post. + * + * @method getComments + * @param {Object} [args] Argument object + */ + getComments : function(args) { + var blogHandle = this.getBlogHandle(); + var entryAnchor = this.getEntryAnchor(); + return this.service.getEntryComments(blogHandle, entryAnchor, args); } - }); + return BlogPost; +}); + +}, +'url:sbt/controls/grid/templates/SortAnchor.html':"
  • \r\n\t${title}\r\n
  • \r\n", +'sbt/authenticator/SSO':function(){ +/* + * © 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. + */ +/** + * Social Business Toolkit SDK. + * Definition of an authentication mechanism. + */ +define(["../declare", "../lang", "../util", "../i18n!../nls/messageSSO"],function(declare, lang, util, ssoMessages) { +/** + * Proxy SSO authentication. + * + * This class triggers the authentication for a service. + */ +return declare(null, { + loginUi: "", + messageSSO: "/sbt/authenticator/templates/MessageSSO.html", + dialogMessageSSO: "authenticator/templates/MessageDialogSSO.html", + url: "", + constructor: function(args){ + lang.mixin(this, args || {}); + }, + + authenticate: function(options) { + var self = this; + require(['sbt/config'], function(config){ + var mode = options.loginUi || config.Properties["loginUi"] || self.loginUi; + var messagePage = options.messageSSO || config.Properties["messageSSO"] || self.messageSSO; + var dialogMessagePage = options.dialogMessageSSO || config.Properties["dialogMessageSSO"] || self.dialogMessageSSO; + if(mode=="popup") { + self._authPopup(options, messagePage, self.url); + } else if(mode=="dialog") { + self._authDialog(options, dialogMessagePage); + } else { + self._authMainWindow(options, messagePage, self.url); + } + }); + return true; + + }, + + _authPopup: function(options, messagePage, sbtUrl) { + var urlParamsMap = { + loginUi: 'popup' + }; + var urlParams = util.createQuery(urlParamsMap, "&"); + var url = sbtUrl+messagePage + '?' + urlParams; + + var windowParamsMap = { + width: window.screen.availWidth / 2, + height: window.screen.availHeight / 2, + left: window.screen.availWidth / 4, + top: window.screen.availHeight / 4, + menubar: 0, + toolbar: 0, + status: 0, + location: 0, + scrollbars: 1, + resizable: 1 + }; + var windowParams = util.createQuery(windowParamsMap, ","); + var loginWindow = window.open(url,'Authentication', windowParams); + loginWindow.globalSSOStrings = ssoMessages; + loginWindow.globalEndpointAlias = options.name; + loginWindow.focus(); + + return true; + }, + + _authDialog: function(options, dialogLoginPage) { + require(["sbt/_bridge/ui/SSO_Dialog", "sbt/dom"], function(dialog, dom) { + dialog.show(options, dialogLoginPage, ssoMessages); + dom.setText('reloginMessage', ssoMessages.message); + dom.setAttr(dom.byId('ssoLoginFormOK'), "value", ssoMessages.relogin_button_text); + }); + + return true; + }, + + _authMainWindow: function(options, loginPage, sbtUrl) { + var urlParamsMap = { + redirectURL: document.URL, + loginUi: 'mainWindow', + message_title: ssoMessages.message_title, + message: ssoMessages.message, + relogin_button_text: ssoMessages.relogin_button_text + }; + + var urlParams = util.createQuery(urlParamsMap, "&"); + var url = sbtUrl+loginPage + '?' + urlParams; + var loginWindow = window.location.href = url; + + return true; + } +} +); +}); +}, +'url:sbt/controls/grid/templates/GridFooter.html':"
    \r\n\t
      \r\n\t\tShow:\r\n\t\t
    • \r\n\t\t\t10\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t25\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t50\r\n\t\t
    • \r\n\t\t
    • \r\n\t\t\t100\r\n\t\t
    • ${nls.items}\r\n\t
    \r\n\t
    \r\n\t\t
    \r\n\t
    \r\n
    \r\n
    \r\n\t${nls.feed}\r\n
    ", +'sbt/connections/controls/sharebox/InputFormWrapper':function(){ +require({cache:{ +'url:sbt/connections/controls/sharebox/templates/InputFormContent.html':"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n"}}); +/* + * © 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. + */ + +define(["sbt/declare", "sbt/connections/controls/WidgetWrapper", "sbt/text!./templates/InputFormContent.html"], function(declare, WidgetWrapper, defaultTemplate) { + /** - * Recommender class represents a recommender of a Blogs post returned by the - * Connections REST API. - * - * @class Recommender - * @namespace sbt.connections + * @class sbt.controls.sharebox.InputFormWrapper */ - var Recommender = declare(AtomEntity, { - - xpath : consts.RecommendersXPath, - categoryScheme : CategoryPerson, - namespaces : consts.BlogNamespaces, - + var InputFormWrapper = declare([ WidgetWrapper ], { /** - * Construct a Blog Post Recommender. + * The html template of the iframe's inner html. * - * @constructor - * @param args + * @property defaultTemplate + * @type String */ - constructor : function(args) { - }, - + defaultTemplate: defaultTemplate, + /** - * Return the value of IBM Connections blog post recommender id + * The args object which will be substituted into the defaultTemplate. * - * @method getRecommenderUuid - * @return {String} id of the blog post recommender + * @property args + * @type Object */ - getRecommenderUuid : function() { - var recommenderUuidPrefix = "urn:lsid:ibm.com:blogs:person-"; - var recommenderUuid = this.getAsString("recommenderUuid"); - if(recommenderUuid && recommenderUuid.indexOf(recommenderUuidPrefix) != -1){ - recommenderUuid = recommenderUuid.substring(recommenderUuidPrefix.length, recommenderUuid.length); - } - return recommenderUuid; + args: null, + + /** + * Get args of the connections InputForm and store them so that they can be substituted into the defaultTemplate later. + * + * @method constructor + * @param {Object} args + * @param {String} args.shareBoxNode Should contain the id of the html element to add the InputForm to. + */ + constructor: function(args){ + this.args = args; } - + }); - /* - * Callbacks used when reading a feed that contains blog entries. - */ - var ConnectionsBlogFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BlogFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new Blog({ - service : service, - data : data - }); - } - }; - - /* - * Callbacks used when reading a feed that contains forum recommendation entries. - */ - var RecommendBlogPostCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.ForumsFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new BlogPost({ - service : service, - data : data - }); - } - }; - - /* - * Callbacks used when reading a feed that contains blog entries. - */ - var ConnectionsTagsFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.TagsXPath - }); - }, - createEntity : function(service,data,response) { - var entryHandler = new XmlDataHandler({ - data : data, - namespaces : consts.Namespaces, - xpath : consts.TagsXPath - }); - return new Tag({ - service : service, - id : entryHandler.getEntityId(), - dataHandler : entryHandler - }); - } - }; - - /* - * Callbacks used when reading a feed that contains blog entries. - */ - var ConnectionsBlogPostsCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BlogFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new BlogPost({ - service : service, - data : data - }); - } + return InputFormWrapper; +}); +}, +'url:sbt/controls/grid/templates/Grid.html':"
    \r\n", +'sbt/url':function(){ +define(['./declare'], function(declare){ + // regexp /^(?:(scheme)(:))?(\/\/)(?:(userna)(:)(passwo)(@))?(domain )(?:(:)(port ))?(path )?(?:(\?)(query ))?(?:(#)(fr))?$/ + var URL_RE = /^(?:([A-z]+)(:))?(\/\/)(?:([^?#]*)(:)([^?#]*)(@))?([\w.\-]+)(?:(:)(\d{0,5}))?([\w.\/\-]+)?(?:(\?)([^?#]*))?(?:(#)(.*))?$/; + var URL_RE_GROUPS = { + 'URL': 0, + 'SCHEME': 1, + 'SCHEME_COLON': 2, + 'SCHEME_SLASHES': 3, + 'USER': 4, + 'PASSWORD_COLON':5, + 'PASSWORD': 6, + 'USER_AT': 7, + 'HOSTNAME': 8, + 'PORT_COLON':9, + 'PORT': 10, + 'PATH': 11, + 'QUERY_QUESTION':12, + 'QUERY': 13, + 'FRAGMENT_HASH': 14, + 'FRAGMENT': 15 }; - /* - * Callbacks used when reading a feed that contains blog entries. - */ - var ConnectionsBlogPostRecommendersCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, -// xpath : consts.RecommendersFeedXpath - xpath : consts.BlogFeedXPath - }); + /** + A class for representing urls. + + @class url + @constructor + **/ + var url = declare(null, { + /* + Holds the parts of the url after URL_RE parses the url. + + @property _resultStore + @type Array + **/ + _resultStore: [], + + /* + * Ensures that, when setting a value, the required delimiter is before it, and when setting a value null, the relevant delimiter is not before it. + * + * e.g. setQuery(query). If there was no ? in the url then the url will still not have one when you set the query. It needsto be set in this case. If there was one and you set it null, it needs to be removed. + */ + _ensureDelimiter: function(urlPart, delimGroupNum, delim){ + if(!urlPart && this._resultStore[delimGroupNum]){// if we are setting port empty, ensure there is no : before the port. + this._resultStore[delimGroupNum] = undefined; + }else if(urlPart && !this._resultStore[delimGroupNum]){// if we are setting port not empty, ensure there is a : before the port. + this._resultStore[delimGroupNum] = delim; + } }, - createEntity : function(service,data,response) { - return new Recommender({ - service : service, - data : data - }); - } - }; - /* - * Callbacks used when reading a feed that contains blog entries. - */ - var ConnectionsBlogPostCommentsCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BlogFeedXPath - }); + + /* + @method constructor + **/ + constructor: function(url){ + this.setUrl(url); }, - createEntity : function(service,data,response) { - return new Comment({ - service : service, - data : data - }); - } - }; - /** - * BlogService class. - * - * @class BlogService - * @namespace sbt.connections - */ - var BlogService = declare(ConnectionsService, { - - contextRootMap: { - blogs : "blogs" + + /** + @method getUrl + @return {String} Returns the url in its current state. + **/ + getUrl: function(){ + return this._resultStore.slice(1).join(""); }, - serviceName : "blogs", - /** - * Default blog homepage handle name if there is not one specified in sbt.properties. - * @returns {String} - */ - handle : "homepage", - + @method setUrl + @param url {String} + **/ + setUrl: function(url){ + this._resultStore = URL_RE.exec(url); + }, + /** - * Constructor for BlogService - * - * @constructor - * @param args - */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + @method getScheme + @return {String} Returns the scheme in its current state. + **/ + getScheme: function(){ + return this._resultStore[URL_RE_GROUPS.SCHEME]; + }, + + /** + @method setScheme + @param scheme {String} + @param keepSlashes {Boolean} If true, keep the // even if the scheme is set empty. e.g. //ibm.com is a valid url + **/ + setScheme: function(scheme, keepSlashes){ + this._ensureDelimiter(scheme, URL_RE_GROUPS.SCHEME_COLON, ':'); + if(!keepSlashes || scheme){ // If they want to keep slashes and the scheme provided is empty, do not do the ensure part. + this._ensureDelimiter(scheme, URL_RE_GROUPS.SCHEME_SLASHES, '//'); + }else{ // they want to keep slashes and the scheme provided is empty + this._resultStore[URL_RE_GROUPS.SCHEME_SLASHES] = '//'; } - this.handle = this.endpoint.serviceMappings.blogHomepageHandle?this.endpoint.serviceMappings.blogHomepageHandle:this.handle; + + this._resultStore[URL_RE_GROUPS.SCHEME] = scheme; }, /** - * Get the All Blogs feed to see a list of all blogs to which the - * authenticated user has access. - * - * @method getAllBlogs - * - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of all blogs. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getAllBlogs : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogsAll); - return this.getEntities(url, options, this.getBlogFeedCallbacks()); + @method getUser + @return {String} Returns the username in its current state. + **/ + getUser: function(){ + return this._resultStore[URL_RE_GROUPS.USER]; }, - + /** - * Get the My Blogs feed to see a list of the blogs to which the - * authenticated user is a member. - * - * @method getMyBlogs - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of my blogs. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getMyBlogs : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogsMy); - return this.getEntities(url, options, this.getBlogFeedCallbacks()); + @method setUser + @param user {String} + **/ + setUser: function(user){ + this._ensureDelimiter(user, URL_RE_GROUPS.USER_AT, '@'); + this._resultStore[URL_RE_GROUPS.USER] = user; }, - + /** - * Get the featured posts feed to find the blog posts that have had the most activity across - * all of the blogs hosted by the Blogs application within the past two weeks - * - * @method getFeaturedBlogs - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of my blogs. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getFeaturedBlogs : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogsFeatured); - return this.getEntities(url, options, this.getBlogFeedCallbacks()); + @method getPassword + @return {String} Returns the password (domain) in its current state. + **/ + getPassword: function(){ + return this._resultStore[URL_RE_GROUPS.PASSWORD]; }, - + /** - * Get the featured posts feed to find the blog posts that have had the most activity across - * all of the blogs hosted by the Blogs application within the past two weeks - * - * @method getFeaturedPosts - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of my blogs. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getFeaturedPosts : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogsPostsFeatured); - return this.getEntities(url, options, this.getBlogPostsCallbacks()); + @method setPassword + @param password {String} + **/ + setPassword: function(password){ + this._ensureDelimiter(password, URL_RE_GROUPS.PASSWORD_COLON, ':'); + this._resultStore[URL_RE_GROUPS.PASSWORD] = password; + }, + + /** + @method getHostName + @return {String} Returns the hostname (domain) in its current state. + **/ + getHostName: function(){ + return this._resultStore[URL_RE_GROUPS.HOSTNAME]; + }, + + /** + @method setHostName + @param hostName {String} + **/ + setHostName: function(hostName){ + this._resultStore[URL_RE_GROUPS.HOSTNAME] = hostName; }, /** - * Get a feed that includes all of the recommended blog posts - * in all of the blogs hosted by the Blogs application. - * - * @method getRecommendedPosts - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of my blogs. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getRecommendedPosts : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogsPostsRecommended); - return this.getEntities(url, options, this.getBlogPostsCallbacks()); + @method getPort + @return {String} Returns the port in its current state. + **/ + getPort: function(){ + return this._resultStore[URL_RE_GROUPS.PORT]; }, /** - * Get the blog posts feed to see a list of posts for all blog . - * - * @method getAllBlogPosts - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of all blogs posts. The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getAllBlogPosts : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomEntriesAll); - return this.getEntities(url, options, this.getBlogPostsCallbacks()); + @method setPort + @param port {Number} + **/ + setPort: function(port){ + this._ensureDelimiter(port, URL_RE_GROUPS.PORT_COLON, ':'); + this._resultStore[URL_RE_GROUPS.PORT] = port; }, /** - * Get the blog posts feed to see a list of posts for a blog . - * - * @method getBlogPosts - * @param {String} blogHandle Handle of the blog of which posts are to be get. - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of posts of a blog . The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getBlogPosts : function(blogHandle, args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this.constructUrl(consts.AtomBlogEntries, null, { - blogHandle : blogHandle - }); - return this.getEntities(url, options, this.getBlogPostsCallbacks()); + @method getPath + @return {String} Returns the path in its current state. + **/ + getPath: function(){ + return this._resultStore[URL_RE_GROUPS.PATH]; }, /** - * Get the blog posts recommenders feed to see a list of recommenders of a blog post. - * - * @method getBlogPostRecommenders - * @param {Object} object representing a blog post. - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of posts of a blog . The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getBlogPostRecommenders : function(blogPost, args) { - var post = this._toBlogPost(blogPost); - var promise = this._validateBlogPost(post); - if (promise) { - return promise; - } - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this.constructUrl(consts.AtomRecommendBlogPost, null, { - postUuid : post.getBlogPostUuid(), - blogHandle : post.getBlogHandle() - }); - return this.getEntities(url, options, this.getBlogPostRecommendersCallbacks()); + @method setPath + @param path {String} + **/ + setPath: function(path){ + this._resultStore[URL_RE_GROUPS.PATH] = path; }, /** - * Get the blog comments feed to see a list of comments for all blogs . - * - * @method getAllBlogComments - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of posts of a blog . The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getAllBlogComments : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogCommentsAll); - return this.getEntities(url, options, this.getBlogPostCommentsCallbacks()); + @method getQuery + @return {String} Returns the query in its current state. + **/ + getQuery: function(){ + return this._resultStore[URL_RE_GROUPS.QUERY]; }, /** - * Get the blog comments feed to see a list of comments for a blog post . - * - * @method getBlogPostComments - * @param {blogHandle} Handle of the blog of which Comments are to be get - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of posts of a blog . The - * parameters must be exactly as they are supported by IBM - * Connections like ps, sortBy etc. - */ - getBlogComments : function(blogHandle, args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this.constructUrl(consts.AtomBlogComments, null, { - blogHandle : blogHandle - }); - return this.getEntities(url, options, this.getBlogPostCommentsCallbacks()); + @method setQuery + @param query {String} + **/ + setQuery: function(query){ + this._ensureDelimiter(query, URL_RE_GROUPS.QUERY_QUESTION, '?'); + this._resultStore[URL_RE_GROUPS.QUERY] = query; }, /** - * Retrieve a blog instance. - * - * @method getBlog - * @param {String } blogUuid - * @param {Object} args Object containing the query arguments to be - * sent (defined in IBM Connections Blogs REST API) - */ - getBlog : function(blogUuid, args) { - var blog = new Blog({ - service : this, - _fields : { blogUuid : blogUuid } - }); - return blog.load(args); + @method getFragment + @return {String} Returns the fragment in its current state. + **/ + getFragment: function(){ + return this._resultStore[URL_RE_GROUPS.FRAGMENT]; + }, + + /** + @method setFragment + @param fragment {String} + **/ + setFragment: function(fragment){ + this._ensureDelimiter(fragment, URL_RE_GROUPS.FRAGMENT_HASH, '#'); + this._resultStore[URL_RE_GROUPS.FRAGMENT] = fragment; }, + + /** + @method getBaseUrl + @return {String} Utility method, returns the url up until before the query. + **/ + getBaseUrl: function(){ + return this._resultStore.slice(1, URL_RE_GROUPS.QUERY).join(""); + } + }); + return url; +}); +}, +'sbt/connections/FollowService':function(){ +/* + * © 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. + */ + +/** + *The following resources are enabled for these applications: + + *Activities + *You can follow any public activity. To follow a private activity, you must be a member of the activity. + *Blogs + *You can follow any stand-alone blog; you cannot follow community blogs. + *Communities + *You do not have to be a member to follow public or moderated communities. You must be a member to follow private communities. + *Files + *You can follow any public file or file folders. You can only follow private files and file folders that have been shared with you. + *Forums + *You can follow any public forum or forum topic. You can only follow private forums if you are a member or owner of the forum. + *News repository + *You can follow any tag. + *Profiles + *You can follow any profile. + *Wikis + *You can follow any public wiki or wiki page. You must be a reader, editor, or owner of a private wiki before you can follow it or one of its pages. + * + * @module sbt.connections.FollowService + */ +define( + [ "../declare", "../config", "../lang", "../stringUtil", "../Promise", + "./FollowConstants", "./ConnectionsService", + "../base/AtomEntity", "../base/XmlDataHandler" ], + function(declare, config, lang, stringUtil, Promise, consts, + ConnectionsService, AtomEntity, XmlDataHandler) { + + var SourceTmpl = ""; + var ResourceTypeTmpl = ""; + var ResourceIdTmpl = ""; + + /** + * FollowedResource class represents an entry for a resource followed by logged in user. + * + * @class FollowedResource + * @namespace sbt.connections + */ + var FollowedResource = declare(AtomEntity, { + + xpath : consts.FollowedResourceXPath, + + /** + * Construct a FollowedResource entity. + * + * @constructor + * @param args + */ + constructor : function(args) { + }, + + /** + * Return extra entry data to be included in post data for this entity. + * + * @returns {String} + */ + createEntryData : function() { + var postData = ""; + var transformer = function(value,key) { + return value; + }; + postData += stringUtil.transform(SourceTmpl, this, transformer, this); + postData += stringUtil.transform(ResourceTypeTmpl, this, transformer, this); + if (this.getResourceId()) { + postData += stringUtil.transform(ResourceIdTmpl, this, transformer, this); + } + return stringUtil.trim(postData); + }, + + /** + * Return the value of IBM Connections followed resource ID from + * resource ATOM entry document. + * + * @method getFollowedResourceUuid + * @return {String} Resource ID + */ + getFollowedResourceUuid : function() { + var followedResourceUuid = this.getAsString("followedResourceUuid"); + return extractFollowedResourceUuid(followedResourceUuid); + }, + + /** + * Sets id of IBM Connections followed resource. + * + * @method setFollowedResourceUuid + * @param {String} followedResourceUuid Id of the followed resource + */ + setFollowedResourceUuid : function(followedResourceUuid) { + return this.setAsString("followedResourceUuid", followedResourceUuid); + }, + + /** + * Return the value of IBM Connections followed resource's service name + * + * @method getSource + * @return {String} Followed resource's service name + */ + getSource : function() { + return this.getAsString("source"); + }, + + /** + * Sets IBM Connections followed resource's service name. + * + * @method setSource + * @param {String} + * Source service name of the followed resource + */ + setSource : function(source) { + return this.setAsString("source", source); + }, + + /** + * Return the value of IBM Connections followed resource's resourceType + * + * @method getResourceType + * @return {String} Followed resource's resource type + */ + getResourceType : function() { + return this.getAsString("resourceType"); + }, - /** - * Create a blog by sending an Atom entry document containing the - * new blog. - * - * @method createBlog - * @param {String/Object} blogOrJson Blog object which denotes the blog to be created. - * @param {Object} [args] Argument object - */ - createBlog : function(blogOrJson,args) { - var blog = this._toBlog(blogOrJson); - var promise = this._validateBlog(blog, false, args); - if (promise) { - return promise; - } + /** + * Sets IBM Connections followed resource's resource type. + * + * @method setResourceType + * @param {String} + * resourceType of the followed resource + */ + setResourceType : function(resourceType) { + return this.setAsString("resourceType", resourceType); + }, - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - if (data) { - var dataHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BlogXPath - }); - blog.setDataHandler(dataHandler); - } - blog.setData(data); - return blog; - }; + /** + * Return the value of IBM Connections followed resource's resourceId + * + * @method getResourceId + * @return {String} Followed resource's resource Id + */ + getResourceId : function() { + return this.getAsString("resourceId"); + }, - var options = { - method : "POST", - query : args || {}, - headers : consts.AtomXmlHeaders, - data : this._constructBlogPostData(blog) - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogCreate); - return this.updateEntity(url, options, callbacks, args); - }, + /** + * Sets IBM Connections followed resource's resourceId. + * + * @method setResourceType + * @param {String} + * resource id of the followed resource + */ + setResourceId : function(resourceId) { + return this.setAsString("resourceId", resourceId); + }, - /** - * Update a blog by sending a replacement blog entry document - * to the existing blog's edit web address. - * All existing blog entry information will be replaced with the new data. To avoid - * deleting all existing data, retrieve any data you want to retain first, and send it back - * with this request. For example, if you want to add a new tag to a blog entry, retrieve - * the existing tags, and send them all back with the new tag in the update request. - * - * @method updateBlog - * @param {String/Object} blogOrJson Blog object - * @param {Object} [args] Argument object - */ - updateBlog : function(blogOrJson,args) { - var blog = this._toBlog(blogOrJson); - var promise = this._validateBlog(blog, true, args); - if (promise) { - return promise; - } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - var blogUuid = blog.getBlogUuid(); - if (data) { - var dataHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BlogXPath - }); - blog.setDataHandler(dataHandler); - } - blog.setBlogUuid(blogUuid); - return blog; - }; + /** + * Return the value of IBM Connections followed resource's type + * + * @method getType + * @return {String} Followed resource's resource type + */ + getType : function() { + return this.getAsString("categoryType"); + }, - var requestArgs = lang.mixin({}, args || {}); - - var options = { - method : "PUT", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : this._constructBlogPostData(blog) - }; - var blogUuid = blog.getBlogUuid(); - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogEditDelete, { - blogUuid : blogUuid - }); - return this.updateEntity(url, options, callbacks, args); - }, + /** + * Sets IBM Connections followed resource's resource type. + * + * @method setCategoryResourceType + * @param {String} + * type of the followed resource + */ + setCategoryType : function(categoryType) { + return this.setAsString("categoryType", categoryType); + }, - /** - * Delete a blog, use the HTTP DELETE method. - * - * @method deleteBlog - * @param {String} blogUuid blog id of the blog or the blog object (of the blog to be deleted) - * @param {Object} [args] Argument object - */ - deleteBlog : function(blogUuid,args) { - var promise = this._validateBlogUuid(blogUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({}, args || {}); - - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogEditDelete, { - blogUuid : blogUuid - }); - return this.deleteEntity(url, options, blogUuid); - }, - - /** - * Retrieve a blog post instance. - * - * @method getBlogPost - * @param {String} blogPostUuid blog post id - * @param {Object} args Object containing the query arguments to be - * sent (defined in IBM Connections Blogs REST API) - */ - getBlogPost : function(blogPostUuid, args) { - var blogPost = new BlogPost({ - service : this, - _fields : { postUuid : blogPostUuid } - }); - return blogPost.load(args); - }, + /** + * Start following + * + * @method startFollowing + * @param {Object} [args] Argument object + */ + startFollowing : function(args) { + return this.service.startFollowing(this, args); + }, + + /** + * Stop following + * + * @method stopFollowing + * @param {Object} [args] Argument object + */ + stopFollowing : function(args) { + return this.service.stopFollowing(this, args); + } - /** - * Retrieve a list of comments for the specified entry in the specified blog. - * - * @method getEntryComments - * @param {String} blogHandle blog handle - * @param {String} entryAnchor entry anchor - * @param {Object} args Object containing the query arguments to be - * sent (defined in IBM Connections Blogs REST API) - */ - getEntryComments : function(blogHandle, entryAnchor, args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this.constructUrl(consts.AtomBlogEntryComments, null, { - blogHandle : blogHandle, - entryAnchor : entryAnchor }); - return this.getEntities(url, options, this.getBlogPostCommentsCallbacks()); - }, + + /* + * Callbacks used when reading a feed that contains followed resource entries. + */ + var FollowResourceFeedCallbacks = { + createEntities : function(service,data,response) { + return new XmlDataHandler({ + service : service, + data : data, + namespaces : consts.Namespaces, + xpath : consts.FollowedResourceFeedXPath + }); + }, + createEntity : function(service,data,response) { + return new FollowedResource({ + service : service, + data : data + }); + } + }; + + /* + * Method used to extract the community uuid for an id url. + */ + var extractFollowedResourceUuid = function(followedResourceUuid) { + var followedResourceUuidPrefix = "urn:lsid:ibm.com:follow:resource-"; + if(followedResourceUuid && followedResourceUuid.indexOf(followedResourceUuidPrefix) != -1){ + followedResourceUuid = followedResourceUuid.substring(followedResourceUuidPrefix.length, followedResourceUuid.length); + } + return followedResourceUuid; + }; - /** - * Create a blog post by sending an Atom entry document containing the - * new blog post. - * - * @method createPost - * @param {String/Object} postOrJson Blog post object which denotes the blog post to be created. - * @param {Object} [args] Argument object - */ - createPost : function(postOrJson, args) { - var post = this._toBlogPost(postOrJson); - var promise = this._validateBlog(post, false, args); - if (promise) { - return promise; - } + /** + * FollowService class. + * + * @class FollowService + * @namespace sbt.connections + */ + var FollowService = declare( + ConnectionsService, + { + contextRootMap : { + activities : "activities", + blogs : "blogs", + communities : "communities", + files : "files", + forums : "forums", + news : "news", + profiles : "profiles", + wikis : "wikis" + }, + + serviceName : "connections", - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - if (data) { - var dataHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BlogPostXPath - }); - post.setDataHandler(dataHandler); - } - post.setData(data); - return post; - }; + /** + * Constructor for FollowService + * + * @constructor + * @param args + */ + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this + .getDefaultEndpointName()); + } + }, + + /** + * Get the followed resources feed + * + * @method getFollowedResources + * @param {String} source String specifying the resource. + * @param {String} resourceType String representing the resource type. + * @param {Object} [args] Addtional request arguments supported by Connections REST API. + */ + getFollowedResources : function(source, resourceType, args) { + var requestArgs = lang.mixin({ + source : source, + type : resourceType + }, args || {}); + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + var url = null; + url = this.constructUrl(consts.AtomFollowAPI, null, { + service : this._getServiceName(source) + }); + return this.getEntities(url, options, this._getFollowedResourceFeedCallbacks()); + }, + + /** + * Get the followed resource + * + * @method getFollowedResource + * @param {String/Object} followedResource + * @param {Object} [args] Object representing various parameters if any + */ + getFollowedResource : function(followedResourceOrJson, args) { + var followedResource = this._toFollowedResource(followedResourceOrJson); + var promise = this._validateFollowedResource(followedResource, false, args); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ + source : followedResource.getSource(), + type : followedResource.getResourceType(), + resource : followedResource.getResourceId() + }, args || {}); + + var options = { + method : "GET", + handleAs : "text", + query : requestArgs + }; + + var callbacks = { + createEntity : function(service,data,response) { + followedResource.xpath = consts.OneFollowedResourceXPath; + followedResource.setData(data); + return followedResource; + } + }; + + var url = null; + url = this.constructUrl(consts.AtomFollowAPI, null, { + service : this._getServiceName(followedResource.getSource()) + }); + return this.getEntity(url, options, followedResource.getResourceId(), callbacks); + }, + + /** + * Start Following a resource + * + * @method startFollowing + * @param {String/Object} followedResource + * @param {Object} [args] Object representing various parameters if any + */ + startFollowing : function(followedResourceOrJson, args) { + var followedResource = this._toFollowedResource(followedResourceOrJson); + var promise = this._validateFollowedResource(followedResource, false, args); + if (promise) { + return promise; + } + + var options = { + method : "POST", + headers : consts.AtomXmlHeaders, + data : followedResource.createPostData() + }; + + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + followedResource.setData(data); + return followedResource; + }; + + var url = null; + url = this.constructUrl(consts.AtomFollowAPI, null, { + service : this._getServiceName(followedResource.getSource()) + }); + + return this.updateEntity(url, options, callbacks); + }, + + /** + * Stop Following a resource + * + * @method stopFollowing + * @param {String/Object} followedResource + * @param {Object} [args] Object representing various parameters if any + */ + stopFollowing : function(followedResourceOrJson, args) { + var followedResource = this._toFollowedResource(followedResourceOrJson); + var promise = this._validateFollowedResource(followedResource, true); + if (promise) { + return promise; + } + + var requestArgs = lang.mixin({ + source : followedResource.getSource(), + type : followedResource.getResourceType(), + resource : followedResource.getResourceId() + }, args || {}); + + var options = { + method : "DELETE", + headers : consts.AtomXmlHeaders, + query : requestArgs + }; + + var url = this.constructUrl(consts.AtomStopFollowAPI, null, { + service : this._getServiceName(followedResource.getSource()), + resourceId : followedResource.getFollowedResourceUuid() + }); + return this.deleteEntity(url, options, followedResource.getResourceId()); + }, + + /** + * Create a FollowedResource object with the specified data. + * + * @method newFollowedResource + * @param {Object} args Object containing the fields for the + * new blog + */ + newFollowedResource : function(args) { + return this._toFollowedResource(args); + }, + + /* + * Callbacks used when reading a feed that contains + * followed resource entries. + */ + _getFollowedResourceFeedCallbacks : function() { + return FollowResourceFeedCallbacks; + }, + + /* + * Validate a blog, and return a Promise if invalid. + */ + _validateFollowedResource : function(followedResource, checkUuid) { + if (!followedResource || !followedResource.getSource()) { + return this.createBadRequestPromise("Invalid argument, resource with source must be specified."); + } + if (!followedResource.getResourceType()) { + return this.createBadRequestPromise("Invalid argument, resource with resource yype must be specified."); + } + if (!followedResource.getResourceId()) { + return this.createBadRequestPromise("Invalid argument, resource with resource id must be specified."); + } + if (checkUuid && !followedResource.getFollowedResourceUuid()) { + return this.createBadRequestPromise("Invalid argument, resource with UUID must be specified."); + } + }, + + /* + * Validate a followedResource UUID, and return a Promise if invalid. + */ + _validateFollowedResourceUuid : function(followedResourceUuid) { + if (!followedResourceUuid || followedResourceUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected followedResourceUuid."); + } + }, + + /* + * Return a Followed Resource instance from FollowedResource or JSON or String. Throws + * an error if the argument was neither. + */ + _toFollowedResource : function(followedResourceOrJsonOrString) { + if (followedResourceOrJsonOrString instanceof FollowedResource) { + return followedResourceOrJsonOrString; + } else { + if (lang.isString(followedResourceOrJsonOrString)) { + followedResourceOrJsonOrString = { + followedResourceUuid : followedResourceOrJsonOrString + }; + } + return new FollowedResource({ + service : this, + _fields : lang.mixin({}, followedResourceOrJsonOrString) + }); + } + }, + + /* + * Return a Followed Resource instance from FollowedResource or JSON or String. Throws + * an error if the argument was neither. + */ + _getServiceName : function(source) { + var contextRoot = this.contextRootMap; + for (var key in contextRoot) { + if(source == key){ + return contextRoot[key]; + } + } + return ""; + } + }); + return FollowService; + }); +}, +'sbt/GadgetTransport':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - var options = { - method : "POST", - query : args || {}, - headers : consts.AtomXmlHeaders, - data : this._constructBlogPostPostData(post) - }; - var url = null; - url = this.constructUrl(consts.AtomBlogPostCreate, null, { - blogHandle : postOrJson.getBlogHandle() - }); - return this.updateEntity(url, options, callbacks, args); +/** + * Implements a transport for when the SDK is used from a gadget. + * @module + */ +define(['./declare','./lang'],function(declare,lang) { + var MethodTypes = { + 'POST': gadgets.io.MethodType.POST, + 'PUT': gadgets.io.MethodType.PUT, + 'DELETE': gadgets.io.MethodType.DELETE, + 'GET': gadgets.io.MethodType.GET + }; + var ContentTypes = { + 'XML': gadgets.io.ContentType.DOM, + 'JSON': gadgets.io.ContentType.JSON, + 'TEXT': gadgets.io.ContentType.TEXT, + 'JSON-COMMENT-OPTIONAL': gadgets.io.ContentType.JSON, + 'JSON-COMMENT-FILTERED': gadgets.io.ContentType.JSON, + 'JAVASCRIPT': gadgets.io.ContentType.JSON + }; + var AuthorizationTypes = { + 'NONE': gadgets.io.AuthorizationType.NONE, + 'OAUTH': gadgets.io.AuthorizationType.OAUTH, + 'OAUTH2': gadgets.io.AuthorizationType.OAUTH2, + 'SIGNED': gadgets.io.AuthorizationType.SIGNED + }; + return declare(null, { + serviceName: null, + constructor: function(args) { + this.serviceName = args.serviceName || null; }, - /** - * Update a post by sending a replacement post entry document - * to the existing post's edit web address. - * All existing post entry information will be replaced with the new data. To avoid - * deleting all existing data, retrieve any data you want to retain first, and send it back - * with this request. For example, if you want to add a new tag to a post entry, retrieve - * the existing tags, and send them all back with the new tag in the update request. - * - * @method updateBost - * @param {String/Object} BlogPost object - * @param {Object} [args] Argument object + * Performs an XHR request using the gadget APIs. + * Warning this is not a final module. Not everything is supported as of yet. + * @param {String} method The HTTP method to use. + * @param {Object} args The arguments for the XHR request. + * @param {boolean} hasBody Indicates whether there is a request body. */ - updatePost : function(postOrJson, args) { - var post = this._toBlogPost(postOrJson); - var promise = this._validateBlogPost(post, true, args); - if (promise) { - return promise; + xhr: function(method,args,hasBody) { + //TODO OAuth support + if(args.sync) { + throw new Error('Gadget transport does not support synchronous requests.'); } - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - var postUuid = post.getBlogPostUuid(); - if (data) { - var dataHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.BlogPostXPath - }); - post.setDataHandler(dataHandler); - } - post.setBlogPostUuid(postUuid); - return post; - }; - - var requestArgs = lang.mixin({}, args || {}); - - var options = { - method : "PUT", - query : requestArgs, - headers : consts.AtomXmlHeaders, - data : this._constructBlogPostPostData(post) - }; - var url = null; - url = this.constructUrl(consts.AtomBlogPostEditDelete, null, { - postUuid : post.getBlogPostUuid(), - blogHandle : post.getBlogHandle() - }); - return this.updateEntity(url, options, callbacks, args); - }, - - /** - * Recommend a post - * - * @method recommendPost - * @param {String/Object} BlogPost object - * @param {String} blogHandle Id of post - */ - recommendPost : function(blogPost) { - var post = this._toBlogPost(blogPost); - var promise = this._validateBlogPost(post); - if (promise) { - return promise; + var params = {}; + params[gadgets.io.RequestParameters.METHOD] = MethodTypes[method.toUpperCase()] || gadgets.io.MethodType.GET; + params[gadgets.io.RequestParameters.CONTENT_TYPE] = ContentTypes[args.handleAs ? args.handleAs.toUpperCase() : 'TEXT']; + params[gadgets.io.RequestParameters.HEADERS] = args.headers || {}; + params[gadgets.io.RequestParameters.POST_DATA] = this.getPostData(params[gadgets.io.RequestParameters.METHOD], args.postData || args.putData); + if(args.preventCache) { + params[gadgets.io.RequestParameters.REFRESH_INTERVAL] = 0; } - var options = { - method : "POST", - headers : consts.AtomXmlHeaders - }; - var url = null; - url = this.constructUrl(consts.AtomRecommendBlogPost, null, { - postUuid : post.getBlogPostUuid(), - blogHandle : post.getBlogHandle() - }); - - return this.updateEntity(url, options, this.getRecommendBlogPostCallbacks()); - }, - - /** - * Unrecommend a post - * - * @method unRecommendPost - * @param {String/Object} blogPost object - * @param {String} blogHandle Id of post - */ - unrecommendPost : function(blogPost) { - var post = this._toBlogPost(blogPost); - var promise = this._validateBlogPost(post); - if (promise) { - return promise; + if(this.serviceName || args.serviceName) { + params[gadgets.io.RequestParameters.OAUTH_SERVICE_NAME] = this.serviceName || args.serviceName; + } + if(args.authType) { + var authorization = args.authType.toUpperCase(); + params[gadgets.io.RequestParameters.AUTHORIZATION] = AuthorizationTypes[authorization] || AuthorizationTypes['NONE']; } - var options = { - method : "DELETE", - headers : consts.AtomXmlHeaders - }; - var url = null; - url = this.constructUrl(consts.AtomRecommendBlogPost, null, { - postUuid : post.getBlogPostUuid(), - blogHandle : post.getBlogHandle() - }); - return this.deleteEntity(url, options, blogPost.getBlogPostUuid()); - }, - - /** - * Delete a blog post, use the HTTP DELETE method. - * - * @method deletePost - * @param {String/Object} blogHandle handle of the blog(of which the post is to be deleted) - * @param {String/Object} postUuid post id of the blog post(of the blog post to be deleted) - * @param {Object} [args] Argument object - */ - deletePost : function(blogHandle, postUuid, args) { - var promise = this._validateUuid(postUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({}, args || {}); - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" + var self = this; + var callback = function(response) { + self.handleResponse(args, response); }; - var url = null; - url = this.constructUrl(consts.AtomBlogPostEditDelete, null, { - blogHandle : blogHandle, - postUuid : postUuid - }); - return this.deleteEntity(url, options, postUuid); - }, - - /** - * Delete a blog comment, use the HTTP DELETE method. - * - * @method deleteComment - * @param {String/Object} blogHandle handle of the blog(of which the post is to be deleted) - * @param {String/Object} comment id of the blog comment(of the blog comment to be deleted) - * @param {Object} [args] Argument object - */ - deleteComment : function(blogHandle, commentUuid, args) { - var promise = this._validateUuid(commentUuid); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({}, args || {}); - var options = { - method : "DELETE", - query : requestArgs, - handleAs : "text" - }; - var url = null; - url = this.constructUrl(consts.AtomBlogCommentEditRemove, null, { - blogHandle : blogHandle, - commentUuid : commentUuid - }); - return this.deleteEntity(url, options, commentUuid); + var url = this.buildUrl(args); + gadgets.io.makeRequest(url, callback, params); }, - - /** - * Create a comment post by sending an Atom entry document containing the - * new blog comment. - * - * @method createComment - * @param {String/Object} commentOrJson Blog comment object. - * @param {Object} [args] Argument object - */ - createComment : function(commentOrJson, args) { - var comment = this._toComment(commentOrJson); - var promise = this._validateComment(comment); - if (promise) { - return promise; + handleResponse: function(args, response) { + if(response.errors && response.errors.length > 0) { + if (args.error || args.handle) { + var error = this.createError(response); + this.notifyError(args, error); + } + } else { + if (response.oauthApprovalUrl) { + this.handleApproval(args, response); + } else { + this.notifyResponse(args, response); + } } - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - if (data) { - var dataHandler = new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.CommentXPath - }); - comment.setDataHandler(dataHandler); - } - comment.setData(data); - return comment; - }; - - var options = { - method : "POST", - query : args || {}, - headers : consts.AtomXmlHeaders, - data : this._constructCommentBlogPostData(comment) - }; - var url = null; - url = this.constructUrl(consts.AtomBlogCommentCreate, null, { - blogHandle : commentOrJson.getBlogHandle(), - postUuid : commentOrJson.getPostUuid() - }); - return this.updateEntity(url, options, callbacks, args); - }, - - /** - * Retrieve a blog comment, use the edit link for the blog entry - * which can be found in the my blogs feed. - * - * @method getComment - * @param {String } blogHandle - * @param {String } commentUuid - * @param {Object} args Object containing the query arguments to be - * sent (defined in IBM Connections Blogs REST API) - */ - getComment : function(blogHandle, commentUuid, args) { - var comment = new Comment({ - service : this, - _fields : { commentUuid : commentUuid } - }); - return comment.load(blogHandle, commentUuid, args); - }, - - /** - * Get the tags feed to see a list of the tags for all blogs. - * - * @method getAllBlogTags - * @param {Object} [args] Object representing various parameters. - * The parameters must be exactly as they are supported by IBM - * Connections. - */ - getAllBlogTags : function(args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this._constructBlogsUrl(consts.AtomBlogsTags); - return this.getEntities(url, options, this.getTagsFeedCallbacks(), args); - }, - - /** - * Get the tags feed to see a list of the tags for a perticular blog. - * - * @method getBlogTags - * @param {String} blogHandle handle of the blog - * @param {Object} [args] Object representing various parameters - * that can be passed to get a feed of blog tags. The - * parameters must be exactly as they are supported by IBM - * Connections. - */ - getBlogTags : function(blogHandle, args) { - var options = { - method : "GET", - handleAs : "text", - query : args || {} - }; - var url = null; - url = this.constructUrl(consts.AtomBlogTags, null, { - blogHandle : blogHandle - }); - return this.getEntities(url, options, this.getTagsFeedCallbacks(), args); }, - - /** - * Create a Blog object with the specified data. - * - * @method newBlog - * @param {Object} args Object containing the fields for the - * new blog - */ - newBlog : function(args) { - return this._toBlog(args); + handleApproval: function(args, response) { + var error = new Error(); + error.code = 401; + error.response = lang.mixin({}, response); + this.notifyError(args, error); }, - - /** - * Create a Blog Post object with the specified data. - * - * @method newBlogPost - * @param {Object} args Object containing the fields for the - * new post - */ - newBlogPost : function(args) { - return this._toBlogPost(args); + notifyResponse: function(args, response) { + if (args.load || args.handle) { + var ioArgs = { + 'args' : args, + 'headers' : response.headers, + '_ioargs' : response + }; + if (args.handle) { + args.handle(response.data || response.text, ioArgs); + } + if (args.load) { + args.load(response.data || response.text, ioArgs); + } + } }, - - /** - * Create a Blog Post comment object with the specified data. - * - * @method newComment - * @param {Object} args Object containing the fields for the - * new comment - */ - newComment : function(args) { - return this._toComment(args); + notifyError: function(args, error) { + if (args.handle) { + args.handle(error); + } + if (args.error) { + args.error(error); + } }, - - /* - * Callbacks used when reading a feed that contains Blog entries. - */ - getBlogFeedCallbacks: function() { - return ConnectionsBlogFeedCallbacks; + createError: function(response) { + var error = new Error(); + error.code = response.rc; + error.message = response.errors[0]; + error.response = lang.mixin({}, response); + return error; }, - - /* - * Callbacks used when reading a feed that contains Blog entries. - */ - getTagsFeedCallbacks: function() { - return ConnectionsTagsFeedCallbacks; + getPostData: function(method, postData) { + if (method == gadgets.io.MethodType.POST || + method == gadgets.io.MethodType.PUT) { + return postData; + } + return ''; }, + buildUrl: function(args) { + var params = []; + var url = args.url; + if (args.content) { + for (name in args.content) { + var param = encodeURIComponent(name) + "=" + encodeURIComponent(args.content[name]); + params.push(param); + } + if (params.length > 0) { + var query = params.join("&"); + url += (~url.indexOf('?') ? '&' : '?') + query; + } + } + return url; + } + }); +}); +}, +'url:sbt/connections/controls/forums/templates/BootstrapTopicRow.html':"\r\n\t\r\n\t\t\r\n\r\n\t\t\r\n\t\t\t${title}\r\n\t\t\r\n\t\r\n", +'sbt/_bridge/ready':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK - ready() function. + */ +define(['dojo/ready'],function(ready) { + return function(fct) { + ready(fct); + }; +}); +}, +'url:sbt/connections/controls/files/templates/CommentRow.html':"\r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \"\"\r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n ${commentEditedLabel}\r\n \r\n \r\n \t\t\t\t\t\t\t${authorName}\r\n \t\t\t\t\t\t\t${authorUserId}\r\n \t\t\t\t\t\t\t\r\n \t\t\t\t\t\t\t\r\n ${_nls.commented} ${createdLabel}\r\n \r\n
    \r\n
    \r\n
    \r\n ${formattedContent}
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n", +'sbt/connections/controls/ViewAllAction':function(){ +/* + * © 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. + */ + +/** + * @module sbt.connections.controls.ViewAllAction + */ +define([ "../../declare", "../../controls/grid/GridAction" ], + function(declare, GridAction) { + + /** + * @class sbt.connections.controls.ViewAllAction + * @namespace sbt.connections.controls + */ + var ViewAllAction = declare(GridAction, { - /* - * Callbacks used when reading a feed that contains Blog entries. - */ - getRecommendBlogPostCallbacks: function() { - return RecommendBlogPostCallbacks; + /**Strings used in the actions */ + nls: { + tooltip: "View All" }, - /* - * Callbacks used when reading a feed that contains Blog entries. - */ - getBlogPostsCallbacks: function() { - return ConnectionsBlogPostsCallbacks; + /**ViewAllAction Constructor function + * @method - constructor + * */ + constructor: function() { }, - /* - * Callbacks used when reading a feed that contains Blog entries. + /** + * Handles displaying a tooltip for an item + * For profiles, the tooltip by default will be a business card + * So nothing is done in this function + * @method - getTooltip + * @param item - The element that will use the tooltip */ - getBlogPostRecommendersCallbacks: function() { - return ConnectionsBlogPostRecommendersCallbacks; + getTooltip: function(item) { + return "derp"; }, - /* - * Callbacks used when reading a feed that contains Blog post comments. + /** + * The execute function is called from the handle click function + * For Profiles by default the business card functionality is used + * which works from the Semantic tag service so nothing is done here. + * @method - execute + * @param item - The item which fired the event + * @param opts + * @param event - The event */ - getBlogPostCommentsCallbacks: function() { - return ConnectionsBlogPostCommentsCallbacks; - }, + execute: function(item, opts, event) { + opts.grid.renderer.hideViewAll = true; + opts.grid.renderer.template = opts.grid.renderer.fullTemplate; + opts.grid.renderer.render(opts.grid, opts.grid.gridNode, item.items, item); + console.log("clicked the view all link"); + } + + }); + + return ViewAllAction; +}); +}, +'url:sbt/connections/controls/files/templates/RecycledFileRow.html':"\r\n \r\n \"\"\r\n \r\n \r\n

    \r\n \r\n ${title}\r\n \r\n

    \r\n \r\n \r\n \r\n \r\n \r\n ${modifiedLabel}\r\n \r\n \r\n ${fileSize}\r\n \r\n \r\n \r\n ${title}\r\n \r\n", +'sbt/pathUtil':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK - URL utilities + */ +define(['./stringUtil'],function(stringUtil) { + return { + concat: function(path1,path2) { + if(!path1) { + return path2; + } + if(!path2) { + return path1; + } + if(stringUtil.endsWith(path1,"/")) { + path1 = path1.substring(0,path1.length-1); + } + if(stringUtil.startsWith(path2,"/")) { + path2 = path2.substring(1); + } + return path1 + "/" + path2; + }, + isAbsolute: function(url) { + return url.indexOf("://")>=0; + } + } +}); +}, +'url:sbt/controls/grid/templates/GridSorter.html':"
    \r\n\t
      \r\n\t\t
    • ${nls.sortBy}
    • \r\n\t\t${sortAnchors}\r\n\t
    \r\n
    \r\n", +'url:sbt/connections/controls/bookmarks/templates/BookmarkListItem.html':"
  • \r\n\t

    ${title}

    \r\n
  • ", +'sbt/connections/controls/profiles/nls/ColleagueGridRenderer':function(){ +/* + * © 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. + */ + +// NLS_CHARSET=UTF-8 +define({ + root: { + viewAll : "View All ({totalCount})", + empty : "No colleagues in the list.", + people: "{totalCount} people", + person: "{totalCount} person" + } +}); + + +}, +'url:sbt/connections/controls/bootstrap/templates/TagAnchor.html':"${tagName}", +'url:sbt/connections/controls/search/templates/span.html':"${content}", +'sbt/_bridge/text':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK. + */ +define([ "dojo/text" ], function(text) { + var load = function(id,require,load) { + text.load(id, require, load); + }; + return { + load : load + }; +}); + +}, +'sbt/_bridge/i18n':function(){ +/* + * © 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. + */ + +/** + * Social Business Toolkit SDK. + */ +define(['dojo/i18n'],function(i18n) { + return i18n; +}); + + + +}, +'sbt/_bridge/Transport':function(){ +/* + * © Copyright IBM Corp. 2014 + * + * 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. + */ + +/** + * Social Business Toolkit SDK. + * + * Implementation of a transport using the Dojo XHR API. + */ +define([ 'dojo/_base/declare', 'dojo/_base/xhr', 'dojo/_base/lang', '../util', '../Promise' ], function(declare, xhr, lang, util, Promise) { + return declare(null, { - /* - * Return a Blog instance from Blog or JSON or String. Throws - * an error if the argument was neither. + /** + * Provides an asynchronous request using the associated Transport. + * + * @method request + * @param {String) + * url The URL the request should be made to. + * @param {Object} + * [options] Optional A hash of any options for the provider. + * @param {String|Object} + * [options.data=null] Data, if any, that should be sent with + * the request. + * @param {String|Object} + * [options.query=null] The query string, if any, that should + * be sent with the request. + * @param {Object} + * [options.headers=null] The headers, if any, that should + * be sent with the request. + * @param {Boolean} + * [options.preventCache=false] If true will send an extra + * query parameter to ensure the the server won©t supply + * cached values. + * @param {String} + * [options.method=GET] The HTTP method that should be used + * to send the request. + * @param {Integer} + * [options.timeout=null] The number of milliseconds to wait + * for the response. If this time passes the request is + * canceled and the promise rejected. + * @param {String} + * [options.handleAs=text] The content handler to process the + * response payload with. + * @return {sbt.Promise} */ - _toBlog : function(blogOrJsonOrString) { - if (blogOrJsonOrString instanceof Blog) { - return blogOrJsonOrString; - } else { - if (lang.isString(blogOrJsonOrString)) { - blogOrJsonOrString = { - blogUuid : blogOrJsonOrString - }; - } - return new Blog({ - service : this, - _fields : lang.mixin({}, blogOrJsonOrString) - }); + request : function(url, options) { + var method = options.method || "GET"; + method = method.toUpperCase(); + var query = this.createQuery(options.query); + var qurl = url; + if(qurl && query){ + qurl += (~qurl.indexOf('?') ? '&' : '?') + query; + } + var args = { + url : qurl, + handleAs : options.handleAs || "text" + }; + //if (options.query) { + // args.content = options.query; + //} + if (options.headers) { + args.headers = options.headers; + } + var hasBody = false; + if (method == "PUT") { + args.putData = options.data || null; + hasBody = true; + } else if (method == "POST") { + args.postData = options.data || null; + hasBody = true; + } else if(method == "GET") { // to ensure each time fresh feed is retrieved with network call + args.preventCache = true; } + + var promise = new Promise(); + promise.response = new Promise(); + var self = this; + args.handle = function(response, ioargs) { + if (response instanceof Error) { + var error = response; + error.response = self.createResponse(url, options, response, ioargs); + promise.rejected(error); + promise.response.rejected(error); + } else { + promise.fulfilled(response); + promise.response.fulfilled(self.createResponse(url, options, response, ioargs)); + } + }; + + this.xhr(method, args, hasBody); + return promise; }, /* - * Return a BlogPost instance from BlogPost or JSON or String. Throws - * an error if the argument was neither. + * Create a response object */ - _toBlogPost : function(postOrJsonOrString) { - if (postOrJsonOrString instanceof BlogPost) { - return postOrJsonOrString; - } else { - if (lang.isString(postOrJsonOrString)) { - postOrJsonOrString = { - postUuid : postOrJsonOrString - }; - } - return new BlogPost({ - service : this, - _fields : lang.mixin({}, postOrJsonOrString) - }); - } + createResponse: function(url, options, response, ioargs) { + var xhr = ioargs._ioargs.xhr; + var handleAs = options.handleAs || "text"; + return { + url : url, + options : options, + data : response, + text : (handleAs == "text") ? response : null, + status : xhr.status, + getHeader : function(headerName) { + return xhr.getResponseHeader(headerName); + }, + xhr : xhr, + _ioargs : ioargs._ioargs + }; }, - + /* - * Return a Comment instance from Comment or JSON or String. Throws - * an error if the argument was neither. + * Create a query string from an object */ - _toComment : function(commentOrJsonOrString) { - if (commentOrJsonOrString instanceof Comment) { - return commentOrJsonOrString; - } else { - if (lang.isString(commentOrJsonOrString)) { - commentOrJsonOrString = { - commentUuid : commentOrJsonOrString - }; + createQuery: function(queryMap) { + if (!queryMap) { + return null; + } + var pairs = []; + for(var name in queryMap){ + var value = queryMap[name]; + if (lang.isArray(value)) { + name = encodeURIComponent(name); + for (var i=0; i= 0 && emails.length > 1) { + var index = (emails.indexOf(id) == 0) ? 1 : 0; + return emails[index]; + } else if(userids.indexOf(id) >= 0 && userids.length > 1) { + var index = (userids.indexOf(id) == 0) ? 1 : 0; + return userids[index]; + } }, - /* - * Extract Blog handle from comment source url - */ - _constructBlogsUrl : function(url, urlParams) { - urlParams = lang.mixin({blogHomepageHandle : this.handle}, urlParams || {}); - return this.constructUrl(url, null, urlParams); + _selectArray : function(doc, expr) { + var nodes = xpath.selectNodes(doc, expr, conn.Namespaces); + var ret = []; + if (nodes) { + for ( var i = 0; i < nodes.length; i++) { + ret.push(stringUtil.trim(nodes[i].text || nodes[i].textContent)); + } + } + return ret; + }, + + _isEmail: function(id) { + return id && id.indexOf('@') >= 0; } }); - return BlogService; -}); + return ColleagueGrid; +}); }, -'sbt/store/parameter':function(){ +'url:sbt/connections/controls/forums/templates/ReplyHeader.html':"\r\n\t${nls.replies}\r\n\t${nls.topic}\r\n\t\r\n\t${nls.author}\r\n\t${nls.date}\r\n", +'sbt/connections/ActivityStreamService':function(){ /* * © Copyright IBM Corp. 2013 * @@ -42273,598 +42229,665 @@ define([ "../declare", "../config", "../lang", "../stringUtil", "../Promise", ". */ /** + * JavaScript API for IBM Connections Activity Stream Service. * + * @module sbt.connections.ActivityStreamService */ -define(["../stringUtil", "../config"], function(stringUtil, config) { - var Formatter = { - defaultFormat: function(param, val) { - return param.key + "=" + val; +define([ "../declare", "../lang", "../stringUtil", "../config", "../Promise", "./ActivityStreamConstants", "./ConnectionsService","../base/BaseEntity", "../base/DataHandler", 'sbt/json'], + function(declare,lang,stringUtil,config,Promise,consts,ConnectionsService, BaseEntity,DataHandler, json) { + + /** + * JsonDataHandler class + * + * @class JsonDataHandler + * @namespace sbt.base + */ + var ActivityStreamsDataHandler = declare(DataHandler, { + + constructor : function(args) { + lang.mixin(this, args); + this.data = args.data; + }, + + getSummary : function() { + if (!this._summary && this.data.totalResults) { + this._summary = { + totalResults : this.data.totalResults, + startIndex : this.data.startIndex, + itemsPerPage : this.data.itemsPerPage + }; + } + return this._summary; }, - sortField: function(vals) { - return function(param, val) { - var v = vals[val] || ""; - return param.key + "=" + v; + + getEntitiesDataArray : function() { + return this.data.list; + } + + }); + + + /** + * ActivityStreamEntry class. + * + * @class ActivityStreamEntry + * @namespace sbt.connections + */ + var ActivityStreamEntry = declare(BaseEntity, { + + data: null, + + /** + * Get published date of activity stream entry + * + * @method getPublishedDate + */ + getPublishedDate: function(){ + return this.dataHandler.data.published; + }, + + /** + * Get plain title of the activity stream entry. this represents the action that was done by actor + * + * @method getPlainTitle + */ + getPlainTitle: function(){ + return this.dataHandler.data.connections.plainTitle; + }, + + /** + * Get actor name of the activity stream entry + * + * @method getActorDisplayName + */ + getActorDisplayName: function(){ + return this.dataHandler.data.actor.displayName; + }, + + /** + * Get full actor object of the activity stream entry. Object holds all properties of actor. + Here is an example of an actor object: + { + connections:{ + state:"active" + }, + objectType:"person", + id:"urn:lsid:lconn.ibm.com:profiles.person:0EE5A7FA-3434-9A59-4825-7A7000278DAA", + displayName:"Frank Adams" + } + * + * @method getActor + */ + getActor: function(){ + return this.dataHandler.data.actor; + }, + + /** + * Get verb of activity stream entry, verb represents the type of action that was done + * + * @method getVerb + */ + getVerb: function(){ + return this.dataHandler.data.verb; + }, + + /** + * Get id of activity stream entry + * + * @method getId + */ + getId: function(){ + return this.dataHandler.data.id; + } + + + }); + + /** + * Callbacks used when reading a feed that contains ActivityStream entries. + */ + var getActivityStreamServiceCallbacks = { + createEntities : function(service,data,response) { + return new ActivityStreamsDataHandler({ + data : data + }); + }, + createEntity : function(service,data,response) { + var entryHandler = new ActivityStreamsDataHandler({ + data : data + }); + return new ActivityStreamEntry({ + service : service, + dataHandler : entryHandler + }); + } + }; + + /** + * ActivityStreamService class. + * + * @class ActivityStreamService + * @namespace sbt.connections + */ + var ActivityStreamService = declare(ConnectionsService, { + + contextRootMap: { + connections: "connections" + }, + + serviceName : "connections", + + /** + * Constructor for ActivityStreamService + * + * @constructor + * @param args + */ + constructor : function(args) { + if (!this.endpoint) { + this.endpoint = config.findEndpoint(this.getDefaultEndpointName()); + } + }, + + /** + * Callbacks used when reading a feed that contains Activity Stream entries. + */ + getActivityStreamCallbacks: function() { + return getActivityStreamServiceCallbacks; + }, + + /** + * Get activity stream for given user, group and application type + * + * @method getStream + * @param {String} [userType] user type for which activity stream is to be obtained. + * If null is passed for userType, then '@public' will be used as + * default + * @param {String} [groupType] group type for which activity stream is to be obtained + * If null is passed for userType, then '@all' will be used as + * default + * @param {String} [applicationType] application type for which activity stream is to be obtained + * If null is passed for userType, then '@all' will be used as + * default + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getStream : function(userType, groupType, applicationType, args) { + var _userType = userType || consts.ASUser.PUBLIC; //Default is public updates + var _groupType = groupType || consts.ASGroup.ALL; // Default is all groups + var _applicationType = applicationType || consts.ASApplication.STATUS; // Default is all Applications +// var url = consts.ActivityStreamUrls.activityStreamBaseUrl+this.endpoint.authType+consts.ActivityStreamUrls.activityStreamRestUrl+_userType+"/"+_groupType+"/"+_applicationType; + var url = this.constructUrl(consts.ActivityStreamUrls.activityStreamBaseUrl+"{authType}"+consts.ActivityStreamUrls.activityStreamRestUrl+"{userType}/{groupType}/{appType}", + {}, + { authType : (this.endpoint.authType == "sso") ? "":this.endpoint.authType, userType : _userType, groupType : _groupType, appType : _applicationType }); + var options = { + method : "GET", + handleAs : "json", + query : args || {} }; + return this.getEntities(url, options, this.getActivityStreamCallbacks()); + }, + + /** + * Get all updates. + * + * @method getAllUpdates + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getAllUpdates : function(args) { + return this.getStream(consts.ASUser.PUBLIC, consts.ASGroup.ALL, consts.ASApplication.ALL, args); + }, + + /** + * Get my status updates. + * + * @method getMyStatusUpdates + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getMyStatusUpdates : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.ALL, consts.ASApplication.STATUS, args); + }, + + /** + * Get status updates from my network. + * + * @method getStatusUpdatesFromMyNetwork + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getStatusUpdatesFromMyNetwork : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.FRIENDS, consts.ASApplication.STATUS, args); + }, + + /** + * Get Updates from My Network + * + * @method getUpdatesFromMyNetwork + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getUpdatesFromMyNetwork : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.FRIENDS, consts.ASApplication.ALL, args); + }, + + /** + * Get Updates from People I Follow + * + * @method getUpdatesFromPeopleIFollow + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getUpdatesFromPeopleIFollow : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.FOLLOWING, consts.ASApplication.STATUS, args); }, - - ascSortOrderBoolean: function(param, val) { - var v = (val === "asc") ? true : false; - return param.key + "=" + v; + + /** + * Get Updates from Communities I Follow + * + * @method getUpdatesFromCommunitiesIFollow + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getUpdatesFromCommunitiesIFollow : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.ALL, consts.ASApplication.COMMUNITIES, args); }, - - sortOrder: function(param,val){ - return param.key + "=" + val; + + /** + * Get Updates from a Community + * + * @method getUpdatesFromCommunity + * @param {String} communityID Community id Community id for which activity Stream + * is to be obtained + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getUpdatesFromCommunity : function(communityID, args) { + var promise = this._validateCommunityUuid(communityID); + if (promise) { + return promise; + } + return this.getStream(consts.ASUser.COMMUNITY+communityID, consts.ASGroup.ALL, consts.ASApplication.ALL, args); }, - oneBasedInteger: function(param, val) { - var v = Math.floor(val); - if(v < 1) { - v = 1; + /** + * Get Updates from a User + * + * @method getUpdatesFromUser + * @param {String} userId User id for which activity Stream + * is to be obtained + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getUpdatesFromUser : function(userId, args) { + var promise = this._validateUserId(userId); + if (promise) { + return promise; } - return param.key + "=" + v; + return this.getStream(userId, consts.ASGroup.INVOLVED, consts.ASApplication.ALL, args); }, - zeroBaseInteger: function(param, val) { - var v = Math.floor(val); - if(v < 0) { - v = 0; - } - return param.key + "=" + v; - } - - }; - - - var Parameter = function(args) { - var self = this; - this.key = args.key; - var formatFunc = args.format || Formatter.defaultFormat; - this.format = function(val) { - return formatFunc(self, val); - }; - }; - - - return { - defaultFormat: function (key){ - return new Parameter({key: key, format: Formatter.defaultFormat}); - }, - - sortField: function(key, sortVals){ - return new Parameter({key: key, format: Formatter.sortField(sortVals)}); - }, - - sortOrder: function(key){ - return new Parameter({key: key, format: Formatter.sortOrder}); - }, - - booleanSortOrder: function (key){ - return new Parameter({key: key, format: Formatter.ascSortOrderBoolean}); - }, + /** + * Get Notifications for Me + * + * @method getNotificationsForMe + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getNotificationsForMe : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.RESPONSES, consts.ASApplication.ALL, args); + }, /** + * Get Notifications from Me * - * @param key - * @returns + * @method getNotificationsFromMe + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - zeroBasedInteger : function(key) { - return new Parameter({ key: key, format: Formatter.zeroBasedInteger }); + getNotificationsFromMe : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.NOTESFROMME, consts.ASApplication.ALL, args); }, /** + * Get Responses to My Content * - * @param key - * @returns + * @method getResponsesToMyContent + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. */ - oneBasedInteger : function(key) { - return new Parameter({ key: key, format: Formatter.oneBasedInteger }); - } - }; -}); - -}, -'sbt/connections/FollowService':function(){ -/* - * © 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. - */ - -/** - *The following resources are enabled for these applications: - - *Activities - *You can follow any public activity. To follow a private activity, you must be a member of the activity. - *Blogs - *You can follow any stand-alone blog; you cannot follow community blogs. - *Communities - *You do not have to be a member to follow public or moderated communities. You must be a member to follow private communities. - *Files - *You can follow any public file or file folders. You can only follow private files and file folders that have been shared with you. - *Forums - *You can follow any public forum or forum topic. You can only follow private forums if you are a member or owner of the forum. - *News repository - *You can follow any tag. - *Profiles - *You can follow any profile. - *Wikis - *You can follow any public wiki or wiki page. You must be a reader, editor, or owner of a private wiki before you can follow it or one of its pages. - * - * @module sbt.connections.FollowService - */ -define( - [ "../declare", "../config", "../lang", "../stringUtil", "../Promise", - "./FollowConstants", "./ConnectionsService", - "../base/AtomEntity", "../base/XmlDataHandler" ], - function(declare, config, lang, stringUtil, Promise, consts, - ConnectionsService, AtomEntity, XmlDataHandler) { - - var SourceTmpl = ""; - var ResourceTypeTmpl = ""; - var ResourceIdTmpl = ""; - - /** - * FollowedResource class represents an entry for a resource followed by logged in user. - * - * @class FollowedResource - * @namespace sbt.connections - */ - var FollowedResource = declare(AtomEntity, { - - xpath : consts.FollowedResourceXPath, - - /** - * Construct a FollowedResource entity. - * - * @constructor - * @param args - */ - constructor : function(args) { - }, - - /** - * Return extra entry data to be included in post data for this entity. - * - * @returns {String} - */ - createEntryData : function() { - var postData = ""; - var transformer = function(value,key) { - return value; - }; - postData += stringUtil.transform(SourceTmpl, this, transformer, this); - postData += stringUtil.transform(ResourceTypeTmpl, this, transformer, this); - if (this.getResourceId()) { - postData += stringUtil.transform(ResourceIdTmpl, this, transformer, this); - } - return stringUtil.trim(postData); - }, - - /** - * Return the value of IBM Connections followed resource ID from - * resource ATOM entry document. - * - * @method getFollowedResourceUuid - * @return {String} Resource ID - */ - getFollowedResourceUuid : function() { - var followedResourceUuid = this.getAsString("followedResourceUuid"); - return extractFollowedResourceUuid(followedResourceUuid); - }, - - /** - * Sets id of IBM Connections followed resource. - * - * @method setFollowedResourceUuid - * @param {String} followedResourceUuid Id of the followed resource - */ - setFollowedResourceUuid : function(followedResourceUuid) { - return this.setAsString("followedResourceUuid", followedResourceUuid); - }, - - /** - * Return the value of IBM Connections followed resource's service name - * - * @method getSource - * @return {String} Followed resource's service name - */ - getSource : function() { - return this.getAsString("source"); - }, - - /** - * Sets IBM Connections followed resource's service name. - * - * @method setSource - * @param {String} - * Source service name of the followed resource - */ - setSource : function(source) { - return this.setAsString("source", source); - }, - - /** - * Return the value of IBM Connections followed resource's resourceType - * - * @method getResourceType - * @return {String} Followed resource's resource type - */ - getResourceType : function() { - return this.getAsString("resourceType"); - }, - - /** - * Sets IBM Connections followed resource's resource type. - * - * @method setResourceType - * @param {String} - * resourceType of the followed resource - */ - setResourceType : function(resourceType) { - return this.setAsString("resourceType", resourceType); - }, - - /** - * Return the value of IBM Connections followed resource's resourceId - * - * @method getResourceId - * @return {String} Followed resource's resource Id - */ - getResourceId : function() { - return this.getAsString("resourceId"); - }, - - /** - * Sets IBM Connections followed resource's resourceId. - * - * @method setResourceType - * @param {String} - * resource id of the followed resource - */ - setResourceId : function(resourceId) { - return this.setAsString("resourceId", resourceId); - }, - - /** - * Return the value of IBM Connections followed resource's type - * - * @method getType - * @return {String} Followed resource's resource type - */ - getType : function() { - return this.getAsString("categoryType"); - }, - - /** - * Sets IBM Connections followed resource's resource type. - * - * @method setCategoryResourceType - * @param {String} - * type of the followed resource - */ - setCategoryType : function(categoryType) { - return this.setAsString("categoryType", categoryType); - }, - - /** - * Start following - * - * @method startFollowing - * @param {Object} [args] Argument object - */ - startFollowing : function(args) { - return this.service.startFollowing(this, args); - }, - - /** - * Stop following - * - * @method stopFollowing - * @param {Object} [args] Argument object - */ - stopFollowing : function(args) { - return this.service.stopFollowing(this, args); - } - - }); - - /* - * Callbacks used when reading a feed that contains followed resource entries. - */ - var FollowResourceFeedCallbacks = { - createEntities : function(service,data,response) { - return new XmlDataHandler({ - service : service, - data : data, - namespaces : consts.Namespaces, - xpath : consts.FollowedResourceFeedXPath - }); - }, - createEntity : function(service,data,response) { - return new FollowedResource({ - service : service, - data : data - }); - } - }; - - /* - * Method used to extract the community uuid for an id url. - */ - var extractFollowedResourceUuid = function(followedResourceUuid) { - var followedResourceUuidPrefix = "urn:lsid:ibm.com:follow:resource-"; - if(followedResourceUuid && followedResourceUuid.indexOf(followedResourceUuidPrefix) != -1){ - followedResourceUuid = followedResourceUuid.substring(followedResourceUuidPrefix.length, followedResourceUuid.length); - } - return followedResourceUuid; - }; - - /** - * FollowService class. - * - * @class FollowService - * @namespace sbt.connections - */ - var FollowService = declare( - ConnectionsService, - { - contextRootMap : { - activities : "activities", - blogs : "blogs", - communities : "communities", - files : "files", - forums : "forums", - news : "news", - profiles : "profiles", - wikis : "wikis" - }, - - serviceName : "connections", - - /** - * Constructor for FollowService - * - * @constructor - * @param args - */ - constructor : function(args) { - if (!this.endpoint) { - this.endpoint = config.findEndpoint(this - .getDefaultEndpointName()); - } - }, - - /** - * Get the followed resources feed - * - * @method getFollowedResources - * @param {String} source String specifying the resource. - * @param {String} resourceType String representing the resource type. - * @param {Object} [args] Addtional request arguments supported by Connections REST API. - */ - getFollowedResources : function(source, resourceType, args) { - var requestArgs = lang.mixin({ - source : source, - type : resourceType - }, args || {}); - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - var url = null; - url = this.constructUrl(consts.AtomFollowAPI, null, { - service : this._getServiceName(source) - }); - return this.getEntities(url, options, this._getFollowedResourceFeedCallbacks()); - }, - - /** - * Get the followed resource - * - * @method getFollowedResource - * @param {String/Object} followedResource - * @param {Object} [args] Object representing various parameters if any - */ - getFollowedResource : function(followedResourceOrJson, args) { - var followedResource = this._toFollowedResource(followedResourceOrJson); - var promise = this._validateFollowedResource(followedResource, false, args); - if (promise) { - return promise; - } - - var requestArgs = lang.mixin({ - source : followedResource.getSource(), - type : followedResource.getResourceType(), - resource : followedResource.getResourceId() - }, args || {}); - - var options = { - method : "GET", - handleAs : "text", - query : requestArgs - }; - - var callbacks = { - createEntity : function(service,data,response) { - followedResource.xpath = consts.OneFollowedResourceXPath; - followedResource.setData(data); - return followedResource; - } - }; - - var url = null; - url = this.constructUrl(consts.AtomFollowAPI, null, { - service : this._getServiceName(followedResource.getSource()) - }); - return this.getEntity(url, options, followedResource.getResourceId(), callbacks); - }, - - /** - * Start Following a resource - * - * @method startFollowing - * @param {String/Object} followedResource - * @param {Object} [args] Object representing various parameters if any - */ - startFollowing : function(followedResourceOrJson, args) { - var followedResource = this._toFollowedResource(followedResourceOrJson); - var promise = this._validateFollowedResource(followedResource, false, args); - if (promise) { - return promise; - } - - var options = { - method : "POST", - headers : consts.AtomXmlHeaders, - data : followedResource.createPostData() - }; - - var callbacks = {}; - callbacks.createEntity = function(service,data,response) { - followedResource.setData(data); - return followedResource; - }; - - var url = null; - url = this.constructUrl(consts.AtomFollowAPI, null, { - service : this._getServiceName(followedResource.getSource()) - }); - - return this.updateEntity(url, options, callbacks); - }, + getResponsesToMyContent : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.RESPONSES, consts.ASApplication.ALL, args); + }, - /** - * Stop Following a resource - * - * @method stopFollowing - * @param {String/Object} followedResource - * @param {Object} [args] Object representing various parameters if any - */ - stopFollowing : function(followedResourceOrJson, args) { - var followedResource = this._toFollowedResource(followedResourceOrJson); - var promise = this._validateFollowedResource(followedResource, true); - if (promise) { - return promise; - } + /** + * Get Actions pending on me + * + * @method getMyActionableItems + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getMyActionableItems : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.ACTIONS, consts.ASApplication.ALL, args); + }, - var requestArgs = lang.mixin({ - source : followedResource.getSource(), - type : followedResource.getResourceType(), - resource : followedResource.getResourceId() - }, args || {}); - - var options = { - method : "DELETE", - headers : consts.AtomXmlHeaders, - query : requestArgs - }; - - var url = this.constructUrl(consts.AtomStopFollowAPI, null, { - service : this._getServiceName(followedResource.getSource()), - resourceId : followedResource.getFollowedResourceUuid() - }); - return this.deleteEntity(url, options, followedResource.getResourceId()); - }, - - /** - * Create a FollowedResource object with the specified data. - * - * @method newFollowedResource - * @param {Object} args Object containing the fields for the - * new blog - */ - newFollowedResource : function(args) { - return this._toFollowedResource(args); - }, + /** + * Get Actions pending on me for an applications + * + * @method getMyActionableItemsForApplication + * @param {String} application name for which pending action items + * are to be obtained + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getMyActionableItemsForApplication : function(application, args) { + var promise = this._validateApplicationName(application); + if (promise) { + return promise; + } + return this.getStream(consts.ASUser.ME, consts.ASGroup.ACTIONS, application, args); + }, + + /** + * Get Updates Saved by me + * + * @method getMySavedItems + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getMySavedItems : function(args) { + return this.getStream(consts.ASUser.ME, consts.ASGroup.SAVED, consts.ASApplication.ALL, args); + }, + + /** + * Get Updates Saved by me + * + * @method getMySavedItemsForApplication + * @param {String} application name for which saved items + * are to be obtained + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + getMySavedItemsForApplication : function(application, args) { + var promise = this._validateApplicationName(application); + if (promise) { + return promise; + } + return this.getStream(consts.ASUser.ME, consts.ASGroup.SAVED, application, args); + }, + + /** + * Get searched view by query + * + * @method searchByQuery + * @param {String} query string for which activity stream search is to be done. + */ + searchByQuery : function(searchString) { + var promise = this._validateSearchQuery(searchString); + if (promise) { + return promise; + } + var args = { + query : searchString + }; + return this.getStream(null, null, null, args); + }, + + /** + * Get searched view by filters + * + * @method searchByFilters + * @param {String} query Filters can be passed to this method to get as activity stream + * filtered by them. here is a sample string of two filters: + * "[{'type':'tag','values':['"+tags+"']},{'type':'tag','values':['test','mobile']}]" + * @param {String} filters Filters can be passed to this method to get as activity stream + * filtered by them. here is a sample string of two filters: + * "[{'type':'tag','values':['"+tags+"']},{'type':'tag','values':['test','mobile']}]" + */ + searchByFilters : function(query, filters) { + var promise = this._validateSearchQuery(query); + if (promise) { + return promise; + } + var promise = this._validateSearchFilters(filters); + if (promise) { + return promise; + } + var args = {}; + args.query = query; + args.filters = filters; + return this.getStream(null, null, null, args); + }, + + /** + * Get searched view by tags + * + * @method searchByTags + * @param {String} tags string containing tags separated by commas for which activity + * stream search is to be done. + */ + searchByTags : function(tags) { + var promise = this._validateSearchTags(tags); + if (promise) { + return promise; + } + var args = {}; + args.filters = "[{'type':'tag','values':['"+tags+"']}]"; + return this.getStream(null, null, null, args); + }, + + /** + * Get searched view by pattern + * + * @method searchByPattern + * @param {String} pattern string containing tags separated by commas for which activity + * stream search is to be done. + */ + searchByPattern : function(pattern) { + var promise = this._validateSearchTags(pattern); + if (promise) { + return promise; + } + var args = {}; + args.custom = pattern; + return this.getStream(null, null, null, args); + }, - /* - * Callbacks used when reading a feed that contains - * followed resource entries. - */ - _getFollowedResourceFeedCallbacks : function() { - return FollowResourceFeedCallbacks; - }, + /** + * post an Activity Stream entry + * + * @method postEntry + * @param {Object} postData a json object representing data to be posted + * @param {String} [userType] user type for which activity stream is to be posted + * If null is passed for userType, then '@me' will be used as + * default + * @param {String} [groupType] group type for which activity stream is to be posted + * If null is passed for userType, then '@all' will be used as + * default + * @param {String} [applicationType] for which activity stream is to be posted + * If null is passed for userType, then '@all' will be used as + * default + * @param {Object} [args] Object representing various query parameters + * that can be passed. The parameters must be exactly as they are + * supported by IBM Connections. + */ + postEntry : function(postData, userType, groupType, applicationType, args) { + var _userType = userType || consts.ASUser.ME; //Default is public updates + var _groupType = groupType || consts.ASGroup.ALL; // Default is all groups + var _applicationType = applicationType || consts.ASApplication.ALL; // Default is all Applications + var url = consts.ActivityStreamUrls.activityStreamBaseUrl+this.endpoint.authType+consts.ActivityStreamUrls.activityStreamRestUrl+_userType+"/"+_groupType+"/"+_applicationType; + var headers = {"Content-Type" : "application/json"}; + var options = { + method : "POST", + query : args || {}, + handleAs : "json", + headers : headers, + data : json.stringify(postData) + }; + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + return data; + }; + return this.updateEntity(url, options, callbacks, args); + }, + + /** + * post an Activity Stream microblog entry + * + * @method postMicroblogEntry + * @param {Object/String} postData a json object representing data to be posted + * @param {String} [userType] user type for which activity stream is to be posted + * If null is passed for userType, then '@public' will be used as + * default + * @param {String} [groupType] group type for which activity stream is to be posted + * If null is passed for userType, then '@all' will be used as + * default + * @param {String} [applicationType] for which activity stream is to be posted + * If null is passed for userType, then '@all' will be used as + * default + * @param {Object} [args] Object representing various parameters + * that can be passed to post an activity stream. + * The parameters must be exactly as they are + * supported by IBM Connections. + */ + postMicroblogEntry : function(postData, userType, groupType, applicationType, args) { + if (typeof postData == "string") { + postData = {"content":postData}; + } else if (typeof postData == "object") { + postData = postData; + } else { + return this.createBadRequestPromise("Invalid argument with postMicroblogEntry, expected String or Object"); + } + var _userType = userType || consts.ASUser.ME; //Default is public updates + var _groupType = groupType || consts.ASGroup.ALL; // Default is all groups + var _applicationType = applicationType || ""; // Default is all Applications + var url = consts.ActivityStreamUrls.activityStreamBaseUrl+this.endpoint.authType+consts.ActivityStreamUrls.activityStreamUBlogRestUrl+_userType+"/"+_groupType+"/"+_applicationType; + var headers = {"Content-Type" : "application/json"}; + var options = { + method : "POST", + query : args || {}, + handleAs : "json", + headers : headers, + data : json.stringify(postData) + }; + var callbacks = {}; + callbacks.createEntity = function(service,data,response) { + return data; + }; + return this.updateEntity(url, options, callbacks, args); + }, + + /* + * Validate a community UUID, and return a Promise if invalid. + */ + _validateCommunityUuid : function(communityUuid) { + if (!communityUuid || communityUuid.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected communityUuid."); + } + }, + + /* + * Validate a search query, and return a Promise if invalid. + */ + _validateSearchQuery : function(searchQuery) { + if (!searchQuery || searchQuery.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected communityUuid."); + } + }, + + /* + * Validate application name, and return a Promise if invalid. + */ + _validateApplicationName : function(application) { + if (!application || application.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected application name."); + } + }, + + /* + * Validate search tags, and return a Promise if invalid. + */ + _validateSearchTags : function(searchTags) { + if (!searchTags || searchTags.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected communityUuid."); + } + }, + + /* + * Validate search filters, and return a Promise if invalid. + */ + _validateSearchFilters : function(searchFilters) { + if (!searchFilters || searchFilters.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected communityUuid."); + } + }, + + /* + * Validate a user ID, and return a Promise if invalid. + */ + _validateUserId : function(userId) { + if (!userId || userId.length == 0) { + return this.createBadRequestPromise("Invalid argument, expected userId."); + } + } - /* - * Validate a blog, and return a Promise if invalid. - */ - _validateFollowedResource : function(followedResource, checkUuid) { - if (!followedResource || !followedResource.getSource()) { - return this.createBadRequestPromise("Invalid argument, resource with source must be specified."); - } - if (!followedResource.getResourceType()) { - return this.createBadRequestPromise("Invalid argument, resource with resource yype must be specified."); - } - if (!followedResource.getResourceId()) { - return this.createBadRequestPromise("Invalid argument, resource with resource id must be specified."); - } - if (checkUuid && !followedResource.getFollowedResourceUuid()) { - return this.createBadRequestPromise("Invalid argument, resource with UUID must be specified."); - } - }, + }); + return ActivityStreamService; +}); - /* - * Validate a followedResource UUID, and return a Promise if invalid. - */ - _validateFollowedResourceUuid : function(followedResourceUuid) { - if (!followedResourceUuid || followedResourceUuid.length == 0) { - return this.createBadRequestPromise("Invalid argument, expected followedResourceUuid."); - } - }, +}, +'url:sbt/connections/controls/search/templates/CommunityBody.html':"
    \r\n
      \r\n ${communityMembers}\r\n
    • \r\n ${updatedLabel}\r\n
    • \r\n ${tagsList}\r\n
    \r\n\r\n
    \r\n\r\n", +'sbt/nls/validate':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ - /* - * Return a Followed Resource instance from FollowedResource or JSON or String. Throws - * an error if the argument was neither. - */ - _toFollowedResource : function(followedResourceOrJsonOrString) { - if (followedResourceOrJsonOrString instanceof FollowedResource) { - return followedResourceOrJsonOrString; - } else { - if (lang.isString(followedResourceOrJsonOrString)) { - followedResourceOrJsonOrString = { - followedResourceUuid : followedResourceOrJsonOrString - }; - } - return new FollowedResource({ - service : this, - _fields : lang.mixin({}, followedResourceOrJsonOrString) - }); - } - }, - - /* - * Return a Followed Resource instance from FollowedResource or JSON or String. Throws - * an error if the argument was neither. - */ - _getServiceName : function(source) { - var contextRoot = this.contextRootMap; - for (var key in contextRoot) { - if(source == key){ - return contextRoot[key]; - } - } - return ""; - } - }); - return FollowService; - }); +/** + * Social Business Toolkit SDK - Default resource bundle for validate module. + */ + + +define({ + root: ({ + error_callback:"Error running error callback : {0}", + error_console:"Error received. Error Code = {0}. Error Message = {1}", + validate_nullObject:"{0}.{1} : Null argument provided for {2}. Expected type is {3}", + validate_expectedType:"{0}.{1} : {2} argument type does not match expected type {3} for {4}" + }) + +}); }, -'url:sbt/connections/controls/search/templates/PersonCard.html':"\r\n \r\n ${authorName}\r\n ${inactiveLabel}\r\n \r\n \r\n ${authorUid}\r\n \r\n\r\n", -'url:sbt/connections/controls/search/templates/PopUpTemplate.html':"\r\n\t\r\n\r\n\t\t\r\n\r\n\t\t\t\r\n\r\n\t\t\t\r\n\t\t\r\n\r\n\t\t\r\n\r\n\t\t\t\r\n\r\n\t\t\t\r\n\t\t\r\n\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\r\n\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\r\n\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\r\n\r\n\t\t\r\n\t\t\t\r\n\r\n\t\t\t\r\n\r\n\t\t\r\n\r\n\t\t\r\n\t\t\t\r\n\r\n\t\t\t\r\n\r\n\t\t\r\n\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t\t\r\n\t\t\t\r\n\r\n\t\t\t\r\n\r\n\t\t\r\n\t\t\r\n\r\n\t\t\t\r\n\r\n\t\t\t\r\n\t\t\r\n\r\n\t\r\n
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon\r\n\t\t\t${nls.allConnections}
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon\r\n\t\t\t${nls.statusUpdates}
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon\r\n\t\t\t${nls.activities}
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon${nls.blogs}
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon\r\n\t\t\t${nls.bookmarks}
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon\r\n\t\t\t${nls.communities}
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon${nls.files}
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon${nls.forums}
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon\r\n\t\t\t${nls.profiles}
    \"\"\r\n\t\t\t\tclass=\"dijitMenuItemIcon${nls.wikis}
    ", -'sbt/i18n':function(){ +'url:sbt/connections/controls/files/templates/FolderRow.html':"\r\n \r\n

    \r\n \r\n ${title} \r\n \r\n

    \r\n
    \r\n \r\n \r\n \t\t\t\t\t\t${authorName}\r\n \t\t\t\t\t\t${authorUserId}\r\n\t\t\t\t\t\r\n\t\t\t\t\t ${_nls.created} ${createdLabel} | ${itemCount} ${_nls.files}\r\n \r\n
    \r\n \r\n \r\n \r\n \"\"\r\n ${_nls.pin}\r\n \r\n \r\n \r\n \r\n \"\"\r\n ${shareLabel}\r\n \r\n", +'sbt/_bridge/localeUtil':function(){ /* * © Copyright IBM Corp. 2012 * @@ -42883,39 +42906,97 @@ define( /** * Social Business Toolkit SDK. - * @module sbt.i18n + * @module sbt.LocaleUtil */ -define(['./_bridge/i18n'],function(i18n) { - var nls = { - todayAt : "Today at ", - on : "on " - }; +define(['dojo/date/locale'],function(locale) { - i18n.getUpdatedLabel = function(dateStr) { - var date = new Date(dateStr); - var dateClone = new Date(date.getTime()); - var now = new Date(); - if (dateClone.setHours(0,0,0,0) == now.setHours(0,0,0,0)) { - return nls.todayAt + this.getLocalizedTime(date); - } else { - return nls.on + this.getLocalizedDate(date); - } - }; - - i18n.getSearchUpdatedLabel = function(dateStr) { - var date = new Date(dateStr); - var dateClone = new Date(date.getTime()); - var now = new Date(); - if (dateClone.setHours(0,0,0,0) == now.setHours(0,0,0,0)) { - return nls.todayAt + this.getLocalizedTime(date); - } else { - return this.getLocalizedDate(date); - } - }; - return i18n; + return{ + + getLocalizedTime : function(date) { + return locale.format(date, { selector:"time",formatLength:"short" }); + }, + + getLocalizedDate : function(date) { + return locale.format(date, { selector:"date",formatLength:"medium" }); + }, + } }); +}, +'sbt/_bridge/dom':function(){ +/* + * © Copyright IBM Corp. 2012 + * + * 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. + */ + +/** + * Social Business Toolkit SDK - Some DOM utilities. + */ +define(['dojo/dom','dojo/_base/window', 'dojo/dom-construct', 'dojo/dom-class'],function(dom,win,domConstruct,domClass) { + return { + byId: function(id) { + return dom.byId(id); + }, + createTextNode: function(text) { + //return dojo.doc.createTextNode(text); + //change also made to define, added 'dojo/_base/window' + return win.doc.createTextNode(text); + }, + create: function(element, props, refNode) { + return domConstruct.create(element, props, refNode); + }, + destroy: function(node) { + return domConstruct.destroy(node); + }, + toDom: function(template, parent) { + return domConstruct.toDom(template, parent); + }, + removeAll: function(node) { + node = this.byId(node); + if(node) { + while(node.firstChild) node.removeChild(node.firstChild); + } + return node; + }, + setText: function(node,text) { + node = this.byId(node); + if(node) { + this.removeAll(node); + node.appendChild(this.createTextNode(text)); + } + return node; + }, + setAttr: function(node,attr,text) { + node = this.byId(node); + if(node) { + if(text) { + node.setAttribute(attr,text); + } else { + node.removeAttribute(attr); + } + } + return node; + }, + addClass: function(node, className) { + return domClass.add(node, className); + }, + removeClass: function(node, className) { + return domClass.remove(node, className); + } + }; +}); }}}); define([], 1); diff --git a/assembly/pom.xml b/assembly/pom.xml index 5e11ab8dbe..81d9585f30 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -16,7 +16,7 @@ com.ibm.sbt com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -84,10 +84,10 @@ wget - http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.59/bin/apache-tomcat-7.0.59.zip + http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.61/bin/apache-tomcat-7.0.61.zip true ${project.build.directory}/tomcat/unzip - 3109af3fda8092c5647fb2380738ee12 + e34610f342045a817b3a100c07c3d1a3 @@ -145,14 +145,14 @@ commons-logging jar false - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/lib + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/lib com.ibm.sbt sbt.dojo180 war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps sbt.dojo180.war @@ -160,7 +160,7 @@ sbt.jquery182 war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps sbt.jquery182.war @@ -168,7 +168,7 @@ sbt.bootstrap211 war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps sbt.bootstrap211.war @@ -176,7 +176,7 @@ sbt.sample.web war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps sbt.sample.web.war @@ -187,7 +187,7 @@ com.ibm.sbt.landing war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps ROOT.war @@ -196,7 +196,7 @@ acme.social.sample.dataapp war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps acme.social.sample.dataapp.war @@ -204,7 +204,7 @@ acme.social.sample.webapp war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps acme.social.sample.webapp.war @@ -212,7 +212,7 @@ helloworld.webapp war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps helloworld.webapp.war @@ -226,7 +226,7 @@ smartcloud.webapp war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps smartcloud.webapp.war @@ -234,7 +234,7 @@ grantaccess.webapp war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps grantaccess.webapp.war @@ -242,7 +242,7 @@ acme.sample.webapp war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps acme.sample.webapp.war @@ -255,7 +255,7 @@ com.ibm.sbt.web war true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/webapps + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps sbt.war @@ -263,21 +263,21 @@ com.ibm.commons jar true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/lib + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/lib com.ibm.sbt com.ibm.commons.runtime jar true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/lib + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/lib com.ibm.sbt com.ibm.commons.xml jar true - ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.59/lib + ${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/lib @@ -318,22 +318,22 @@ + dir="${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/webapps/ROOT" /> + todir="${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/lib" /> + todir="${project.build.directory}/tomcat/unzip/apache-tomcat-7.0.61/conf"> @@ -370,7 +370,7 @@ com.ibm.sbt sbt.dojo180 - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt sbt.jquery182 - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt sbt.bootstrap211 - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt sbt.sample.web - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war @@ -450,7 +450,7 @@ com.ibm.sbt com.ibm.sbt.landing - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war @@ -458,21 +458,21 @@ com.ibm.sbt acme.social.sample.dataapp - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt acme.social.sample.webapp - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt helloworld.webapp - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war @@ -485,25 +485,26 @@ com.ibm.sbt smartcloud.webapp - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt grantaccess.webapp - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt acme.sample.webapp - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war + @@ -511,7 +512,7 @@ com.ibm.sbt com.ibm.sbt.web - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war @@ -523,7 +524,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt @@ -531,22 +532,30 @@ 9.0.0 + + com.ibm.sbt + bss.provisioning.sample.app + 1.1.4.20150504-1700 + + + + com.ibm.sbt com.ibm.sbt.php.wordpress - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 zip com.ibm.sbt com.ibm.sbt.php.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 zip com.ibm.sbt com.ibm.sbt.php.moodle - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 zip diff --git a/commons/com.ibm.commons.runtime/META-INF/MANIFEST.MF b/commons/com.ibm.commons.runtime/META-INF/MANIFEST.MF index ca81a720a2..01d0de6756 100644 --- a/commons/com.ibm.commons.runtime/META-INF/MANIFEST.MF +++ b/commons/com.ibm.commons.runtime/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Common Runtime Classes Bundle-SymbolicName: com.ibm.commons.runtime -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Export-Package: com.ibm.commons.runtime,com.ibm.commons.runtime.beans, com.ibm.commons.runtime.impl,com.ibm.commons.runtime.impl.app,com.ibm diff --git a/commons/com.ibm.commons.runtime/pom.xml b/commons/com.ibm.commons.runtime/pom.xml index 72b9c89657..1e30530275 100644 --- a/commons/com.ibm.commons.runtime/pom.xml +++ b/commons/com.ibm.commons.runtime/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.commons - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/commons/com.ibm.commons.xml/pom.xml b/commons/com.ibm.commons.xml/pom.xml index 93101257e9..1831f5f181 100644 --- a/commons/com.ibm.commons.xml/pom.xml +++ b/commons/com.ibm.commons.xml/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.commons - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 9.0.0 diff --git a/commons/com.ibm.commons/pom.xml b/commons/com.ibm.commons/pom.xml index 68c597e071..1ae3788a98 100644 --- a/commons/com.ibm.commons/pom.xml +++ b/commons/com.ibm.commons/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.commons - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 9.0.0 diff --git a/commons/pom.xml b/commons/pom.xml index 70f323eb7a..3bf1f7e013 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.commons diff --git a/deps/com.ibm.sbt.bootstrap211/pom.xml b/deps/com.ibm.sbt.bootstrap211/pom.xml index 6a543c9d93..9f8f84e462 100644 --- a/deps/com.ibm.sbt.bootstrap211/pom.xml +++ b/deps/com.ibm.sbt.bootstrap211/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.dependencies - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/deps/com.ibm.sbt.ckeditor422/pom.xml b/deps/com.ibm.sbt.ckeditor422/pom.xml index fc43f0d13e..2b0fdb32a2 100644 --- a/deps/com.ibm.sbt.ckeditor422/pom.xml +++ b/deps/com.ibm.sbt.ckeditor422/pom.xml @@ -7,6 +7,6 @@ com.ibm.sbt com.ibm.sbt.dependencies - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/deps/com.ibm.sbt.dojo180/pom.xml b/deps/com.ibm.sbt.dojo180/pom.xml index 9d67f41de4..ac1d1a4ed6 100644 --- a/deps/com.ibm.sbt.dojo180/pom.xml +++ b/deps/com.ibm.sbt.dojo180/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.dependencies - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/deps/com.ibm.sbt.jquery182/pom.xml b/deps/com.ibm.sbt.jquery182/pom.xml index 3d25790eb8..287c19422b 100644 --- a/deps/com.ibm.sbt.jquery182/pom.xml +++ b/deps/com.ibm.sbt.jquery182/pom.xml @@ -7,6 +7,6 @@ com.ibm.sbt com.ibm.sbt.dependencies - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/deps/pom.xml b/deps/pom.xml index fc013f92cc..9ed569b7da 100644 --- a/deps/pom.xml +++ b/deps/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt.bootstrap211 diff --git a/domino/com.ibm.sbt.domino.feature/feature.xml b/domino/com.ibm.sbt.domino.feature/feature.xml index 1475e9b3b7..9be7e08df3 100644 --- a/domino/com.ibm.sbt.domino.feature/feature.xml +++ b/domino/com.ibm.sbt.domino.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/domino/com.ibm.sbt.domino.feature/pom.xml b/domino/com.ibm.sbt.domino.feature/pom.xml index 01c0c89c66..2600669906 100644 --- a/domino/com.ibm.sbt.domino.feature/pom.xml +++ b/domino/com.ibm.sbt.domino.feature/pom.xml @@ -6,6 +6,6 @@ com.ibm.sbt com.ibm.sbt.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/domino/com.ibm.sbt.domino.updatesite/pom.xml b/domino/com.ibm.sbt.domino.updatesite/pom.xml index e7f3ff7889..ebddbe2b31 100644 --- a/domino/com.ibm.sbt.domino.updatesite/pom.xml +++ b/domino/com.ibm.sbt.domino.updatesite/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/domino/com.ibm.sbt.domino.updatesite/site.xml b/domino/com.ibm.sbt.domino.updatesite/site.xml index b73d14ca42..2d159cd604 100644 --- a/domino/com.ibm.sbt.domino.updatesite/site.xml +++ b/domino/com.ibm.sbt.domino.updatesite/site.xml @@ -1,6 +1,6 @@ - - - + + + diff --git a/domino/com.ibm.sbt.opensocial.domino.explorer.feature/feature.xml b/domino/com.ibm.sbt.opensocial.domino.explorer.feature/feature.xml index 59d3f807a4..a41c448654 100644 --- a/domino/com.ibm.sbt.opensocial.domino.explorer.feature/feature.xml +++ b/domino/com.ibm.sbt.opensocial.domino.explorer.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/domino/com.ibm.sbt.opensocial.domino.explorer.feature/pom.xml b/domino/com.ibm.sbt.opensocial.domino.explorer.feature/pom.xml index 3e08257499..b2cf522f70 100644 --- a/domino/com.ibm.sbt.opensocial.domino.explorer.feature/pom.xml +++ b/domino/com.ibm.sbt.opensocial.domino.explorer.feature/pom.xml @@ -6,6 +6,6 @@ com.ibm.sbt com.ibm.sbt.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/domino/com.ibm.sbt.opensocial.domino.explorer/META-INF/MANIFEST.MF b/domino/com.ibm.sbt.opensocial.domino.explorer/META-INF/MANIFEST.MF index 09a12d03fb..136a988600 100644 --- a/domino/com.ibm.sbt.opensocial.domino.explorer/META-INF/MANIFEST.MF +++ b/domino/com.ibm.sbt.opensocial.domino.explorer/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: OpenSocial Explorer Bundle-SymbolicName: com.ibm.sbt.opensocial.domino.explorer;singleton:=true -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: javax.servlet, diff --git a/domino/com.ibm.sbt.opensocial.domino.explorer/pom.xml b/domino/com.ibm.sbt.opensocial.domino.explorer/pom.xml index 7df05762e9..0a451f1bd7 100644 --- a/domino/com.ibm.sbt.opensocial.domino.explorer/pom.xml +++ b/domino/com.ibm.sbt.opensocial.domino.explorer/pom.xml @@ -8,7 +8,7 @@ com.ibm.sbt com.ibm.sbt.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/domino/com.ibm.sbt.opensocial.domino.feature/feature.xml b/domino/com.ibm.sbt.opensocial.domino.feature/feature.xml index 3724688318..80f2b1ba46 100644 --- a/domino/com.ibm.sbt.opensocial.domino.feature/feature.xml +++ b/domino/com.ibm.sbt.opensocial.domino.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/domino/com.ibm.sbt.opensocial.domino.feature/pom.xml b/domino/com.ibm.sbt.opensocial.domino.feature/pom.xml index 9e8d4ae3ea..299909914d 100644 --- a/domino/com.ibm.sbt.opensocial.domino.feature/pom.xml +++ b/domino/com.ibm.sbt.opensocial.domino.feature/pom.xml @@ -6,6 +6,6 @@ com.ibm.sbt com.ibm.sbt.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/domino/com.ibm.sbt.opensocial.domino/META-INF/MANIFEST.MF b/domino/com.ibm.sbt.opensocial.domino/META-INF/MANIFEST.MF index 0972686d6f..1a66fa7227 100644 --- a/domino/com.ibm.sbt.opensocial.domino/META-INF/MANIFEST.MF +++ b/domino/com.ibm.sbt.opensocial.domino/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Domino Opensocial App Bundle-SymbolicName: com.ibm.sbt.opensocial.domino;singleton:=true -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Activator: com.ibm.sbt.opensocial.domino.internal.OpenSocialPlugin Bundle-Vendor: IBM Bundle-ActivationPolicy: lazy diff --git a/domino/com.ibm.sbt.opensocial.domino/pom.xml b/domino/com.ibm.sbt.opensocial.domino/pom.xml index 7d5fd84a3f..7906bb2b48 100644 --- a/domino/com.ibm.sbt.opensocial.domino/pom.xml +++ b/domino/com.ibm.sbt.opensocial.domino/pom.xml @@ -6,7 +6,7 @@ com.ibm.sbt com.ibm.sbt.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/domino/com.ibm.sbt.playground/META-INF/MANIFEST.MF b/domino/com.ibm.sbt.playground/META-INF/MANIFEST.MF index e7b2ea30d1..6c35396f4e 100644 --- a/domino/com.ibm.sbt.playground/META-INF/MANIFEST.MF +++ b/domino/com.ibm.sbt.playground/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Playground related classes Bundle-SymbolicName: com.ibm.sbt.playground -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Require-Bundle: com.ibm.commons, com.ibm.commons.xml, diff --git a/domino/com.ibm.sbt.playground/pom.xml b/domino/com.ibm.sbt.playground/pom.xml index fb62d5b8a3..382e1c26fb 100644 --- a/domino/com.ibm.sbt.playground/pom.xml +++ b/domino/com.ibm.sbt.playground/pom.xml @@ -6,7 +6,7 @@ com.ibm.sbt com.ibm.sbt.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/domino/com.ibm.xsp.opensocial/META-INF/MANIFEST.MF b/domino/com.ibm.xsp.opensocial/META-INF/MANIFEST.MF index 258bc077fa..8fedb02396 100644 --- a/domino/com.ibm.xsp.opensocial/META-INF/MANIFEST.MF +++ b/domino/com.ibm.xsp.opensocial/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: OpenSocial Library for XPages Bundle-SymbolicName: com.ibm.xsp.opensocial;singleton:=true -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Bundle-ClassPath: . Require-Bundle: org.eclipse.core.runtime, diff --git a/domino/com.ibm.xsp.opensocial/pom.xml b/domino/com.ibm.xsp.opensocial/pom.xml index 0160cd426a..c07c0c0103 100644 --- a/domino/com.ibm.xsp.opensocial/pom.xml +++ b/domino/com.ibm.xsp.opensocial/pom.xml @@ -6,7 +6,7 @@ com.ibm.sbt com.ibm.sbt.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/domino/com.ibm.xsp.sbtsdk/META-INF/MANIFEST.MF b/domino/com.ibm.xsp.sbtsdk/META-INF/MANIFEST.MF index 41ca87c864..22770f23cd 100644 --- a/domino/com.ibm.xsp.sbtsdk/META-INF/MANIFEST.MF +++ b/domino/com.ibm.xsp.sbtsdk/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Domino Bundle-SymbolicName: com.ibm.xsp.sbtsdk;singleton:=true -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Activator: com.ibm.xsp.sbtsdk.Activator Bundle-Vendor: IBM Bundle-ClassPath: ., diff --git a/domino/com.ibm.xsp.sbtsdk/pom.xml b/domino/com.ibm.xsp.sbtsdk/pom.xml index f2c03b732e..23ea0fefd4 100644 --- a/domino/com.ibm.xsp.sbtsdk/pom.xml +++ b/domino/com.ibm.xsp.sbtsdk/pom.xml @@ -6,7 +6,7 @@ com.ibm.sbt com.ibm.sbt.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/domino/pom.xml b/domino/pom.xml index d994eea310..7f0de5406f 100644 --- a/domino/pom.xml +++ b/domino/pom.xml @@ -15,7 +15,7 @@ com.ibm.sbt com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.xsp.sbtsdk diff --git a/libraries/com.ibm.sbt.libs.domino/META-INF/MANIFEST.MF b/libraries/com.ibm.sbt.libs.domino/META-INF/MANIFEST.MF index ee2e978458..10a9252d45 100644 --- a/libraries/com.ibm.sbt.libs.domino/META-INF/MANIFEST.MF +++ b/libraries/com.ibm.sbt.libs.domino/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Domino specific libraries Bundle-SymbolicName: com.ibm.sbt.libs.domino -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Fragment-Host: com.ibm.sbt.libs Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/libraries/com.ibm.sbt.libs.domino/pom.xml b/libraries/com.ibm.sbt.libs.domino/pom.xml index 5a6559294c..9aa40aac8d 100644 --- a/libraries/com.ibm.sbt.libs.domino/pom.xml +++ b/libraries/com.ibm.sbt.libs.domino/pom.xml @@ -6,7 +6,7 @@ com.ibm.sbt com.ibm.sbt.libraries - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/libraries/com.ibm.sbt.libs.j2ee/META-INF/MANIFEST.MF b/libraries/com.ibm.sbt.libs.j2ee/META-INF/MANIFEST.MF index ca37a9aab2..4a6ad2efb0 100644 --- a/libraries/com.ibm.sbt.libs.j2ee/META-INF/MANIFEST.MF +++ b/libraries/com.ibm.sbt.libs.j2ee/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: J2EE specific libraries Bundle-SymbolicName: com.ibm.sbt.libs.j2ee -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Fragment-Host: com.ibm.sbt.libs Bundle-ClassPath: ., diff --git a/libraries/com.ibm.sbt.libs.j2ee/pom.xml b/libraries/com.ibm.sbt.libs.j2ee/pom.xml index d889514449..5eda177b8e 100644 --- a/libraries/com.ibm.sbt.libs.j2ee/pom.xml +++ b/libraries/com.ibm.sbt.libs.j2ee/pom.xml @@ -6,6 +6,6 @@ com.ibm.sbt com.ibm.sbt.libraries - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/libraries/com.ibm.sbt.libs/META-INF/MANIFEST.MF b/libraries/com.ibm.sbt.libs/META-INF/MANIFEST.MF index 41c6ea8040..b296dee2a2 100644 --- a/libraries/com.ibm.sbt.libs/META-INF/MANIFEST.MF +++ b/libraries/com.ibm.sbt.libs/META-INF/MANIFEST.MF @@ -2,6 +2,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Third party libraries used by the SDK Bundle-SymbolicName: com.ibm.sbt.libs -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Eclipse-ExtensibleAPI: true diff --git a/libraries/com.ibm.sbt.libs/pom.xml b/libraries/com.ibm.sbt.libs/pom.xml index 5805a0a52b..d12e4264eb 100644 --- a/libraries/com.ibm.sbt.libs/pom.xml +++ b/libraries/com.ibm.sbt.libs/pom.xml @@ -7,6 +7,6 @@ com.ibm.sbt com.ibm.sbt.libraries - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/libraries/pom.xml b/libraries/pom.xml index c56459fa00..32c38b4425 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt.libs diff --git a/php/moodle-block/pom.xml b/php/moodle-block/pom.xml index c768165686..7fef652441 100644 --- a/php/moodle-block/pom.xml +++ b/php/moodle-block/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.phpsdk - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -58,7 +58,7 @@ com.ibm.sbt com.ibm.sbt.php.core zip - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/php/php-core/pom.xml b/php/php-core/pom.xml index 0f262b3f40..557365676d 100644 --- a/php/php-core/pom.xml +++ b/php/php-core/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.phpsdk - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/php/pom.xml b/php/pom.xml index 4959520aad..c78d5a0616 100644 --- a/php/pom.xml +++ b/php/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 php-core diff --git a/php/wordpress-plugin/pom.xml b/php/wordpress-plugin/pom.xml index 71a14fe338..11b2b721dd 100644 --- a/php/wordpress-plugin/pom.xml +++ b/php/wordpress-plugin/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.phpsdk - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -58,7 +58,7 @@ com.ibm.sbt com.ibm.sbt.php.core zip - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/pom.xml b/pom.xml index f659e32052..6617ac783c 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ pom com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 org.sonatype.oss diff --git a/samples/com.ibm.sbt.samples.commons/META-INF/MANIFEST.MF b/samples/com.ibm.sbt.samples.commons/META-INF/MANIFEST.MF index c768b1fff7..ffb753115d 100644 --- a/samples/com.ibm.sbt.samples.commons/META-INF/MANIFEST.MF +++ b/samples/com.ibm.sbt.samples.commons/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Snipped discovery related classes Bundle-SymbolicName: com.ibm.sbt.samples.commons -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Require-Bundle: com.ibm.commons, com.ibm.commons.xml, diff --git a/samples/com.ibm.sbt.samples.commons/pom.xml b/samples/com.ibm.sbt.samples.commons/pom.xml index 2ef86ff363..aaef998e51 100644 --- a/samples/com.ibm.sbt.samples.commons/pom.xml +++ b/samples/com.ibm.sbt.samples.commons/pom.xml @@ -6,7 +6,7 @@ com.ibm.sbt com.ibm.sbt.samples - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/domino/com.ibm.sbt.domino.playground.feature/feature.xml b/samples/domino/com.ibm.sbt.domino.playground.feature/feature.xml index 3e72d38873..142437a693 100644 --- a/samples/domino/com.ibm.sbt.domino.playground.feature/feature.xml +++ b/samples/domino/com.ibm.sbt.domino.playground.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/samples/domino/com.ibm.sbt.domino.playground.feature/pom.xml b/samples/domino/com.ibm.sbt.domino.playground.feature/pom.xml index 997ecd8782..88cdcfd7ec 100644 --- a/samples/domino/com.ibm.sbt.domino.playground.feature/pom.xml +++ b/samples/domino/com.ibm.sbt.domino.playground.feature/pom.xml @@ -5,7 +5,7 @@ com.ibm.sbt com.ibm.sbt.samples.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/domino/com.ibm.sbt.domino.playground.updatesite/pom.xml b/samples/domino/com.ibm.sbt.domino.playground.updatesite/pom.xml index de299bf7c2..d4aeca337b 100644 --- a/samples/domino/com.ibm.sbt.domino.playground.updatesite/pom.xml +++ b/samples/domino/com.ibm.sbt.domino.playground.updatesite/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.samples.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/samples/domino/com.ibm.sbt.domino.playground.updatesite/site.xml b/samples/domino/com.ibm.sbt.domino.playground.updatesite/site.xml index 130c393c65..8d171cb81a 100644 --- a/samples/domino/com.ibm.sbt.domino.playground.updatesite/site.xml +++ b/samples/domino/com.ibm.sbt.domino.playground.updatesite/site.xml @@ -1,4 +1,4 @@ - + diff --git a/samples/domino/com.ibm.xsp.sbtsdk.playground.sbt/META-INF/MANIFEST.MF b/samples/domino/com.ibm.xsp.sbtsdk.playground.sbt/META-INF/MANIFEST.MF index 68eb378894..e2cd034d80 100644 --- a/samples/domino/com.ibm.xsp.sbtsdk.playground.sbt/META-INF/MANIFEST.MF +++ b/samples/domino/com.ibm.xsp.sbtsdk.playground.sbt/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ICS SBT Specific Fragment Bundle-SymbolicName: com.ibm.xsp.sbtsdk.playground.sbt;singleton:=true -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Fragment-Host: com.ibm.xsp.sbtsdk.playground Export-Package: com.ibm.xsp.sbtsdk.playground.sbt,com.ibm.xsp.sbtsdk.p diff --git a/samples/domino/com.ibm.xsp.sbtsdk.playground.sbt/pom.xml b/samples/domino/com.ibm.xsp.sbtsdk.playground.sbt/pom.xml index 501baf01f5..dad828ae57 100644 --- a/samples/domino/com.ibm.xsp.sbtsdk.playground.sbt/pom.xml +++ b/samples/domino/com.ibm.xsp.sbtsdk.playground.sbt/pom.xml @@ -6,6 +6,6 @@ com.ibm.sbt com.ibm.sbt.samples.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/domino/com.ibm.xsp.sbtsdk.playground/META-INF/MANIFEST.MF b/samples/domino/com.ibm.xsp.sbtsdk.playground/META-INF/MANIFEST.MF index d93a7cc523..dd7ad2043a 100644 --- a/samples/domino/com.ibm.xsp.sbtsdk.playground/META-INF/MANIFEST.MF +++ b/samples/domino/com.ibm.xsp.sbtsdk.playground/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Domino Playground Bundle-SymbolicName: com.ibm.xsp.sbtsdk.playground;singleton:=true -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Eclipse-ExtensibleAPI: true Bundle-Vendor: IBM Require-Bundle: org.eclipse.core.runtime, diff --git a/samples/domino/com.ibm.xsp.sbtsdk.playground/pom.xml b/samples/domino/com.ibm.xsp.sbtsdk.playground/pom.xml index 12741ebd50..d55dfbb043 100644 --- a/samples/domino/com.ibm.xsp.sbtsdk.playground/pom.xml +++ b/samples/domino/com.ibm.xsp.sbtsdk.playground/pom.xml @@ -6,6 +6,6 @@ com.ibm.sbt com.ibm.sbt.samples.domino - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/domino/pom.xml b/samples/domino/pom.xml index 4219d0912f..4c8aa350f5 100644 --- a/samples/domino/pom.xml +++ b/samples/domino/pom.xml @@ -15,7 +15,7 @@ com.ibm.sbt com.ibm.sbt.samples - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.xsp.sbtsdk.playground diff --git a/samples/j2ee/acme/acme.sample.webapp/pom.xml b/samples/j2ee/acme/acme.sample.webapp/pom.xml index 785afe3224..c2580e972b 100644 --- a/samples/j2ee/acme/acme.sample.webapp/pom.xml +++ b/samples/j2ee/acme/acme.sample.webapp/pom.xml @@ -5,7 +5,7 @@ com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.samples.acme @@ -35,7 +35,7 @@ com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 org.eclipse.core @@ -56,7 +56,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/j2ee/acme/acme.social.sample.dataapp/pom.xml b/samples/j2ee/acme/acme.social.sample.dataapp/pom.xml index fbc75edc4e..ca71e14d59 100644 --- a/samples/j2ee/acme/acme.social.sample.dataapp/pom.xml +++ b/samples/j2ee/acme/acme.social.sample.dataapp/pom.xml @@ -5,7 +5,7 @@ com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.samples.acme diff --git a/samples/j2ee/acme/acme.social.sample.ear/pom.xml b/samples/j2ee/acme/acme.social.sample.ear/pom.xml index ce83d153e1..c4da9053df 100644 --- a/samples/j2ee/acme/acme.social.sample.ear/pom.xml +++ b/samples/j2ee/acme/acme.social.sample.ear/pom.xml @@ -6,7 +6,7 @@ com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.samples.acme @@ -55,31 +55,31 @@ com.ibm.sbt sbt.dojo180 - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt com.ibm.sbt.web - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt acme.social.sample.dataapp - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt acme.sample.webapp - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt acme.social.sample.webapp - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war diff --git a/samples/j2ee/acme/acme.social.sample.webapp/pom.xml b/samples/j2ee/acme/acme.social.sample.webapp/pom.xml index c8651e797a..b85b281882 100644 --- a/samples/j2ee/acme/acme.social.sample.webapp/pom.xml +++ b/samples/j2ee/acme/acme.social.sample.webapp/pom.xml @@ -5,7 +5,7 @@ com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.samples.acme @@ -35,7 +35,7 @@ com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 org.eclipse.core @@ -56,7 +56,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/j2ee/acme/pom.xml b/samples/j2ee/acme/pom.xml index 82bdcdaff8..dbc20a3c9f 100644 --- a/samples/j2ee/acme/pom.xml +++ b/samples/j2ee/acme/pom.xml @@ -7,7 +7,7 @@ com.ibm.samples.j2ee com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 acme.sample.webapp diff --git a/samples/j2ee/pom.xml b/samples/j2ee/pom.xml index 45a1b738f8..9a3d602aab 100644 --- a/samples/j2ee/pom.xml +++ b/samples/j2ee/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt.samples com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 acme diff --git a/samples/j2ee/snippets/com.ibm.sbt.automation.core/pom.xml b/samples/j2ee/snippets/com.ibm.sbt.automation.core/pom.xml index a9d5512283..c3a37f9f7a 100644 --- a/samples/j2ee/snippets/com.ibm.sbt.automation.core/pom.xml +++ b/samples/j2ee/snippets/com.ibm.sbt.automation.core/pom.xml @@ -6,7 +6,7 @@ com.ibm.sbt com.ibm.samples.snippets - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -20,7 +20,7 @@ com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt @@ -35,7 +35,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 org.mozilla @@ -72,12 +72,12 @@ com.ibm.sbt com.ibm.sbt.core.test - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.samples.commons - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 eclipse-plugin diff --git a/samples/j2ee/snippets/com.ibm.sbt.automation.test/pom.xml b/samples/j2ee/snippets/com.ibm.sbt.automation.test/pom.xml index ff795e1807..0fe2e6a400 100644 --- a/samples/j2ee/snippets/com.ibm.sbt.automation.test/pom.xml +++ b/samples/j2ee/snippets/com.ibm.sbt.automation.test/pom.xml @@ -6,7 +6,7 @@ com.ibm.sbt com.ibm.samples.snippets - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -54,12 +54,12 @@ com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.automation.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/samples/j2ee/snippets/com.ibm.sbt.landing/pom.xml b/samples/j2ee/snippets/com.ibm.sbt.landing/pom.xml index 402340f809..9b0c2ab951 100644 --- a/samples/j2ee/snippets/com.ibm.sbt.landing/pom.xml +++ b/samples/j2ee/snippets/com.ibm.sbt.landing/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.samples.snippets - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/samples/j2ee/snippets/com.ibm.sbt.sample.ear/pom.xml b/samples/j2ee/snippets/com.ibm.sbt.sample.ear/pom.xml index 151cec6df3..7578539170 100644 --- a/samples/j2ee/snippets/com.ibm.sbt.sample.ear/pom.xml +++ b/samples/j2ee/snippets/com.ibm.sbt.sample.ear/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.samples.snippets - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -56,31 +56,31 @@ com.ibm.sbt sbt.dojo180 - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt com.ibm.sbt.web - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt sbt.sample.web - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt sbt.bootstrap211 - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war com.ibm.sbt sbt.jquery182 - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 war diff --git a/samples/j2ee/snippets/com.ibm.sbt.sample.web/pom.xml b/samples/j2ee/snippets/com.ibm.sbt.sample.web/pom.xml index e3083edf73..043f62e590 100644 --- a/samples/j2ee/snippets/com.ibm.sbt.sample.web/pom.xml +++ b/samples/j2ee/snippets/com.ibm.sbt.sample.web/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.samples.snippets - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -20,12 +20,12 @@ com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.samples.commons - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt @@ -40,7 +40,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/j2ee/snippets/pom.xml b/samples/j2ee/snippets/pom.xml index 4b0efcb96e..ceeb8a7477 100644 --- a/samples/j2ee/snippets/pom.xml +++ b/samples/j2ee/snippets/pom.xml @@ -7,7 +7,7 @@ com.ibm.samples.j2ee com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/samples/j2ee/templates/demosocial.webapp/pom.xml b/samples/j2ee/templates/demosocial.webapp/pom.xml index b3ab3b358b..f552a4d0ef 100644 --- a/samples/j2ee/templates/demosocial.webapp/pom.xml +++ b/samples/j2ee/templates/demosocial.webapp/pom.xml @@ -9,14 +9,14 @@ com.ibm.sbt com.ibm.samples.templates - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt @@ -31,7 +31,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/j2ee/templates/grantaccess.webapp/pom.xml b/samples/j2ee/templates/grantaccess.webapp/pom.xml index de16125fb2..61a1a83c51 100644 --- a/samples/j2ee/templates/grantaccess.webapp/pom.xml +++ b/samples/j2ee/templates/grantaccess.webapp/pom.xml @@ -9,14 +9,14 @@ com.ibm.sbt com.ibm.samples.templates - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt @@ -31,7 +31,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/j2ee/templates/helloworld.webapp/pom.xml b/samples/j2ee/templates/helloworld.webapp/pom.xml index 2992888ad2..36e3f04cee 100644 --- a/samples/j2ee/templates/helloworld.webapp/pom.xml +++ b/samples/j2ee/templates/helloworld.webapp/pom.xml @@ -9,14 +9,14 @@ com.ibm.sbt com.ibm.samples.templates - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt @@ -31,7 +31,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/j2ee/templates/mysocial.webapp/pom.xml b/samples/j2ee/templates/mysocial.webapp/pom.xml index 520a673fc3..c2db674dec 100644 --- a/samples/j2ee/templates/mysocial.webapp/pom.xml +++ b/samples/j2ee/templates/mysocial.webapp/pom.xml @@ -9,7 +9,7 @@ com.ibm.sbt com.ibm.samples.templates - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/samples/j2ee/templates/pom.xml b/samples/j2ee/templates/pom.xml index 4c6f19059a..1a4b2f0d56 100644 --- a/samples/j2ee/templates/pom.xml +++ b/samples/j2ee/templates/pom.xml @@ -7,7 +7,7 @@ com.ibm.samples.j2ee com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 demosocial.webapp diff --git a/samples/j2ee/templates/smartcloud.webapp/pom.xml b/samples/j2ee/templates/smartcloud.webapp/pom.xml index 603b8ed6bc..8995388db9 100644 --- a/samples/j2ee/templates/smartcloud.webapp/pom.xml +++ b/samples/j2ee/templates/smartcloud.webapp/pom.xml @@ -9,14 +9,14 @@ com.ibm.sbt com.ibm.samples.templates - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt @@ -31,7 +31,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/j2ee/templates/social.helloworld.webapp/pom.xml b/samples/j2ee/templates/social.helloworld.webapp/pom.xml index 78c602683b..d8f9ca403c 100644 --- a/samples/j2ee/templates/social.helloworld.webapp/pom.xml +++ b/samples/j2ee/templates/social.helloworld.webapp/pom.xml @@ -9,14 +9,14 @@ com.ibm.sbt com.ibm.samples.templates - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt @@ -31,7 +31,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/j2ee/templates/sso.sample.webapp/pom.xml b/samples/j2ee/templates/sso.sample.webapp/pom.xml index 8453abd9e0..283c38b4c5 100644 --- a/samples/j2ee/templates/sso.sample.webapp/pom.xml +++ b/samples/j2ee/templates/sso.sample.webapp/pom.xml @@ -9,14 +9,14 @@ com.ibm.sbt com.ibm.samples.templates - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 javax.servlet diff --git a/samples/java/bss.provisioning.sample.app/dependency-reduced-pom.xml b/samples/java/bss.provisioning.sample.app/dependency-reduced-pom.xml new file mode 100644 index 0000000000..8efd94b24b --- /dev/null +++ b/samples/java/bss.provisioning.sample.app/dependency-reduced-pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + com.ibm.sbt + bss.provisioning.sample.app + bss.provisioning.sample.app + 1.1.4.20150504-1700 + http://maven.apache.org + + + + maven-shade-plugin + 2.3 + + + package + + shade + + + + + com.ibm.sbt.provisioning.sample.app.task.BSSProvisioning + + + + + + + + + + + junit + junit + 3.8.1 + test + + + + UTF-8 + + + diff --git a/samples/java/bss.provisioning.sample.app/pom.xml b/samples/java/bss.provisioning.sample.app/pom.xml index 4b12ad7e6a..8c3f340110 100644 --- a/samples/java/bss.provisioning.sample.app/pom.xml +++ b/samples/java/bss.provisioning.sample.app/pom.xml @@ -2,14 +2,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.ibm.sbt bss.provisioning.sample.app - 0.0.1 jar - - bss.provisioning.sample.app - http://maven.apache.org - + + + com.ibm.sbt + com.ibm.sbt.samples.java + 1.1.4.20150504-1700 + + UTF-8 @@ -18,7 +19,7 @@ com.ibm.sbt com.ibm.sbt.core - LATEST + 1.1.4.20150504-1700 junit @@ -27,6 +28,8 @@ test + + diff --git a/samples/java/pom.xml b/samples/java/pom.xml index b777ca2edc..4a9f45380f 100644 --- a/samples/java/pom.xml +++ b/samples/java/pom.xml @@ -8,7 +8,7 @@ com.ibm.sbt.samples com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 sbt.sample.app diff --git a/samples/java/sbt.sample.app/pom.xml b/samples/java/sbt.sample.app/pom.xml index 0509b8ab0d..6f4237c700 100644 --- a/samples/java/sbt.sample.app/pom.xml +++ b/samples/java/sbt.sample.app/pom.xml @@ -7,14 +7,14 @@ com.ibm.sbt com.ibm.sbt.samples.java - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt @@ -29,7 +29,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 \ No newline at end of file diff --git a/samples/pom.xml b/samples/pom.xml index 2f5f7422c1..81e21a82d3 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -26,7 +26,7 @@ com.ibm.sbt com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt.samples.commons diff --git a/sdk/com.ibm.sbt.core.test/pom.xml b/sdk/com.ibm.sbt.core.test/pom.xml index 1abd63522c..7b21f6d58a 100644 --- a/sdk/com.ibm.sbt.core.test/pom.xml +++ b/sdk/com.ibm.sbt.core.test/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.sdk - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -55,17 +55,17 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt com.ibm.sbt.web - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 org.mozilla diff --git a/sdk/com.ibm.sbt.core/META-INF/MANIFEST.MF b/sdk/com.ibm.sbt.core/META-INF/MANIFEST.MF index 2d3c3b93e5..855a273564 100644 --- a/sdk/com.ibm.sbt.core/META-INF/MANIFEST.MF +++ b/sdk/com.ibm.sbt.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: SBT core Java code Bundle-SymbolicName: com.ibm.sbt.core;singleton:=true -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Require-Bundle: com.ibm.sbt.libs, com.ibm.commons, diff --git a/sdk/com.ibm.sbt.core/pom.xml b/sdk/com.ibm.sbt.core/pom.xml index 21c1d0e442..b293519381 100644 --- a/sdk/com.ibm.sbt.core/pom.xml +++ b/sdk/com.ibm.sbt.core/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.sdk - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -40,7 +40,7 @@ com.ibm.sbt com.ibm.commons.runtime - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt diff --git a/sdk/com.ibm.sbt.proxy.web/META-INF/MANIFEST.MF b/sdk/com.ibm.sbt.proxy.web/META-INF/MANIFEST.MF index c3763ef6f9..5aeab4c962 100644 --- a/sdk/com.ibm.sbt.proxy.web/META-INF/MANIFEST.MF +++ b/sdk/com.ibm.sbt.proxy.web/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: SBT Proxy Bundle-SymbolicName: com.ibm.sbt.proxy.web;singleton:=true -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-Vendor: IBM Require-Bundle: com.ibm.sbt.core, com.ibm.commons, diff --git a/sdk/com.ibm.sbt.proxy.web/pom.xml b/sdk/com.ibm.sbt.proxy.web/pom.xml index 9ac6b57e59..99f2cfe8d7 100644 --- a/sdk/com.ibm.sbt.proxy.web/pom.xml +++ b/sdk/com.ibm.sbt.proxy.web/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.sdk - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 @@ -16,6 +16,7 @@ org.apache.maven.plugins maven-war-plugin + 2.5 make-a-war @@ -28,11 +29,11 @@ - org.apache.maven.plugins maven-install-plugin + 2.5 install @@ -51,16 +52,14 @@ - - com.ibm.sbt com.ibm.sbt.core - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 eclipse-plugin diff --git a/sdk/com.ibm.sbt.web/META-INF/MANIFEST.MF b/sdk/com.ibm.sbt.web/META-INF/MANIFEST.MF index 6d7d221d89..81818f7bf9 100644 --- a/sdk/com.ibm.sbt.web/META-INF/MANIFEST.MF +++ b/sdk/com.ibm.sbt.web/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Web Bundle-SymbolicName: com.ibm.sbt.web;singleton:=true -Bundle-Version: 1.1.4.qualifier +Bundle-Version: 1.1.4.20150504-1700 Bundle-ActivationPolicy: lazy Bundle-Activator: com.ibm.sbt.web.SbtWebActivator Require-Bundle: org.eclipse.core.runtime diff --git a/sdk/com.ibm.sbt.web/pom.xml b/sdk/com.ibm.sbt.web/pom.xml index 420bf954fe..00826a9ce1 100644 --- a/sdk/com.ibm.sbt.web/pom.xml +++ b/sdk/com.ibm.sbt.web/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt.sdk - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 diff --git a/sdk/com.ibm.sbt.web/src/main/webapp/js/sdk/_bridges/dojo-amd/localeUtil.js b/sdk/com.ibm.sbt.web/src/main/webapp/js/sdk/_bridges/dojo-amd/localeUtil.js index 63a1684615..34c7366efd 100644 --- a/sdk/com.ibm.sbt.web/src/main/webapp/js/sdk/_bridges/dojo-amd/localeUtil.js +++ b/sdk/com.ibm.sbt.web/src/main/webapp/js/sdk/_bridges/dojo-amd/localeUtil.js @@ -29,7 +29,7 @@ define(['dojo/date/locale'],function(locale) { getLocalizedDate : function(date) { return locale.format(date, { selector:"date",formatLength:"medium" }); }, - }; + } }); diff --git a/sdk/pom.xml b/sdk/pom.xml index a2ee1c5d26..298389cabc 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -7,7 +7,7 @@ com.ibm.sbt com.ibm.sbt - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700 com.ibm.sbt.core diff --git a/sdk/sbt.sso.webapp-archetype/pom.xml b/sdk/sbt.sso.webapp-archetype/pom.xml index 0aee45a609..1aaa52b210 100644 --- a/sdk/sbt.sso.webapp-archetype/pom.xml +++ b/sdk/sbt.sso.webapp-archetype/pom.xml @@ -28,6 +28,6 @@ com.ibm.sbt com.ibm.sbt.sdk - 1.1.4-SNAPSHOT + 1.1.4.20150504-1700