Forums

Home » Mobile » Liferay Mobile SDK

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Nha Duong
Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
March 20, 2014 2:43 AM
Answer

Nha Duong

Rank: New Member

Posts: 24

Join Date: February 20, 2014

Recent Posts

Im doing App for Journalist in iOS, but i don't know how to add(upload) a Article(Content).

I was research Structure, Template and structure of Article but not yet

Everyone have any idea for this!

Please help. Thank you!
Bruno Farache
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
March 22, 2014 2:00 PM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 584

Join Date: May 14, 2007

Recent Posts

Cong, you probably need to use this class: LRJournalArticleService_v62.
Nha Duong
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
May 26, 2014 8:37 PM
Answer

Nha Duong

Rank: New Member

Posts: 24

Join Date: February 20, 2014

Recent Posts

Thank Bruno Farache so much. but i don't how to pass parametter to server.

In funtion JSONWS below
 1
 2- (NSDictionary *)
 3addArticleWithGroupId:(long long)groupId
 4folderId:(long long)folderId
 5classNameId:(long long)classNameId
 6classPK:(long long)classPK
 7articleId:(NSString *)articleId
 8autoArticleId:(BOOL)autoArticleId
 9titleMap:(NSDictionary *)titleMap
10descriptionMap:(NSDictionary *)descriptionMap
11content:(NSString *)content type:(NSString *)type
12ddmStructureKey:(NSString *)ddmStructureKey
13ddmTemplateKey:(NSString *)ddmTemplateKey
14layoutUuid:(NSString *)layoutUuid
15displayDateMonth:(int)displayDateMonth
16displayDateDay:(int)displayDateDay
17displayDateYear:(int)displayDateYear
18displayDateHour:(int)displayDateHour
19displayDateMinute:(int)displayDateMinute
20expirationDateMonth:(int)expirationDateMonth
21expirationDateDay:(int)expirationDateDay
22expirationDateYear:(int)expirationDateYear
23expirationDateHour:(int)expirationDateHour
24expirationDateMinute:(int)expirationDateMinute
25neverExpire:(BOOL)neverExpire
26reviewDateMonth:(int)reviewDateMonth
27reviewDateDay:(int)reviewDateDay
28reviewDateYear:(int)reviewDateYear
29reviewDateHour:(int)reviewDateHour
30reviewDateMinute:(int)reviewDateMinute
31neverReview:(BOOL)neverReview
32indexable:(BOOL)indexable
33articleURL:(NSString *)articleURL
34serviceContext:(NSDictionary *)serviceContext
35error:(NSError **)error;


Some parameter below You can have example to pass to server., i don't know create them.
1
2titleMap:(NSDictionary *)titleMap
3descriptionMap:(NSDictionary *)descriptionMap
4serviceContext:(NSDictionary *)serviceContext

Please help. thanks!
Bruno Farache
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
March 24, 2014 6:28 AM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 584

Join Date: May 14, 2007

Recent Posts

Look at the javadocs, if it doesn't help, I would debug this method and see what are their values.

Service context in many cases can be null.

 1/**
 2     * Adds a web content article with additional parameters.
 3     *
 4     * @param  groupId the primary key of the web content article's group
 5     * @param  folderId the primary key of the web content article folder
 6     * @param  classNameId the primary key of the DDMStructure class if the web
 7     *         content article is related to a DDM structure, the primary key of
 8     *         the class name associated with the article, or {@link
 9     *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
10     * @param  classPK the primary key of the DDM structure, if the primary key
11     *         of the DDMStructure class is given as the
12     *         <code>classNameId</code> parameter, the primary key of the class
13     *         associated with the web content article, or <code>0</code>
14     *         otherwise
15     * @param  articleId the primary key of the web content article
16     * @param  autoArticleId whether to auto generate the web content article ID
17     * @param  titleMap the web content article's locales and localized titles
18     * @param  descriptionMap the web content article's locales and localized
19     *         descriptions
20     * @param  content the HTML content wrapped in XML. For more information,
21     *         see the content example in the class description for {@link
22     *         JournalArticleLocalServiceImpl}.
23     * @param  type the structure's type, if the web content article is related
24     *         to a DDM structure. For more information, see {@link
25     *         com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}.
26     * @param  ddmStructureKey the primary key of the web content article's DDM
27     *         structure, if the article is related to a DDM structure, or
28     *         <code>null</code> otherwise
29     * @param  ddmTemplateKey the primary key of the web content article's DDM
30     *         template (optionally <code>null</code>). If the article is
31     *         related to a DDM structure, the template's structure must match
32     *         it.
33     * @param  layoutUuid the unique string identifying the web content
34     *         article's display page
35     * @param  displayDateMonth the month the web content article is set to
36     *         display
37     * @param  displayDateDay the calendar day the web content article is set to
38     *         display
39     * @param  displayDateYear the year the web content article is set to
40     *         display
41     * @param  displayDateHour the hour the web content article is set to
42     *         display
43     * @param  displayDateMinute the minute the web content article is set to
44     *         display
45     * @param  expirationDateMonth the month the web content article is set to
46     *         expire
47     * @param  expirationDateDay the calendar day the web content article is set
48     *         to expire
49     * @param  expirationDateYear the year the web content article is set to
50     *         expire
51     * @param  expirationDateHour the hour the web content article is set to
52     *         expire
53     * @param  expirationDateMinute the minute the web content article is set to
54     *         expire
55     * @param  neverExpire whether the web content article is not set to auto
56     *         expire
57     * @param  reviewDateMonth the month the web content article is set for
58     *         review
59     * @param  reviewDateDay the calendar day the web content article is set for
60     *         review
61     * @param  reviewDateYear the year the web content article is set for review
62     * @param  reviewDateHour the hour the web content article is set for review
63     * @param  reviewDateMinute the minute the web content article is set for
64     *         review
65     * @param  neverReview whether the web content article is not set for review
66     * @param  indexable whether the web content article is searchable
67     * @param  smallImage whether the web content article has a small image
68     * @param  smallImageURL the web content article's small image URL
69     * @param  smallFile the web content article's small image file
70     * @param  images the web content's images
71     * @param  articleURL the web content article's accessible URL
72     * @param  serviceContext the service context to be applied. Can set the
73     *         UUID, creation date, modification date, expando bridge
74     *         attributes, guest permissions, group permissions, asset category
75     *         IDs, asset tag names, asset link entry IDs, the "urlTitle"
76     *         attribute, and workflow actions for the web content article. Can
77     *         also set whether to add the default guest and group permissions.
78     * @return the web content article
79     * @throws PortalException if the user did not have permission to add the
80     *         web content article or if a portal exception occurred
81     * @throws SystemException if a system exception occurred
82     */
Nha Duong
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
March 25, 2014 12:23 AM
Answer

