Hi Ajith,

Few things.

1. Did you reopen the relevant JIRA?
2. We need a fix for this too. If a resource is already existing the UI
should be able to detect that and provide a warning. But the way in which
it is being done seems to be having issues. We need to discuss and
implement a better solution for this.

Thanks,
Senaka.

On Sat, Jun 9, 2012 at 7:36 AM, <aji...@wso2.com> wrote:

> Author: ajithn
> Date: Fri Jun  8 22:06:31 2012
> New Revision: 129608
> URL: http://wso2.org/svn/browse/wso2?view=rev&revision=129608
>
> Log:
> Revert commits 128973 128972 and 128972 that caused to failures in API
> Manager
>
> Modified:
>
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/common/GovernanceArtifactManager.java
>
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/generic/GenericArtifactManager.java
>
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_ajaxprocessor.jsp
>
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_edit.jsp
>
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic/src/main/java/org/wso2/carbon/governance/generic/services/ManageGenericArtifactService.java
>
> Modified:
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/common/GovernanceArtifactManager.java
> URL:
> http://wso2.org/svn/browse/wso2/carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/common/GovernanceArtifactManager.java?rev=129608&r1=129607&r2=129608&view=diff
>
> ==============================================================================
> ---
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/common/GovernanceArtifactManager.java
>       (original)
> +++
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/common/GovernanceArtifactManager.java
>       Fri Jun  8 22:06:31 2012
> @@ -26,14 +26,12 @@
>  import org.apache.commons.logging.LogFactory;
>  import
> org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifact;
>  import org.wso2.carbon.governance.api.exception.GovernanceException;
> -import org.wso2.carbon.governance.api.util.GovernanceConstants;
>  import org.wso2.carbon.governance.api.util.GovernanceUtils;
>  import org.wso2.carbon.registry.core.Association;
>  import org.wso2.carbon.registry.core.Registry;
>  import org.wso2.carbon.registry.core.Resource;
>  import org.wso2.carbon.registry.core.exceptions.RegistryException;
>  import org.wso2.carbon.registry.core.utils.RegistryUtils;
> -import org.wso2.carbon.ui.CarbonUIMessage;
>
>  import javax.xml.namespace.QName;
>  import java.util.*;
> @@ -113,7 +111,7 @@
>      *
>      * @throws GovernanceException if the operation failed.
>      */
> -    public String addGovernanceArtifact(GovernanceArtifact artifact)
> throws GovernanceException {
> +    public void addGovernanceArtifact(GovernanceArtifact artifact) throws
> GovernanceException {
>         // adding the attributes for name, namespace + artifact
>         if (artifact.getQName() == null ||
> artifact.getQName().getLocalPart() == null) {
>             String msg = "A valid qualified name was not set for this
> artifact";
> @@ -140,43 +138,33 @@
>             resource.setMediaType(mediaType);
>             setContent(artifact, resource);
>             // the artifact will not actually stored in the tmp path.
> -
> -// if an artifact is already existing in the defined location, then a
> error message will be prompted, to avoid the old artifact being replaced by
> the new one
>             String path = GovernanceUtils.getPathFromPathExpression(
>                     pathExpression, artifact);
> -            if(registry.resourceExists(path)){
> -                String msg = "An identical resource already exists in the
> defined path";
> -                log.error(msg);
> -                return msg;
> +            if (registry.resourceExists(path)) {
> +                Resource oldResource = registry.get(path);
> +                Properties properties = (Properties)
> oldResource.getProperties().clone();
> +                resource.setProperties(properties);
> +                String oldContent;
> +                Object content = oldResource.getContent();
> +                if (content instanceof String) {
> +                    oldContent = (String) content;
> +                } else {
> +                    oldContent = new String((byte[]) content);
> +                }
> +                String newContent;
> +                content = resource.getContent();
> +                if (content instanceof String) {
> +                    newContent = (String) content;
> +                } else {
> +                    newContent = new String((byte[]) content);
> +                }
> +                if (newContent.equals(oldContent)) {
> +                    artifact.setId(oldResource.getUUID());
> +                    addRelationships(path, artifact);
> +                    succeeded = true;
> +                    return;
> +                }
>             }
> -
> -//  if an artifact is already existing in the defined location, then the
> content of the old resource will be transfered to the new resource, wich is
> disabled
> -//            if (registry.resourceExists(path)) {
> -//                Resource oldResource = registry.get(path);
> -//                Properties properties = (Properties)
> oldResource.getProperties().clone();
> -//                resource.setProperties(properties);
> -//                String oldContent;
> -//                Object content = oldResource.getContent();
> -//                if (content instanceof String) {
> -//                    oldContent = (String) content;
> -//                } else {
> -//                    oldContent = new String((byte[]) content);
> -//                }
> -//                String newContent;
> -//                content = resource.getContent();
> -//                if (content instanceof String) {
> -//                    newContent = (String) content;
> -//                } else {
> -//                    newContent = new String((byte[]) content);
> -//                }
> -//                if (newContent.equals(oldContent)) {
> -//                    artifact.setId(oldResource.getUUID());
> -//                    addRelationships(path, artifact);
> -//                    succeeded = true;
> -//                    return;
> -//                }
> -//            }
> -
>             String artifactId = artifact.getId();
>             resource.setUUID(artifactId);
>             registry.put(path, resource);
> @@ -184,7 +172,6 @@
>             addRelationships(path, artifact);
>
>             succeeded = true;
> -            return path;
>         }
>         catch (RegistryException e) {
>             String msg;
>
> Modified:
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/generic/GenericArtifactManager.java
> URL:
> http://wso2.org/svn/browse/wso2/carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/generic/GenericArtifactManager.java?rev=129608&r1=129607&r2=129608&view=diff
>
> ==============================================================================
> ---
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/generic/GenericArtifactManager.java
> (original)
> +++
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.api/src/main/java/org/wso2/carbon/governance/api/generic/GenericArtifactManager.java
> Fri Jun  8 22:06:31 2012
> @@ -139,8 +139,8 @@
>      *
>      * @throws GovernanceException if the operation failed.
>      */
> -    public String addGenericArtifact(GenericArtifact artifact) throws
> GovernanceException {
> -        return manager.addGovernanceArtifact(artifact);
> +    public void addGenericArtifact(GenericArtifact artifact) throws
> GovernanceException {
> +         manager.addGovernanceArtifact(artifact);
>     }
>
>     /**
>
> Modified:
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_ajaxprocessor.jsp
> URL:
> http://wso2.org/svn/browse/wso2/carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_ajaxprocessor.jsp?rev=129608&r1=129607&r2=129608&view=diff
>
> ==============================================================================
> ---
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_ajaxprocessor.jsp
>      (original)
> +++
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_ajaxprocessor.jsp
>      Fri Jun  8 22:06:31 2012
> @@ -41,16 +41,6 @@
>     try {
>         String effectivePath =
> ManageGenericArtifactUtil.addArtifactContent(
>                 head, request, config, session, dataName, dataNamespace);
> -
> -        if(effectivePath.contains("An identical resource already exists
> in the defined path")){
> -%>
> -        <script type="text/javascript">
> -            window.location =
> "../generic/add_edit.jsp?region=<%=request.getParameter("region")%>&item=<%=request.getParameter("item")%>&key=<%=request.getParameter("key")%>&lifecycleAttribute=<%=request.getParameter("lifecycleAttribute")%>&breadcrumb=<%=request.getParameter("breadcrumb")%>&duplicateWarning="
> + encodeURIComponent("<%=effectivePath%>");
> -        </script>
> -<%
> -        return;
> -        }
> -
>         if (effectivePath != null){
>             try {
>                 if(request.getParameter("path")!=null){
> @@ -78,4 +68,8 @@
>     </script><%
>     return;
>  }
> -%>
> \ No newline at end of file
> +%>
> +
> +
> +
> +
> \ No newline at end of file
>
> Modified:
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_edit.jsp
> URL:
> http://wso2.org/svn/browse/wso2/carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_edit.jsp?rev=129608&r1=129607&r2=129608&view=diff
>
> ==============================================================================
> ---
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_edit.jsp
>       (original)
> +++
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic.ui/src/main/resources/web/generic/add_edit.jsp
>       Fri Jun  8 22:06:31 2012
> @@ -88,11 +88,6 @@
>         <% if (request.getParameter("wsdlError") != null) { %>
>
> CARBON.showErrorDialog(decodeURIComponent("<%=request.getParameter("wsdlError")%>"));
>         <% } %>
> -        <% if (request.getParameter("duplicateWarning") != null) { %>
> -
> CARBON.showWarningDialog(decodeURIComponent("<%=request.getParameter("duplicateWarning")%>"),function(){
> -                 window.history.back()
> -             });
> -        <% } %>
>         function addEditArtifact(){
>         sessionAwareFunction(function() {
>             var versionElement =
> document.getElementById('id_Overview_Version');
>
> Modified:
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic/src/main/java/org/wso2/carbon/governance/generic/services/ManageGenericArtifactService.java
> URL:
> http://wso2.org/svn/browse/wso2/carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic/src/main/java/org/wso2/carbon/governance/generic/services/ManageGenericArtifactService.java?rev=129608&r1=129607&r2=129608&view=diff
>
> ==============================================================================
> ---
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic/src/main/java/org/wso2/carbon/governance/generic/services/ManageGenericArtifactService.java
>  (original)
> +++
> carbon/platform/trunk/components/governance/org.wso2.carbon.governance.generic/src/main/java/org/wso2/carbon/governance/generic/services/ManageGenericArtifactService.java
>  Fri Jun  8 22:06:31 2012
> @@ -74,19 +74,14 @@
>                     configuration.getRelationshipDefinitions());
>             GenericArtifact artifact = manager.newGovernanceArtifact(
>                     new StAXOMBuilder(reader).getDocumentElement());
> -            String returnPath = manager.addGenericArtifact(artifact);
> +            manager.addGenericArtifact(artifact);
>             if (lifecycleAttribute != null) {
>                 String lifecycle =
> artifact.getAttribute(lifecycleAttribute);
>                 if (lifecycle != null) {
>                     artifact.attachLifecycle(lifecycle);
>                 }
>             }
> -//            return RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH +
> artifact.getPath();
> -            if(returnPath.contains("An identical resource already exists
> in the defined path")){
> -                return returnPath;
> -            }else{
> -                return RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH +
> returnPath;
> -            }
> +            return RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH +
> artifact.getPath();
>         } catch (Exception e) {
>             String msg = "Unable to add artifact. ";
>             if (e instanceof RegistryException) {
> _______________________________________________
> Commits mailing list
> comm...@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/commits
>



-- 
*Senaka Fernando*
Member - Integration Technologies Management Committee;
Technical Lead; WSO2 Inc.; http://wso2.com*
Member; Apache Software Foundation; http://apache.org

E-mail: senaka AT wso2.com
**P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818
Linked-In: http://linkedin.com/in/senakafernando

*Lean . Enterprise . Middleware
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to