Skip to content

Commit

Permalink
Merge pull request #38 from jmpascal/master
Browse files Browse the repository at this point in the history
[Clean] Remove siteService error code.
  • Loading branch information
JM.PASCAL committed Mar 28, 2013
2 parents f2ac71c + 60a704a commit 8350000
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,47 +118,12 @@ public interface ErrorCodeRegistry
/** The site could not be found. */
int SITE_NOTFOUND = 402;

/**
* Failed to add favorite site.
*
* @since 1.1.0
*/
int SITE_NOT_FAVORITED = 403;

/**
* Failed to remove favorite site.
*
* @since 1.1.0
*/
int SITE_NOT_UNFAVORITED = 404;

/**
* User is already a member or requested to be a member of the site.
*
* @since 1.1.0
*/
int SITE_ALREADY_MEMBER = 405;

/**
* Failed to join site.
*
* @since 1.1.0
*/
int SITE_NOT_JOINED = 406;

/**
* Failed to cancel request to join site.
*
* @since 1.1.0
*/
int SITE_CANCEL_JOINED = 407;

/**
* Failed to leave site.
*
* @since 1.1.0
*/
int SITE_NOT_LEFT = 408;
int SITE_ALREADY_MEMBER = 403;

// ///////////////////////////////////
// ACTIVITI STREAM ERRORS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void cancelJoinSiteRequest(JoinSiteRequestImpl joinSiteRequest)
try
{
String link = getCancelJoinSiteRequestUrl(joinSiteRequest);
delete(new UrlBuilder(link), ErrorCodeRegistry.SITE_CANCEL_JOINED);
delete(new UrlBuilder(link), ErrorCodeRegistry.SITE_GENERIC);
}
catch (Exception e)
{
Expand Down Expand Up @@ -284,13 +284,13 @@ public Site cancelRequestToJoinSite(Site site)
}

if (isObjectNull(joinSiteRequest)) { throw new AlfrescoServiceException(
ErrorCodeRegistry.SITE_CANCEL_JOINED,
ErrorCodeRegistry.SITE_GENERIC,
Messagesl18n.getString("ErrorCodeRegistry.SITE_NOT_JOINED.parsing")); }

String link = getCancelJoinSiteRequestUrl(joinSiteRequest);
delete(new UrlBuilder(link), ErrorCodeRegistry.SITE_CANCEL_JOINED);
delete(new UrlBuilder(link), ErrorCodeRegistry.SITE_GENERIC);
updatedSite = new SiteImpl(site, false, false, site.isFavorite());
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_CANCEL_JOINED);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_GENERIC);
}
catch (Exception e)
{
Expand Down Expand Up @@ -319,10 +319,10 @@ public Site leaveSite(Site site)
try
{
String link = getLeaveSiteUrl(site);
delete(new UrlBuilder(link), ErrorCodeRegistry.SITE_NOT_LEFT);
delete(new UrlBuilder(link), ErrorCodeRegistry.SITE_GENERIC);
updateExtraPropertyCache(site.getShortName(), false, false, site.isFavorite());
updatedSite = new SiteImpl(site, false, false, site.isFavorite());
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_NOT_LEFT);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_GENERIC);
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ public void write(OutputStream out) throws IOException
{
formDataM.write(out);
}
}, ErrorCodeRegistry.SITE_NOT_FAVORITED);
}, ErrorCodeRegistry.SITE_GENERIC);
updateExtraPropertyCache(site.getIdentifier(), site.isPendingMember(), site.isMember(), true);
updatedSite = new SiteImpl(site, site.isPendingMember(), site.isMember(), true);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_NOT_FAVORITED);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_GENERIC);
}
catch (Exception e)
{
Expand All @@ -210,10 +210,10 @@ public Site removeFavoriteSite(Site site)
{
String link = CloudUrlRegistry.getRemoveUserPreferenceUrl((CloudSession) session,
session.getPersonIdentifier(), site.getGUID());
delete(new UrlBuilder(link), ErrorCodeRegistry.SITE_NOT_UNFAVORITED);
delete(new UrlBuilder(link), ErrorCodeRegistry.SITE_GENERIC);
updateExtraPropertyCache(site.getIdentifier(), site.isPendingMember(), site.isMember(), false);
updatedSite = new SiteImpl(site, site.isPendingMember(), site.isMember(), false);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_NOT_UNFAVORITED);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_GENERIC);
}
catch (Exception e)
{
Expand Down Expand Up @@ -268,7 +268,7 @@ public void write(OutputStream out) throws IOException

updateExtraPropertyCache(site.getIdentifier(), false, true, site.isFavorite());
updatedSite = new SiteImpl(site, false, true, site.isFavorite());
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_NOT_JOINED);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_GENERIC);