Nha Duong

Rank: New Member

Posts: 24

Join Date: February 20, 2014

Recent Posts

I tried many times but still not working.
Im stopping with error "Domain=com.liferay.mobile.sync.ErrorDomain Code=-1 "com.liferay.portlet.journal.ArticleTitleException" UserInfo=0x9b68b00 {NSLocalizedDescription=com.liferay.portlet.journal.ArticleTitleException}" .

In the function has some parameters i don't really understand.

I hope you can show parameters really as you said! A invoke complete.
Thank you!
Bruno Farache
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
March 25, 2014 3:55 PM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 584

Join Date: May 14, 2007

Recent Posts

Looking into the service source code, either this map is empty or it hasn't the Locale.en_US key (which is the articleDefaultLocale):

1if ((classNameId == JournalArticleConstants.CLASSNAME_ID_DEFAULT) &&
2            (titleMap.isEmpty() ||
3             Validator.isNull(titleMap.get(articleDefaultLocale)))) {
4
5            throw new ArticleTitleException();
6        }


This may be happening because the NSDictionary is not being parsed to Map<Locale, String> correctly, I will check. I think the best way to make it work is to create a hook with a simplified version of this method that just calls it with default values. You probably don't need that complex method with that many parameters.
Nha Duong
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
May 7, 2014 1:31 AM
Answer

Nha Duong

Rank: New Member

Posts: 24

Join Date: February 20, 2014

Recent Posts

I had addArticle to Server with web service "addArticle", but have a problem

I pass "content" parameter with Value XML allow:
<?xml version="1.0"?>
<root available-locales="vi_VN" default-locale="vi_VN">
<dynamic-element name="imgA" index="0" type="image" index-type="keyword">
<dynamic-content language-id="vi_VN">[this is value send to server]</dynamic-content>
</dynamic-element>
</root>

with element is IMAGE, i pass with none data then OK
But pass a value same URL Image internet or URL image in server itself(in Document and media).
I see parameter when get content from article exist same "/image/journal/article?img_id=199092&amp;t=1399447258367" , in the Web with this parameter i choose file local to finish.

Any idea to pass image parameter . Please help!
Thanks!
Bruno Farache
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
May 7, 2014 12:33 PM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 584

Join Date: May 14, 2007

Recent Posts

Nha, I don't understand your question, can you please rephrase?
Nha Duong
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
May 9, 2014 8:02 AM
Answer

Nha Duong

Rank: New Member

Posts: 24

Join Date: February 20, 2014

Recent Posts

I want addArticle with parameters have a image, same in web have button choose file
Bruno Farache
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
May 10, 2014 5:10 AM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 584

Join Date: May 14, 2007

Recent Posts

Ah OK, you want to upload the image from your app.

There's probably some remote service that does that, but that's the same problem we discussed in this thread. Currently, even though such remote service may exist, you cannot upload binaries from the SDK.

As an alternative, you could pass the image URL of an existing image, like you said, using the "Documents and Media" structure field type or simply a "Text" field type containing the URL for an image and using that value within your Web Content Template to display the image.
Nha Duong
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
May 29, 2014 7:49 AM
Answer

Nha Duong

Rank: New Member

Posts: 24

Join Date: February 20, 2014

Recent Posts

Bruno, i addArticle with "titleMap" parametter is
1
2NSString mytitle=@"my title ,";
3@{"en_US": mytitle}


'mytitle' have special character same: ',' , ':' ...
occur error
1Error Domain=com.liferay.mobile Code=-1 "Expected a ':' after a key at character 43"
2UserInfo=0x1b15d8a0 {NSLocalizedDescription=Expected a ':' after a key at character 43}


I don't understand. i think error occur because encode json.!
Thanks so much for your help!
Bruno Farache
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
May 29, 2014 7:13 AM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 584

Join Date: May 14, 2007

Recent Posts

Can you try escaping the slash "/" with a back slash "\/":

NSString mytitle=@"my title ,[\/color]"
Nha Duong
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
May 29, 2014 7:57 AM
Answer

Nha Duong

Rank: New Member

Posts: 24

Join Date: February 20, 2014

Recent Posts

Im sorry Bruno.
mytitle have some characters:
1 comma(,)
2colon(:)  then occur error.
Bruno Farache
RE: Add Article (Content) to Server Liferay 6.2 with SDK Mobile iOS
May 29, 2014 9:38 AM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 584

Join Date: May 14, 2007

Recent Posts

Ah OK!

Would mind creating a test case like this one? It will speed up things.

Right now I working on that issue about uploading binaries and files.