public String joinContentLink() { ContentRecordVO contentVo = this.getContentVo(this.getContentId()); if (null == contentVo || !contentVo.isOnLine()) { ApsSystemUtils.getLogger() .severe("Contenuto '" + this.getContentId() + "' INESISTENTE O NON PUBBLICO"); return FAILURE; } if (this.isContentOnPageType()) { // Fa il forward alla scelta pagina di destinazione return "configContentOnPageLink"; } else { String[] destinations = {null, this.getContentId(), null}; this.buildEntryContentAnchorDest(); this.getLinkAttributeHelper() .joinLink(destinations, SymbolicLink.CONTENT_TYPE, this.getRequest()); return SUCCESS; } }
private StringApiResponse deleteResource(Properties properties, ResourceInterface resource) throws ApiException, Throwable { StringApiResponse response = new StringApiResponse(); try { String id = properties.getProperty("id"); if (null == resource) { throw new ApiException( IApiErrorCodes.API_VALIDATION_ERROR, "Resource with code '" + id + "' does not exist", Response.Status.CONFLICT); } UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER); if (null == user) { user = this.getUserManager().getGuestUser(); } if (!this.getAuthorizationManager().isAuthOnGroup(user, resource.getMainGroup())) { throw new ApiException( IApiErrorCodes.API_VALIDATION_ERROR, "Resource not allowed for user '" + user.getUsername() + "' - resource group '" + resource.getMainGroup() + "'", Response.Status.FORBIDDEN); } List<String> references = ((ResourceUtilizer) this.getContentManager()).getResourceUtilizers(id); if (references != null && references.size() > 0) { boolean found = false; for (int i = 0; i < references.size(); i++) { String reference = references.get(i); ContentRecordVO record = this.getContentManager().loadContentVO(reference); if (null != record) { found = true; response.addError( new ApiError( IApiErrorCodes.API_VALIDATION_ERROR, "Resource " + id + " referenced to content " + record.getId() + " - '" + record.getDescr() + "'", Response.Status.CONFLICT)); } } if (found) { response.setResult(IResponseBuilder.FAILURE, null); return response; } } this.getResourceManager().deleteResource(resource); response.setResult(IResponseBuilder.SUCCESS, null); } catch (ApiException ae) { response.addErrors(ae.getErrors()); response.setResult(IResponseBuilder.FAILURE, null); } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "deleteResource"); throw new ApsSystemException("Error deleting resource", t); } return response; }