break;
case MODERATED:
Expand All @@ -285,22 +285,22 @@ public void write(OutputStream out) throws IOException
{
updateExtraPropertyCache(site.getIdentifier(), true, false, site.isFavorite());
updatedSite = new SiteImpl(site, true, false, site.isFavorite());
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_NOT_JOINED);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_GENERIC);
}
else
{
throw new AlfrescoServiceException(ErrorCodeRegistry.SITE_NOT_JOINED,
throw new AlfrescoServiceException(ErrorCodeRegistry.SITE_GENERIC,
Messagesl18n.getString("ErrorCodeRegistry.SITE_NOT_JOINED.parsing"));
}

break;
case PRIVATE:
throw new AlfrescoServiceException(ErrorCodeRegistry.SITE_NOT_JOINED,
throw new AlfrescoServiceException(ErrorCodeRegistry.SITE_GENERIC,
Messagesl18n.getString("ErrorCodeRegistry.SITE_NOT_JOINED.private"));
default:
if (resp.getResponseCode() != HttpStatus.SC_OK && resp.getResponseCode() != HttpStatus.SC_CREATED)
{
convertStatusCode(resp, ErrorCodeRegistry.SITE_NOT_JOINED);
convertStatusCode(resp, ErrorCodeRegistry.SITE_GENERIC);
}
throw new IllegalArgumentException(String.format(
Messagesl18n.getString("ErrorCodeRegistry.GENERAL_INVALID_ARG_NULL"), "visibility"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ public void write(OutputStream out) throws IOException
{
formDataM.write(out);
}
}, ErrorCodeRegistry.SITE_NOT_FAVORITED);
}, ErrorCodeRegistry.SITE_GENERIC);
updateExtraPropertyCache(site.getIdentifier(), site.isPendingMember(), site.isMember(), addSite);
updatedSite = new SiteImpl(site, site.isPendingMember(), site.isMember(), addSite);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_NOT_FAVORITED);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_GENERIC);
}
catch (Exception e)
{
Expand Down Expand Up @@ -364,15 +364,15 @@ public void write(OutputStream out) throws IOException
{
formData.write(out);
}
}, ErrorCodeRegistry.SITE_NOT_JOINED);
}, ErrorCodeRegistry.SITE_GENERIC);

// By default Contains informations about authority &
// membership
json = JsonUtils.parseObject(resp.getStream(), resp.getCharset());

updateExtraPropertyCache(site.getIdentifier(), false, true, site.isFavorite());
updatedSite = new SiteImpl(site, false, true, site.isFavorite());
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_NOT_JOINED);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_GENERIC);
break;

case MODERATED:
Expand Down Expand Up @@ -400,23 +400,23 @@ public void write(OutputStream out) throws IOException
{
formDataM.write(out);
}
}, ErrorCodeRegistry.SITE_NOT_JOINED);
}, ErrorCodeRegistry.SITE_GENERIC);
json = JsonUtils.parseObject(resp.getStream(), resp.getCharset());
Map<String, Object> jmo = (Map<String, Object>) json.get(OnPremiseConstant.DATA_VALUE);
if (jmo != null)
{
updateExtraPropertyCache(site.getIdentifier(), true, false, site.isFavorite());
updatedSite = new SiteImpl(site, true, false, site.isFavorite());
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_NOT_JOINED);
validateUpdateSite(updatedSite, ErrorCodeRegistry.SITE_GENERIC);
}
else
{
throw new AlfrescoServiceException(ErrorCodeRegistry.SITE_NOT_JOINED,
throw new AlfrescoServiceException(ErrorCodeRegistry.SITE_GENERIC,
Messagesl18n.getString("ErrorCodeRegistry.SITE_NOT_JOINED.parsing"));
}
break;
case PRIVATE:
throw new AlfrescoServiceException(ErrorCodeRegistry.SITE_NOT_JOINED,
throw new AlfrescoServiceException(ErrorCodeRegistry.SITE_GENERIC,
Messagesl18n.getString("ErrorCodeRegistry.SITE_NOT_JOINED.private"));
default:
throw new IllegalArgumentException(String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,11 @@ public void checkRendition(Document doc, boolean validateRendition, boolean vali
}
}
}

@Override
public void testCRUDNode()
{
super.testCRUDNode();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public void testSiteMembership()
}
catch (AlfrescoServiceException e)
{
Assert.assertTrue(e.getErrorCode() == ErrorCodeRegistry.SITE_NOT_JOINED);
Assert.assertTrue(e.getErrorCode() == ErrorCodeRegistry.SITE_GENERIC);
}

// It's not possible to join a moderated site where user has already a
Expand Down Expand Up @@ -810,7 +810,7 @@ public void testSiteMembership()
}
catch (AlfrescoServiceException e)
{
Assert.assertTrue(e.getErrorCode() == ErrorCodeRegistry.SITE_CANCEL_JOINED);
Assert.assertTrue(e.getErrorCode() == ErrorCodeRegistry.SITE_GENERIC);
}

// It's not possible to leave a fake site
Expand All @@ -832,7 +832,7 @@ public void testSiteMembership()
}
catch (AlfrescoServiceException e)
{
Assert.assertTrue(e.getErrorCode() == ErrorCodeRegistry.SITE_NOT_LEFT);
Assert.assertTrue(e.getErrorCode() == ErrorCodeRegistry.SITE_GENERIC);
}

// It's not possible to leave a private site where you are not member
Expand All @@ -843,7 +843,7 @@ public void testSiteMembership()
}
catch (AlfrescoServiceException e)
{
Assert.assertTrue(e.getErrorCode() == ErrorCodeRegistry.SITE_NOT_LEFT);
Assert.assertTrue(e.getErrorCode() == ErrorCodeRegistry.SITE_GENERIC);
}
}

Expand Down

0 comments on commit 8350000

Please sign in to comment.